2023.11.13 (0)
commit
b3691fe2ce
|
|
@ -0,0 +1,3 @@
|
|||
build/*
|
||||
local/*
|
||||
fuzzcrash/*
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# STB Libraries
|
||||
|
||||
https://github.com/nothings/stb
|
||||
|
||||
# FreeType Library
|
||||
|
||||
https://freetype.org/
|
||||
|
||||
# PCG Random Number Generator
|
||||
|
||||
https://www.pcg-random.org/
|
||||
|
||||
# Spall
|
||||
|
||||
https://gravitymoth.com/
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
Copyright © 2022,2023 Allen Webster <https://mr4th.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
### Copyright
|
||||
Copyright (C) 2022,2023 Allen Webster <https://mr4th.com>
|
||||
|
||||
Distributed with the MIT open source license, see LICENSE.txt.
|
||||
|
||||
Code in the "src/dependencies" directory is not the original work of the copyright holder, but all code there is available with a license that is compatible with the license of the entire codebase. See DEPENDENCIES.md to find the original sources for that code.
|
||||
|
||||
### Contact
|
||||
allenw@mr4th.com
|
||||
|
||||
### Purpose
|
||||
This codebase acts as the workspace for a number of projects of the Mr. 4th Lab.
|
||||
|
||||
Early development was documented on the Mr. 4th Programming YouTube channel https://www.youtube.com/Mr4thProgramming
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
root_path=$PWD
|
||||
opts_path="$root_path/bin/options"
|
||||
bld_path="$root_path/bin/bld"
|
||||
local_path="$root_path/local"
|
||||
src_path="$root_path/src"
|
||||
build_path="$root_path/build"
|
||||
fuzz_path="$root_path/fuzzcrash"
|
||||
program_pather="$local_path/exe_paths.txt"
|
||||
|
||||
. $local_path/local_vars.sh
|
||||
. $bld_path/bld_core.sh
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
###### Parse Arguments ########################################################
|
||||
command=$1
|
||||
args=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
args+=(${!i})
|
||||
done
|
||||
|
||||
###### Source the Core ########################################################
|
||||
bld_path="$(dirname $(realpath "$0"))"
|
||||
source "$bld_path/bld_core.sh"
|
||||
|
||||
###### Dispatch ###############################################################
|
||||
if [ "$command" == "cmp" ]; then
|
||||
bld_compile "${args[@]}"
|
||||
elif [ "$command" == "lnk" ]; then
|
||||
bld_link "${args[@]}"
|
||||
elif [ "$command" == "lib" ]; then
|
||||
bld_lib "${args[@]}"
|
||||
elif [ "$command" == "unit" ]; then
|
||||
bld_unit "${args[@]}"
|
||||
else
|
||||
echo "unknown command '$command'"
|
||||
fi
|
||||
|
||||
|
|
@ -0,0 +1,757 @@
|
|||
#!/bin/bash
|
||||
|
||||
###### Usage ##################################################################
|
||||
# To use the bld build system in a bash script, some setup is required:
|
||||
# 1. Define paths:
|
||||
# root_path, opts_path, bld_path, local_path, src_path,
|
||||
# build_path, fuzz_path, program_pather
|
||||
# 2. Define local variables:
|
||||
# compiler, compile_mode, arch, linker, ctx_opts
|
||||
# 3. Then include this core file with "." prefix:
|
||||
# . $bld_path/bld_core.sh
|
||||
#
|
||||
#
|
||||
# The following bld functions form the core "commands":
|
||||
# bld_compile, bld_link, bld_lib, bld_unit
|
||||
#
|
||||
# And there are several more helper functions:
|
||||
# bld_print_implicit_opts, bld_load_local_opts
|
||||
#
|
||||
#
|
||||
# Signatures:
|
||||
# bld_compile <source-file> <zero-or-more-options>
|
||||
# bld_link <out-name> <one-or-more-source-files-objs-or-libs> -- \
|
||||
# <zero-or-more-options>
|
||||
# bld_lib <out-name> <one-or-more-source-files-or-objs> -- \
|
||||
# <zero-or-more-options>
|
||||
# bld_unit <source-file> <zero-or-more-options>
|
||||
#
|
||||
# bld_print_implicit_opts (no arguments)
|
||||
# bld_load_local_opts (no arguments)
|
||||
#
|
||||
#
|
||||
# Shared notes for all:
|
||||
# + Options are gathered from the arguments, from the local context, and
|
||||
# in the case of the commands bld_compile and bld_unit, from the source file.
|
||||
# + Options gathered from local context are prefixed with their context
|
||||
# variable like so [var:val]. So for example, on windows the options list
|
||||
# includes [os:windows].
|
||||
# + Options in source files are specified between the strings //$ and //.
|
||||
# + Object file extensions should be named based on whether they were
|
||||
# generated by a compiler or assembler. Compiled objects should have the
|
||||
# extension .cmp:o and assembled objects should have the extension
|
||||
# .asm:o. The system automatically changes the name to match the correct
|
||||
# extension given the context.
|
||||
# + Static library files should have the extension .lib. The system
|
||||
# automatically changes the name to match the correct extension given the
|
||||
# context.
|
||||
# + When the option "diagnostics" is included, extra details will be printed
|
||||
# from the bld commands. Showing the full list of options, invokation lines,
|
||||
# and the build path.
|
||||
#
|
||||
# bld_compile:
|
||||
# + Creates an object file from a single source file via the selected compiler.
|
||||
#
|
||||
# bld_link:
|
||||
# + Creates executables and shared binaries from source files, object files,
|
||||
# and static libraries. First uses the bld_compile command on the source
|
||||
# files.
|
||||
# + Uses the selected linker.
|
||||
# + If the short name for the linker does not work for any reason, the
|
||||
# full path to the linker may be specified in a filter file pointed to by
|
||||
# the setup variable `program_pather`
|
||||
# + The output is a shared binary (.dll or .so) when the option "dll" is
|
||||
# included.
|
||||
#
|
||||
# bld_lib:
|
||||
# + Creates a static library from source files and object files. First uses
|
||||
# the bld_compile command on the source files. Uses the OS to determine the
|
||||
# correct archiver.
|
||||
#
|
||||
# bld_unit:
|
||||
# + Creates an executable (or shared binary) from a single source file.
|
||||
# This command essentially does a single bld_compile then bld_link. With
|
||||
# two differences:
|
||||
# 1. The options from the source file are visible to the bld_link.
|
||||
# 2. The name of the executable is determined either from the first option
|
||||
# in the list or from the source file name if there are no options.
|
||||
#
|
||||
# bld_print_implicit_opts:
|
||||
# + Shows the implicit options loaded from the local parameters script.
|
||||
#
|
||||
# bld_load_local_opts:
|
||||
# + It is possible and sometimes useful to modify the local parameters after
|
||||
# they are loaded to create certain kinds of build scripts. This function
|
||||
# resets the local parameters to their original states by rerunning the
|
||||
# local parameters script.
|
||||
|
||||
|
||||
###### Flags From Opts ########################################################
|
||||
|
||||
function bld_flags_from_opts {
|
||||
###### parse arguments ####################################################
|
||||
local in_file=$1
|
||||
local opts=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
opts+=(${!i})
|
||||
done
|
||||
|
||||
###### load file ##########################################################
|
||||
local flags_raw=()
|
||||
IFS=$'\r\n' GLOBIGNORE='*' command eval 'flags_raw=($(cat $in_file))'
|
||||
|
||||
###### filter #############################################################
|
||||
local flags=()
|
||||
for ((i=0;i<${#flags_raw[@]};i+=1)); do
|
||||
local flag=${flags_raw[i]}
|
||||
|
||||
###### skip blanks and comments #######################################
|
||||
if [[ -z "${flag// }" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "${flag:0:1}" == "#" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
###### parse line filters #############################################
|
||||
local line_filters=()
|
||||
while [[ $flag = *">"* ]]; do
|
||||
line_filters+=("${flag%%>*}")
|
||||
flag="${flag#*>}"
|
||||
done
|
||||
|
||||
###### check filters ##################################################
|
||||
local can_include=1
|
||||
for ((j=0;j<${#line_filters[@]};j+=1)); do
|
||||
can_include=0
|
||||
for ((k=0;k<${#opts[@]};k+=1)); do
|
||||
if [[ ${opts[k]} = ${line_filters[j]} ]]; then
|
||||
can_include=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$can_include" = "0" ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$can_include" = "1" ]]; then
|
||||
flags+=("${flag}")
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${flags[@]}"
|
||||
}
|
||||
|
||||
###### Opts From Src ##########################################################
|
||||
|
||||
function bld_opts_from_src {
|
||||
###### split file into tokens #############################################
|
||||
local in_file=$1
|
||||
local tokens=($(grep "//\\$" $in_file))
|
||||
|
||||
###### parse ##############################################################
|
||||
local in_params_range="0"
|
||||
local params=()
|
||||
for ((i=0; i<${#tokens[@]}; i+=1)); do
|
||||
local string="${tokens[i]}"
|
||||
if [[ "$in_params_range" == "0" ]]; then
|
||||
if [[ "$string" == "//$" ]]; then
|
||||
in_params_range="1"
|
||||
fi
|
||||
elif [[ "$in_params_range" == "1" ]]; then
|
||||
if [[ "${string:0:2}" == "//" ]]; then
|
||||
break
|
||||
fi
|
||||
params+=($string)
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${params[@]}"
|
||||
}
|
||||
|
||||
###### Dedup ##################################################################
|
||||
|
||||
function bld_dedup {
|
||||
###### parse arguments ####################################################
|
||||
local in=()
|
||||
for ((i=1; i<=$#; i+=1)); do
|
||||
in+=(${!i})
|
||||
done
|
||||
|
||||
###### dedup ##############################################################
|
||||
local out=()
|
||||
for ((i=0; i<${#in[@]}; i+=1)); do
|
||||
local string=${in[i]}
|
||||
local is_dup="0"
|
||||
for ((j=0; j<${#out[@]}; j+=1)); do
|
||||
if [[ "$string" == "${out[j]}" ]]; then
|
||||
is_dup="1"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$is_dup" == "0" ]]; then
|
||||
out+=($string)
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${out[@]}"
|
||||
}
|
||||
|
||||
###### Has Opt ################################################################
|
||||
|
||||
function bld_has_opt {
|
||||
###### parse arguments ####################################################
|
||||
local key_opt=$1
|
||||
local opts=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
opts+=(${!i})
|
||||
done
|
||||
|
||||
###### scan ###############################################################
|
||||
local has_key=0
|
||||
for ((i=0;i<${#opts[@]};i+=1)); do
|
||||
local opt=${opts[i]}
|
||||
if [[ "$opt" == "$key_opt" ]]; then
|
||||
has_key=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo $has_key
|
||||
}
|
||||
|
||||
###### Load Local Options #####################################################
|
||||
|
||||
function bld_load_local_opts {
|
||||
###### os cracking ########################################################
|
||||
os="undefined"
|
||||
if [ "$OSTYPE" == "win32" ] ||
|
||||
[ "$OSTYPE" == "msys" ]; then
|
||||
os="windows"
|
||||
elif [ "$OSTYPE" == "linux-gnu" ]; then
|
||||
os="linux"
|
||||
elif [ "$OSTYPE" == "darwin" ]; then
|
||||
os="mac"
|
||||
fi
|
||||
###### load parameters from the local script ################################
|
||||
if [ -f "$local_path/local_vars.sh" ]; then
|
||||
source "$local_path/local_vars.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
###### Implicit Opts ##########################################################
|
||||
|
||||
function bld_implicit_opts {
|
||||
local linker_opt=""
|
||||
if [[ "$linker" == "link" || "$linker" == "lld-link" ]]; then
|
||||
linker_opt="link:msvc"
|
||||
fi
|
||||
echo $ctx_opts cmp:$compiler mode:$compile_mode asm:$assembler
|
||||
echo link:$linker $linker_opt os:$os arch:$arch
|
||||
}
|
||||
|
||||
###### Print Implicit Options #################################################
|
||||
|
||||
function bld_print_implicit_opts {
|
||||
local opts=($(bld_implicit_opts))
|
||||
local bracketed=()
|
||||
for ((i=0; i<=${#opts[@]}; i+=1)); do
|
||||
local opt="${opts[i]}"
|
||||
if [ "$opt" != "" ]; then
|
||||
bracketed+=("[${opts[i]}]")
|
||||
fi
|
||||
done
|
||||
echo "${bracketed[@]}"
|
||||
}
|
||||
|
||||
###### Print Help #############################################################
|
||||
|
||||
function bld_print_obj_note {
|
||||
echo "NOTE: the interface does not use standrd object file extensions"
|
||||
echo "NOTE: use 'cmp:o' for object files produced by a compiler"
|
||||
echo "NOTE: use 'asm:o' for object files produced by an assembler"
|
||||
}
|
||||
|
||||
###### Compile ################################################################
|
||||
|
||||
function bld_compile {
|
||||
local i=0
|
||||
|
||||
###### parse arguments ####################################################
|
||||
local in_file=$1
|
||||
local opts=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
opts+=(${!i})
|
||||
done
|
||||
if [ "$in_file" == "" ]; then
|
||||
echo "ERROR(compile): missing input file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
###### finish in file #####################################################
|
||||
local final_in_file=$in_file
|
||||
|
||||
###### determine build kind ###############################################
|
||||
local ext="${final_in_file##*.}"
|
||||
local build_kind="undetermined"
|
||||
if [[ "$ext" == "c" || "$ext" == "cpp" ]]; then
|
||||
build_kind="compile"
|
||||
elif [[ "$ext" == "asm" ]]; then
|
||||
build_kind="assemble"
|
||||
else
|
||||
echo "ERROR(compile): unrecgonized source type $final_in_file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
###### finish options #####################################################
|
||||
local src_opts=($(bld_opts_from_src $final_in_file))
|
||||
local impl_opts=($(bld_implicit_opts))
|
||||
local all_opts=($(bld_dedup ${impl_opts[@]} ${opts[@]} ${src_opts[@]}))
|
||||
|
||||
###### diagnostics ########################################################
|
||||
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
|
||||
|
||||
###### out file name ######################################################
|
||||
local dot_ext_o=""
|
||||
if [[ "$build_kind" == "compile" ]]; then
|
||||
dot_ext_o=$(bld_ext_cmpo)
|
||||
elif [[ "$build_kind" == "assemble" ]]; then
|
||||
dot_ext_o=$(bld_ext_asmo)
|
||||
fi
|
||||
local file_base=${final_in_file##*/}
|
||||
local file_base_no_ext=${file_base%.*}
|
||||
local out_file="$file_base_no_ext$dot_ext_o"
|
||||
|
||||
###### get real flags #####################################################
|
||||
local flags=""
|
||||
if [[ "$build_kind" == "compile" ]]; then
|
||||
flags=$(bld_flags_from_opts $opts_path/compiler_flags.txt ${all_opts[@]})
|
||||
else
|
||||
flags=$(bld_flags_from_opts $opts_path/assembler_flags.txt ${all_opts[@]})
|
||||
fi
|
||||
|
||||
###### move to output folder ##############################################
|
||||
mkdir -p "$build_path"
|
||||
cd $build_path
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "build path: $build_path"
|
||||
fi
|
||||
|
||||
###### delete existing object file ########################################
|
||||
rm -f "$out_file_base.o"
|
||||
rm -f "$out_file_base.obj"
|
||||
|
||||
###### final flags ########################################################
|
||||
local final_flags=""
|
||||
if [[ "$build_kind" == "compile" ]]; then
|
||||
final_flags="-c -I$src_path ${flags}"
|
||||
elif [[ "$build_kind" == "assemble" ]]; then
|
||||
final_flags="-c ${flags}"
|
||||
fi
|
||||
|
||||
###### compile ############################################################
|
||||
if [[ "$build_kind" == "compile" ]]; then
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "cmp $final_in_file -- ${all_opts[@]}"
|
||||
echo $compiler "$final_in_file" $final_flags
|
||||
fi
|
||||
if [ "$compiler" == "clang" ]; then
|
||||
echo "$file_base"
|
||||
fi
|
||||
$compiler "$final_in_file" $final_flags
|
||||
elif [[ "$build_kind" == "assemble" ]]; then
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "asm $final_in_file -- ${all_opts[@]}"
|
||||
echo $assembler $final_flags "$final_in_file"
|
||||
fi
|
||||
$assembler $final_flags "$final_in_file"
|
||||
fi
|
||||
|
||||
# return of status from compiler is automatic here.
|
||||
}
|
||||
|
||||
###### Link ###################################################################
|
||||
|
||||
function bld_link {
|
||||
local i=0
|
||||
|
||||
###### parse arguments ####################################################
|
||||
local out_name=$1
|
||||
local in_files=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
if [ "${!i}" == "--" ]; then
|
||||
break
|
||||
fi
|
||||
in_files+=(${!i})
|
||||
done
|
||||
local opts=()
|
||||
for ((i+=1; i<=$#; i+=1)); do
|
||||
opts+=(${!i})
|
||||
done
|
||||
if [ "$out_name" == "" ]; then
|
||||
echo "link: missing output name"
|
||||
return 1
|
||||
fi
|
||||
if [ "${#in_files}" == "0" ]; then
|
||||
echo "link: missing input file(s)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
###### finish options #####################################################
|
||||
local impl_opts=($(bld_implicit_opts))
|
||||
local all_opts=($(bld_dedup ${opts[@]} ${impl_opts[@]}))
|
||||
|
||||
###### diagnostics ########################################################
|
||||
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
|
||||
|
||||
###### sort in files ######################################################
|
||||
local in_src=()
|
||||
local in_cmpo=()
|
||||
local in_asmo=()
|
||||
local in_lib=()
|
||||
for ((i=0; i<${#in_files[@]}; i+=1)); do
|
||||
local file="${in_files[i]}"
|
||||
local ext="${file##*.}"
|
||||
if [[ "$ext" == "c" || "$ext" == "cpp" || "$ext" == "asm" ]]; then
|
||||
in_src+=($file)
|
||||
elif [[ "$ext" == "cmp:o" ]]; then
|
||||
in_cmpo+=($file)
|
||||
elif [[ "$ext" == "asm:o" ]]; then
|
||||
in_asmo+=($file)
|
||||
elif [[ "$ext" == "lib" ]]; then
|
||||
in_lib+=($file)
|
||||
else
|
||||
echo "WARNING: ignoring unrecgonized file type $file"
|
||||
if [[ "$ext" == "obj" || "$ext" == "o" ]]; then
|
||||
bld_print_obj_note
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
###### auto correct compiled object files #################################
|
||||
local dot_ext_cmpo=$(bld_ext_cmpo)
|
||||
for ((i=0; i<${#in_cmpo[@]}; i+=1)); do
|
||||
local file_name="${in_cmpo[i]}"
|
||||
local base_name="${file_name%.*}"
|
||||
in_cmpo[$i]="$base_name$dot_ext_cmpo"
|
||||
done
|
||||
|
||||
###### auto correct assembled object files ################################
|
||||
local dot_ext_asmo=$(bld_ext_asmo)
|
||||
for ((i=0; i<${#in_asmo[@]}; i+=1)); do
|
||||
local file_name="${in_asmo[i]}"
|
||||
local base_name="${file_name%.*}"
|
||||
in_asmo[$i]="$base_name$dot_ext_asmo"
|
||||
done
|
||||
|
||||
###### combine object files ###############################################
|
||||
local in_obj=()
|
||||
for ((i=0; i<${#in_cmpo[@]}; i+=1)); do
|
||||
local file="${in_cmpo[i]}"
|
||||
in_obj+=($file)
|
||||
done
|
||||
for ((i=0; i<${#in_asmo[@]}; i+=1)); do
|
||||
local file="${in_asmo[i]}"
|
||||
in_obj+=($file)
|
||||
done
|
||||
|
||||
###### compile source files ###############################################
|
||||
for ((i=0; i<${#in_src[@]}; i+=1)); do
|
||||
local file="${in_src[i]}"
|
||||
bld_compile "$file" ${all_opts[@]}
|
||||
local status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
return $status
|
||||
fi
|
||||
done
|
||||
|
||||
###### intermediate object files ##########################################
|
||||
local interm_obj=()
|
||||
for ((i=0; i<${#in_src[@]}; i+=1)); do
|
||||
local file_name="${in_src[i]}"
|
||||
local base_name="${file_name##*/}"
|
||||
local base_name_no_ext="${base_name%.*}"
|
||||
local ext="${base_name##*.}"
|
||||
if [[ "$ext" == "c" || "$ext" == "cpp" ]]; then
|
||||
interm_obj+=($base_name_no_ext$dot_ext_cmpo)
|
||||
elif [[ "$ext" == "asm" ]]; then
|
||||
interm_obj+=($base_name_no_ext$dot_ext_asmo)
|
||||
fi
|
||||
done
|
||||
|
||||
###### get real flags #####################################################
|
||||
local flags=$(bld_flags_from_opts $opts_path/linker_flags.txt ${all_opts[@]})
|
||||
|
||||
###### out file name ######################################################
|
||||
local dot_ext_out=""
|
||||
local is_dll=$(bld_has_opt dll ${all_opts[@]})
|
||||
if [ "$is_dll" == "0" ]; then
|
||||
dot_ext_out=$(bld_ext_exe)
|
||||
else
|
||||
dot_ext_out=$(bld_ext_dll)
|
||||
fi
|
||||
out_file="$out_name$dot_ext_out"
|
||||
|
||||
###### move to output folder ##############################################
|
||||
mkdir -p "$build_path"
|
||||
cd $build_path
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "build path: $build_path"
|
||||
fi
|
||||
|
||||
###### final files to linker ##############################################
|
||||
local final_in_files="${interm_obj[@]} ${in_obj[@]} ${in_lib[@]}"
|
||||
|
||||
###### set first diagnostic string ########################################
|
||||
local first_diagnostic_string="lnk $final_in_files -- ${all_opts[@]}"
|
||||
|
||||
###### linker executable name #############################################
|
||||
local linker_exe=$linker
|
||||
local linker_rename=$(bld_flags_from_opts $program_pather "link:$linker")
|
||||
if [[ "$linker_rename" != "" ]]; then
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "linker rename: $linker_rename"
|
||||
fi
|
||||
linker_exe=$linker_rename
|
||||
fi
|
||||
|
||||
###### link ###############################################################
|
||||
local status=0
|
||||
local invokation=""
|
||||
if [[ "$linker" == "link" || "$linker" == "lld-link" ]]; then
|
||||
invokation="-OUT:$out_file $flags $final_in_files"
|
||||
elif [ "$linker" == "clang" ]; then
|
||||
invokation="-o $out_file $flags $final_in_files"
|
||||
else
|
||||
echo "ERROR(link): invokation not defined for this linker"
|
||||
status=1
|
||||
fi
|
||||
if [ "$invokation" != "" ]; then
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo $first_diagnostic_string
|
||||
echo $linker_exe $invokation
|
||||
fi
|
||||
echo "$out_file"
|
||||
"$linker_exe" $invokation
|
||||
status=$?
|
||||
fi
|
||||
|
||||
return $status
|
||||
}
|
||||
|
||||
###### Library ################################################################
|
||||
|
||||
function bld_lib {
|
||||
local i=0
|
||||
|
||||
###### parse arguments ####################################################
|
||||
local out_name=$1
|
||||
local in_files=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
if [ "${!i}" == "--" ]; then
|
||||
break
|
||||
fi
|
||||
in_files+=(${!i})
|
||||
done
|
||||
local opts=()
|
||||
for ((i+=1; i<=$#; i+=1)); do
|
||||
opts+=(${!i})
|
||||
done
|
||||
if [ "$out_name" == "" ]; then
|
||||
echo "lib: missing output name"
|
||||
return 1
|
||||
fi
|
||||
if [ "${#in_files}" == "0" ]; then
|
||||
echo "lib: missing input file(s)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
###### finish options #####################################################
|
||||
local impl_opts=($(bld_implicit_opts))
|
||||
local all_opts=($(bld_dedup ${opts[@]} ${impl_opts[@]}))
|
||||
|
||||
###### diagnostics ########################################################
|
||||
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
|
||||
|
||||
###### sort in files ######################################################
|
||||
local in_src=()
|
||||
local in_cmpo=()
|
||||
local in_asmo=()
|
||||
for ((i=0; i<${#in_files[@]}; i+=1)); do
|
||||
local file="${in_files[i]}"
|
||||
local ext="${file##*.}"
|
||||
if [[ "$ext" == "c" || "$ext" == "cpp" ]]; then
|
||||
in_src+=($file)
|
||||
elif [[ "$ext" == "cmp:o" ]]; then
|
||||
in_cmpo+=($file)
|
||||
elif [[ "$ext" == "asm:o" ]]; then
|
||||
in_asmo+=($file)
|
||||
else
|
||||
echo "WARNING: ignoring unrecgonized file type $file"
|
||||
if [[ "$ext" == "obj" || "$ext" == "o" ]]; then
|
||||
bld_print_obj_note
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
###### auto correct compiled object files #################################
|
||||
local dot_ext_cmpo=$(bld_ext_cmpo)
|
||||
for ((i=0; i<${#in_cmpo[@]}; i+=1)); do
|
||||
local file_name="${in_cmpo[i]}"
|
||||
local base_name="${file_name%.*}"
|
||||
in_cmpo[$i]=$base_name$dot_ext_cmpo
|
||||
done
|
||||
|
||||
###### auto correct assembled object files ################################
|
||||
local dot_ext_asmo=$(bld_ext_asmo)
|
||||
for ((i=0; i<${#in_asmo[@]}; i+=1)); do
|
||||
local file_name="${in_asmo[i]}"
|
||||
local base_name="${file_name%.*}"
|
||||
in_asmo[$i]="$base_name$dot_ext_asmo"
|
||||
done
|
||||
|
||||
###### combine object files ###############################################
|
||||
local in_obj=()
|
||||
for ((i=0; i<${#in_cmpo[@]}; i+=1)); do
|
||||
local file="${in_cmpo[i]}"
|
||||
in_obj+=($file)
|
||||
done
|
||||
for ((i=0; i<${#in_asmo[@]}; i+=1)); do
|
||||
local file="${in_asmo[i]}"
|
||||
in_obj+=($file)
|
||||
done
|
||||
|
||||
###### compile source files ###############################################
|
||||
for ((i=0; i<${#in_src[@]}; i+=1)); do
|
||||
bld_compile "${in_src[i]}" ${all_opts[@]}
|
||||
local status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
return $status
|
||||
fi
|
||||
done
|
||||
|
||||
###### intermediate object files ##########################################
|
||||
local interm_obj=()
|
||||
for ((i=0; i<${#in_src[@]}; i+=1)); do
|
||||
local file_name="${in_src[i]}"
|
||||
local base_name="${file_name##*/}"
|
||||
local base_name_no_ext="${base_name%.*}"
|
||||
local ext="${base_name##*.}"
|
||||
if [[ "$ext" == "c" || "$ext" == "cpp" ]]; then
|
||||
interm_obj+=($base_name_no_ext$dot_ext_cmpo)
|
||||
elif [[ "$ext" == "asm" ]]; then
|
||||
interm_obj+=($base_name_no_ext$dot_ext_asmo)
|
||||
fi
|
||||
done
|
||||
|
||||
###### out file name ######################################################
|
||||
local out_file=""
|
||||
if [ "$os" == "windows" ]; then
|
||||
out_file="$out_name.lib"
|
||||
elif [ "$os" == "linux" || "$os" == "mac" ]; then
|
||||
out_file="lib$out_name.a"
|
||||
else
|
||||
echo "ERROR(lib): static library output not defined for OS: $os"
|
||||
fi
|
||||
|
||||
###### final library build input files ####################################
|
||||
local final_in_files="${interm_obj[@]} ${in_obj[@]}"
|
||||
|
||||
###### move to output folder ##############################################
|
||||
mkdir -p "$build_path"
|
||||
cd $build_path
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "build path: $build_path"
|
||||
fi
|
||||
|
||||
###### set first diagnostic string ########################################
|
||||
local first_diagnostic_string="lib $final_in_files -- ${all_opts[@]}"
|
||||
|
||||
###### build library ######################################################
|
||||
local status=0
|
||||
if [ "$os" == "windows" ]; then
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo $first_diagnostic_string
|
||||
echo lib -nologo -OUT:"$out_file" $final_in_files
|
||||
fi
|
||||
echo "$out_file"
|
||||
lib -nologo -OUT:"$out_file" $final_in_files
|
||||
status=$?
|
||||
elif [ "$os" == "linux" || "$os" == "mac" ]; then
|
||||
# TODO(allen): invoke ar here - make sure to delete the original .a first
|
||||
# because ar does not (seem) to replace the output file, just append
|
||||
echo "TODO: implement ar path in bld_core.sh:bld_lib"
|
||||
status=1
|
||||
else
|
||||
echo "ERROR(lib): static library invokation not defined for OS: $os"
|
||||
status=1
|
||||
fi
|
||||
|
||||
return $status
|
||||
}
|
||||
|
||||
###### Unit ###################################################################
|
||||
|
||||
function bld_unit {
|
||||
local i=0
|
||||
|
||||
###### parse arguments ####################################################
|
||||
local main_file=$1
|
||||
local opts=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
opts+=(${!i})
|
||||
done
|
||||
if [ "$main_file" == "" ]; then
|
||||
echo "unit: missing main file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
###### set out name #######################################################
|
||||
local out_name=""
|
||||
if [ "${#opts}" == "0" ]; then
|
||||
local file_base=${main_file##*/}
|
||||
local file_base_no_ext=${file_base%.*}
|
||||
out_name=$file_base_no_ext
|
||||
else
|
||||
out_name="${opts[0]}"
|
||||
fi
|
||||
|
||||
###### finish options #####################################################
|
||||
local src_opts=$(bld_opts_from_src $main_file)
|
||||
local impl_opts=($(bld_implicit_opts))
|
||||
local all_opts=($(bld_dedup $out_name ${opts[@]} ${src_opts[@]} ${impl_opts[@]}))
|
||||
|
||||
###### link ###############################################################
|
||||
bld_link $out_name $main_file ${in_files[@]} -- ${all_opts[@]}
|
||||
}
|
||||
|
||||
###### Special Ifs ############################################################
|
||||
|
||||
function bld_ext_cmpo {
|
||||
echo $(bld_flags_from_opts $opts_path/file_extensions.txt cmp:$compiler "cmp:o")
|
||||
}
|
||||
function bld_ext_asmo {
|
||||
echo $(bld_flags_from_opts $opts_path/file_extensions.txt asm:$assembler "asm:o")
|
||||
}
|
||||
function bld_ext_exe {
|
||||
echo $(bld_flags_from_opts $opts_path/file_extensions.txt os:$os exe)
|
||||
}
|
||||
function bld_ext_dll {
|
||||
echo $(bld_flags_from_opts $opts_path/file_extensions.txt os:$os dll)
|
||||
}
|
||||
|
||||
###### Load Locals ############################################################
|
||||
bld_load_local_opts
|
||||
|
||||
###############################################################################
|
||||
# TODO: Notes for future itations on this sytem
|
||||
# - With the addition of the assembler, it is now becoming clear that the
|
||||
# bld_compile path is feeling a bit overloaded and that the mapping of
|
||||
# interface extensions to real extensions, and the mapping of interface
|
||||
# extensions to inferred build steps, are major complicating factors.
|
||||
# A new strategy for organizing multiple builders, and multiple conversion
|
||||
# paths that may be inferred from a set of possible starting points would
|
||||
# stand to simplify a lot of the system.
|
||||
# - Switching out object file extensions
|
||||
# - Subtlties of invoking different build kinds in bld_compile
|
||||
# - Tracking subkinds through bld_link and bld_lib
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
|
||||
echo
|
||||
echo --------- Profile Providers ---------
|
||||
|
||||
compiler="clang"
|
||||
compile_mode="release"
|
||||
linker="clang"
|
||||
bld_compile $src_path/base/base_profiling_by_spall.c
|
||||
bld_load_local_opts
|
||||
|
||||
|
||||
echo
|
||||
echo --------- Free Type ---------
|
||||
|
||||
cd $root_path
|
||||
$root_path/bin/build_freetype.bat
|
||||
|
||||
|
||||
echo
|
||||
echo --------- Core Programs ---------
|
||||
bld_unit $src_path/main.cpp test
|
||||
bld_unit $src_path/main.c test
|
||||
|
||||
bld_unit $src_path/play_temp_wave.c
|
||||
|
||||
|
||||
echo
|
||||
echo --------- Core Partial Targets ---------
|
||||
|
||||
bld_compile $src_path/d3d11/d3d11_target.cpp
|
||||
|
||||
|
||||
echo
|
||||
echo --------- Examples ---------
|
||||
|
||||
bld_unit $src_path/examples/win32_opengl_context_init_example.c
|
||||
|
||||
bld_unit $src_path/examples/opengl_scratch.c
|
||||
|
||||
bld_unit $src_path/examples/d3d11_example.cpp
|
||||
|
||||
bld_unit $src_path/examples/freetype_example.c
|
||||
|
||||
|
||||
echo
|
||||
echo --------- Euler ---------
|
||||
|
||||
bld_link euler $src_path/euler.c $src_path/euler_asm.asm
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
bld_link euler $src_path/euler.c $src_path/euler_asm.asm
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
|
||||
# bin/build_test.sh
|
||||
|
||||
# bld_unit $src_path/main.cpp test
|
||||
bld_unit $src_path/main.c test
|
||||
|
||||
# bld_unit $src_path/play_temp_wave.c
|
||||
|
||||
|
||||
# bld_unit $src_path/fuzz.c fuzz
|
||||
|
||||
# bld_compile $src_path/d3d11/d3d11_target.cpp
|
||||
# bld_compile $src_path/main.c
|
||||
# bld_link test main.obj d3d11_target.obj -- graphical freetype
|
||||
|
||||
# bld_link euler $src_path/euler.c $src_path/euler_asm.asm
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
@echo off
|
||||
|
||||
REM This script assumes we run it from the root of the repository.
|
||||
|
||||
SET ROOT=%CD%
|
||||
|
||||
SET FREETYPE_ROOT=%ROOT%\src\dependencies\freetype-2.12.1
|
||||
|
||||
SET INCS=
|
||||
SET INCS=%INCS% -I%ROOT%\src\dependencies\freetype_build
|
||||
SET INCS=%INCS% -I%FREETYPE_ROOT%\include
|
||||
|
||||
SET FILES=
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftsystem.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftinit.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftdebug.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftbase.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftbbox.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftglyph.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\base\ftbitmap.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\sfnt\sfnt.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\truetype\truetype.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\smooth\smooth.c
|
||||
SET FILES=%FILES% %FREETYPE_ROOT%\src\psnames\psnames.c
|
||||
|
||||
if not exist "%ROOT%\build" mkdir %ROOT%\build
|
||||
cd %ROOT%\build
|
||||
if not exist "%ROOT%\build\freetype" mkdir %ROOT%\build\freetype
|
||||
cd %ROOT%\build\freetype
|
||||
|
||||
del *.obj
|
||||
cl -c -nologo -Zi -DFT2_BUILD_LIBRARY %INCS% %FILES%
|
||||
lib -nologo -OUT:"freetype.lib" *.obj
|
||||
|
||||
cd %ROOT%\build
|
||||
copy freetype\freetype.lib freetype.lib
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
bld_unit $src_path/examples/freetype_example.c
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
bld_unit $src_path/examples/opengl_scratch.c
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
bld_unit $src_path/play_temp_wave.c
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
compiler="clang"
|
||||
compile_mode="release"
|
||||
linker="clang"
|
||||
bld_compile $src_path/base/base_profiling_by_spall.c
|
||||
bld_load_local_opts
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
bld_unit $src_path/examples/stb_ttf_scratch.c
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
. bin/begin_bld_session.sh
|
||||
bld_print_implicit_opts
|
||||
|
||||
bld_unit $src_path/examples/win32_opengl_context_init_example.c
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir -p "local"
|
||||
cp bin/initfiles/init.local_vars.sh local/local_vars.sh
|
||||
cp bin/initfiles/init.exe_paths.txt local/exe_paths.txt
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
link:link>???
|
||||
|
||||
## The MSVC linker has been known to reside at this/these location(s)
|
||||
## in some installations
|
||||
# /c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/link.exe
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
compiler="cl"
|
||||
compile_mode="debug"
|
||||
assembler="ml64"
|
||||
arch="x64"
|
||||
linker="link"
|
||||
ctx_opts=""
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
asm:ml64>-nologo
|
||||
asm:ml64>mode:debug>-Zi
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
###### Include Paths ##########################################################
|
||||
-I../src/dependencies
|
||||
freetype>-I../src/dependencies/freetype-2.12.1/include
|
||||
|
||||
|
||||
###### CL #####################################################################
|
||||
cmp:cl>-nologo
|
||||
cmp:cl>-FC
|
||||
cmp:cl>-GR-
|
||||
cmp:cl>-EHa
|
||||
|
||||
cmp:cl>sanitizer>-fsanitize=address
|
||||
|
||||
###### Clang ##################################################################
|
||||
cmp:clang>-Wno-writable-strings
|
||||
cmp:clang>-Wno-switch
|
||||
cmp:clang>-Wno-deprecated-declarations
|
||||
|
||||
cmp:clang>sanitizer>-fsanitize=address
|
||||
cmp:clang>sanitizer>-fsanitize=undefined
|
||||
cmp:clang>os:linux>sanitizer>-fsanitize=safe-stack
|
||||
cmp:clang>fuzzer>-fsanitize=fuzzer
|
||||
|
||||
###### Debug ##################################################################
|
||||
mode:debug>-DENABLE_ASSERT=1
|
||||
mode:release>-DENABLE_ASSERT=0
|
||||
cmp:cl>mode:debug>-Zi
|
||||
cmp:clang>mode:debug>-g
|
||||
|
||||
sanitizer>-DENABLE_SANITIZER=1
|
||||
|
||||
###### Profiling ##############################################################
|
||||
manualprofile>-DENABLE_MANUAL_PROFILE=1
|
||||
spall>-DPROFILER_SPALL=1
|
||||
|
||||
cmp:clang>autoprofile>-finstrument-functions
|
||||
autoprofile>-DENABLE_AUTO_PROFILE=1
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
cmp:o>cmp:cl>.obj
|
||||
cmp:o>cmp:clang>.o
|
||||
cmp:o>cmp:gcc>.o
|
||||
|
||||
asm:o>asm:ml64>.obj
|
||||
|
||||
exe>os:windows>.exe
|
||||
dll>os:windows>.dll
|
||||
dll>os:linux>.so
|
||||
dll>os:mac>.so
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
###### link ###################################################################
|
||||
link:msvc>-nologo
|
||||
link:msvc>-DEFAULTLIB:libcmt
|
||||
link:msvc>-OPT:REF
|
||||
link:msvc>-INCREMENTAL:NO
|
||||
link:msvc>-DEBUG
|
||||
link:msvc>arch:x64>-MACHINE:X64
|
||||
link:msvc>console>-SUBSYSTEM:CONSOLE
|
||||
link:msvc>graphical>-SUBSYSTEM:WINDOWS
|
||||
|
||||
###### Windows ################################################################
|
||||
|
||||
link:msvc>os:windows>Winmm.lib
|
||||
link:msvc>os:windows>Userenv.lib
|
||||
link:msvc>os:windows>Advapi32.lib
|
||||
link:msvc>os:windows>graphical>User32.lib
|
||||
link:msvc>os:windows>graphical>Gdi32.lib
|
||||
|
||||
link:clang>os:windows>-lWinmm.lib
|
||||
link:clang>os:windows>-lUserenv.lib
|
||||
link:clang>os:windows>-lAdvapi32.lib
|
||||
link:clang>os:windows>graphical>-lUser32.lib
|
||||
link:clang>os:windows>graphical>-lGdi32.lib
|
||||
|
||||
link:msvc>freetype>freetype.lib
|
||||
link:clang>freetype>freetype.lib
|
||||
|
||||
spall>base_profiling_by_spall.o
|
||||
|
||||
###### Sanitizer ##############################################################
|
||||
|
||||
link:clang>sanitizer>-fsanitize=address
|
||||
link:clang>sanitizer>-fsanitize=undefined
|
||||
link:clang>os:linux>sanitizer>-fsanitize=safe-stack
|
||||
link:clang>fuzzer>-fsanitize=fuzzer
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
version(2);
|
||||
project_name = "test";
|
||||
patterns = {
|
||||
"*.c",
|
||||
"*.cpp",
|
||||
"*.h",
|
||||
"*.m",
|
||||
"*.bat",
|
||||
"*.sh",
|
||||
"*.asm",
|
||||
"*.4coder",
|
||||
"*.txt",
|
||||
};
|
||||
blacklist_patterns = {
|
||||
".*",
|
||||
};
|
||||
load_paths_base = {
|
||||
{ ".", .relative = true, .recursive = true, },
|
||||
};
|
||||
load_paths = {
|
||||
.win = load_paths_base,
|
||||
.linux = load_paths_base,
|
||||
.mac = load_paths_base,
|
||||
};
|
||||
|
||||
commands = {
|
||||
.build_fly = { .out = "*compilation*", .footer_panel = false,
|
||||
.save_dirty_files = true,
|
||||
.win = "git_bash bin/build_fly.sh",
|
||||
.linux = "bin/build_fly.sh",
|
||||
.mac = "bin/build_fly.sh", },
|
||||
|
||||
.build_freetype = { .out = "*compilation*", .footer_panel = true,
|
||||
.save_dirty_files = true,
|
||||
.win = "bin\build_freetype.bat ", },
|
||||
|
||||
.build_all = { .out = "*compilation*", .footer_panel = false,
|
||||
.save_dirty_files = true,
|
||||
.win = "git_bash bin/build_all_targets.sh", },
|
||||
|
||||
.build_profiling_by_spall = { .out = "*compilation*", .footer_panel = true,
|
||||
.save_dirty_files = true,
|
||||
.win = "git_bash bin/build_profiling_by_spall.sh", },
|
||||
|
||||
.run = { .out = "*run*", .footer_panel = false,
|
||||
.win = "pushd build & test.exe" },
|
||||
|
||||
.run_fuzzer = { .out = "*fuzz*", .footer_panel = false,
|
||||
.win = "pushd build & fuzz.exe -artifact_prefix=../fuzzcrash/" },
|
||||
};
|
||||
|
||||
|
||||
fkey_command = {
|
||||
.F1 = "build_fly",
|
||||
.F2 = "run",
|
||||
|
||||
.F5 = "build_all",
|
||||
|
||||
.F9 = "run_fuzzer",
|
||||
};
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
////////////////////////////////
|
||||
// NOTE(allen): Color Functions
|
||||
|
||||
function V3F32
|
||||
color_rgb_from_hsv(F32 h, F32 s, F32 v){
|
||||
// TODO(allen): study this and determine how to do this best
|
||||
|
||||
F32 c = v*s;
|
||||
|
||||
F32 h6 = h*6;
|
||||
U32 case_n = (U32)(h6);
|
||||
F32 h6_mod2_adj = ((case_n|1) - 1);
|
||||
F32 h6_mod2 = h6 - h6_mod2_adj;
|
||||
|
||||
F32 x = c*(1 - abs_F32(h6_mod2 - 1));
|
||||
|
||||
F32 rp,gp,bp;
|
||||
switch (case_n){
|
||||
case 0:case 6: rp = c; gp = x; bp = 0; break;
|
||||
case 1: rp = x; gp = c; bp = 0; break;
|
||||
case 2: rp = 0; gp = c; bp = x; break;
|
||||
case 3: rp = 0; gp = x; bp = c; break;
|
||||
case 4: rp = x; gp = 0; bp = c; break;
|
||||
case 5: rp = c; gp = 0; bp = x; break;
|
||||
}
|
||||
|
||||
F32 m = v - c;
|
||||
|
||||
F32 r = (rp + m);
|
||||
F32 g = (gp + m);
|
||||
F32 b = (bp + m);
|
||||
|
||||
V3F32 result = {r, g, b};
|
||||
return(result);
|
||||
}
|
||||
|
||||
// TODO(allen): RESEARCH: what is really really the most
|
||||
// fair way to convert from 8-bits to a [0,1] float and back?
|
||||
|
||||
function U32
|
||||
color_u32_from_4f32(F32 x0, F32 x1, F32 x2, F32 x3){
|
||||
U32 b0 = (U32)(x0*256);
|
||||
U32 b1 = (U32)(x1*256);
|
||||
U32 b2 = (U32)(x2*256);
|
||||
U32 b3 = (U32)(x3*256);
|
||||
|
||||
U32 c0 = Clamp(0, b0, 255);
|
||||
U32 c1 = Clamp(0, b1, 255);
|
||||
U32 c2 = Clamp(0, b2, 255);
|
||||
U32 c3 = Clamp(0, b3, 255);
|
||||
|
||||
U32 result = ((c0) |
|
||||
(c1 << 8) |
|
||||
(c2 << 16) |
|
||||
(c3 << 24));
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
function V4F32
|
||||
color_4f32_from_u32(U32 c){
|
||||
V4F32 result = {0};
|
||||
result.x = ((c >> 0)&0xFF)/255.f;
|
||||
result.y = ((c >> 8)&0xFF)/255.f;
|
||||
result.z = ((c >> 16)&0xFF)/255.f;
|
||||
result.w = ((c >> 24)&0xFF)/255.f;
|
||||
return(result);
|
||||
}
|
||||
|
||||
function F32
|
||||
color_linear_from_srgb_single(F32 x){
|
||||
F32 r = 0.f;
|
||||
if (x <= 0.04045f){
|
||||
r = x/12.92f;
|
||||
}
|
||||
else{
|
||||
r = pow_F32(((x + 0.055f)/1.055f), 2.4f);
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
function F32
|
||||
color_srgb_from_linear_single(F32 x){
|
||||
F32 r = 0.f;
|
||||
if (x <= 0.0031308f){
|
||||
r = x*12.92f;
|
||||
}
|
||||
else{
|
||||
r = pow_F32(x, 1/2.4f)*1.055f - 0.055f;
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
function U32
|
||||
color_linear_from_srgb_u32(U32 srgb){
|
||||
V4F32 c = color_4f32_from_u32(srgb);
|
||||
V4F32 d = c;
|
||||
d.x = color_linear_from_srgb_single(d.x);
|
||||
d.y = color_linear_from_srgb_single(d.y);
|
||||
d.z = color_linear_from_srgb_single(d.z);
|
||||
U32 result = color_u32_from_4f32(V4_EXPANDED(d));
|
||||
return(result);
|
||||
}
|
||||
|
||||
function U32
|
||||
color_srgb_from_linear_u32(U32 lin){
|
||||
V4F32 c = color_4f32_from_u32(lin);
|
||||
V4F32 d = c;
|
||||
d.x = color_srgb_from_linear_single(d.x);
|
||||
d.y = color_srgb_from_linear_single(d.y);
|
||||
d.z = color_srgb_from_linear_single(d.z);
|
||||
U32 result = color_u32_from_4f32(V4_EXPANDED(d));
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/* date = July 26th 2022 10:28 am */
|
||||
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Color Functions
|
||||
|
||||
function V3F32 color_rgb_from_hsv(F32 h, F32 s, F32 v);
|
||||
|
||||
function U32 color_u32_from_4f32(F32 x0, F32 x1, F32 x2, F32 x3);
|
||||
function V4F32 color_4f32_from_u32(U32 c);
|
||||
|
||||
function F32 color_linear_from_srgb_single(F32 x_srgb);
|
||||
function F32 color_srgb_from_linear_single(F32 x_lin);
|
||||
|
||||
function U32 color_linear_from_srgb_u32(U32 srgb);
|
||||
function U32 color_srgb_from_linear_u32(U32 lin);
|
||||
|
||||
|
||||
#endif //COLOR_H
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Decibel Math
|
||||
|
||||
function F32
|
||||
audgen_mul_from_decibel(F32 db){
|
||||
F32 div_db = db/10.f;
|
||||
F32 exp_db = pow_F32(10.f, div_db);
|
||||
return(exp_db);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Rate
|
||||
|
||||
function AUDGEN_Rate
|
||||
audgen_rate(F32 sample_per_second){
|
||||
AUDGEN_Rate result = {0};
|
||||
result.sample_per_second = sample_per_second;
|
||||
result.delta_t = 1.f/sample_per_second;
|
||||
return(result);
|
||||
}
|
||||
|
||||
function U64
|
||||
audgen_i_from_t(F32 sample_per_second, F32 t){
|
||||
U64 result = (U64)(sample_per_second*t);
|
||||
return(result);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Basic Arithmetic
|
||||
|
||||
function void
|
||||
audgen_add_in_place(F32 *dst, F32 *src, U64 sample_count){
|
||||
F32 *dptr = dst;
|
||||
F32 *sptr = src;
|
||||
F32 *opl = src + sample_count;
|
||||
for (; sptr < opl; sptr += 1, dptr += 1){
|
||||
*dptr += *sptr;
|
||||
}
|
||||
}
|
||||
|
||||
function void
|
||||
audgen_scalar_mul_in_place(F32 scalar, F32 *dst, U64 sample_count){
|
||||
F32 *ptr = dst;
|
||||
F32 *opl = dst + sample_count;
|
||||
for (; ptr < opl; ptr += 1){
|
||||
*ptr = scalar*(*ptr);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Filters
|
||||
|
||||
function void
|
||||
audgen_low_pass_in_place(F32 alpha, F32 *dst, U64 sample_count){
|
||||
// TODO(allen): low-level optimization
|
||||
// low pass: Y = (1 - alpha)*[-1]Y + alpha*X
|
||||
|
||||
F32 *ptr = dst;
|
||||
F32 *opl = dst + sample_count;
|
||||
if (ptr < opl){
|
||||
F32 n_alpha = 1.f - alpha;
|
||||
F32 v = alpha*(*ptr);
|
||||
*ptr = v;
|
||||
for (; ptr < opl; ptr += 1){
|
||||
v = alpha*(*ptr) + n_alpha*v;
|
||||
*ptr = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function void
|
||||
audgen_high_pass_in_place(F32 alpha, F32 *dst, U64 sample_count){
|
||||
// TODO(allen): low-level optimization
|
||||
// high pass: Y = alpha*([-1]Y + X - [-1]X)
|
||||
|
||||
F32 *ptr = dst;
|
||||
F32 *opl = ptr + sample_count;
|
||||
if (ptr < opl){
|
||||
F32 d = 0;
|
||||
ptr += 1;
|
||||
for (; ptr < opl; ptr += 1){
|
||||
F32 x = *ptr;
|
||||
F32 y = alpha*(d + x);
|
||||
*ptr = y;
|
||||
d = y - x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function F32
|
||||
audgen_low_pass_alpha(F32 delta_t, F32 freq){
|
||||
F32 rc = 1.f/(tau_F32*freq);
|
||||
F32 alpha = delta_t/(delta_t + rc);
|
||||
return(alpha);
|
||||
}
|
||||
|
||||
function F32
|
||||
audgen_high_pass_alpha(F32 delta_t, F32 freq){
|
||||
F32 rc = 1.f/(tau_F32*freq);
|
||||
F32 alpha = rc/(rc + delta_t);
|
||||
return(alpha);
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/* date = July 17th 2021 7:52 pm */
|
||||
|
||||
#ifndef AUDIO_GEN_H
|
||||
#define AUDIO_GEN_H
|
||||
|
||||
////////////////////////////////
|
||||
// TODO(allen): Notes, Unfinished Issues, Etc.
|
||||
// [ ] Do we want a 12tet half step as a constant?
|
||||
// Seems like it might make more sense to bundle this
|
||||
// with some kind of notion of "scale information"
|
||||
// [ ] Same idea as above but with all those hand written
|
||||
// scale constants (kind of a different problem, but it still
|
||||
// hasn't been deeply thought through).
|
||||
// [ ] If we do want to keep these, what's a good naming scheme?
|
||||
// [ ] Resampling (change of rate)
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Constants
|
||||
|
||||
global F32 audgen_silent_db = -40.f;
|
||||
global F32 audgen_half_step = 0.083333333f; // 2^(1/12)
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Types
|
||||
|
||||
typedef struct AUDGEN_Rate{
|
||||
F32 sample_per_second;
|
||||
F32 delta_t;
|
||||
} AUDGEN_Rate;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Decibel Math
|
||||
|
||||
function F32 audgen_mul_from_decibel(F32 db);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Rate
|
||||
|
||||
function AUDGEN_Rate audgen_rate(F32 sample_per_second);
|
||||
|
||||
function U64 audgen_i_from_t(F32 sample_per_second, F32 t);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Basic Arithmetic
|
||||
|
||||
function void audgen_add_in_place(F32 *dst, F32 *src, U64 sample_count);
|
||||
function void audgen_scalar_mul_in_place(F32 scalar, F32 *dst, U64 sample_count);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Audio Generation Filters
|
||||
|
||||
// low pass: Y = (1 - alpha)*[-1]Y + alpha*X
|
||||
// high pass: Y = alpha*[-1]Y + alpha*X - alpha*[-1]X
|
||||
|
||||
function void audgen_low_pass_in_place(F32 alpha, F32 *dst, U64 sample_count);
|
||||
function void audgen_high_pass_in_place(F32 alpha, F32 *dst, U64 sample_count);
|
||||
|
||||
function F32 audgen_low_pass_alpha(F32 delta_t, F32 freq);
|
||||
function F32 audgen_high_pass_alpha(F32 delta_t, F32 freq);
|
||||
|
||||
#endif //AUDIO_GEN_H
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/* date = September 7th 2023 7:47 pm */
|
||||
|
||||
#ifndef BASE_BASIC_TYPES_H
|
||||
#define BASE_BASIC_TYPES_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Basic Types
|
||||
|
||||
#include <stdint.h>
|
||||
typedef int8_t S8;
|
||||
typedef int16_t S16;
|
||||
typedef int32_t S32;
|
||||
typedef int64_t S64;
|
||||
typedef uint8_t U8;
|
||||
typedef uint16_t U16;
|
||||
typedef uint32_t U32;
|
||||
typedef uint64_t U64;
|
||||
typedef S8 B8;
|
||||
typedef S16 B16;
|
||||
typedef S32 B32;
|
||||
typedef S64 B64;
|
||||
typedef float F32;
|
||||
typedef double F64;
|
||||
|
||||
typedef void VoidFunc(void);
|
||||
|
||||
#endif //BASE_BASIC_TYPES_H
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,168 @@
|
|||
/* date = August 19th 2023 1:28 pm */
|
||||
|
||||
#ifndef BASE_BIG_FUNCTIONS_H
|
||||
#define BASE_BIG_FUNCTIONS_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Symbolic Constant Functions
|
||||
|
||||
link_function OperatingSystem operating_system_from_context(void);
|
||||
link_function Architecture architecture_from_context(void);
|
||||
|
||||
link_function char* string_from_operating_system(OperatingSystem os);
|
||||
link_function char* string_from_architecture(Architecture arch);
|
||||
link_function char* string_from_month(Month month);
|
||||
link_function char* string_from_day_of_week(DayOfWeek day_of_week);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Time Functions
|
||||
|
||||
link_function DenseTime dense_time_from_date_time(DateTime *date_time);
|
||||
link_function DateTime date_time_from_dense_time(DenseTime dense_time);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Memory Functions
|
||||
|
||||
link_function Arena* arena_alloc_reserve(U64 reserve_size, B32 growing);
|
||||
link_function Arena* arena_alloc(void);
|
||||
link_function void arena_release(Arena *arena);
|
||||
link_function void* arena_push_no_zero(Arena *arena, U64 size);
|
||||
link_function void arena_pop_to(Arena *arena, U64 pos);
|
||||
link_function U64 arena_current_pos(Arena *arena);
|
||||
|
||||
link_function void* arena_push(Arena *arena, U64 size);
|
||||
link_function void arena_align(Arena *arena, U64 pow2_align);
|
||||
link_function void arena_pop_amount(Arena *arena, U64 amount);
|
||||
|
||||
#define push_array(a,T,c) (T*)arena_push((a), sizeof(T)*(c))
|
||||
#define push_array_no_zero(a,T,c) (T*)arena_push_no_zero((a), sizeof(T)*(c))
|
||||
|
||||
link_function ArenaTemp arena_begin_temp(Arena *arena);
|
||||
link_function void arena_end_temp(ArenaTemp *temp);
|
||||
|
||||
link_function ArenaTemp arena_get_scratch(Arena **conflict_array, U32 count);
|
||||
#define arena_release_scratch(temp) arena_end_temp(temp)
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): String Compound Constructor Functions
|
||||
|
||||
link_function void str8_list_push_explicit(String8List *list, String8 string,
|
||||
String8Node *node_memory);
|
||||
link_function void str8_list_push(Arena *arena, String8List *list, String8 string);
|
||||
|
||||
link_function String8 str8_join(Arena *arena, String8List *list,
|
||||
StringJoin *optional_join);
|
||||
|
||||
link_function String8List str8_split(Arena *arena, String8 string,
|
||||
U8 *split_characters, U32 count);
|
||||
|
||||
link_function String8 str8_pushfv(Arena *arena, char *fmt, va_list args);
|
||||
link_function String8 str8_pushf(Arena *arena, char *fmt, ...);
|
||||
link_function void str8_list_pushf(Arena *arena, String8List *list, char *fmt, ...);
|
||||
|
||||
link_function String8 str8_push_copy(Arena *arena, String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): String Comparison Functions
|
||||
|
||||
link_function B32 str8_match(String8 a, String8 b, StringMatchFlags flags);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Unicode Functions
|
||||
|
||||
link_function StringDecode str_decode_utf8(U8 *str, U32 cap);
|
||||
link_function U32 str_encode_utf8(U8 *dst, U32 codepoint);
|
||||
link_function StringDecode str_decode_utf16(U16 *str, U32 cap);
|
||||
link_function U32 str_encode_utf16(U16 *dst, U32 codepoint);
|
||||
|
||||
link_function String32 str32_from_str8(Arena *arena, String8 string);
|
||||
link_function String8 str8_from_str32(Arena *arena, String32 string);
|
||||
link_function String16 str16_from_str8(Arena *arena, String8 string);
|
||||
link_function String8 str8_from_str16(Arena *arena, String16 string);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Log
|
||||
|
||||
link_function void log_accum_begin(void);
|
||||
link_function void log_emit(String8 message);
|
||||
link_function void log_emitf(char *fmt, ...);
|
||||
link_function String8 log_accum_end(Arena *arena);
|
||||
|
||||
typedef struct LOG_Node{
|
||||
struct LOG_Node *next;
|
||||
U64 pos;
|
||||
String8List log;
|
||||
} LOG_Node;
|
||||
|
||||
typedef struct LOG_ThreadVars{
|
||||
Arena *arena;
|
||||
LOG_Node *stack;
|
||||
// TODO(allen): eliminate over stack & replace with
|
||||
// chaining arena for log
|
||||
U64 over_stack;
|
||||
} LOG_ThreadVars;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Errors
|
||||
|
||||
link_function void er_accum_begin(void);
|
||||
link_function void er_emit(String8 error);
|
||||
link_function void er_emitf(char *fmt, ...);
|
||||
link_function String8 er_accum_end(Arena *arena);
|
||||
|
||||
typedef struct ER_Node{
|
||||
struct ER_Node *next;
|
||||
U64 pos;
|
||||
String8 error;
|
||||
} ER_Node;
|
||||
|
||||
typedef struct ER_ThreadVars{
|
||||
Arena *arena;
|
||||
ER_Node *stack;
|
||||
U64 over_stack;
|
||||
} ER_ThreadVars;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Interleaving Functions
|
||||
|
||||
link_function String8 bop_interleave(Arena *arena, void **in,
|
||||
U64 lane_count, U64 el_size, U64 el_count);
|
||||
|
||||
link_function String8* bop_uninterleave(Arena *arena, void *in,
|
||||
U64 lane_count, U64 el_size, U64 el_count);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Conversions
|
||||
|
||||
link_function String8 bop_f32_from_s24(Arena *arena, String8 in);
|
||||
link_function String8 bop_s24_from_f32(Arena *arena, String8 in);
|
||||
link_function String8 bop_s16_from_f32(Arena *arena, String8 in);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): PRNG Functions
|
||||
|
||||
// TODO(allen): Build out more high level features for a good prng layer.
|
||||
|
||||
link_function PRNG prng_make_from_seed(PRNG_Seed *seed);
|
||||
|
||||
link_function U32 prng_next_u32(PRNG *prng);
|
||||
link_function U64 prng_next_u64(PRNG *prng);
|
||||
|
||||
link_function U32 prng_next_bounded(PRNG *prng, U32 bound);
|
||||
|
||||
// [0,1]
|
||||
link_function F32 prng_next_unital_f32(PRNG *prng);
|
||||
// [-1,1]
|
||||
link_function F32 prng_next_biunital_f32(PRNG *prng);
|
||||
|
||||
link_function B32 prng_next_pcoin(PRNG *prng, F32 p);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Big Math Functions
|
||||
|
||||
link_function F32 math_gaussian(F32 sigma, F32 x);
|
||||
link_function Array_F32 math_gaussian_kernel(Arena *arena, F32 sigma,
|
||||
U32 extra_reach);
|
||||
|
||||
|
||||
#endif //BASE_BIG_FUNCTIONS_H
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
/* date = August 19th 2023 1:23 pm */
|
||||
|
||||
#ifndef BASE_CONTEXT_H
|
||||
#define BASE_CONTEXT_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Context Cracking
|
||||
|
||||
// NOTE(allen): Development Settings
|
||||
#if !defined(ENABLE_ASSERT)
|
||||
# define ENABLE_ASSERT 0
|
||||
#endif
|
||||
#if !defined(ENABLE_SANITIZER)
|
||||
# define ENABLE_SANITIZER 0
|
||||
#endif
|
||||
#if !defined(ENABLE_MANUAL_PROFILE)
|
||||
# define ENABLE_MANUAL_PROFILE 0
|
||||
#endif
|
||||
#if !defined(ENABLE_AUTO_PROFILE)
|
||||
# define ENABLE_AUTO_PROFILE 0
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_ANY_PROFILE)
|
||||
# error user should not configure ENABLE_ANY_PROFILE
|
||||
#endif
|
||||
|
||||
#if ENABLE_MANUAL_PROFILE || ENABLE_AUTO_PROFILE
|
||||
# define ENABLE_ANY_PROFILE 1
|
||||
#else
|
||||
# define ENABLE_ANY_PROFILE 0
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE(allen): Untangle Compiler, OS & Architecture
|
||||
#if defined(__clang__)
|
||||
# define COMPILER_CLANG 1
|
||||
|
||||
# if defined(_WIN32)
|
||||
# define OS_WINDOWS 1
|
||||
# elif defined(__gnu_linux__)
|
||||
# define OS_LINUX 1
|
||||
# elif defined(__APPLE__) && defined(__MACH__)
|
||||
# define OS_MAC 1
|
||||
# else
|
||||
# error missing OS detection
|
||||
# endif
|
||||
|
||||
# if defined(__amd64__)
|
||||
# define ARCH_X64 1
|
||||
// TODO(allen): verify this works on clang
|
||||
# elif defined(__i386__)
|
||||
# define ARCH_X86 1
|
||||
// TODO(allen): verify this works on clang
|
||||
# elif defined(__arm__)
|
||||
# define ARCH_ARM 1
|
||||
// TODO(allen): verify this works on clang
|
||||
# elif defined(__aarch64__)
|
||||
# define ARCH_ARM64 1
|
||||
# else
|
||||
# error missing ARCH detection
|
||||
# endif
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_CL 1
|
||||
|
||||
# if defined(_WIN32)
|
||||
# define OS_WINDOWS 1
|
||||
# else
|
||||
# error missing OS detection
|
||||
# endif
|
||||
|
||||
# if defined(_M_AMD64)
|
||||
# define ARCH_X64 1
|
||||
# elif defined(_M_I86)
|
||||
# define ARCH_X86 1
|
||||
# elif defined(_M_ARM)
|
||||
# define ARCH_ARM 1
|
||||
// TODO(allen): ARM64?
|
||||
# else
|
||||
# error missing ARCH detection
|
||||
# endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# define COMPILER_GCC 1
|
||||
|
||||
# if defined(_WIN32)
|
||||
# define OS_WINDOWS 1
|
||||
# elif defined(__gnu_linux__)
|
||||
# define OS_LINUX 1
|
||||
# elif defined(__APPLE__) && defined(__MACH__)
|
||||
# define OS_MAC 1
|
||||
# else
|
||||
# error missing OS detection
|
||||
# endif
|
||||
|
||||
# if defined(__amd64__)
|
||||
# define ARCH_X64 1
|
||||
# elif defined(__i386__)
|
||||
# define ARCH_X86 1
|
||||
# elif defined(__arm__)
|
||||
# define ARCH_ARM 1
|
||||
# elif defined(__aarch64__)
|
||||
# define ARCH_ARM64 1
|
||||
# else
|
||||
# error missing ARCH detection
|
||||
# endif
|
||||
|
||||
#else
|
||||
# error no context cracking for this compiler
|
||||
#endif
|
||||
|
||||
#if !defined(COMPILER_CL)
|
||||
# define COMPILER_CL 0
|
||||
#endif
|
||||
#if !defined(COMPILER_CLANG)
|
||||
# define COMPILER_CLANG 0
|
||||
#endif
|
||||
#if !defined(COMPILER_GCC)
|
||||
# define COMPILER_GCC 0
|
||||
#endif
|
||||
#if !defined(OS_WINDOWS)
|
||||
# define OS_WINDOWS 0
|
||||
#endif
|
||||
#if !defined(OS_LINUX)
|
||||
# define OS_LINUX 0
|
||||
#endif
|
||||
#if !defined(OS_MAC)
|
||||
# define OS_MAC 0
|
||||
#endif
|
||||
#if !defined(ARCH_X64)
|
||||
# define ARCH_X64 0
|
||||
#endif
|
||||
#if !defined(ARCH_X86)
|
||||
# define ARCH_X86 0
|
||||
#endif
|
||||
#if !defined(ARCH_ARM)
|
||||
# define ARCH_ARM 0
|
||||
#endif
|
||||
#if !defined(ARCH_ARM64)
|
||||
# define ARCH_ARM64 0
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE(allen): Language
|
||||
#if defined(__cplusplus)
|
||||
# define LANG_CXX 1
|
||||
#else
|
||||
# define LANG_C 1
|
||||
#endif
|
||||
|
||||
#if !defined(LANG_CXX)
|
||||
# define LANG_CXX 0
|
||||
#endif
|
||||
#if !defined(LANG_C)
|
||||
# define LANG_C 0
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE(allen): Profiler
|
||||
#if !defined(PROFILER_SPALL)
|
||||
# define PROFILER_SPALL 0
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE(allen): Determine Intrinsics Mode
|
||||
#if OS_WINDOWS
|
||||
# if COMPILER_CL || COMPILER_CLANG
|
||||
# define INTRINSICS_MICROSOFT 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(INTRINSICS_MICROSOFT)
|
||||
# define INTRINSICS_MICROSOFT 0
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE(allen): Setup Pointer Size Macro
|
||||
#if ARCH_X64 || ARCH_ARM64
|
||||
# define ARCH_ADDRSIZE 64
|
||||
#else
|
||||
# define ARCH_ADDRSIZE 32
|
||||
#endif
|
||||
|
||||
#endif //BASE_CONTEXT_H
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/* date = January 31st 2022 7:55 pm */
|
||||
|
||||
#ifndef BASE_DEFAULT_MEMORY_H
|
||||
#define BASE_DEFAULT_MEMORY_H
|
||||
|
||||
#if !defined(mem_reserve)
|
||||
# define mem_reserve os_memory_reserve
|
||||
#endif
|
||||
#if !defined(mem_commit)
|
||||
# define mem_commit os_memory_commit
|
||||
#endif
|
||||
#if !defined(mem_decommit)
|
||||
# define mem_decommit os_memory_decommit
|
||||
#endif
|
||||
#if !defined(mem_release)
|
||||
# define mem_release os_memory_release
|
||||
#endif
|
||||
|
||||
#endif //BASE_DEFAULT_MEMORY_H
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef BASE_INC_C
|
||||
#define BASE_INC_C
|
||||
|
||||
#include "base_small_functions.c"
|
||||
|
||||
#endif //BASE_INC_C
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/* date = February 26th 2021 11:58 am */
|
||||
|
||||
#ifndef BASE_INC_H
|
||||
#define BASE_INC_H
|
||||
|
||||
#include "base_default_memory.h"
|
||||
|
||||
#include "base_context.h"
|
||||
#include "base_macros.h"
|
||||
|
||||
#include "base_basic_types.h"
|
||||
#include "base_types.h"
|
||||
#include "base_intrinsic.h"
|
||||
|
||||
#include "base_small_functions.h"
|
||||
#include "base_big_functions.h"
|
||||
|
||||
#include "base_profiling.h"
|
||||
|
||||
|
||||
#endif //BASE_INC_H
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/* date = August 27th 2023 4:17 pm */
|
||||
|
||||
#ifndef BASE_INTRINSIC_H
|
||||
#define BASE_INTRINSIC_H
|
||||
|
||||
#if INTRINSICS_MICROSOFT
|
||||
|
||||
# include <intrin.h>
|
||||
# define intrinsic_rdtsc() __rdtsc()
|
||||
|
||||
#endif
|
||||
|
||||
#endif //BASE_INTRINSIC_H
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
/* date = August 19th 2023 1:25 pm */
|
||||
|
||||
#ifndef BASE_MACROS_H
|
||||
#define BASE_MACROS_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Helper Macros
|
||||
|
||||
#define Stmnt(S) do{ S }while(0)
|
||||
|
||||
#if !defined(AssertBreak)
|
||||
# define AssertBreak() (*(volatile int*)0 = 0)
|
||||
#endif
|
||||
|
||||
#if ENABLE_ASSERT
|
||||
# define Assert(c) Stmnt( if (!(c)){ AssertBreak(); } )
|
||||
#else
|
||||
# define Assert(c)
|
||||
#endif
|
||||
|
||||
#define StaticAssert(c,l) typedef U8 Glue(l,__LINE__) [(c)?1:-1]
|
||||
|
||||
#define Stringify_(S) #S
|
||||
#define Stringify(S) Stringify_(S)
|
||||
#define Glue_(A,B) A##B
|
||||
#define Glue(A,B) Glue_(A,B)
|
||||
|
||||
#define ArrayCount(a) (sizeof(a)/sizeof(*(a)))
|
||||
|
||||
#define IntFromPtr(p) (U64)((U8*)p - (U8*)0)
|
||||
#define PtrFromInt(n) (void*)((U8*)0 + (n))
|
||||
|
||||
#define Member(T,m) (((T*)0)->m)
|
||||
#define OffsetOfMember(T,m) IntFromPtr(&Member(T,m))
|
||||
|
||||
#define Implies(a,b) (!(a) || (b))
|
||||
|
||||
#define Min(a,b) (((a)<(b))?(a):(b))
|
||||
#define Max(a,b) (((a)>(b))?(a):(b))
|
||||
#define Clamp(a,x,b) (((x)<(a))?(a):\
|
||||
((b)<(x))?(b):(x))
|
||||
#define ClampTop(a,b) Min(a,b)
|
||||
#define ClampBot(a,b) Max(a,b)
|
||||
|
||||
#define AlignUpPow2(x,p) (((x) + (p) - 1)&~((p) - 1))
|
||||
#define AlignDownPow2(x,p) ((x)&~((p) - 1))
|
||||
#define IsPow2OrZero(x) (((x)&((x)-1)) == 0)
|
||||
|
||||
#define MagicP(T,x,s) ((T)(x) << (s))
|
||||
#define MagicU32(a,b,c,d) \
|
||||
(MagicP(U32,a,0) | MagicP(U32,b,8) | MagicP(U32,c,16) | MagicP(U32,d,24))
|
||||
|
||||
#define Boolify(x) ((x) != 0)
|
||||
|
||||
#define KB(x) ((x) << 10)
|
||||
#define MB(x) ((x) << 20)
|
||||
#define GB(x) ((x) << 30)
|
||||
#define TB(x) ((U64)(x) << 40llu)
|
||||
|
||||
#define Thousand(x) ((x)*1000)
|
||||
#define Million(x) ((x)*1000000llu)
|
||||
#define Billion(x) ((x)*1000000000llu)
|
||||
#define Trillion(x) ((x)*1000000000000llu)
|
||||
|
||||
#if LANG_CXX
|
||||
# define c_linkage extern "C"
|
||||
#else
|
||||
# define c_linkage extern
|
||||
#endif
|
||||
|
||||
#if COMPILER_CL
|
||||
# define threadvar __declspec(thread)
|
||||
#elif COMPILER_CLANG
|
||||
# define threadvar __thread
|
||||
#else
|
||||
# error threadvar defined for this compiler
|
||||
#endif
|
||||
|
||||
#if COMPILER_CL
|
||||
# define shared_export __declspec(dllexport)
|
||||
#elif COMPILER_CLANG
|
||||
# define shared_export __declspec(dllexport)
|
||||
#else
|
||||
# error shared_export not defined for this compiler
|
||||
#endif
|
||||
|
||||
#if COMPILER_CLANG
|
||||
# define noinstrument __attribute__((no_instrument_function))
|
||||
#else
|
||||
# define noinstrument
|
||||
#endif
|
||||
|
||||
// TODO(allen): clean up this situation
|
||||
#define link_global c_linkage
|
||||
#define link_threadvar c_linkage threadvar
|
||||
#define global static
|
||||
#define local static
|
||||
#define function static
|
||||
#define link_function c_linkage
|
||||
#define shared_function c_linkage shared_export
|
||||
// TODO(allen): set this to be *real* read only data
|
||||
#define read_only
|
||||
|
||||
#include <string.h>
|
||||
#define MemoryZero(p,z) memset((p), 0, (z))
|
||||
#define MemoryZeroStruct(p) MemoryZero((p), sizeof(*(p)))
|
||||
#define MemoryZeroArray(p) MemoryZero((p), sizeof(p))
|
||||
#define MemoryZeroTyped(p,c) MemoryZero((p), sizeof(*(p))*(c))
|
||||
|
||||
#define MemoryMatch(a,b,z) (memcmp((a),(b),(z)) == 0)
|
||||
|
||||
#define MemoryCopy(d,s,z) memmove((d), (s), (z))
|
||||
#define MemoryCopyStruct(d,s) MemoryCopy((d),(s),\
|
||||
Min(sizeof(*(d)),sizeof(*(s))))
|
||||
#define MemoryCopyArray(d,s) MemoryCopy((d),(s),Min(sizeof(s),sizeof(d)))
|
||||
#define MemoryCopyTyped(d,s,c) MemoryCopy((d),(s),\
|
||||
Min(sizeof(*(d)),sizeof(*(s)))*(c))
|
||||
|
||||
#if COMPILER_CLANG && ENABLE_SANITIZER
|
||||
# include <sanitizer/asan_interface.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_SANITIZER
|
||||
# define AsanPoison(p,z) __asan_poison_memory_region((p),(z))
|
||||
# define AsanUnpoison(p,z) __asan_unpoison_memory_region((p),(z))
|
||||
#else
|
||||
# define AsanPoison(p,z)
|
||||
# define AsanUnpoison(p,z)
|
||||
#endif
|
||||
|
||||
#define AsciiID4(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a))
|
||||
#define ExpandAsciiID(x) (int)(sizeof(x)), (char*)(&(x))
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Linked List Macros
|
||||
|
||||
#define DLLPushBack_NP(f,l,n,next,prev) ((f)==0?\
|
||||
((f)=(l)=(n),(n)->next=(n)->prev=0):\
|
||||
((n)->prev=(l),(l)->next=(n),(l)=(n),(n)->next=0))
|
||||
#define DLLPushBack(f,l,n) DLLPushBack_NP(f,l,n,next,prev)
|
||||
|
||||
#define DLLPushFront(f,l,n) DLLPushBack_NP(l,f,n,prev,next)
|
||||
|
||||
#define DLLRemove_NP(f,l,n,next,prev) ((f)==(n)?\
|
||||
((f)==(l)?\
|
||||
((f)=(l)=(0)):\
|
||||
((f)=(f)->next,(f)->prev=0)):\
|
||||
(l)==(n)?\
|
||||
((l)=(l)->prev,(l)->next=0):\
|
||||
((n)->next->prev=(n)->prev,\
|
||||
(n)->prev->next=(n)->next))
|
||||
#define DLLRemove(f,l,n) DLLRemove_NP(f,l,n,next,prev)
|
||||
|
||||
#define SLLQueuePush_N(f,l,n,next) (((f)==0?\
|
||||
(f)=(l)=(n):\
|
||||
((l)->next=(n),(l)=(n))),\
|
||||
(n)->next=0)
|
||||
#define SLLQueuePush(f,l,n) SLLQueuePush_N(f,l,n,next)
|
||||
|
||||
#define SLLQueuePushFront_N(f,l,n,next) ((f)==0?\
|
||||
((f)=(l)=(n),(n)->next=0):\
|
||||
((n)->next=(f),(f)=(n)))
|
||||
#define SLLQueuePushFront(f,l,n) SLLQueuePushFront_N(f,l,n,next)
|
||||
|
||||
#define SLLQueuePop_N(f,l,next) ((f)==(l)?\
|
||||
(f)=(l)=0:\
|
||||
((f)=(f)->next))
|
||||
#define SLLQueuePop(f,l) SLLQueuePop_N(f,l,next)
|
||||
|
||||
#define SLLStackPush_N(f,n,next) ((n)->next=(f),(f)=(n))
|
||||
#define SLLStackPush(f,n) SLLStackPush_N(f,n,next)
|
||||
|
||||
#define SLLStackPop_N(f,next) ((f)==0?0:\
|
||||
((f)=(f)->next))
|
||||
#define SLLStackPop(f) SLLStackPop_N(f,next)
|
||||
|
||||
#endif //BASE_MACROS_H
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/* date = September 2nd 2023 6:05 pm */
|
||||
|
||||
#ifndef BASE_PROFILING_H
|
||||
#define BASE_PROFILING_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Profiling Implementable Interface
|
||||
|
||||
#if ENABLE_ANY_PROFILE
|
||||
|
||||
link_function void prof_open(char *name);
|
||||
link_function void prof_close(void);
|
||||
link_function void prof_thread_begin(void);
|
||||
link_function void prof_thread_end(void);
|
||||
link_function void prof_thread_flush(void);
|
||||
link_function void prof_begin(char *name, U32 len);
|
||||
link_function void prof_end(void);
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Profiling Provider
|
||||
|
||||
#if ENABLE_ANY_PROFILE
|
||||
# if PROFILER_SPALL
|
||||
# include "base_profiling_by_spall.h"
|
||||
# else
|
||||
# error no profiler setup but manual profiling is enabled
|
||||
# endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Profiling User Interface
|
||||
|
||||
#if ENABLE_ANY_PROFILE
|
||||
# define ProfOpen(n) prof_open((char*)(n))
|
||||
# define ProfClose() prof_close()
|
||||
# define ProfThreadBegin() prof_thread_begin()
|
||||
# define ProfThreadEnd() prof_thread_end()
|
||||
# define ProfThreadFlush() prof_thread_flush()
|
||||
# define ProfBegin(n) prof_begin_inl((n), sizeof(n) - 1)
|
||||
# define ProfEnd() prof_end_inl()
|
||||
#else
|
||||
# define ProfOpen(n)
|
||||
# define ProfClose()
|
||||
# define ProfThreadBegin()
|
||||
# define ProfThreadEnd()
|
||||
# define ProfThreadFlush()
|
||||
# define ProfBegin(n)
|
||||
# define ProfEnd()
|
||||
#endif
|
||||
|
||||
#if ENABLE_MANUAL_PROFILE
|
||||
# define ProfBeginManual(n) ProfBegin(n)
|
||||
# define ProfEndManual() ProfEnd()
|
||||
#else
|
||||
# define ProfBeginManual(n)
|
||||
# define ProfEndManual()
|
||||
#endif
|
||||
|
||||
#define ProfBeginFunc() ProfBeginManual(__FUNCTION__)
|
||||
#define ProfEndFunc() ProfEndManual()
|
||||
|
||||
#endif //BASE_PROFILING_H
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
////////////////////////////////
|
||||
// NOTE(allen): Implement Auto Profiling Hooks
|
||||
|
||||
#if COMPILER_CLANG
|
||||
|
||||
link_function void
|
||||
__cyg_profile_func_enter(void *fn, void *caller){
|
||||
prof_begin_inl("func", sizeof("func") - 1);
|
||||
}
|
||||
|
||||
link_function void
|
||||
__cyg_profile_func_exit(void *fn, void *caller){
|
||||
prof_end_inl();
|
||||
}
|
||||
|
||||
#else
|
||||
# error no auto profiling hooks implemented for this compiler
|
||||
#endif
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
////////////////////////////////
|
||||
// NOTE(allen): Profiling by Spall
|
||||
|
||||
// includes
|
||||
|
||||
#if ENABLE_MANUAL_PROFILE || ENABLE_AUTO_PROFILE
|
||||
# error cannot build profiling-by-spall with profiling enabled
|
||||
#endif
|
||||
|
||||
#define PROFILER_SPALL 1
|
||||
#define ENABLE_MANUAL_PROFILE 1
|
||||
|
||||
#include "base/base_context.h"
|
||||
#include "base/base_macros.h"
|
||||
#include "base/base_basic_types.h"
|
||||
#include "base/base_intrinsic.h"
|
||||
#include "base_profiling.h"
|
||||
|
||||
#include "base_profiling_auto.c"
|
||||
|
||||
#define SPALL_BUFFER_CAP MB(1)
|
||||
|
||||
// linkable global/thread variables
|
||||
|
||||
SpallProfile spall_ctx = {0};
|
||||
threadvar SpallBuffer spall_buffer = {0};
|
||||
|
||||
// windows implementation
|
||||
#if OS_WINDOWS
|
||||
|
||||
#undef function
|
||||
#include <Windows.h>
|
||||
#define function static
|
||||
|
||||
function U64
|
||||
spallprof_tick_per_usecond(void){
|
||||
typedef int QueryInfoType(S32, void*, U32, U32*);
|
||||
|
||||
U64 result = Billion(3);
|
||||
B32 accurate = 0;
|
||||
|
||||
HMODULE ntdll = LoadLibrary("ntdll.dll");
|
||||
if (ntdll != 0){
|
||||
QueryInfoType *NtQuerySystemInformation =
|
||||
(QueryInfoType*)GetProcAddress(ntdll, "NtQuerySystemInformation");
|
||||
if (NtQuerySystemInformation != 0){
|
||||
// TODO(allen): audit
|
||||
volatile U64 *hsuv = 0;
|
||||
U32 size = 0;
|
||||
S32 query_result =
|
||||
NtQuerySystemInformation(0xc5, (void**)&hsuv, sizeof(hsuv), &size);
|
||||
if (size == sizeof(hsuv) && query_result >= 0){
|
||||
result = (Million(10) << 32)/(hsuv[1] >> 32);
|
||||
accurate = 1;
|
||||
}
|
||||
}
|
||||
FreeLibrary(ntdll);
|
||||
}
|
||||
|
||||
if (!accurate){
|
||||
// TODO(allen): This is forcing any program that is built with profiling
|
||||
// by spall to also link as a 'graphical' program. How else could I deal
|
||||
// with this bit?
|
||||
MessageBoxA(0, "Could not acquire accurate rdtsc/sec value",
|
||||
"Profiling by Spall: Error", MB_OK);
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
function void*
|
||||
spallprof_alloc(U64 size){
|
||||
void *result = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
Assert(result != 0);
|
||||
return(result);
|
||||
}
|
||||
|
||||
function void
|
||||
spallprof_free(void *ptr, U64 size){
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
#else
|
||||
# error need no implementation for profiling by spall on this os
|
||||
#endif
|
||||
|
||||
// profiling interface implementation
|
||||
|
||||
link_function void
|
||||
prof_open(char *name){
|
||||
U64 tick_per_usecond = spallprof_tick_per_usecond();
|
||||
spall_ctx = spall_init_file(name, 1000000./tick_per_usecond);
|
||||
}
|
||||
|
||||
link_function void
|
||||
prof_close(void){
|
||||
spall_quit(&spall_ctx);
|
||||
}
|
||||
|
||||
link_function void
|
||||
prof_thread_begin(void){
|
||||
void *buffer = spallprof_alloc(SPALL_BUFFER_CAP);
|
||||
spall_buffer.length = SPALL_BUFFER_CAP;
|
||||
spall_buffer.data = buffer;
|
||||
spall_buffer_init(&spall_ctx, &spall_buffer);
|
||||
}
|
||||
|
||||
link_function void
|
||||
prof_thread_end(void){
|
||||
spall_buffer_quit(&spall_ctx, &spall_buffer);
|
||||
spallprof_free(spall_buffer.data, spall_buffer.length);
|
||||
MemoryZeroStruct(&spall_buffer);
|
||||
}
|
||||
|
||||
link_function void
|
||||
prof_thread_flush(void){
|
||||
spall_buffer_flush(&spall_ctx, &spall_buffer);
|
||||
}
|
||||
|
||||
link_function void
|
||||
prof_begin(char *name, U32 len){
|
||||
spall_buffer_begin(&spall_ctx, &spall_buffer, name, len, intrinsic_rdtsc());
|
||||
}
|
||||
|
||||
link_function void
|
||||
prof_end(void){
|
||||
spall_buffer_end(&spall_ctx, &spall_buffer, intrinsic_rdtsc());
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/* date = September 2nd 2023 6:10 pm */
|
||||
|
||||
#ifndef BASE_PROFILING_BY_SPALL_H
|
||||
#define BASE_PROFILING_BY_SPALL_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Profiling by Spall
|
||||
|
||||
#include "spall/spall.h"
|
||||
|
||||
link_global SpallProfile spall_ctx;
|
||||
link_threadvar SpallBuffer spall_buffer;
|
||||
|
||||
#define prof_begin_inl(n,z) \
|
||||
spall_buffer_begin(&spall_ctx, &spall_buffer, (n), (z), intrinsic_rdtsc())
|
||||
#define prof_end_inl() \
|
||||
spall_buffer_end(&spall_ctx, &spall_buffer, intrinsic_rdtsc())
|
||||
|
||||
#endif //BASE_PROFILING_BY_SPALL_H
|
||||
|
|
@ -0,0 +1,463 @@
|
|||
////////////////////////////////
|
||||
// NOTE(allen): Float Constant Functions
|
||||
|
||||
function F32
|
||||
inf_F32(void){
|
||||
U32 u = 0x7f800000;
|
||||
F32 *p = (F32*)&u;
|
||||
return(*p);
|
||||
}
|
||||
|
||||
function F32
|
||||
neg_inf_F32(void){
|
||||
U32 u = 0xff800000;
|
||||
F32 *p = (F32*)&u;
|
||||
return(*p);
|
||||
}
|
||||
|
||||
function B32
|
||||
is_inf_or_nan_F32(F32 x){
|
||||
U32 u = *(U32*)&x;
|
||||
B32 result = ((u&0x7f800000) == 0x7f800000);
|
||||
return(result);
|
||||
}
|
||||
|
||||
function F64
|
||||
inf_F64(void){
|
||||
U64 u = 0x7ff0000000000000;
|
||||
F64 *p = (F64*)&u;
|
||||
return(*p);
|
||||
}
|
||||
|
||||
function F64
|
||||
neg_inf_F64(void){
|
||||
U64 u = 0xfff0000000000000;
|
||||
F64 *p = (F64*)&u;
|
||||
return(*p);
|
||||
}
|
||||
|
||||
function B64
|
||||
is_inf_or_nan_F64(F64 x){
|
||||
U64 u = *(U64*)&x;
|
||||
B64 result = ((u&0x7ff0000000000000) == 0x7ff0000000000000);
|
||||
return(result);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Math Functions
|
||||
|
||||
function F32
|
||||
abs_F32(F32 x){
|
||||
union{ F32 f; U32 u; } r;
|
||||
r.f = x;
|
||||
r.u &= 0x7fffffff;
|
||||
return(r.f);
|
||||
}
|
||||
|
||||
function F64
|
||||
abs_F64(F64 x){
|
||||
union{ F64 f; U64 u; } r;
|
||||
r.f = x;
|
||||
r.u &= 0x7fffffffffffffff;
|
||||
return(r.f);
|
||||
}
|
||||
|
||||
function F32
|
||||
sign_F32(F32 x){
|
||||
union{ F32 f; U32 u; } r;
|
||||
r.f = x;
|
||||
F32 result = (r.u&0x80000000)?-1.f:1.f;
|
||||
return(result);
|
||||
}
|
||||
|
||||
function F64
|
||||
sign_F64(F64 x){
|
||||
union{ F64 f; U32 u; } r;
|
||||
r.f = x;
|
||||
F64 result = (r.u&0x8000000000000000)?-1.:1.;
|
||||
return(result);
|
||||
}
|
||||
|
||||
#include <math.h>
|
||||
|
||||
function F32
|
||||
sqrt_F32(F32 x){
|
||||
return(sqrtf(x));
|
||||
}
|
||||
|
||||
function F32
|
||||
sin_F32(F32 x){
|
||||
return(sinf(x));
|
||||
}
|
||||
|
||||
function F32
|
||||
cos_F32(F32 x){
|
||||
return(cosf(x));
|
||||
}
|
||||
|
||||
function F32
|
||||
tan_F32(F32 x){
|
||||
return(tanf(x));
|
||||
}
|
||||
|
||||
function F32
|
||||
atan_F32(F32 x){
|
||||
return(atanf(x));
|
||||
}
|
||||
|
||||
function F32
|
||||
atan2_F32(F32 x, F32 y){
|
||||
return(atan2f(y, x));
|
||||
}
|
||||
|
||||
function F32
|
||||
ln_F32(F32 x){
|
||||
return(logf(x));
|
||||
}
|
||||
|
||||
function F32
|
||||
pow_F32(F32 base, F32 x){
|
||||
return(powf(base, x));
|
||||
}
|
||||
|
||||
function F64
|
||||
sqrt_F64(F64 x){
|
||||
return(sqrt(x));
|
||||
}
|
||||
|
||||
function F64
|
||||
sin_F64(F64 x){
|
||||
return(sin(x));
|
||||
}
|
||||
|
||||
function F64
|
||||
cos_F64(F64 x){
|
||||
return(cos(x));
|
||||
}
|
||||
|
||||
function F64
|
||||
tan_F64(F64 x){
|
||||
return(tan(x));
|
||||
}
|
||||
|
||||
function F64
|
||||
atan_F64(F64 x){
|
||||
return(atanf(x));
|
||||
}
|
||||
|
||||
function F64
|
||||
ln_F64(F64 x){
|
||||
return(log(x));
|
||||
}
|
||||
|
||||
function F64
|
||||
pow_F64(F64 base, F64 x){
|
||||
return(powf(base, x));
|
||||
}
|
||||
|
||||
function F32
|
||||
lerp(F32 a, F32 t, F32 b){
|
||||
F32 x = a + (b - a)*t;
|
||||
return(x);
|
||||
}
|
||||
|
||||
function F32
|
||||
unlerp(F32 a, F32 x, F32 b){
|
||||
F32 t = 0.f;
|
||||
if (a != b){
|
||||
t = (x - a)/(b - a);
|
||||
}
|
||||
return(t);
|
||||
}
|
||||
|
||||
function F32
|
||||
lerp_range(RangeF32 r, F32 t){
|
||||
F32 x = r.min + (r.max - r.min)*t;
|
||||
return(x);
|
||||
}
|
||||
|
||||
function F32
|
||||
trunc_F32(F32 x){
|
||||
// TODO(allen): does this always work?
|
||||
// can we do better?
|
||||
return((F32)(S32)x);
|
||||
}
|
||||
|
||||
function F32
|
||||
floor_F32(F32 x){
|
||||
F32 r = (F32)((S32)x);
|
||||
if (r > x){
|
||||
r -= 1.f;
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
function F32
|
||||
ceil_F32(F32 x){
|
||||
F32 r = (F32)((S32)x);
|
||||
if (r < x){
|
||||
r += 1.f;
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
function F32
|
||||
mod_F32(F32 x, F32 m){
|
||||
Assert(m > 0.f);
|
||||
// + | -
|
||||
F32 q = (x/m); // (x/m) | (x/m)
|
||||
S32 q_s32 = (S32)q; // floor(x/m) | ceil(x/m)
|
||||
F32 r = m*(F32)q_s32;// m*floor(x/m) | m*ceil(x/m)
|
||||
// <= x | >= x
|
||||
F32 d = x - r;
|
||||
if (d < 0){
|
||||
d += m;
|
||||
}
|
||||
return(d);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Compound Type Functions
|
||||
|
||||
function V2S32
|
||||
v2s32(S32 x, S32 y){
|
||||
V2S32 r = {x, y};
|
||||
return(r);
|
||||
}
|
||||
|
||||
function V2F32
|
||||
v2f32(F32 x, F32 y){
|
||||
V2F32 r = {x, y};
|
||||
return(r);
|
||||
}
|
||||
|
||||
function V3F32
|
||||
v3f32(F32 x, F32 y, F32 z){
|
||||
V3F32 r = {x, y, z};
|
||||
return(r);
|
||||
}
|
||||
|
||||
function V4F32
|
||||
v4f32(F32 x, F32 y, F32 z, F32 w){
|
||||
V4F32 r = {x, y, z, w};
|
||||
return(r);
|
||||
}
|
||||
|
||||
function RangeF32
|
||||
rangef32(F32 min, F32 max){
|
||||
RangeF32 r = {min, max};
|
||||
if (max < min){
|
||||
r.min = max;
|
||||
r.max = min;
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
function RectF32
|
||||
rectf32(F32 x0, F32 y0, F32 x1, F32 y1){
|
||||
RectF32 r = {x0, y0, x1, y1};
|
||||
if (x1 < x0){
|
||||
r.x0 = x1;
|
||||
r.x1 = x0;
|
||||
}
|
||||
if (y1 < y0){
|
||||
r.y0 = y1;
|
||||
r.y1 = y0;
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
function RectF32
|
||||
rectf32_vec(V2F32 min, V2F32 max){
|
||||
RectF32 r = rectf32(min.x, min.y, max.x, max.y);
|
||||
return(r);
|
||||
}
|
||||
|
||||
function RectF32
|
||||
rectf32_range(RangeF32 x, RangeF32 y){
|
||||
RectF32 r = rectf32(x.min, y.min, x.max, y.max);
|
||||
return(r);
|
||||
}
|
||||
|
||||
function RectF32
|
||||
rectf32_from_rects32(RectS32 *r){
|
||||
RectF32 result = {(F32)r->x0, (F32)r->y0, (F32)r->x1, (F32)r->y1};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function V2F32
|
||||
v2f32_add(V2F32 a, V2F32 b){
|
||||
V2F32 result = {a.x + b.x, a.y + b.y};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function V2F32
|
||||
v2f32_sub(V2F32 a, V2F32 b){
|
||||
V2F32 result = {a.x - b.x, a.y - b.y};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function V2F32
|
||||
v2f32_scalar_mul(F32 s, V2F32 v){
|
||||
V2F32 result = {s*v.x, s*v.y};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function V2F32
|
||||
v2f32_polar(F32 theta, F32 radius){
|
||||
V2F32 result = {radius*cos_F32(theta), radius*sin_F32(theta)};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function F32
|
||||
angle_from_v2f32(V2F32 v){
|
||||
F32 result = atan2_F32(v.x, v.y);
|
||||
return(result);
|
||||
}
|
||||
|
||||
function V2S32
|
||||
dim_from_rects32(RectS32 r){
|
||||
V2S32 result = {r.x1 - r.x0, r.y1 - r.y0};
|
||||
return(result);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Character Functions
|
||||
|
||||
function B32
|
||||
str8_char_is_slash(U8 c){
|
||||
return(c == '/' || c == '\\');
|
||||
}
|
||||
|
||||
function U8
|
||||
str8_char_uppercase(U8 c){
|
||||
if ('a' <= c && c <= 'z'){
|
||||
c += 'A' - 'a';
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
function U8
|
||||
str8_char_lowercase(U8 c){
|
||||
if ('A' <= c && c <= 'Z'){
|
||||
c += 'a' - 'A';
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): String Constructor Functions
|
||||
|
||||
function String8
|
||||
str8(U8 *str, U64 size){
|
||||
String8 result = {str, size};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_range(U8 *first, U8 *opl){
|
||||
String8 result = {first, (U64)(opl - first)};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_cstring(U8 *cstr){
|
||||
U8 *ptr = cstr;
|
||||
for (;*ptr != 0; ptr += 1);
|
||||
String8 result = str8_range(cstr, ptr);
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_prefix(String8 str, U64 size){
|
||||
U64 size_clamped = ClampTop(size, str.size);
|
||||
String8 result = {str.str, size_clamped};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_chop(String8 str, U64 amount){
|
||||
U64 amount_clamped = ClampTop(amount, str.size);
|
||||
U64 remaining_size = str.size - amount_clamped;
|
||||
String8 result = {str.str, remaining_size};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_postfix(String8 str, U64 size){
|
||||
U64 size_clamped = ClampTop(size, str.size);
|
||||
U64 skip_to = str.size - size_clamped;
|
||||
String8 result = {str.str + skip_to, size_clamped};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_skip(String8 str, U64 amount){
|
||||
U64 amount_clamped = ClampTop(amount, str.size);
|
||||
U64 remaining_size = str.size - amount_clamped;
|
||||
String8 result = {str.str + amount_clamped, remaining_size};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_substr_opl(String8 str, U64 first, U64 opl){
|
||||
U64 opl_clamped = ClampTop(opl, str.size);
|
||||
U64 first_clamped = ClampTop(first, opl_clamped);
|
||||
String8 result = {str.str + first_clamped, opl_clamped - first_clamped};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String8
|
||||
str8_substr_size(String8 str, U64 first, U64 size){
|
||||
String8 result = str8_substr_opl(str, first, first + size);
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String16
|
||||
str16(U16 *str, U64 size){
|
||||
String16 result = {str, size};
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String16
|
||||
str16_cstring(U16 *cstr){
|
||||
U16 *ptr = cstr;
|
||||
for (;*ptr != 0; ptr += 1);
|
||||
String16 result = {cstr, (U64)(ptr - cstr)};
|
||||
return(result);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): String Path Helpers
|
||||
|
||||
function String8
|
||||
str8_chop_last_slash(String8 string){
|
||||
String8 result = string;
|
||||
if (string.size > 0){
|
||||
// pos one past last slash
|
||||
U64 pos = string.size;
|
||||
for (S64 i = string.size - 1; i >= 0; i -= 1){
|
||||
if (str8_char_is_slash(string.str[i])){
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// chop result string
|
||||
result.size = pos;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Helpers for Serializer/Deserializer Code
|
||||
|
||||
function B32
|
||||
str8_read(String8 data, U64 off, void *dst, U64 size){
|
||||
B32 result = 0;
|
||||
if (off + size <= data.size){
|
||||
result = 1;
|
||||
MemoryCopy(dst, data.str + off, size);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/* date = August 19th 2023 1:28 pm */
|
||||
|
||||
#ifndef BASE_SMALL_FUNCTIONS_H
|
||||
#define BASE_SMALL_FUNCTIONS_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Float Constant Functions
|
||||
|
||||
function F32 inf_F32(void);
|
||||
function F32 neg_inf_F32(void);
|
||||
function B32 is_inf_or_nan_F32(F32 x);
|
||||
function F64 inf_F64(void);
|
||||
function F64 neg_inf_or_nan_F64(void);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Numeric Functions
|
||||
|
||||
function F32 abs_F32(F32 x);
|
||||
function F64 abs_F64(F64 x);
|
||||
function F32 sign_F32(F32 x);
|
||||
function F64 sign_F64(F64 x);
|
||||
|
||||
// TODO(allen): trig functions based on turns instead of radians?
|
||||
|
||||
function F32 sqrt_F32(F32 x);
|
||||
function F32 sin_F32(F32 x);
|
||||
function F32 cos_F32(F32 x);
|
||||
function F32 tan_F32(F32 x);
|
||||
function F32 atan_F32(F32 x);
|
||||
function F32 atan2_F32(F32 x, F32 y);
|
||||
function F32 ln_F32(F32 x);
|
||||
function F32 pow_F32(F32 base, F32 x);
|
||||
|
||||
function F64 sqrt_F64(F64 x);
|
||||
function F64 sin_F64(F64 x);
|
||||
function F64 cos_F64(F64 x);
|
||||
function F64 tan_F64(F64 x);
|
||||
function F64 atan_F64(F64 x);
|
||||
function F64 ln_F64(F64 x);
|
||||
function F64 pow_F64(F64 base, F64 x);
|
||||
|
||||
function F32 lerp(F32 a, F32 t, F32 b);
|
||||
function F32 unlerp(F32 a, F32 x, F32 b);
|
||||
|
||||
function F32 lerp_range(RangeF32 range, F32 t);
|
||||
|
||||
function F32 trunc_F32(F32 x);
|
||||
function F32 floor_F32(F32 x);
|
||||
function F32 ceil_F32(F32 x);
|
||||
|
||||
function F32 mod_F32(F32 x, F32 m);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Compound Type Functions
|
||||
|
||||
function V2S32 v2s32(S32 x, S32 y);
|
||||
|
||||
function V2F32 v2f32(F32 x, F32 y);
|
||||
function V3F32 v3f32(F32 x, F32 y, F32 z);
|
||||
function V4F32 v4f32(F32 x, F32 y, F32 z, F32 w);
|
||||
|
||||
function RangeF32 rangef32(F32 min, F32 max);
|
||||
|
||||
function RectF32 rectf32(F32 x0, F32 y0, F32 x1, F32 y1);
|
||||
function RectF32 rectf32_vec(V2F32 min, V2F32 max);
|
||||
function RectF32 rectf32_range(RangeF32 x, RangeF32 y);
|
||||
function RectF32 rectf32_from_rects32(RectS32 *r);
|
||||
|
||||
function V2F32 v2f32_add(V2F32 a, V2F32 b);
|
||||
function V2F32 v2f32_sub(V2F32 a, V2F32 b);
|
||||
function V2F32 v2f32_scalar_mul(F32 s, V2F32 v);
|
||||
|
||||
function V2F32 v2f32_polar(F32 theta, F32 radius);
|
||||
function F32 angle_from_v2f32(V2F32 v);
|
||||
|
||||
function V2S32 dim_from_rects32(RectS32 r);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Character Functions
|
||||
|
||||
function B32 str8_char_is_slash(U8 c);
|
||||
|
||||
function U8 str8_char_uppercase(U8 c);
|
||||
function U8 str8_char_lowercase(U8 c);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): String Constructor Functions
|
||||
|
||||
function String8 str8(U8 *str, U64 size);
|
||||
function String8 str8_range(U8 *first, U8 *opl);
|
||||
function String8 str8_cstring(U8 *cstr);
|
||||
|
||||
#define str8_lit(s) str8((U8*)(s), sizeof(s) - 1)
|
||||
#define str8_typed(s) str8((U8*)(s), sizeof(*(s)))
|
||||
|
||||
function String8 str8_prefix(String8 str, U64 size);
|
||||
function String8 str8_chop(String8 str, U64 amount);
|
||||
function String8 str8_postfix(String8 str, U64 size);
|
||||
function String8 str8_skip(String8 str, U64 amount);
|
||||
function String8 str8_substr_opl(String8 str, U64 first, U64 opl);
|
||||
function String8 str8_substr_size(String8 str, U64 first, U64 size);
|
||||
|
||||
function String16 str16(U16 *str, U64 size);
|
||||
function String16 str16_cstring(U16 *cstr);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): String Path Helpers
|
||||
|
||||
function String8 str8_chop_last_slash(String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Helpers for Serializer/Deserializer Code
|
||||
|
||||
function B32 str8_read(String8 data, U64 off, void *dst, U64 size);
|
||||
#define str8_read_typed(d,o,p) str8_read((d), (o), p, sizeof(*(p)))
|
||||
|
||||
|
||||
#endif //BASE_SMALL_FUNCTIONS_H
|
||||
|
|
@ -0,0 +1,312 @@
|
|||
/* date = January 22nd 2021 3:51 pm */
|
||||
|
||||
#ifndef BASE_TYPES_H
|
||||
#define BASE_TYPES_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Variadic Functions
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Basic Constants
|
||||
|
||||
global S8 min_S8 = (S8) 0x80;
|
||||
global S16 min_S16 = (S16)0x8000;
|
||||
global S32 min_S32 = (S32)0x80000000;
|
||||
global S64 min_S64 = (S64)0x8000000000000000llu;
|
||||
|
||||
global S8 max_S8 = (S8) 0x7f;
|
||||
global S16 max_S16 = (S16)0x7fff;
|
||||
global S32 max_S32 = (S32)0x7fffffff;
|
||||
global S64 max_S64 = (S64)0x7fffffffffffffffllu;
|
||||
|
||||
global U8 max_U8 = 0xff;
|
||||
global U16 max_U16 = 0xffff;
|
||||
global U32 max_U32 = 0xffffffff;
|
||||
global U64 max_U64 = 0xffffffffffffffffllu;
|
||||
|
||||
global F32 machine_epsilon_F32 = 1.1920929e-7f;
|
||||
global F32 pi_F32 = 3.14159265359f;
|
||||
global F32 tau_F32 = 6.28318530718f;
|
||||
global F32 e_F32 = 2.71828182846f;
|
||||
global F32 gold_big_F32 = 1.61803398875f;
|
||||
global F32 gold_small_F32 = 0.61803398875f;
|
||||
|
||||
global F64 machine_epsilon_F64 = 2.220446e-16;
|
||||
global F64 pi_F64 = 3.14159265359;
|
||||
global F64 tau_F64 = 6.28318530718;
|
||||
global F64 e_F64 = 2.71828182846;
|
||||
global F64 gold_big_F64 = 1.61803398875;
|
||||
global F64 gold_small_F64 = 0.61803398875;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Symbolic Constants
|
||||
|
||||
typedef enum Axis{
|
||||
Axis_X,
|
||||
Axis_Y,
|
||||
Axis_Z,
|
||||
Axis_W
|
||||
} Axis;
|
||||
|
||||
typedef enum Side{
|
||||
Side_Min,
|
||||
Side_Max
|
||||
} Side;
|
||||
|
||||
typedef enum OperatingSystem{
|
||||
OperatingSystem_Null,
|
||||
OperatingSystem_Windows,
|
||||
OperatingSystem_Linux,
|
||||
OperatingSystem_Mac,
|
||||
OperatingSystem_COUNT
|
||||
} OperatingSystem;
|
||||
|
||||
typedef enum Architecture{
|
||||
Architecture_Null,
|
||||
Architecture_X64,
|
||||
Architecture_X86,
|
||||
Architecture_Arm,
|
||||
Architecture_Arm64,
|
||||
Architecture_COUNT
|
||||
} Architecture;
|
||||
|
||||
typedef enum Month{
|
||||
Month_Jan,
|
||||
Month_Feb,
|
||||
Month_Mar,
|
||||
Month_Apr,
|
||||
Month_May,
|
||||
Month_Jun,
|
||||
Month_Jul,
|
||||
Month_Aug,
|
||||
Month_Sep,
|
||||
Month_Oct,
|
||||
Month_Nov,
|
||||
Month_Dec
|
||||
} Month;
|
||||
|
||||
typedef enum DayOfWeek{
|
||||
DayOfWeek_Sunday,
|
||||
DayOfWeek_Monday,
|
||||
DayOfWeek_Tuesday,
|
||||
DayOfWeek_Wednesday,
|
||||
DayOfWeek_Thursday,
|
||||
DayOfWeek_Friday,
|
||||
DayOfWeek_Saturday
|
||||
} DayOfWeek;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Compound Types
|
||||
|
||||
typedef struct V2S32{
|
||||
S32 x;
|
||||
S32 y;
|
||||
} V2S32;
|
||||
|
||||
typedef struct V2F32{
|
||||
F32 x;
|
||||
F32 y;
|
||||
} V2F32;
|
||||
|
||||
typedef struct V3F32{
|
||||
F32 x;
|
||||
F32 y;
|
||||
F32 z;
|
||||
} V3F32;
|
||||
|
||||
typedef struct V4F32{
|
||||
F32 x;
|
||||
F32 y;
|
||||
F32 z;
|
||||
F32 w;
|
||||
} V4F32;
|
||||
|
||||
#define V2_EXPANDED(v) ((v).x), ((v).y)
|
||||
#define V3_EXPANDED(v) ((v).x), ((v).y), ((v).z)
|
||||
#define V4_EXPANDED(v) ((v).x), ((v).y), ((v).z), ((v).w)
|
||||
|
||||
typedef struct RangeF32{
|
||||
F32 min;
|
||||
F32 max;
|
||||
} RangeF32;
|
||||
|
||||
typedef struct RectS32{
|
||||
S32 x0;
|
||||
S32 y0;
|
||||
S32 x1;
|
||||
S32 y1;
|
||||
} RectS32;
|
||||
|
||||
typedef struct RectF32{
|
||||
F32 x0;
|
||||
F32 y0;
|
||||
F32 x1;
|
||||
F32 y1;
|
||||
} RectF32;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Basic Compound Types
|
||||
|
||||
typedef struct Array_U32{
|
||||
U32 *vals;
|
||||
U64 count;
|
||||
} Array_U32;
|
||||
|
||||
typedef struct Array_F32{
|
||||
F32 *vals;
|
||||
U64 count;
|
||||
} Array_F32;
|
||||
|
||||
typedef struct Array_V2F32{
|
||||
V2F32 *vals;
|
||||
U64 count;
|
||||
} Array_V2F32;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Data Access Flags
|
||||
|
||||
typedef U32 DataAccessFlags;
|
||||
enum{
|
||||
DataAccessFlag_Read = (1 << 0),
|
||||
DataAccessFlag_Write = (1 << 1),
|
||||
DataAccessFlag_Execute = (1 << 2),
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Time
|
||||
|
||||
typedef U64 DenseTime;
|
||||
|
||||
typedef struct DateTime{
|
||||
U16 msec; // [0,999]
|
||||
U8 sec; // [0,60]
|
||||
U8 min; // [0,59]
|
||||
U8 hour; // [0,23]
|
||||
U8 day; // [1,31]
|
||||
U8 mon; // [1,12]
|
||||
S16 year; // 1 = 1 CE; 2020 = 2020 CE; 0 = 1 BCE; -100 = 101 BCE; etc.
|
||||
} DateTime;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): File Properties
|
||||
|
||||
typedef U32 FilePropertyFlags;
|
||||
enum{
|
||||
FilePropertyFlag_IsFolder = (1 << 0),
|
||||
};
|
||||
|
||||
typedef struct FileProperties{
|
||||
U64 size;
|
||||
FilePropertyFlags flags;
|
||||
DenseTime create_time;
|
||||
DenseTime modify_time;
|
||||
DataAccessFlags access;
|
||||
} FileProperties;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Base Pre-Requisites
|
||||
|
||||
#if !defined(mem_reserve)
|
||||
# error missing definition for 'mem_reserve' type: (U64)->void*
|
||||
#endif
|
||||
#if !defined(mem_commit)
|
||||
# error missing definition for 'mem_commit' type: (void*,U64)->B32
|
||||
#endif
|
||||
#if !defined(mem_decommit)
|
||||
# error missing definition for 'mem_decommit' type: (void*,U64)->void
|
||||
#endif
|
||||
#if !defined(mem_release)
|
||||
# error missing definition for 'mem_release' type: (void*,U64)->void
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Arena Types
|
||||
|
||||
typedef struct Arena{
|
||||
struct Arena *current;
|
||||
struct Arena *prev;
|
||||
U64 alignment;
|
||||
B8 growing;
|
||||
U8 filler[7];
|
||||
U64 base_pos;
|
||||
U64 chunk_cap;
|
||||
U64 chunk_pos;
|
||||
U64 chunk_commit_pos;
|
||||
} Arena;
|
||||
|
||||
typedef struct ArenaTemp{
|
||||
Arena *arena;
|
||||
U64 pos;
|
||||
} ArenaTemp;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): String Types
|
||||
|
||||
typedef struct String8{
|
||||
U8 *str;
|
||||
U64 size;
|
||||
} String8;
|
||||
|
||||
typedef struct String8Node{
|
||||
struct String8Node *next;
|
||||
String8 string;
|
||||
} String8Node;
|
||||
|
||||
typedef struct String8List{
|
||||
String8Node *first;
|
||||
String8Node *last;
|
||||
U64 node_count;
|
||||
U64 total_size;
|
||||
} String8List;
|
||||
|
||||
typedef struct StringJoin{
|
||||
String8 pre;
|
||||
String8 mid;
|
||||
String8 post;
|
||||
} StringJoin;
|
||||
|
||||
typedef U32 StringMatchFlags;
|
||||
enum{
|
||||
StringMatchFlag_NoCase = 1 << 0,
|
||||
};
|
||||
|
||||
typedef struct String16{
|
||||
U16 *str;
|
||||
U64 size;
|
||||
} String16;
|
||||
|
||||
typedef struct String32{
|
||||
U32 *str;
|
||||
U64 size;
|
||||
} String32;
|
||||
|
||||
#define str8_expand(s) (int)((s).size), ((s).str)
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Unicode Helper Types
|
||||
|
||||
typedef struct StringDecode{
|
||||
U32 codepoint;
|
||||
U32 size;
|
||||
} StringDecode;
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): PRNG Types
|
||||
|
||||
#include "pcg/pcg_basic.h"
|
||||
|
||||
typedef struct PRNG{
|
||||
pcg32_random_t gen[2];
|
||||
} PRNG;
|
||||
|
||||
typedef struct PRNG_Seed{
|
||||
union{
|
||||
U8 v[32];
|
||||
U64 u64[4];
|
||||
};
|
||||
} PRNG_Seed;
|
||||
|
||||
|
||||
#endif //BASE_H
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/* date = May 27th 2022 8:28 pm */
|
||||
|
||||
#ifndef D3D11_API_DEFS_H
|
||||
#define D3D11_API_DEFS_H
|
||||
|
||||
#include "win32/win32_inc.h"
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <dxgi.h>
|
||||
#include <D3Dcompiler.h>
|
||||
|
||||
//- d3d function types
|
||||
|
||||
#define X(M,N,R,P) typedef R W32_##N P;
|
||||
#include "d3d11_api_funcs.h"
|
||||
#undef X
|
||||
|
||||
//- d3d function pointers
|
||||
|
||||
#define X(M,N,R,P) global W32_##N * w32_##N = 0;
|
||||
#include "d3d11_api_funcs.h"
|
||||
#undef X
|
||||
|
||||
#endif //D3D11_API_DEFS_H
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
X(dxgi, CreateDXGIFactory, HRESULT, (REFIID,void**))
|
||||
X(d3d11, D3D11CreateDevice, HRESULT,
|
||||
(IDXGIAdapter*,D3D_DRIVER_TYPE,HMODULE,UINT,
|
||||
D3D_FEATURE_LEVEL*,UINT,UINT,ID3D11Device**,
|
||||
D3D_FEATURE_LEVEL*,ID3D11DeviceContext**))
|
||||
X(d3dcompiler, D3DCompile, HRESULT,
|
||||
(LPCVOID,SIZE_T,LPCSTR,D3D_SHADER_MACRO*,
|
||||
ID3DInclude*,LPCSTR,LPCSTR,UINT,UINT,ID3DBlob**,
|
||||
ID3DBlob**))
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/* date = May 27th 2022 8:31 pm */
|
||||
|
||||
#ifndef D3D11_INC_H
|
||||
#define D3D11_INC_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): D3D11 Defines
|
||||
|
||||
#include "d3d11_api_defs.h"
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Includes
|
||||
|
||||
#include "d3d11_sys.h"
|
||||
|
||||
#endif //D3D11_INC_H
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
////////////////////////////////
|
||||
// NOTE(allen): D3D11 Function Implementations
|
||||
|
||||
global W32_D3D11Window w32_d3d11_window_slots[GFX_MAX_WINDOW_COUNT];
|
||||
|
||||
#define w32_d3d11_slot_from_handle(h) (w32_d3d11_window_slots + ((U64)(h) - 1))
|
||||
|
||||
link_function B32
|
||||
d3d11_init(void){
|
||||
B32 error = 0;
|
||||
|
||||
//- one proceed if not already initialized
|
||||
if (w32_d3d11.dxgi == 0){
|
||||
|
||||
//- set up window slots
|
||||
if (!error){
|
||||
MemoryZeroArray(w32_d3d11_window_slots);
|
||||
}
|
||||
|
||||
//- load d3d11 modules
|
||||
if (!error){
|
||||
w32_d3d11.dxgi = LoadLibraryA("dxgi.dll");
|
||||
w32_d3d11.d3d11 = LoadLibraryA("d3d11.dll");
|
||||
w32_d3d11.d3dcompiler = LoadLibraryA("d3dcompiler_47.dll");
|
||||
|
||||
if (w32_d3d11.dxgi == 0 ||
|
||||
w32_d3d11.d3d11 == 0 ||
|
||||
w32_d3d11.d3dcompiler == 0){
|
||||
er_emit(str8_lit("failed to initialize d3d11 dll(s)"));
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- load & check d3d11 functions
|
||||
if (!error){
|
||||
#define X(M,N,R,P) W32_PROC_ADDR(w32_##N, w32_d3d11.M, #N);
|
||||
#include "d3d11_api_funcs.h"
|
||||
#undef X
|
||||
|
||||
B32 missing_d3d_func = 0;
|
||||
#define X(M,N,R,P) if (w32_##N == 0){ missing_d3d_func = 1; }
|
||||
#include "d3d11_api_funcs.h"
|
||||
#undef X
|
||||
|
||||
if (missing_d3d_func){
|
||||
er_emit(str8_lit("failed to load d3d11 function(s)"));
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- device & context
|
||||
if (!error){
|
||||
UINT flags = D3D11_CREATE_DEVICE_DEBUG;
|
||||
HRESULT r = w32_D3D11CreateDevice(0, D3D_DRIVER_TYPE_HARDWARE, 0,
|
||||
flags, 0, 0,
|
||||
D3D11_SDK_VERSION,
|
||||
&w32_d3d11.device, 0, &w32_d3d11.ctx);
|
||||
|
||||
if (r != S_OK){
|
||||
er_emit(str8_lit("failed to create d3d11 device"));
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- debug
|
||||
if (!error){
|
||||
HRESULT r = w32_d3d11.device->QueryInterface(__uuidof(ID3D11Debug),
|
||||
(void**)(&w32_d3d11.dbg));
|
||||
(void)(r);
|
||||
}
|
||||
|
||||
//- on error clean up "non-temps"
|
||||
if (error){
|
||||
if (w32_d3d11.dxgi != 0){
|
||||
FreeLibrary(w32_d3d11.dxgi);
|
||||
}
|
||||
if (w32_d3d11.d3d11 != 0){
|
||||
FreeLibrary(w32_d3d11.d3d11);
|
||||
}
|
||||
if (w32_d3d11.d3dcompiler != 0){
|
||||
FreeLibrary(w32_d3d11.d3dcompiler);
|
||||
}
|
||||
|
||||
if (w32_d3d11.device != 0){
|
||||
w32_d3d11.device->Release();
|
||||
}
|
||||
if (w32_d3d11.ctx != 0){
|
||||
w32_d3d11.ctx->Release();
|
||||
}
|
||||
if (w32_d3d11.dbg != 0){
|
||||
w32_d3d11.dbg->Release();
|
||||
}
|
||||
|
||||
#define X(M,N,R,P) w32_##N = 0;
|
||||
#include "d3d11_api_funcs.h"
|
||||
#undef X
|
||||
MemoryZeroStruct(&w32_d3d11);
|
||||
}
|
||||
}
|
||||
|
||||
//- fill result
|
||||
B32 result = (!error);
|
||||
return(result);
|
||||
}
|
||||
|
||||
link_function void
|
||||
d3d11_window_release(GFX_Window *window){
|
||||
if (gfx_window_is_valid(window)){
|
||||
W32_D3D11Window *slot = w32_d3d11_slot_from_handle(window);
|
||||
if (slot->swap_chain != 0){
|
||||
slot->swap_chain->Release();
|
||||
}
|
||||
|
||||
// NOTE(allen): Annoying. We have to do this to ensure
|
||||
// immediate release of the swap chain. The API does some
|
||||
// defering of freeing on these things for some reason, and
|
||||
// the freeing won't kick in no matter how many frees are
|
||||
// queued up, even managing to crash *the entire computer*
|
||||
// when I was testing it. In practice it might be annoying
|
||||
// to have this clear state changing the state of the
|
||||
// system? And if only a few releases like this are likely
|
||||
// to be queued up between natural calls to these, maybe
|
||||
// it's just fine. Keep an eye on this issue.
|
||||
w32_d3d11.ctx->ClearState();
|
||||
w32_d3d11.ctx->Flush();
|
||||
|
||||
MemoryZeroStruct(slot);
|
||||
}
|
||||
}
|
||||
|
||||
link_function B32
|
||||
d3d11_equip_window(GFX_Window *window){
|
||||
String8 error = {};
|
||||
|
||||
if (!gfx_window_is_valid(window)){
|
||||
error = str8_lit("error invalid window handle");
|
||||
}
|
||||
if (gfx_window_get_equipped_data(window) != 0){
|
||||
error = str8_lit("error window is already equipped");
|
||||
}
|
||||
|
||||
//- swap chain
|
||||
IDXGISwapChain *swap_chain = 0;
|
||||
if (error.str == 0){
|
||||
W32_Window *window_slot = gfx_w32_window_from_handle(window);
|
||||
W32_D3D11Window *slot = w32_d3d11_slot_from_handle(window);
|
||||
|
||||
IDXGIFactory *factory = 0;
|
||||
HRESULT factory_result = w32_CreateDXGIFactory(__uuidof(IDXGIFactory),
|
||||
(void**)&factory);
|
||||
if (factory_result == S_OK){
|
||||
DXGI_SWAP_CHAIN_DESC desc = {};
|
||||
desc.BufferDesc.Width = 1024;
|
||||
desc.BufferDesc.Height = 768;
|
||||
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
desc.BufferCount = 1;
|
||||
desc.OutputWindow = window_slot->wnd;
|
||||
desc.Windowed = 1;
|
||||
factory->CreateSwapChain(w32_d3d11.device, &desc, &swap_chain);
|
||||
factory->Release();
|
||||
}
|
||||
|
||||
if (swap_chain == 0){
|
||||
error = str8_lit("error w/ swap chain");
|
||||
}
|
||||
}
|
||||
|
||||
//- fill equipment
|
||||
if (error.str == 0){
|
||||
W32_D3D11Window *slot = w32_d3d11_slot_from_handle(window);
|
||||
slot->swap_chain = swap_chain;
|
||||
|
||||
gfx_window_set_equipped_data(window, slot, d3d11_window_release);
|
||||
}
|
||||
|
||||
//- on error cleanup "non-temps"
|
||||
if (error.str != 0){
|
||||
if (swap_chain != 0){
|
||||
swap_chain->Release();
|
||||
}
|
||||
|
||||
// NOTE(allen): Annoying. Need this for swap chain
|
||||
// to release properly. More thoughts in d3d11_window_release.
|
||||
w32_d3d11.ctx->ClearState();
|
||||
w32_d3d11.ctx->Flush();
|
||||
}
|
||||
|
||||
//- fill result
|
||||
B32 result = (error.str == 0);
|
||||
return(result);
|
||||
}
|
||||
|
||||
global IDXGISwapChain *w32_d3d11_swap_chain = 0;
|
||||
|
||||
link_function ID3D11RenderTargetView*
|
||||
d3d11_begin_render(GFX_Window *window){
|
||||
ID3D11RenderTargetView *result = 0;
|
||||
// TODO(allen): Check equipment here
|
||||
if (gfx_window_is_valid(window) &&
|
||||
w32_d3d11_swap_chain == 0){
|
||||
W32_D3D11Window *slot = w32_d3d11_slot_from_handle(window);
|
||||
IDXGISwapChain *swap_chain = slot->swap_chain;
|
||||
|
||||
// get view
|
||||
ID3D11Texture2D *buffer = 0;
|
||||
DWORD buffer_result =
|
||||
swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)(&buffer));
|
||||
if (buffer_result == S_OK){
|
||||
ID3D11RenderTargetView *view = 0;
|
||||
DWORD view_result =
|
||||
w32_d3d11.device->CreateRenderTargetView(buffer, 0, &view);
|
||||
if (view_result == S_OK){
|
||||
result = view;
|
||||
w32_d3d11_swap_chain = swap_chain;
|
||||
}
|
||||
}
|
||||
|
||||
// release buffer
|
||||
if (buffer != 0){
|
||||
buffer->Release();
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
link_function void
|
||||
d3d11_end_render(ID3D11RenderTargetView *view){
|
||||
if (w32_d3d11_swap_chain != 0){
|
||||
w32_d3d11_swap_chain->Present(0, 0);
|
||||
view->Release();
|
||||
w32_d3d11_swap_chain = 0;
|
||||
}
|
||||
}
|
||||
|
||||
link_function W32_D3D11Window*
|
||||
d3d11_window_from_gfx_window(GFX_Window *w){
|
||||
W32_D3D11Window *result = 0;
|
||||
// TODO(allen): Check equipment here
|
||||
if (gfx_window_is_valid(w)){
|
||||
result = w32_d3d11_slot_from_handle(w);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/* date = May 27th 2022 8:29 pm */
|
||||
|
||||
#ifndef D3D11_SYS_H
|
||||
#define D3D11_SYS_H
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): D3D11 Types
|
||||
|
||||
typedef struct W32_D3D11Globals{
|
||||
HMODULE dxgi;
|
||||
HMODULE d3d11;
|
||||
HMODULE d3dcompiler;
|
||||
|
||||
ID3D11Device *device;
|
||||
ID3D11DeviceContext *ctx;
|
||||
ID3D11Debug *dbg;
|
||||
} W32_D3D11Globals;
|
||||
|
||||
typedef struct W32_D3D11Window{
|
||||
IDXGISwapChain *swap_chain;
|
||||
} W32_D3D11Window;
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): D3D11 Globals
|
||||
|
||||
global W32_D3D11Globals w32_d3d11 = {0};
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): System D3D11 Functions
|
||||
|
||||
link_function B32 d3d11_init(void);
|
||||
|
||||
link_function B32 d3d11_equip_window(GFX_Window *w);
|
||||
|
||||
link_function ID3D11RenderTargetView*d3d11_begin_render(GFX_Window *w);
|
||||
link_function void d3d11_end_render(ID3D11RenderTargetView *view);
|
||||
|
||||
link_function W32_D3D11Window* d3d11_window_from_gfx_window(GFX_Window *w);
|
||||
|
||||
#endif //D3D11S_SYS_H
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
////////////////////////////////
|
||||
// NOTE(allen): Includes
|
||||
|
||||
#ifndef D3D11_TARGET_CPP
|
||||
#define D3D11_TARGET_CPP
|
||||
|
||||
#include "base/base_inc.h"
|
||||
#include "gfx/gfx_inc.h"
|
||||
|
||||
#include "d3d11/d3d11_inc.h"
|
||||
|
||||
#include "base/base_inc.c"
|
||||
#include "d3d11/d3d11_sys.cpp"
|
||||
|
||||
#endif //D3D11_TARGET_CPP
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
FREETYPE LICENSES
|
||||
-----------------
|
||||
|
||||
The FreeType 2 font engine is copyrighted work and cannot be used
|
||||
legally without a software license. In order to make this project
|
||||
usable to a vast majority of developers, we distribute it under two
|
||||
mutually exclusive open-source licenses.
|
||||
|
||||
This means that *you* must choose *one* of the two licenses described
|
||||
below, then obey all its terms and conditions when using FreeType 2 in
|
||||
any of your projects or products.
|
||||
|
||||
- The FreeType License, found in the file `docs/FTL.TXT`, which is
|
||||
similar to the original BSD license *with* an advertising clause
|
||||
that forces you to explicitly cite the FreeType project in your
|
||||
product's documentation. All details are in the license file.
|
||||
This license is suited to products which don't use the GNU General
|
||||
Public License.
|
||||
|
||||
Note that this license is compatible to the GNU General Public
|
||||
License version 3, but not version 2.
|
||||
|
||||
- The GNU General Public License version 2, found in
|
||||
`docs/GPLv2.TXT` (any later version can be used also), for
|
||||
programs which already use the GPL. Note that the FTL is
|
||||
incompatible with GPLv2 due to its advertisement clause.
|
||||
|
||||
The contributed BDF and PCF drivers come with a license similar to
|
||||
that of the X Window System. It is compatible to the above two
|
||||
licenses (see files `src/bdf/README` and `src/pcf/README`). The same
|
||||
holds for the source code files `src/base/fthash.c` and
|
||||
`include/freetype/internal/fthash.h`; they wer part of the BDF driver
|
||||
in earlier FreeType versions.
|
||||
|
||||
The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
|
||||
too is compatible to the above two licenses.
|
||||
|
||||
The MD5 checksum support (only used for debugging in development
|
||||
builds) is in the public domain.
|
||||
|
||||
|
||||
--- end of LICENSE.TXT ---
|
||||
|
|
@ -0,0 +1,348 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftdebug.c
|
||||
*
|
||||
* Debugging and logging component for amiga (body).
|
||||
*
|
||||
* Copyright (C) 1996-2022 by
|
||||
* David Turner, Robert Wilhelm, Werner Lemberg, and Detlef Wuerkner.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used,
|
||||
* modified, and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* This component contains various macros and functions used to ease the
|
||||
* debugging of the FreeType engine. Its main purpose is in assertion
|
||||
* checking, tracing, and error detection.
|
||||
*
|
||||
* There are now three debugging modes:
|
||||
*
|
||||
* - trace mode
|
||||
*
|
||||
* Error and trace messages are sent to the log file (which can be the
|
||||
* standard error output).
|
||||
*
|
||||
* - error mode
|
||||
*
|
||||
* Only error messages are generated.
|
||||
*
|
||||
* - release mode:
|
||||
*
|
||||
* No error message is sent or generated. The code is free from any
|
||||
* debugging parts.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Based on the default `ftdebug.c' file,
|
||||
* replaced `vprintf' with `KVPrintF',
|
||||
* commented out `exit',
|
||||
* replaced `getenv' with `GetVar'.
|
||||
*/
|
||||
|
||||
#include <exec/types.h>
|
||||
#include <utility/tagitem.h>
|
||||
#include <dos/exall.h>
|
||||
#include <dos/var.h>
|
||||
|
||||
#define __NOLIBBASE__
|
||||
#define __NOLOBALIFACE__
|
||||
#define __USE_INLINE__
|
||||
|
||||
#include <proto/dos.h>
|
||||
#include <clib/debug_protos.h>
|
||||
|
||||
#ifndef __amigaos4__
|
||||
extern struct Library* DOSBase;
|
||||
#else
|
||||
extern struct DOSIFace* IDOS;
|
||||
#endif
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_ERROR
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Message( const char* fmt,
|
||||
... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
KVPrintF( fmt, ap );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Panic( const char* fmt,
|
||||
... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
KVPrintF( fmt, ap );
|
||||
va_end( ap );
|
||||
|
||||
/* exit( EXIT_FAILURE ); */
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( int )
|
||||
FT_Throw( FT_Error error,
|
||||
int line,
|
||||
const char* file )
|
||||
{
|
||||
#if 0
|
||||
/* activating the code in this block makes FreeType very chatty */
|
||||
fprintf( stderr,
|
||||
"%s:%d: error 0x%02x: %s\n",
|
||||
file,
|
||||
line,
|
||||
error,
|
||||
FT_Error_String( error ) );
|
||||
#else
|
||||
FT_UNUSED( error );
|
||||
FT_UNUSED( line );
|
||||
FT_UNUSED( file );
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
|
||||
/* array of trace levels, initialized to 0; */
|
||||
/* this gets adjusted at run-time */
|
||||
static int ft_trace_levels_enabled[trace_count];
|
||||
|
||||
/* array of trace levels, always initialized to 0 */
|
||||
static int ft_trace_levels_disabled[trace_count];
|
||||
|
||||
/* a pointer to either `ft_trace_levels_enabled' */
|
||||
/* or `ft_trace_levels_disabled' */
|
||||
int* ft_trace_levels;
|
||||
|
||||
/* define array of trace toggle names */
|
||||
#define FT_TRACE_DEF( x ) #x ,
|
||||
|
||||
static const char* ft_trace_toggles[trace_count + 1] =
|
||||
{
|
||||
#include <freetype/internal/fttrace.h>
|
||||
NULL
|
||||
};
|
||||
|
||||
#undef FT_TRACE_DEF
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( FT_Int )
|
||||
FT_Trace_Get_Count( void )
|
||||
{
|
||||
return trace_count;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( const char * )
|
||||
FT_Trace_Get_Name( FT_Int idx )
|
||||
{
|
||||
int max = FT_Trace_Get_Count();
|
||||
|
||||
|
||||
if ( idx < max )
|
||||
return ft_trace_toggles[idx];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Disable( void )
|
||||
{
|
||||
ft_trace_levels = ft_trace_levels_disabled;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Enable( void )
|
||||
{
|
||||
ft_trace_levels = ft_trace_levels_enabled;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Initialize the tracing sub-system. This is done by retrieving the
|
||||
* value of the `FT2_DEBUG' environment variable. It must be a list of
|
||||
* toggles, separated by spaces, `;', or `,'. Example:
|
||||
*
|
||||
* export FT2_DEBUG="any:3 memory:7 stream:5"
|
||||
*
|
||||
* This requests that all levels be set to 3, except the trace level for
|
||||
* the memory and stream components which are set to 7 and 5,
|
||||
* respectively.
|
||||
*
|
||||
* See the file `include/freetype/internal/fttrace.h' for details of
|
||||
* the available toggle names.
|
||||
*
|
||||
* The level must be between 0 and 7; 0 means quiet (except for serious
|
||||
* runtime errors), and 7 means _very_ verbose.
|
||||
*/
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
{
|
||||
/* const char* ft2_debug = ft_getenv( "FT2_DEBUG" ); */
|
||||
char buf[256];
|
||||
const char* ft2_debug = &buf[0];
|
||||
|
||||
|
||||
/* if ( ft2_debug ) */
|
||||
if ( GetVar( "FT2_DEBUG", (STRPTR)ft2_debug, 256, LV_VAR ) > 0 )
|
||||
{
|
||||
const char* p = ft2_debug;
|
||||
const char* q;
|
||||
|
||||
|
||||
for ( ; *p; p++ )
|
||||
{
|
||||
/* skip leading whitespace and separators */
|
||||
if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
|
||||
continue;
|
||||
|
||||
/* read toggle name, followed by ':' */
|
||||
q = p;
|
||||
while ( *p && *p != ':' )
|
||||
p++;
|
||||
|
||||
if ( !*p )
|
||||
break;
|
||||
|
||||
if ( *p == ':' && p > q )
|
||||
{
|
||||
FT_Int n, i, len = (FT_Int)( p - q );
|
||||
FT_Int level = -1, found = -1;
|
||||
|
||||
|
||||
for ( n = 0; n < trace_count; n++ )
|
||||
{
|
||||
const char* toggle = ft_trace_toggles[n];
|
||||
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
{
|
||||
if ( toggle[i] != q[i] )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i == len && toggle[i] == 0 )
|
||||
{
|
||||
found = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* read level */
|
||||
p++;
|
||||
if ( *p )
|
||||
{
|
||||
level = *p - '0';
|
||||
if ( level < 0 || level > 7 )
|
||||
level = -1;
|
||||
}
|
||||
|
||||
if ( found >= 0 && level >= 0 )
|
||||
{
|
||||
if ( found == trace_any )
|
||||
{
|
||||
/* special case for `any' */
|
||||
for ( n = 0; n < trace_count; n++ )
|
||||
ft_trace_levels_enabled[n] = level;
|
||||
}
|
||||
else
|
||||
ft_trace_levels_enabled[found] = level;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ft_trace_levels = ft_trace_levels_enabled;
|
||||
}
|
||||
|
||||
|
||||
#else /* !FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
|
||||
FT_BASE_DEF( FT_Int )
|
||||
FT_Trace_Get_Count( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
FT_BASE_DEF( const char * )
|
||||
FT_Trace_Get_Name( FT_Int idx )
|
||||
{
|
||||
FT_UNUSED( idx );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Disable( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Enable( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
|
||||
#endif /* !FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
@ -0,0 +1,530 @@
|
|||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsystem.c */
|
||||
/* */
|
||||
/* Amiga-specific FreeType low-level system interface (body). */
|
||||
/* */
|
||||
/* Copyright (C) 1996-2022 by */
|
||||
/* David Turner, Robert Wilhelm, Werner Lemberg and Detlef Würkner. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file contains the Amiga interface used by FreeType to access */
|
||||
/* low-level, i.e. memory management, i/o access as well as thread */
|
||||
/* synchronisation. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Maintained by Detlef Würkner <TetiSoft@apg.lahn.de> */
|
||||
/* */
|
||||
/* Based on the original ftsystem.c, */
|
||||
/* modified to avoid fopen(), fclose(), fread(), fseek(), ftell(), */
|
||||
/* malloc(), realloc(), and free(). */
|
||||
/* */
|
||||
/* Those C library functions are often not thread-safe or cant be */
|
||||
/* used in a shared Amiga library. If that's not a problem for you, */
|
||||
/* you can of course use the default ftsystem.c with C library calls */
|
||||
/* instead. */
|
||||
/* */
|
||||
/* This implementation needs exec V39+ because it uses AllocPooled() etc */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
#define __NOLIBBASE__
|
||||
#define __NOGLOBALIFACE__
|
||||
#define __USE_INLINE__
|
||||
#include <proto/exec.h>
|
||||
#include <dos/stdio.h>
|
||||
#include <proto/dos.h>
|
||||
#ifdef __amigaos4__
|
||||
extern struct ExecIFace *IExec;
|
||||
extern struct DOSIFace *IDOS;
|
||||
#else
|
||||
extern struct Library *SysBase;
|
||||
extern struct Library *DOSBase;
|
||||
#endif
|
||||
|
||||
#define IOBUF_SIZE 512
|
||||
|
||||
/* structure that helps us to avoid
|
||||
* useless calls of Seek() and Read()
|
||||
*/
|
||||
struct SysFile
|
||||
{
|
||||
BPTR file;
|
||||
ULONG iobuf_start;
|
||||
ULONG iobuf_end;
|
||||
UBYTE iobuf[IOBUF_SIZE];
|
||||
};
|
||||
|
||||
#ifndef __amigaos4__
|
||||
/* C implementation of AllocVecPooled (see autodoc exec/AllocPooled) */
|
||||
APTR
|
||||
Alloc_VecPooled( APTR poolHeader,
|
||||
ULONG memSize )
|
||||
{
|
||||
ULONG newSize = memSize + sizeof ( ULONG );
|
||||
ULONG *mem = AllocPooled( poolHeader, newSize );
|
||||
|
||||
if ( !mem )
|
||||
return NULL;
|
||||
*mem = newSize;
|
||||
return mem + 1;
|
||||
}
|
||||
|
||||
/* C implementation of FreeVecPooled (see autodoc exec/AllocPooled) */
|
||||
void
|
||||
Free_VecPooled( APTR poolHeader,
|
||||
APTR memory )
|
||||
{
|
||||
ULONG *realmem = (ULONG *)memory - 1;
|
||||
|
||||
FreePooled( poolHeader, realmem, *realmem );
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_CONFIG_H
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/ftsystem.h>
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/fttypes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* MEMORY MANAGEMENT INTERFACE */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* It is not necessary to do any error checking for the */
|
||||
/* allocation-related functions. This is done by the higher level */
|
||||
/* routines like ft_mem_alloc() or ft_mem_realloc(). */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_alloc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory allocation function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* size :: The requested size in bytes. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The address of newly allocated block. */
|
||||
/* */
|
||||
FT_CALLBACK_DEF( void* )
|
||||
ft_alloc( FT_Memory memory,
|
||||
long size )
|
||||
{
|
||||
#ifdef __amigaos4__
|
||||
return AllocVecPooled( memory->user, size );
|
||||
#else
|
||||
return Alloc_VecPooled( memory->user, size );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_realloc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory reallocation function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* cur_size :: The current size of the allocated memory block. */
|
||||
/* */
|
||||
/* new_size :: The newly requested size in bytes. */
|
||||
/* */
|
||||
/* block :: The current address of the block in memory. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The address of the reallocated memory block. */
|
||||
/* */
|
||||
FT_CALLBACK_DEF( void* )
|
||||
ft_realloc( FT_Memory memory,
|
||||
long cur_size,
|
||||
long new_size,
|
||||
void* block )
|
||||
{
|
||||
void* new_block;
|
||||
|
||||
#ifdef __amigaos4__
|
||||
new_block = AllocVecPooled ( memory->user, new_size );
|
||||
#else
|
||||
new_block = Alloc_VecPooled ( memory->user, new_size );
|
||||
#endif
|
||||
if ( new_block != NULL )
|
||||
{
|
||||
CopyMem ( block, new_block,
|
||||
( new_size > cur_size ) ? cur_size : new_size );
|
||||
#ifdef __amigaos4__
|
||||
FreeVecPooled ( memory->user, block );
|
||||
#else
|
||||
Free_VecPooled ( memory->user, block );
|
||||
#endif
|
||||
}
|
||||
return new_block;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_free */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory release function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* block :: The address of block in memory to be freed. */
|
||||
/* */
|
||||
FT_CALLBACK_DEF( void )
|
||||
ft_free( FT_Memory memory,
|
||||
void* block )
|
||||
{
|
||||
#ifdef __amigaos4__
|
||||
FreeVecPooled( memory->user, block );
|
||||
#else
|
||||
Free_VecPooled( memory->user, block );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* RESOURCE MANAGEMENT INTERFACE */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT io
|
||||
|
||||
/* We use the macro STREAM_FILE for convenience to extract the */
|
||||
/* system-specific stream handle from a given FreeType stream object */
|
||||
#define STREAM_FILE( stream ) ( (struct SysFile *)stream->descriptor.pointer )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_amiga_stream_close */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The function to close a stream. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: A pointer to the stream object. */
|
||||
/* */
|
||||
FT_CALLBACK_DEF( void )
|
||||
ft_amiga_stream_close( FT_Stream stream )
|
||||
{
|
||||
struct SysFile* sysfile;
|
||||
|
||||
sysfile = STREAM_FILE( stream );
|
||||
Close ( sysfile->file );
|
||||
FreeMem ( sysfile, sizeof ( struct SysFile ));
|
||||
|
||||
stream->descriptor.pointer = NULL;
|
||||
stream->size = 0;
|
||||
stream->base = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_amiga_stream_io */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The function to open a stream. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: A pointer to the stream object. */
|
||||
/* */
|
||||
/* offset :: The position in the data stream to start reading. */
|
||||
/* */
|
||||
/* buffer :: The address of buffer to store the read data. */
|
||||
/* */
|
||||
/* count :: The number of bytes to read from the stream. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The number of bytes actually read. */
|
||||
/* */
|
||||
FT_CALLBACK_DEF( unsigned long )
|
||||
ft_amiga_stream_io( FT_Stream stream,
|
||||
unsigned long offset,
|
||||
unsigned char* buffer,
|
||||
unsigned long count )
|
||||
{
|
||||
struct SysFile* sysfile;
|
||||
unsigned long read_bytes;
|
||||
|
||||
if ( count != 0 )
|
||||
{
|
||||
sysfile = STREAM_FILE( stream );
|
||||
|
||||
/* handle the seek */
|
||||
if ( (offset < sysfile->iobuf_start) || (offset + count > sysfile->iobuf_end) )
|
||||
{
|
||||
/* requested offset implies we need a buffer refill */
|
||||
if ( !sysfile->iobuf_end || offset != sysfile->iobuf_end )
|
||||
{
|
||||
/* a physical seek is necessary */
|
||||
Seek( sysfile->file, offset, OFFSET_BEGINNING );
|
||||
}
|
||||
sysfile->iobuf_start = offset;
|
||||
sysfile->iobuf_end = 0; /* trigger a buffer refill */
|
||||
}
|
||||
|
||||
/* handle the read */
|
||||
if ( offset + count <= sysfile->iobuf_end )
|
||||
{
|
||||
/* we have buffer and requested bytes are all inside our buffer */
|
||||
CopyMem( &sysfile->iobuf[offset - sysfile->iobuf_start], buffer, count );
|
||||
read_bytes = count;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* (re)fill buffer */
|
||||
if ( count <= IOBUF_SIZE )
|
||||
{
|
||||
/* requested bytes is a subset of the buffer */
|
||||
read_bytes = Read( sysfile->file, sysfile->iobuf, IOBUF_SIZE );
|
||||
if ( read_bytes == -1UL )
|
||||
{
|
||||
/* error */
|
||||
read_bytes = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sysfile->iobuf_end = offset + read_bytes;
|
||||
CopyMem( sysfile->iobuf, buffer, count );
|
||||
if ( read_bytes > count )
|
||||
{
|
||||
read_bytes = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we actually need more than our buffer can hold, so we decide
|
||||
** to do a single big read, and then copy the last IOBUF_SIZE
|
||||
** bytes of that to our internal buffer for later use */
|
||||
read_bytes = Read( sysfile->file, buffer, count );
|
||||
if ( read_bytes == -1UL )
|
||||
{
|
||||
/* error */
|
||||
read_bytes = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG bufsize;
|
||||
|
||||
bufsize = ( read_bytes > IOBUF_SIZE ) ? IOBUF_SIZE : read_bytes;
|
||||
sysfile->iobuf_end = offset + read_bytes;
|
||||
sysfile->iobuf_start = sysfile->iobuf_end - bufsize;
|
||||
CopyMem( &buffer[read_bytes - bufsize] , sysfile->iobuf, bufsize );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
read_bytes = 0;
|
||||
}
|
||||
|
||||
return read_bytes;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftobjs.h */
|
||||
|
||||
FT_BASE_DEF( FT_Error )
|
||||
FT_Stream_Open( FT_Stream stream,
|
||||
const char* filepathname )
|
||||
{
|
||||
struct FileInfoBlock* fib;
|
||||
struct SysFile* sysfile;
|
||||
|
||||
|
||||
if ( !stream )
|
||||
return FT_THROW( Invalid_Stream_Handle );
|
||||
|
||||
#ifdef __amigaos4__
|
||||
sysfile = AllocMem ( sizeof (struct SysFile ), MEMF_SHARED );
|
||||
#else
|
||||
sysfile = AllocMem ( sizeof (struct SysFile ), MEMF_PUBLIC );
|
||||
#endif
|
||||
if ( !sysfile )
|
||||
{
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
||||
|
||||
return FT_THROW( Cannot_Open_Resource );
|
||||
}
|
||||
sysfile->file = Open( (STRPTR)filepathname, MODE_OLDFILE );
|
||||
if ( !sysfile->file )
|
||||
{
|
||||
FreeMem ( sysfile, sizeof ( struct SysFile ));
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
||||
|
||||
return FT_THROW( Cannot_Open_Resource );
|
||||
}
|
||||
|
||||
fib = AllocDosObject( DOS_FIB, NULL );
|
||||
if ( !fib )
|
||||
{
|
||||
Close ( sysfile->file );
|
||||
FreeMem ( sysfile, sizeof ( struct SysFile ));
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
||||
|
||||
return FT_THROW( Cannot_Open_Resource );
|
||||
}
|
||||
if ( !( ExamineFH( sysfile->file, fib ) ) )
|
||||
{
|
||||
FreeDosObject( DOS_FIB, fib );
|
||||
Close ( sysfile->file );
|
||||
FreeMem ( sysfile, sizeof ( struct SysFile ));
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
||||
|
||||
return FT_THROW( Cannot_Open_Resource );
|
||||
}
|
||||
stream->size = fib->fib_Size;
|
||||
FreeDosObject( DOS_FIB, fib );
|
||||
|
||||
stream->descriptor.pointer = (void *)sysfile;
|
||||
stream->pathname.pointer = (char*)filepathname;
|
||||
sysfile->iobuf_start = 0;
|
||||
sysfile->iobuf_end = 0;
|
||||
stream->pos = 0;
|
||||
|
||||
stream->read = ft_amiga_stream_io;
|
||||
stream->close = ft_amiga_stream_close;
|
||||
|
||||
if ( !stream->size )
|
||||
{
|
||||
ft_amiga_stream_close( stream );
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " opened `%s' but zero-sized\n", filepathname ));
|
||||
return FT_THROW( Cannot_Open_Stream );
|
||||
}
|
||||
|
||||
FT_TRACE1(( "FT_Stream_Open:" ));
|
||||
FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
|
||||
filepathname, stream->size ));
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_MEMORY
|
||||
|
||||
extern FT_Int
|
||||
ft_mem_debug_init( FT_Memory memory );
|
||||
|
||||
extern void
|
||||
ft_mem_debug_done( FT_Memory memory );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* documentation is in ftobjs.h */
|
||||
|
||||
FT_BASE_DEF( FT_Memory )
|
||||
FT_New_Memory( void )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
#ifdef __amigaos4__
|
||||
memory = (FT_Memory)AllocVec( sizeof ( *memory ), MEMF_SHARED );
|
||||
#else
|
||||
memory = (FT_Memory)AllocVec( sizeof ( *memory ), MEMF_PUBLIC );
|
||||
#endif
|
||||
if ( memory )
|
||||
{
|
||||
#ifdef __amigaos4__
|
||||
memory->user = CreatePool( MEMF_SHARED, 16384, 16384 );
|
||||
#else
|
||||
memory->user = CreatePool( MEMF_PUBLIC, 16384, 16384 );
|
||||
#endif
|
||||
if ( memory->user == NULL )
|
||||
{
|
||||
FreeVec( memory );
|
||||
memory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
memory->alloc = ft_alloc;
|
||||
memory->realloc = ft_realloc;
|
||||
memory->free = ft_free;
|
||||
#ifdef FT_DEBUG_MEMORY
|
||||
ft_mem_debug_init( memory );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return memory;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftobjs.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Done_Memory( FT_Memory memory )
|
||||
{
|
||||
#ifdef FT_DEBUG_MEMORY
|
||||
ft_mem_debug_done( memory );
|
||||
#endif
|
||||
|
||||
DeletePool( memory->user );
|
||||
FreeVec( memory );
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
coding: latin-1
|
||||
End:
|
||||
*/
|
||||
/* END */
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
#
|
||||
# FreeType 2 host platform detection rules
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# This sub-Makefile is in charge of detecting the current platform. It sets
|
||||
# the following variables:
|
||||
#
|
||||
# PLATFORM_DIR The configuration and system-specific directory. Usually
|
||||
# `builds/$(PLATFORM)' but can be different for custom builds
|
||||
# of the library.
|
||||
#
|
||||
# The following variables must be defined in system specific `detect.mk'
|
||||
# files:
|
||||
#
|
||||
# PLATFORM The detected platform. This will default to `ansi' if
|
||||
# auto-detection fails.
|
||||
# CONFIG_FILE The configuration sub-makefile to use. This usually depends
|
||||
# on the compiler defined in the `CC' environment variable.
|
||||
# DELETE The shell command used to remove a given file.
|
||||
# COPY The shell command used to copy one file.
|
||||
# SEP The platform-specific directory separator.
|
||||
# COMPILER_SEP The separator used in arguments of the compilation tools.
|
||||
# CC The compiler to use.
|
||||
#
|
||||
# You need to set the following variable(s) before calling it:
|
||||
#
|
||||
# TOP_DIR The top-most directory in the FreeType library source
|
||||
# hierarchy. If not defined, it will default to `.'.
|
||||
|
||||
# Set auto-detection default to `ansi' resp. UNIX-like operating systems.
|
||||
#
|
||||
PLATFORM := ansi
|
||||
DELETE := $(RM)
|
||||
COPY := cp
|
||||
CAT := cat
|
||||
SEP := /
|
||||
|
||||
BUILD_CONFIG := $(TOP_DIR)/builds
|
||||
|
||||
# These two assignments must be delayed.
|
||||
PLATFORM_DIR = $(BUILD_CONFIG)/$(PLATFORM)
|
||||
CONFIG_RULES = $(PLATFORM_DIR)/$(CONFIG_FILE)
|
||||
|
||||
# We define the BACKSLASH variable to hold a single back-slash character.
|
||||
# This is needed because a line like
|
||||
#
|
||||
# SEP := \
|
||||
#
|
||||
# does not work with GNU Make (the backslash is interpreted as a line
|
||||
# continuation). While a line like
|
||||
#
|
||||
# SEP := \\
|
||||
#
|
||||
# really defines $(SEP) as `\' on Unix, and `\\' on Dos and Windows!
|
||||
#
|
||||
BACKSLASH := $(strip \ )
|
||||
|
||||
# Find all auto-detectable platforms.
|
||||
#
|
||||
PLATFORMS := $(notdir $(subst /detect.mk,,$(wildcard $(BUILD_CONFIG)/*/detect.mk)))
|
||||
.PHONY: $(PLATFORMS) ansi
|
||||
|
||||
# Filter out platform specified as setup target.
|
||||
#
|
||||
PLATFORM := $(firstword $(filter $(MAKECMDGOALS),$(PLATFORMS)))
|
||||
|
||||
# If no setup target platform was specified, enable auto-detection/
|
||||
# default platform.
|
||||
#
|
||||
ifeq ($(PLATFORM),)
|
||||
PLATFORM := ansi
|
||||
endif
|
||||
|
||||
# If the user has explicitly asked for `ansi' on the command line,
|
||||
# disable auto-detection.
|
||||
#
|
||||
ifeq ($(findstring ansi,$(MAKECMDGOALS)),)
|
||||
# Now, include all detection rule files found in the `builds/<system>'
|
||||
# directories. Note that the calling order of the various `detect.mk'
|
||||
# files isn't predictable.
|
||||
#
|
||||
include $(wildcard $(BUILD_CONFIG)/*/detect.mk)
|
||||
endif
|
||||
|
||||
# In case no detection rule file was successful, use the default.
|
||||
#
|
||||
ifndef CONFIG_FILE
|
||||
CONFIG_FILE := ansi.mk
|
||||
setup: std_setup
|
||||
.PHONY: setup
|
||||
endif
|
||||
|
||||
# Flash out and copy rules.
|
||||
#
|
||||
.PHONY: std_setup
|
||||
|
||||
std_setup:
|
||||
$(info )
|
||||
$(info $(PROJECT_TITLE) build system -- automatic system detection)
|
||||
$(info )
|
||||
$(info The following settings are used:)
|
||||
$(info )
|
||||
$(info $(empty) platform $(PLATFORM))
|
||||
$(info $(empty) compiler $(CC))
|
||||
$(info $(empty) configuration directory $(subst /,$(SEP),$(PLATFORM_DIR)))
|
||||
$(info $(empty) configuration rules $(subst /,$(SEP),$(CONFIG_RULES)))
|
||||
$(info )
|
||||
$(info If this does not correspond to your system or settings please remove the file)
|
||||
$(info `$(CONFIG_MK)' from this directory then read the INSTALL file for help.)
|
||||
$(info )
|
||||
$(info Otherwise, simply type `$(MAKE)' again to build the library,)
|
||||
$(info or `$(MAKE) refdoc' to build the API reference (this needs Python >= 3.5).)
|
||||
$(info )
|
||||
@$(COPY) $(subst /,$(SEP),$(CONFIG_RULES) $(CONFIG_MK))
|
||||
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
#
|
||||
# FreeType 2 exports sub-Makefile
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 2005-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
|
||||
# OTHER MAKEFILES.
|
||||
|
||||
|
||||
# This sub-Makefile is used to compute the list of exported symbols whenever
|
||||
# the EXPORTS_LIST variable is defined by one of the platform or compiler
|
||||
# specific build files.
|
||||
#
|
||||
# EXPORTS_LIST contains the name of the `list' file, for example a Windows
|
||||
# .DEF file.
|
||||
#
|
||||
ifneq ($(EXPORTS_LIST),)
|
||||
|
||||
# CCexe is the compiler used to compile the `apinames' tool program
|
||||
# on the host machine. This isn't necessarily the same as the compiler
|
||||
# which can be a cross-compiler for a different architecture, for example.
|
||||
#
|
||||
ifeq ($(CCexe),)
|
||||
CCexe := $(CC)
|
||||
endif
|
||||
|
||||
# TE acts like T, but for executables instead of object files.
|
||||
ifeq ($(TE),)
|
||||
TE := $T
|
||||
endif
|
||||
|
||||
# The list of public headers we're going to parse.
|
||||
PUBLIC_HEADERS := $(filter-out $(PUBLIC_DIR)/ftmac.h, \
|
||||
$(wildcard $(PUBLIC_DIR)/*.h))
|
||||
ifneq ($(ftmac_c),)
|
||||
PUBLIC_HEADERS += $(PUBLIC_DIR)/ftmac.h
|
||||
endif
|
||||
|
||||
# The `apinames' source and executable. We use $E_BUILD as the host
|
||||
# executable suffix, which *includes* the final dot.
|
||||
#
|
||||
# Note that $(APINAMES_OPTIONS) is empty, except for Windows compilers.
|
||||
#
|
||||
APINAMES_SRC := $(subst /,$(SEP),$(TOP_DIR)/src/tools/apinames.c)
|
||||
APINAMES_EXE := $(subst /,$(SEP),$(OBJ_DIR)/apinames$(E_BUILD))
|
||||
|
||||
$(APINAMES_EXE): $(APINAMES_SRC)
|
||||
$(CCexe) $(CCexe_CFLAGS) $(TE)$@ $< $(CCexe_LDFLAGS)
|
||||
|
||||
.PHONY: symbols_list
|
||||
|
||||
symbols_list: $(EXPORTS_LIST)
|
||||
|
||||
# We manually add TT_New_Context and TT_RunIns, which are needed by TT
|
||||
# debuggers, to the EXPORTS_LIST.
|
||||
#
|
||||
$(EXPORTS_LIST): $(APINAMES_EXE) $(PUBLIC_HEADERS)
|
||||
$(subst /,$(SEP),$(APINAMES_EXE)) -o$@ $(APINAMES_OPTIONS) $(PUBLIC_HEADERS)
|
||||
@echo TT_New_Context >> $(EXPORTS_LIST)
|
||||
@echo TT_RunIns >> $(EXPORTS_LIST)
|
||||
|
||||
$(PROJECT_LIBRARY): $(EXPORTS_LIST)
|
||||
|
||||
CLEAN += $(EXPORTS_LIST) \
|
||||
$(APINAMES_EXE)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
#
|
||||
# FreeType 2 library sub-Makefile
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
|
||||
# OTHER MAKEFILES.
|
||||
|
||||
|
||||
# The following variables (set by other Makefile components, in the
|
||||
# environment, or on the command line) are used:
|
||||
#
|
||||
# PLATFORM_DIR The architecture-dependent directory,
|
||||
# e.g., `$(TOP_DIR)/builds/unix'. Added to INCLUDES also.
|
||||
#
|
||||
# OBJ_DIR The directory in which object files are created.
|
||||
#
|
||||
# LIB_DIR The directory in which the library is created.
|
||||
#
|
||||
# DOC_DIR The directory in which the API reference is created.
|
||||
#
|
||||
# INCLUDES A list of directories to be included additionally.
|
||||
#
|
||||
# DEVEL_DIR Development directory which is added to the INCLUDES
|
||||
# variable before the standard include directories.
|
||||
#
|
||||
# CFLAGS Compilation flags. This overrides the default settings
|
||||
# in the platform-specific configuration files.
|
||||
#
|
||||
# FTSYS_SRC If set, its value is used as the name of a replacement
|
||||
# file for `src/base/ftsystem.c'.
|
||||
#
|
||||
# FTDEBUG_SRC If set, its value is used as the name of a replacement
|
||||
# file for `src/base/ftdebug.c'. [For a normal build, this
|
||||
# file does nothing.]
|
||||
#
|
||||
# FTMODULE_H The file which contains the list of module classes for
|
||||
# the current build. Usually, this is automatically
|
||||
# created by `modules.mk'.
|
||||
#
|
||||
# BASE_OBJ_S
|
||||
# BASE_OBJ_M A list of base objects (for single object and multiple
|
||||
# object builds, respectively). Set up in
|
||||
# `src/base/rules.mk'.
|
||||
#
|
||||
# BASE_EXT_OBJ A list of base extension objects. Set up in
|
||||
# `src/base/rules.mk'.
|
||||
#
|
||||
# DRV_OBJ_S
|
||||
# DRV_OBJ_M A list of driver objects (for single object and multiple
|
||||
# object builds, respectively). Set up cumulatively in
|
||||
# `src/<driver>/rules.mk'.
|
||||
#
|
||||
# CLEAN
|
||||
# DISTCLEAN The sub-makefiles can append additional stuff to these two
|
||||
# variables which is to be removed for the `clean' resp.
|
||||
# `distclean' target.
|
||||
#
|
||||
# TOP_DIR, SEP,
|
||||
# COMPILER_SEP,
|
||||
# LIBRARY, CC,
|
||||
# A, I, O, T Check `config.mk' for details.
|
||||
|
||||
|
||||
# The targets `objects' and `library' are defined at the end of this
|
||||
# Makefile after all other rules have been included.
|
||||
#
|
||||
.PHONY: single multi objects library refdoc refdoc-venv
|
||||
|
||||
# default target -- build single objects and library
|
||||
#
|
||||
single: objects library
|
||||
|
||||
# `multi' target -- build multiple objects and library
|
||||
#
|
||||
multi: objects library
|
||||
|
||||
|
||||
# The FreeType source directory, usually `./src'.
|
||||
#
|
||||
SRC_DIR := $(TOP_DIR)/src
|
||||
|
||||
# The directory where the base layer components are placed, usually
|
||||
# `./src/base'.
|
||||
#
|
||||
BASE_DIR := $(SRC_DIR)/base
|
||||
|
||||
# Other derived directories.
|
||||
#
|
||||
PUBLIC_DIR := $(TOP_DIR)/include/freetype
|
||||
INTERNAL_DIR := $(PUBLIC_DIR)/internal
|
||||
SERVICES_DIR := $(INTERNAL_DIR)/services
|
||||
CONFIG_DIR := $(PUBLIC_DIR)/config
|
||||
|
||||
# The documentation directory.
|
||||
#
|
||||
DOC_DIR ?= $(TOP_DIR)/docs
|
||||
|
||||
# The final name of the library file.
|
||||
#
|
||||
PROJECT_LIBRARY := $(LIB_DIR)/$(LIBRARY).$A
|
||||
|
||||
|
||||
# include paths
|
||||
#
|
||||
# IMPORTANT NOTE: The architecture-dependent directory must ALWAYS be placed
|
||||
# before the standard include list. Porters are then able to
|
||||
# put their own version of some of the FreeType components
|
||||
# in the `builds/<system>' directory, as these files will
|
||||
# override the default sources.
|
||||
#
|
||||
INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) \
|
||||
$(DEVEL_DIR) \
|
||||
$(PLATFORM_DIR) \
|
||||
$(TOP_DIR)/include)
|
||||
|
||||
INCLUDE_FLAGS := $(INCLUDES:%=$I%)
|
||||
|
||||
# For a development build, we assume that the external library dependencies
|
||||
# defined in `ftoption.h' are fulfilled, so we directly access the necessary
|
||||
# include directory information using `pkg-config'.
|
||||
#
|
||||
ifdef DEVEL_DIR
|
||||
INCLUDE_FLAGS += $(shell pkg-config --cflags libpng)
|
||||
INCLUDE_FLAGS += $(shell pkg-config --cflags harfbuzz)
|
||||
INCLUDE_FLAGS += $(shell pkg-config --cflags libbrotlidec)
|
||||
endif
|
||||
|
||||
|
||||
# C flags used for the compilation of an object file. This must include at
|
||||
# least the paths for the `base' and `builds/<system>' directories;
|
||||
# debug/optimization/warning flags + ansi compliance if needed.
|
||||
#
|
||||
# $(INCLUDE_FLAGS) should come before $(CFLAGS) to avoid problems with
|
||||
# old FreeType versions.
|
||||
#
|
||||
# Note what we also define the macro FT2_BUILD_LIBRARY when building
|
||||
# FreeType. This is required to let our sources include the internal
|
||||
# headers (something forbidden by clients).
|
||||
#
|
||||
# `CPPFLAGS' might be specified by the user in the environment.
|
||||
#
|
||||
FT_CFLAGS = $(CPPFLAGS) \
|
||||
$(CFLAGS) \
|
||||
$DFT2_BUILD_LIBRARY
|
||||
|
||||
FT_COMPILE := $(CC) $(ANSIFLAGS) $(INCLUDE_FLAGS) $(FT_CFLAGS)
|
||||
|
||||
|
||||
# Include the `exports' rules file.
|
||||
#
|
||||
include $(TOP_DIR)/builds/exports.mk
|
||||
|
||||
|
||||
# Initialize the list of objects.
|
||||
#
|
||||
OBJECTS_LIST :=
|
||||
|
||||
|
||||
# Define $(PUBLIC_H) as the list of all public header files located in
|
||||
# `$(TOP_DIR)/include/freetype'. $(INTERNAL_H), and $(CONFIG_H) are defined
|
||||
# similarly. $(FTOPTION_H) is the option file used in the compilation.
|
||||
#
|
||||
# This is used to simplify the dependency rules -- if one of these files
|
||||
# changes, the whole library is recompiled.
|
||||
#
|
||||
ifneq ($(wildcard $(OBJ_DIR)/ftoption.h),)
|
||||
FTOPTION_H := $(OBJ_DIR)/ftoption.h
|
||||
else ifneq ($(wildcard $(PLATFORM_DIR)/ftoption.h),)
|
||||
FTOPTION_H := $(PLATFORM_DIR)/ftoption.h
|
||||
endif
|
||||
|
||||
PUBLIC_H := $(wildcard $(PUBLIC_DIR)/*.h)
|
||||
INTERNAL_H := $(wildcard $(INTERNAL_DIR)/*.h) \
|
||||
$(wildcard $(SERVICES_DIR)/*.h)
|
||||
CONFIG_H := $(wildcard $(CONFIG_DIR)/*.h) \
|
||||
$(wildcard $(PLATFORM_DIR)/config/*.h) \
|
||||
$(FTMODULE_H) \
|
||||
$(FTOPTION_H)
|
||||
DEVEL_H := $(wildcard $(TOP_DIR)/devel/*.h)
|
||||
|
||||
FREETYPE_H := $(PUBLIC_H) $(INTERNAL_H) $(CONFIG_H) $(DEVEL_H)
|
||||
|
||||
|
||||
# ftsystem component
|
||||
#
|
||||
FTSYS_SRC ?= $(BASE_DIR)/ftsystem.c
|
||||
|
||||
FTSYS_OBJ := $(OBJ_DIR)/ftsystem.$O
|
||||
|
||||
OBJECTS_LIST += $(FTSYS_OBJ)
|
||||
|
||||
$(FTSYS_OBJ): $(FTSYS_SRC) $(FREETYPE_H)
|
||||
$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
|
||||
|
||||
|
||||
# ftdebug component
|
||||
#
|
||||
FTDEBUG_SRC ?= $(BASE_DIR)/ftdebug.c
|
||||
|
||||
FTDEBUG_OBJ := $(OBJ_DIR)/ftdebug.$O
|
||||
|
||||
OBJECTS_LIST += $(FTDEBUG_OBJ)
|
||||
|
||||
$(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
|
||||
$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
|
||||
|
||||
|
||||
# Include all rule files from FreeType components.
|
||||
#
|
||||
include $(SRC_DIR)/base/rules.mk
|
||||
include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES))
|
||||
include $(SRC_DIR)/dlg/rules.mk
|
||||
|
||||
|
||||
# ftinit component
|
||||
#
|
||||
# The C source `ftinit.c' contains the FreeType initialization routines.
|
||||
# It is able to automatically register one or more drivers when the API
|
||||
# function FT_Init_FreeType() is called.
|
||||
#
|
||||
# The set of initial drivers is determined by the driver Makefiles
|
||||
# includes above. Each driver Makefile updates the FTINIT_xxx lists
|
||||
# which contain additional include paths and macros used to compile the
|
||||
# single `ftinit.c' source.
|
||||
#
|
||||
FTINIT_SRC := $(BASE_DIR)/ftinit.c
|
||||
FTINIT_OBJ := $(OBJ_DIR)/ftinit.$O
|
||||
|
||||
OBJECTS_LIST += $(FTINIT_OBJ)
|
||||
|
||||
$(FTINIT_OBJ): $(FTINIT_SRC) $(FREETYPE_H)
|
||||
$(FT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
|
||||
|
||||
|
||||
# ftver component
|
||||
#
|
||||
# The VERSIONINFO resource `ftver.rc' contains version and copyright
|
||||
# to be compiled by windres and tagged into DLL usually.
|
||||
#
|
||||
ifneq ($(RC),)
|
||||
FTVER_SRC := $(BASE_DIR)/ftver.rc
|
||||
FTVER_OBJ := $(OBJ_DIR)/ftver.$O
|
||||
|
||||
OBJECTS_LIST += $(FTVER_OBJ)
|
||||
|
||||
$(FTVER_OBJ): $(FTVER_SRC)
|
||||
$(RC) -o $@ $<
|
||||
endif
|
||||
|
||||
|
||||
# All FreeType library objects.
|
||||
#
|
||||
OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M) $(DLG_OBJS_M)
|
||||
OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S) $(DLG_OBJS_S)
|
||||
|
||||
|
||||
# The target `multi' on the Make command line indicates that we want to
|
||||
# compile each source file independently.
|
||||
#
|
||||
# Otherwise, each module/driver is compiled in a single object file through
|
||||
# source file inclusion (see `src/base/ftbase.c' or
|
||||
# `src/truetype/truetype.c' for examples).
|
||||
#
|
||||
BASE_OBJECTS := $(OBJECTS_LIST)
|
||||
|
||||
ifneq ($(findstring multi,$(MAKECMDGOALS)),)
|
||||
OBJECTS_LIST += $(OBJ_M)
|
||||
else
|
||||
OBJECTS_LIST += $(OBJ_S)
|
||||
endif
|
||||
|
||||
objects: $(OBJECTS_LIST)
|
||||
|
||||
library: $(PROJECT_LIBRARY)
|
||||
|
||||
# Run `docwriter' in the current Python environment.
|
||||
#
|
||||
PYTHON ?= python
|
||||
|
||||
refdoc:
|
||||
@echo Running docwriter...
|
||||
$(PYTHON) -m docwriter \
|
||||
--prefix=ft2 \
|
||||
--title=FreeType-$(version) \
|
||||
--site=reference \
|
||||
--output=$(DOC_DIR) \
|
||||
$(PUBLIC_DIR)/*.h \
|
||||
$(PUBLIC_DIR)/config/*.h \
|
||||
$(PUBLIC_DIR)/cache/*.h
|
||||
@echo Building static site...
|
||||
cd $(DOC_DIR) && mkdocs build
|
||||
@echo Done.
|
||||
|
||||
# Variables for running `refdoc' with Python's `virtualenv'. The
|
||||
# environment is created in `DOC_DIR/env' and is gitignored.
|
||||
#
|
||||
# We still need to cd into `DOC_DIR' to build `mkdocs' because paths in
|
||||
# `mkdocs.yml' are relative to the current working directory.
|
||||
#
|
||||
VENV_NAME := env
|
||||
VENV_DIR := $(DOC_DIR)$(SEP)$(VENV_NAME)
|
||||
ENV_PYTHON := $(VENV_DIR)$(SEP)$(BIN)$(SEP)$(PYTHON)
|
||||
|
||||
refdoc-venv:
|
||||
@echo Setting up virtualenv for Python...
|
||||
virtualenv --python=$(PYTHON) $(VENV_DIR)
|
||||
@echo Installing docwriter...
|
||||
$(ENV_PYTHON) -m pip install docwriter
|
||||
@echo Running docwriter...
|
||||
$(ENV_PYTHON) -m docwriter \
|
||||
--prefix=ft2 \
|
||||
--title=FreeType-$(version) \
|
||||
--site=reference \
|
||||
--output=$(DOC_DIR) \
|
||||
$(PUBLIC_DIR)/*.h \
|
||||
$(PUBLIC_DIR)/config/*.h \
|
||||
$(PUBLIC_DIR)/cache/*.h
|
||||
@echo Building static site...
|
||||
cd $(DOC_DIR) && $(VENV_NAME)$(SEP)$(BIN)$(SEP)python -m mkdocs build
|
||||
@echo Done.
|
||||
|
||||
.PHONY: clean_project_std distclean_project_std
|
||||
|
||||
# Standard cleaning and distclean rules. These are not accepted
|
||||
# on all systems though.
|
||||
#
|
||||
clean_project_std:
|
||||
-$(DELETE) $(BASE_OBJECTS) $(OBJ_M) $(OBJ_S) $(CLEAN)
|
||||
|
||||
distclean_project_std: clean_project_std
|
||||
-$(DELETE) $(PROJECT_LIBRARY)
|
||||
-$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
|
||||
|
||||
|
||||
.PHONY: clean_project_dos distclean_project_dos
|
||||
|
||||
# The Dos command shell does not support very long list of arguments, so
|
||||
# we are stuck with wildcards.
|
||||
#
|
||||
# Don't break the command lines with \; this prevents the "del" command from
|
||||
# working correctly on Win9x.
|
||||
#
|
||||
clean_project_dos:
|
||||
-$(DELETE) $(subst /,$(SEP),$(OBJ_DIR)/*.$O $(CLEAN) $(NO_OUTPUT))
|
||||
|
||||
distclean_project_dos: clean_project_dos
|
||||
-$(DELETE) $(subst /,$(SEP),$(PROJECT_LIBRARY) $(DISTCLEAN) $(NO_OUTPUT))
|
||||
|
||||
|
||||
.PHONY: remove_config_mk remove_ftmodule_h
|
||||
|
||||
# Remove configuration file (used for distclean).
|
||||
#
|
||||
remove_config_mk:
|
||||
-$(DELETE) $(subst /,$(SEP),$(CONFIG_MK) $(NO_OUTPUT))
|
||||
|
||||
# Remove module list (used for distclean).
|
||||
#
|
||||
remove_ftmodule_h:
|
||||
-$(DELETE) $(subst /,$(SEP),$(FTMODULE_H) $(NO_OUTPUT))
|
||||
|
||||
|
||||
.PHONY: clean distclean
|
||||
|
||||
# The `config.mk' file must define `clean_project' and `distclean_project'.
|
||||
# Implementations may use to relay these to either the `std' or `dos'
|
||||
# versions from above, or simply provide their own implementation.
|
||||
#
|
||||
clean: clean_project
|
||||
distclean: distclean_project remove_config_mk remove_ftmodule_h
|
||||
-$(DELETE) $(subst /,$(SEP),$(DOC_DIR)/*.html $(NO_OUTPUT))
|
||||
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# Link instructions for Dos-like systems (Dos, Win32, OS/2)
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifdef BUILD_PROJECT
|
||||
|
||||
.PHONY: clean_project distclean_project
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP_DIR)/builds/$(PROJECT).mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_project: clean_project_dos
|
||||
distclean_project: distclean_project_dos
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# this is compiler-specific
|
||||
#
|
||||
$(PROJECT_LIBRARY): $(OBJECTS_LIST)
|
||||
ifdef CLEAN_LIBRARY
|
||||
-$(CLEAN_LIBRARY) $(NO_OUTPUT)
|
||||
endif
|
||||
$(LINK_LIBRARY)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# Link instructions for standard systems
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
ifdef BUILD_PROJECT
|
||||
|
||||
.PHONY: clean_project distclean_project
|
||||
|
||||
# Now include the main sub-makefile. It contains all the rules used to
|
||||
# build the library with the previous variables defined.
|
||||
#
|
||||
include $(TOP_DIR)/builds/$(PROJECT).mk
|
||||
|
||||
# The cleanup targets.
|
||||
#
|
||||
clean_project: clean_project_std
|
||||
distclean_project: distclean_project_std
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# this is compiler-specific
|
||||
#
|
||||
$(PROJECT_LIBRARY): $(OBJECTS_LIST)
|
||||
ifdef CLEAN_LIBRARY
|
||||
-$(CLEAN_LIBRARY) $(NO_OUTPUT)
|
||||
endif
|
||||
$(LINK_LIBRARY)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# FreeType 2 modules sub-Makefile
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# DO NOT INVOKE THIS MAKEFILE DIRECTLY! IT IS MEANT TO BE INCLUDED BY
|
||||
# OTHER MAKEFILES.
|
||||
|
||||
|
||||
# This file is in charge of handling the generation of the modules list
|
||||
# file.
|
||||
|
||||
|
||||
# Build the modules list.
|
||||
#
|
||||
$(FTMODULE_H): $(MODULES_CFG)
|
||||
$(FTMODULE_H_INIT)
|
||||
$(FTMODULE_H_CREATE)
|
||||
$(FTMODULE_H_DONE)
|
||||
|
||||
ifneq ($(findstring $(PLATFORM),dos windows os2),)
|
||||
OPEN_MODULE := @echo$(space)
|
||||
CLOSE_MODULE := >> $(subst /,$(SEP),$(FTMODULE_H))
|
||||
REMOVE_MODULE := @-$(DELETE) $(subst /,$(SEP),$(FTMODULE_H))
|
||||
else
|
||||
OPEN_MODULE := @echo "
|
||||
CLOSE_MODULE := " >> $(FTMODULE_H)
|
||||
REMOVE_MODULE := @-$(DELETE) $(FTMODULE_H)
|
||||
endif
|
||||
|
||||
|
||||
define FTMODULE_H_INIT
|
||||
$(REMOVE_MODULE)
|
||||
$(info Generating modules list in $(FTMODULE_H)...)
|
||||
$(OPEN_MODULE)/* This is a generated file. */$(CLOSE_MODULE)
|
||||
endef
|
||||
|
||||
# It is no mistake that the final closing parenthesis is on the
|
||||
# next line -- it produces proper newlines during the expansion
|
||||
# of `foreach'.
|
||||
#
|
||||
define FTMODULE_H_CREATE
|
||||
$(foreach COMMAND,$(FTMODULE_H_COMMANDS),$($(COMMAND))
|
||||
)
|
||||
endef
|
||||
|
||||
define FTMODULE_H_DONE
|
||||
$(OPEN_MODULE)/* EOF */$(CLOSE_MODULE)
|
||||
$(info done.)
|
||||
endef
|
||||
|
||||
|
||||
# $(OPEN_DRIVER) & $(CLOSE_DRIVER) are used to specify a given font driver
|
||||
# in the `module.mk' rules file.
|
||||
#
|
||||
OPEN_DRIVER := $(OPEN_MODULE)FT_USE_MODULE(
|
||||
CLOSE_DRIVER := )$(CLOSE_MODULE)
|
||||
|
||||
ECHO_DRIVER := @echo "* module:$(space)
|
||||
ECHO_DRIVER_DESC := (
|
||||
ECHO_DRIVER_DONE := )"
|
||||
|
||||
# Each `module.mk' in the `src/*' subdirectories adds a variable with
|
||||
# commands to $(FTMODULE_H_COMMANDS). Note that we can't use SRC_DIR here.
|
||||
#
|
||||
-include $(patsubst %,$(TOP_DIR)/src/%/module.mk,$(MODULES))
|
||||
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,322 @@
|
|||
#
|
||||
# FreeType build system -- top-level sub-Makefile
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# This file is designed for GNU Make, do not use it with another Make tool!
|
||||
#
|
||||
# It works as follows:
|
||||
#
|
||||
# - When invoked for the first time, this Makefile includes the rules found
|
||||
# in `PROJECT/builds/detect.mk'. They are in charge of detecting the
|
||||
# current platform.
|
||||
#
|
||||
# A summary of the detection is displayed, and the file `config.mk' is
|
||||
# created in the current directory.
|
||||
#
|
||||
# - When invoked later, this Makefile includes the rules found in
|
||||
# `config.mk'. This sub-Makefile defines some system-specific variables
|
||||
# (like compiler, compilation flags, object suffix, etc.), then includes
|
||||
# the rules found in `PROJECT/builds/PROJECT.mk', used to build the
|
||||
# library.
|
||||
#
|
||||
# See the comments in `builds/detect.mk' and `builds/PROJECT.mk' for more
|
||||
# details on host platform detection and library builds.
|
||||
|
||||
|
||||
# First of all, check whether we have `$(value ...)'. We do this by testing
|
||||
# for `$(eval ...)' which has been introduced in the same GNU make version.
|
||||
|
||||
eval_available :=
|
||||
$(eval eval_available := T)
|
||||
ifneq ($(eval_available),T)
|
||||
$(error FreeType's build system needs a Make program which supports $$(value))
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: all dist distclean modules setup
|
||||
|
||||
|
||||
# The `space' variable is used to avoid trailing spaces in defining the
|
||||
# `T' variable later.
|
||||
#
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
|
||||
|
||||
# The main configuration file, defining the `XXX_MODULES' variables. We
|
||||
# prefer a `modules.cfg' file in OBJ_DIR over TOP_DIR.
|
||||
#
|
||||
ifndef MODULES_CFG
|
||||
MODULES_CFG := $(TOP_DIR)/modules.cfg
|
||||
ifneq ($(wildcard $(OBJ_DIR)/modules.cfg),)
|
||||
MODULES_CFG := $(OBJ_DIR)/modules.cfg
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# FTMODULE_H, as its name suggests, indicates where the FreeType module
|
||||
# class file resides.
|
||||
#
|
||||
FTMODULE_H ?= $(OBJ_DIR)/ftmodule.h
|
||||
|
||||
|
||||
include $(MODULES_CFG)
|
||||
|
||||
|
||||
# The list of modules we are using.
|
||||
#
|
||||
MODULES := $(FONT_MODULES) \
|
||||
$(HINTING_MODULES) \
|
||||
$(RASTER_MODULES) \
|
||||
$(AUX_MODULES)
|
||||
|
||||
|
||||
CONFIG_MK ?= config.mk
|
||||
|
||||
# If no configuration sub-makefile is present, or if `setup' is the target
|
||||
# to be built, run the auto-detection rules to figure out which
|
||||
# configuration rules file to use.
|
||||
#
|
||||
# Note that the configuration file is put in the current directory, which is
|
||||
# not necessarily $(TOP_DIR).
|
||||
|
||||
# If `config.mk' is not present, set `check_platform'.
|
||||
#
|
||||
ifeq ($(wildcard $(CONFIG_MK)),)
|
||||
check_platform := 1
|
||||
endif
|
||||
|
||||
# If `setup' is one of the targets requested, set `check_platform'.
|
||||
#
|
||||
ifneq ($(findstring setup,$(MAKECMDGOALS)),)
|
||||
check_platform := 1
|
||||
endif
|
||||
|
||||
|
||||
# Include the automatic host platform detection rules when we need to
|
||||
# check the platform.
|
||||
#
|
||||
ifdef check_platform
|
||||
|
||||
all modules: setup
|
||||
|
||||
include $(TOP_DIR)/builds/detect.mk
|
||||
|
||||
# For builds directly from the git repository we need to copy files
|
||||
# from `subprojects/dlg' to `src/dlg' and `include/dlg'.
|
||||
#
|
||||
ifeq ($(wildcard $(TOP_DIR)/src/dlg/dlg.*),)
|
||||
ifeq ($(wildcard $(TOP_DIR)/subprojects/dlg/*),)
|
||||
copy_submodule: check_out_submodule
|
||||
endif
|
||||
|
||||
setup: copy_submodule
|
||||
endif
|
||||
|
||||
# This rule makes sense for Unix only to remove files created by a run of
|
||||
# the configure script which hasn't been successful (so that no
|
||||
# `config.mk' has been created). It uses the built-in $(RM) command of
|
||||
# GNU make. Similarly, `nul' is created if e.g. `make setup windows' has
|
||||
# been erroneously used.
|
||||
#
|
||||
# Note: This test is duplicated in `builds/unix/detect.mk'.
|
||||
#
|
||||
is_unix := $(strip $(wildcard /sbin/init) \
|
||||
$(wildcard /usr/sbin/init) \
|
||||
$(wildcard /dev/null) \
|
||||
$(wildcard /hurd/auth))
|
||||
ifneq ($(is_unix),)
|
||||
|
||||
distclean:
|
||||
$(RM) builds/unix/config.cache
|
||||
$(RM) builds/unix/config.log
|
||||
$(RM) builds/unix/config.status
|
||||
$(RM) builds/unix/unix-def.mk
|
||||
$(RM) builds/unix/unix-cc.mk
|
||||
$(RM) builds/unix/freetype2.pc
|
||||
$(RM) nul
|
||||
|
||||
endif # test is_unix
|
||||
|
||||
# IMPORTANT:
|
||||
#
|
||||
# `setup' must be defined by the host platform detection rules to create
|
||||
# the `config.mk' file in the current directory.
|
||||
|
||||
else
|
||||
|
||||
# A configuration sub-Makefile is present -- simply run it.
|
||||
#
|
||||
all: single
|
||||
|
||||
BUILD_PROJECT := yes
|
||||
include $(CONFIG_MK)
|
||||
|
||||
endif # test check_platform
|
||||
|
||||
|
||||
.PHONY: check_out_submodule copy_submodule
|
||||
|
||||
check_out_submodule:
|
||||
$(info Checking out submodule in `subprojects/dlg')
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
copy_submodule:
|
||||
$(info Copying files from `subprojects/dlg' to `src/dlg' and `include/dlg')
|
||||
ifeq ($(wildcard include/dlg),)
|
||||
mkdir $(subst /,$(SEP),include/dlg)
|
||||
endif
|
||||
$(COPY) $(subst /,$(SEP),subprojects/dlg/include/dlg/output.h include/dlg)
|
||||
$(COPY) $(subst /,$(SEP),subprojects/dlg/include/dlg/dlg.h include/dlg)
|
||||
$(COPY) $(subst /,$(SEP),subprojects/dlg/src/dlg/dlg.c src/dlg)
|
||||
|
||||
|
||||
# We always need the list of modules in ftmodule.h.
|
||||
#
|
||||
all setup: $(FTMODULE_H)
|
||||
|
||||
|
||||
# The `modules' target unconditionally rebuilds the module list.
|
||||
#
|
||||
modules:
|
||||
$(FTMODULE_H_INIT)
|
||||
$(FTMODULE_H_CREATE)
|
||||
$(FTMODULE_H_DONE)
|
||||
|
||||
include $(TOP_DIR)/builds/modules.mk
|
||||
|
||||
|
||||
# get FreeType version string, using a
|
||||
# poor man's `sed' emulation with make's built-in string functions
|
||||
#
|
||||
work := $(strip $(shell $(CAT) \
|
||||
$(subst /,$(SEP),$(TOP_DIR)/include/freetype/freetype.h)))
|
||||
work := $(subst |,x,$(work))
|
||||
work := $(subst $(space),|,$(work))
|
||||
work := $(subst \#define|FREETYPE_MAJOR|,$(space),$(work))
|
||||
work := $(word 2,$(work))
|
||||
major := $(subst |,$(space),$(work))
|
||||
major := $(firstword $(major))
|
||||
|
||||
work := $(subst \#define|FREETYPE_MINOR|,$(space),$(work))
|
||||
work := $(word 2,$(work))
|
||||
minor := $(subst |,$(space),$(work))
|
||||
minor := $(firstword $(minor))
|
||||
|
||||
work := $(subst \#define|FREETYPE_PATCH|,$(space),$(work))
|
||||
work := $(word 2,$(work))
|
||||
patch := $(subst |,$(space),$(work))
|
||||
patch := $(firstword $(patch))
|
||||
|
||||
# ifneq ($(findstring x0x,x$(patch)x),)
|
||||
# version := $(major).$(minor)
|
||||
# winversion := $(major)$(minor)
|
||||
# else
|
||||
version := $(major).$(minor).$(patch)
|
||||
winversion := $(major)$(minor)$(patch)
|
||||
version_tag := VER-$(major)-$(minor)-$(patch)
|
||||
# endif
|
||||
|
||||
|
||||
# This target builds the tarballs.
|
||||
#
|
||||
# Not to be run by a normal user -- there are no attempts to make it
|
||||
# generic.
|
||||
|
||||
dist:
|
||||
-rm -rf tmp
|
||||
rm -f freetype-$(version).tar.gz
|
||||
rm -f freetype-$(version).tar.xz
|
||||
rm -f ft$(winversion).zip
|
||||
|
||||
for d in `find . -wholename '*/.git' -prune \
|
||||
-o -type f \
|
||||
-o -print` ; do \
|
||||
mkdir -p tmp/$$d ; \
|
||||
done ;
|
||||
|
||||
currdir=`pwd` ; \
|
||||
for f in `find . -wholename '*/.git' -prune \
|
||||
-o -name .gitattributes \
|
||||
-o -name .gitignore \
|
||||
-o -name .gitlab-ci.yml \
|
||||
-o -name .gitmodules \
|
||||
-o -name .mailmap \
|
||||
-o -type d \
|
||||
-o -print` ; do \
|
||||
ln -s $$currdir/$$f tmp/$$f ; \
|
||||
done
|
||||
|
||||
cd tmp ; \
|
||||
$(MAKE) devel ; \
|
||||
$(MAKE) do-dist
|
||||
|
||||
mv tmp freetype-$(version)
|
||||
|
||||
tar -H ustar -chf - freetype-$(version) \
|
||||
| gzip -9 -c > freetype-$(version).tar.gz
|
||||
tar -H ustar -chf - freetype-$(version) \
|
||||
| xz -c > freetype-$(version).tar.xz
|
||||
|
||||
@# Use CR/LF for zip files.
|
||||
zip -lr9 ft$(winversion).zip freetype-$(version)
|
||||
|
||||
rm -fr freetype-$(version)
|
||||
|
||||
|
||||
# The locations of the latest `config.guess' and `config.sub' versions (from
|
||||
# GNU `config' git repository), relative to the `tmp' directory used during
|
||||
# `make dist'.
|
||||
#
|
||||
CONFIG_GUESS = ~/git/config/config.guess
|
||||
CONFIG_SUB = ~/git/config/config.sub
|
||||
|
||||
# We also use this repository to access the gnulib script that converts git
|
||||
# commit messages to a ChangeLog file.
|
||||
CHANGELOG_SCRIPT = ~/git/config/gitlog-to-changelog
|
||||
|
||||
|
||||
# Don't say `make do-dist'. Always use `make dist' instead.
|
||||
#
|
||||
.PHONY: do-dist
|
||||
|
||||
do-dist: distclean refdoc
|
||||
@# Without removing the files, `autoconf' and friends follow links.
|
||||
rm -f builds/unix/aclocal.m4
|
||||
rm -f builds/unix/configure.ac
|
||||
rm -f builds/unix/configure
|
||||
|
||||
sh autogen.sh
|
||||
rm -rf builds/unix/autom4te.cache
|
||||
|
||||
cp $(CONFIG_GUESS) builds/unix
|
||||
cp $(CONFIG_SUB) builds/unix
|
||||
|
||||
@# Generate `ChangeLog' file with commits since release 2.11.0
|
||||
@# (when we stopped creating this file manually).
|
||||
$(CHANGELOG_SCRIPT) \
|
||||
--format='%B%n' \
|
||||
--no-cluster \
|
||||
-- VER-2-11-0..$(version_tag) \
|
||||
> ChangeLog
|
||||
|
||||
@# Remove intermediate files created by the `refdoc' target.
|
||||
rm -rf docs/markdown
|
||||
rm -f docs/mkdocs.yml
|
||||
|
||||
@# Remove more stuff related to git.
|
||||
rm -rf subprojects
|
||||
|
||||
# EOF
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,177 @@
|
|||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro compares two version strings. Due to the various number of
|
||||
# minor-version numbers that can exist, and the fact that string
|
||||
# comparisons are not compatible with numeric comparisons, this is not
|
||||
# necessarily trivial to do in a autoconf script. This macro makes doing
|
||||
# these comparisons easy.
|
||||
#
|
||||
# The six basic comparisons are available, as well as checking equality
|
||||
# limited to a certain number of minor-version levels.
|
||||
#
|
||||
# The operator OP determines what type of comparison to do, and can be one
|
||||
# of:
|
||||
#
|
||||
# eq - equal (test A == B)
|
||||
# ne - not equal (test A != B)
|
||||
# le - less than or equal (test A <= B)
|
||||
# ge - greater than or equal (test A >= B)
|
||||
# lt - less than (test A < B)
|
||||
# gt - greater than (test A > B)
|
||||
#
|
||||
# Additionally, the eq and ne operator can have a number after it to limit
|
||||
# the test to that number of minor versions.
|
||||
#
|
||||
# eq0 - equal up to the length of the shorter version
|
||||
# ne0 - not equal up to the length of the shorter version
|
||||
# eqN - equal up to N sub-version levels
|
||||
# neN - not equal up to N sub-version levels
|
||||
#
|
||||
# When the condition is true, shell commands ACTION-IF-TRUE are run,
|
||||
# otherwise shell commands ACTION-IF-FALSE are run. The environment
|
||||
# variable 'ax_compare_version' is always set to either 'true' or 'false'
|
||||
# as well.
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
|
||||
# AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
|
||||
#
|
||||
# would both be true.
|
||||
#
|
||||
# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
|
||||
# AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
|
||||
#
|
||||
# would both be false.
|
||||
#
|
||||
# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
|
||||
#
|
||||
# would be true because it is only comparing two minor versions.
|
||||
#
|
||||
# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
|
||||
#
|
||||
# would be true because it is only comparing the lesser number of minor
|
||||
# versions of the two values.
|
||||
#
|
||||
# Note: The characters that separate the version numbers do not matter. An
|
||||
# empty string is the same as version 0. OP is evaluated by autoconf, not
|
||||
# configure, so must be a string, not a variable.
|
||||
#
|
||||
# The author would like to acknowledge Guido Draheim whose advice about
|
||||
# the m4_case and m4_ifvaln functions make this macro only include the
|
||||
# portions necessary to perform the specific comparison specified by the
|
||||
# OP argument in the final configure script.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 13
|
||||
|
||||
dnl #########################################################################
|
||||
AC_DEFUN([AX_COMPARE_VERSION], [
|
||||
AC_REQUIRE([AC_PROG_AWK])
|
||||
|
||||
# Used to indicate true or false condition
|
||||
ax_compare_version=false
|
||||
|
||||
# Convert the two version strings to be compared into a format that
|
||||
# allows a simple string comparison. The end result is that a version
|
||||
# string of the form 1.12.5-r617 will be converted to the form
|
||||
# 0001001200050617. In other words, each number is zero padded to four
|
||||
# digits, and non digits are removed.
|
||||
AS_VAR_PUSHDEF([A],[ax_compare_version_A])
|
||||
A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
|
||||
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
|
||||
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
|
||||
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
|
||||
-e 's/[[^0-9]]//g'`
|
||||
|
||||
AS_VAR_PUSHDEF([B],[ax_compare_version_B])
|
||||
B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
|
||||
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
|
||||
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
|
||||
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
|
||||
-e 's/[[^0-9]]//g'`
|
||||
|
||||
dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
|
||||
dnl # then the first line is used to determine if the condition is true.
|
||||
dnl # The sed right after the echo is to remove any indented white space.
|
||||
m4_case(m4_tolower($2),
|
||||
[lt],[
|
||||
ax_compare_version=`echo "x$A
|
||||
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
|
||||
],
|
||||
[gt],[
|
||||
ax_compare_version=`echo "x$A
|
||||
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
|
||||
],
|
||||
[le],[
|
||||
ax_compare_version=`echo "x$A
|
||||
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
|
||||
],
|
||||
[ge],[
|
||||
ax_compare_version=`echo "x$A
|
||||
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
|
||||
],[
|
||||
dnl Split the operator from the subversion count if present.
|
||||
m4_bmatch(m4_substr($2,2),
|
||||
[0],[
|
||||
# A count of zero means use the length of the shorter version.
|
||||
# Determine the number of characters in A and B.
|
||||
ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
|
||||
ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
|
||||
|
||||
# Set A to no more than B's length and B to no more than A's length.
|
||||
A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
|
||||
B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
|
||||
],
|
||||
[[0-9]+],[
|
||||
# A count greater than zero means use only that many subversions
|
||||
A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
|
||||
B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
|
||||
],
|
||||
[.+],[
|
||||
AC_WARNING(
|
||||
[invalid OP numeric parameter: $2])
|
||||
],[])
|
||||
|
||||
# Pad zeros at end of numbers to make same length.
|
||||
ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
|
||||
B="$B`echo $A | sed 's/./0/g'`"
|
||||
A="$ax_compare_version_tmp_A"
|
||||
|
||||
# Check for equality or inequality as necessary.
|
||||
m4_case(m4_tolower(m4_substr($2,0,2)),
|
||||
[eq],[
|
||||
test "x$A" = "x$B" && ax_compare_version=true
|
||||
],
|
||||
[ne],[
|
||||
test "x$A" != "x$B" && ax_compare_version=true
|
||||
],[
|
||||
AC_WARNING([invalid OP parameter: $2])
|
||||
])
|
||||
])
|
||||
|
||||
AS_VAR_POPDEF([A])dnl
|
||||
AS_VAR_POPDEF([B])dnl
|
||||
|
||||
dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
|
||||
if test "$ax_compare_version" = "true" ; then
|
||||
m4_ifvaln([$4],[$4],[:])dnl
|
||||
m4_ifvaln([$5],[else $5])dnl
|
||||
fi
|
||||
]) dnl AX_COMPARE_VERSION
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_prog_python_version.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PROG_PYTHON_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Makes sure that python supports the version indicated. If true the shell
|
||||
# commands in ACTION-IF-TRUE are executed. If not the shell commands in
|
||||
# ACTION-IF-FALSE are run. Note if $PYTHON is not set (for example by
|
||||
# running AC_CHECK_PROG or AC_PATH_PROG) the macro will fail.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# AC_PATH_PROG([PYTHON],[python])
|
||||
# AX_PROG_PYTHON_VERSION([2.4.4],[ ... ],[ ... ])
|
||||
#
|
||||
# This will check to make sure that the python you have supports at least
|
||||
# version 2.4.4.
|
||||
#
|
||||
# NOTE: This macro uses the $PYTHON variable to perform the check.
|
||||
# AX_WITH_PYTHON can be used to set that variable prior to running this
|
||||
# macro. The $PYTHON_VERSION variable will be valorized with the detected
|
||||
# version.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 12
|
||||
|
||||
AC_DEFUN([AX_PROG_PYTHON_VERSION],[
|
||||
AC_REQUIRE([AC_PROG_SED])
|
||||
AC_REQUIRE([AC_PROG_GREP])
|
||||
|
||||
AS_IF([test -n "$PYTHON"],[
|
||||
ax_python_version="$1"
|
||||
|
||||
AC_MSG_CHECKING([for python version])
|
||||
changequote(<<,>>)
|
||||
python_version=`$PYTHON -V 2>&1 | $GREP "^Python " | $SED -e 's/^.* \([0-9]*\.[0-9]*\.[0-9]*\)/\1/'`
|
||||
changequote([,])
|
||||
AC_MSG_RESULT($python_version)
|
||||
|
||||
AC_SUBST([PYTHON_VERSION],[$python_version])
|
||||
|
||||
AX_COMPARE_VERSION([$ax_python_version],[le],[$python_version],[
|
||||
:
|
||||
$2
|
||||
],[
|
||||
:
|
||||
$3
|
||||
])
|
||||
],[
|
||||
AC_MSG_WARN([could not find the python interpreter])
|
||||
$3
|
||||
])
|
||||
])
|
||||
|
|
@ -0,0 +1,522 @@
|
|||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro figures out how to build C programs using POSIX threads. It
|
||||
# sets the PTHREAD_LIBS output variable to the threads library and linker
|
||||
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
|
||||
# flags that are needed. (The user can also force certain compiler
|
||||
# flags/libs to be tested by setting these environment variables.)
|
||||
#
|
||||
# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is
|
||||
# needed for multi-threaded programs (defaults to the value of CC
|
||||
# respectively CXX otherwise). (This is necessary on e.g. AIX to use the
|
||||
# special cc_r/CC_r compiler alias.)
|
||||
#
|
||||
# NOTE: You are assumed to not only compile your program with these flags,
|
||||
# but also to link with them as well. For example, you might link with
|
||||
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
|
||||
# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
|
||||
#
|
||||
# If you are only building threaded programs, you may wish to use these
|
||||
# variables in your default LIBS, CFLAGS, and CC:
|
||||
#
|
||||
# LIBS="$PTHREAD_LIBS $LIBS"
|
||||
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
|
||||
# CC="$PTHREAD_CC"
|
||||
# CXX="$PTHREAD_CXX"
|
||||
#
|
||||
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
|
||||
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
|
||||
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
#
|
||||
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
|
||||
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
|
||||
# PTHREAD_CFLAGS.
|
||||
#
|
||||
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
|
||||
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
|
||||
# is not found. If ACTION-IF-FOUND is not specified, the default action
|
||||
# will define HAVE_PTHREAD.
|
||||
#
|
||||
# Please let the authors know if this macro fails on any platform, or if
|
||||
# you have any other suggestions or comments. This macro was based on work
|
||||
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
|
||||
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
|
||||
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
|
||||
# grateful for the helpful feedback of numerous users.
|
||||
#
|
||||
# Updated for Autoconf 2.68 by Daniel Richard G.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
|
||||
# Copyright (c) 2019 Marc Stevens <marc.stevens@cwi.nl>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 30
|
||||
|
||||
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
|
||||
AC_DEFUN([AX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_TARGET])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_PROG_SED])
|
||||
AC_LANG_PUSH([C])
|
||||
ax_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on Tru64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
|
||||
ax_pthread_save_CC="$CC"
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
|
||||
AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"])
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
|
||||
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
|
||||
AC_MSG_RESULT([$ax_pthread_ok])
|
||||
if test "x$ax_pthread_ok" = "xno"; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
CC="$ax_pthread_save_CC"
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items with a "," contain both
|
||||
# C compiler flags (before ",") and linker flags (after ","). Other items
|
||||
# starting with a "-" are C compiler flags, and remaining items are
|
||||
# library names, except for "none" which indicates that we try without
|
||||
# any flags at all, and "pthread-config" which is a program returning
|
||||
# the flags for the Pth emulation library.
|
||||
|
||||
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
|
||||
# (Note: HP C rejects this with "bad form for `-t' option")
|
||||
# -pthreads: Solaris/gcc (Note: HP C also rejects)
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads and
|
||||
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
|
||||
# is present but should not be used directly; and before -mthreads,
|
||||
# because the compiler interprets this as "-mt" + "-hreads")
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case $target_os in
|
||||
|
||||
freebsd*)
|
||||
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
|
||||
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
|
||||
;;
|
||||
|
||||
hpux*)
|
||||
|
||||
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
|
||||
# multi-threading and also sets -lpthread."
|
||||
|
||||
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
|
||||
;;
|
||||
|
||||
openedition*)
|
||||
|
||||
# IBM z/OS requires a feature-test macro to be defined in order to
|
||||
# enable POSIX threads at all, so give the user a hint if this is
|
||||
# not set. (We don't define these ourselves, as they can affect
|
||||
# other portions of the system API in unpredictable ways.)
|
||||
|
||||
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
|
||||
[
|
||||
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
|
||||
AX_PTHREAD_ZOS_MISSING
|
||||
# endif
|
||||
],
|
||||
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
|
||||
;;
|
||||
|
||||
solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (N.B.: The stubs are missing
|
||||
# pthread_cleanup_push, or rather a function called by this macro,
|
||||
# so we could check for that, but who knows whether they'll stub
|
||||
# that too in a future libc.) So we'll check first for the
|
||||
# standard Solaris way of linking pthreads (-mt -lpthread).
|
||||
|
||||
ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Are we compiling with Clang?
|
||||
|
||||
AC_CACHE_CHECK([whether $CC is Clang],
|
||||
[ax_cv_PTHREAD_CLANG],
|
||||
[ax_cv_PTHREAD_CLANG=no
|
||||
# Note that Autoconf sets GCC=yes for Clang as well as GCC
|
||||
if test "x$GCC" = "xyes"; then
|
||||
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
|
||||
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
|
||||
# if defined(__clang__) && defined(__llvm__)
|
||||
AX_PTHREAD_CC_IS_CLANG
|
||||
# endif
|
||||
],
|
||||
[ax_cv_PTHREAD_CLANG=yes])
|
||||
fi
|
||||
])
|
||||
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
|
||||
|
||||
|
||||
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
|
||||
|
||||
# Note that for GCC and Clang -pthread generally implies -lpthread,
|
||||
# except when -nostdlib is passed.
|
||||
# This is problematic using libtool to build C++ shared libraries with pthread:
|
||||
# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460
|
||||
# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333
|
||||
# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555
|
||||
# To solve this, first try -pthread together with -lpthread for GCC
|
||||
|
||||
AS_IF([test "x$GCC" = "xyes"],
|
||||
[ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"])
|
||||
|
||||
# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first
|
||||
|
||||
AS_IF([test "x$ax_pthread_clang" = "xyes"],
|
||||
[ax_pthread_flags="-pthread,-lpthread -pthread"])
|
||||
|
||||
|
||||
# The presence of a feature test macro requesting re-entrant function
|
||||
# definitions is, on some systems, a strong hint that pthreads support is
|
||||
# correctly enabled
|
||||
|
||||
case $target_os in
|
||||
darwin* | hpux* | linux* | osf* | solaris*)
|
||||
ax_pthread_check_macro="_REENTRANT"
|
||||
;;
|
||||
|
||||
aix*)
|
||||
ax_pthread_check_macro="_THREAD_SAFE"
|
||||
;;
|
||||
|
||||
*)
|
||||
ax_pthread_check_macro="--"
|
||||
;;
|
||||
esac
|
||||
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
|
||||
[ax_pthread_check_cond=0],
|
||||
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
|
||||
|
||||
|
||||
if test "x$ax_pthread_ok" = "xno"; then
|
||||
for ax_pthread_try_flag in $ax_pthread_flags; do
|
||||
|
||||
case $ax_pthread_try_flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
*,*)
|
||||
PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
|
||||
PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
|
||||
AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
|
||||
PTHREAD_CFLAGS="$ax_pthread_try_flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
|
||||
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
|
||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
|
||||
PTHREAD_LIBS="-l$ax_pthread_try_flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
|
||||
# if $ax_pthread_check_cond
|
||||
# error "$ax_pthread_check_macro must be defined"
|
||||
# endif
|
||||
static void *some_global = NULL;
|
||||
static void routine(void *a)
|
||||
{
|
||||
/* To avoid any unused-parameter or
|
||||
unused-but-set-parameter warning. */
|
||||
some_global = a;
|
||||
}
|
||||
static void *start_routine(void *a) { return a; }],
|
||||
[pthread_t th; pthread_attr_t attr;
|
||||
pthread_create(&th, 0, start_routine, 0);
|
||||
pthread_join(th, 0);
|
||||
pthread_attr_init(&attr);
|
||||
pthread_cleanup_push(routine, 0);
|
||||
pthread_cleanup_pop(0) /* ; */])],
|
||||
[ax_pthread_ok=yes],
|
||||
[])
|
||||
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
|
||||
AC_MSG_RESULT([$ax_pthread_ok])
|
||||
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Clang needs special handling, because older versions handle the -pthread
|
||||
# option in a rather... idiosyncratic way
|
||||
|
||||
if test "x$ax_pthread_clang" = "xyes"; then
|
||||
|
||||
# Clang takes -pthread; it has never supported any other flag
|
||||
|
||||
# (Note 1: This will need to be revisited if a system that Clang
|
||||
# supports has POSIX threads in a separate library. This tends not
|
||||
# to be the way of modern systems, but it's conceivable.)
|
||||
|
||||
# (Note 2: On some systems, notably Darwin, -pthread is not needed
|
||||
# to get POSIX threads support; the API is always present and
|
||||
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
|
||||
# -pthread does define _REENTRANT, and while the Darwin headers
|
||||
# ignore this macro, third-party headers might not.)
|
||||
|
||||
# However, older versions of Clang make a point of warning the user
|
||||
# that, in an invocation where only linking and no compilation is
|
||||
# taking place, the -pthread option has no effect ("argument unused
|
||||
# during compilation"). They expect -pthread to be passed in only
|
||||
# when source code is being compiled.
|
||||
#
|
||||
# Problem is, this is at odds with the way Automake and most other
|
||||
# C build frameworks function, which is that the same flags used in
|
||||
# compilation (CFLAGS) are also used in linking. Many systems
|
||||
# supported by AX_PTHREAD require exactly this for POSIX threads
|
||||
# support, and in fact it is often not straightforward to specify a
|
||||
# flag that is used only in the compilation phase and not in
|
||||
# linking. Such a scenario is extremely rare in practice.
|
||||
#
|
||||
# Even though use of the -pthread flag in linking would only print
|
||||
# a warning, this can be a nuisance for well-run software projects
|
||||
# that build with -Werror. So if the active version of Clang has
|
||||
# this misfeature, we search for an option to squash it.
|
||||
|
||||
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
|
||||
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
|
||||
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
|
||||
# Create an alternate version of $ac_link that compiles and
|
||||
# links in two steps (.c -> .o, .o -> exe) instead of one
|
||||
# (.c -> exe), because the warning occurs only in the second
|
||||
# step
|
||||
ax_pthread_save_ac_link="$ac_link"
|
||||
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
|
||||
ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"`
|
||||
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
|
||||
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
|
||||
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
|
||||
ac_link="$ax_pthread_save_ac_link"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
|
||||
[ac_link="$ax_pthread_2step_ac_link"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
|
||||
[break])
|
||||
])
|
||||
done
|
||||
ac_link="$ax_pthread_save_ac_link"
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
|
||||
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
|
||||
])
|
||||
|
||||
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
|
||||
no | unknown) ;;
|
||||
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
|
||||
esac
|
||||
|
||||
fi # $ax_pthread_clang = yes
|
||||
|
||||
|
||||
|
||||
# Various other checks:
|
||||
if test "x$ax_pthread_ok" = "xyes"; then
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_CACHE_CHECK([for joinable pthread attribute],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
|
||||
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[int attr = $ax_pthread_attr; return attr /* ; */])],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
|
||||
[])
|
||||
done
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
|
||||
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
|
||||
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
|
||||
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
|
||||
[$ax_cv_PTHREAD_JOINABLE_ATTR],
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
ax_pthread_joinable_attr_defined=yes
|
||||
])
|
||||
|
||||
AC_CACHE_CHECK([whether more special flags are required for pthreads],
|
||||
[ax_cv_PTHREAD_SPECIAL_FLAGS],
|
||||
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
|
||||
case $target_os in
|
||||
solaris*)
|
||||
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
|
||||
;;
|
||||
esac
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
|
||||
test "x$ax_pthread_special_flags_added" != "xyes"],
|
||||
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
|
||||
ax_pthread_special_flags_added=yes])
|
||||
|
||||
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
|
||||
[[int i = PTHREAD_PRIO_INHERIT;
|
||||
return i;]])],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=no])
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
|
||||
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
|
||||
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
|
||||
ax_pthread_prio_inherit_defined=yes
|
||||
])
|
||||
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
|
||||
# More AIX lossage: compile with *_r variant
|
||||
if test "x$GCC" != "xyes"; then
|
||||
case $target_os in
|
||||
aix*)
|
||||
AS_CASE(["x/$CC"],
|
||||
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
|
||||
[#handle absolute path differently from PATH based program lookup
|
||||
AS_CASE(["x$CC"],
|
||||
[x/*],
|
||||
[
|
||||
AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])
|
||||
AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])])
|
||||
],
|
||||
[
|
||||
AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])
|
||||
AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])])
|
||||
]
|
||||
)
|
||||
])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
|
||||
test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"
|
||||
|
||||
AC_SUBST([PTHREAD_LIBS])
|
||||
AC_SUBST([PTHREAD_CFLAGS])
|
||||
AC_SUBST([PTHREAD_CC])
|
||||
AC_SUBST([PTHREAD_CXX])
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test "x$ax_pthread_ok" = "xyes"; then
|
||||
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
|
||||
:
|
||||
else
|
||||
ax_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
AC_LANG_POP
|
||||
])dnl AX_PTHREAD
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,99 @@
|
|||
#
|
||||
# FreeType 2 configuration file to detect a UNIX host platform.
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
.PHONY: setup
|
||||
|
||||
ifeq ($(PLATFORM),ansi)
|
||||
|
||||
# Note: this test is duplicated in "builds/toplevel.mk".
|
||||
#
|
||||
is_unix := $(strip $(wildcard /sbin/init) \
|
||||
$(wildcard /usr/sbin/init) \
|
||||
$(wildcard /dev/null) \
|
||||
$(wildcard /hurd/auth))
|
||||
ifneq ($(is_unix),)
|
||||
|
||||
PLATFORM := unix
|
||||
|
||||
endif # test is_unix
|
||||
endif # test PLATFORM ansi
|
||||
|
||||
ifeq ($(PLATFORM),unix)
|
||||
COPY := cp
|
||||
DELETE := rm -f
|
||||
CAT := cat
|
||||
|
||||
# If `devel' is the requested target, we use a special configuration
|
||||
# file named `unix-dev.mk'. It disables optimization and libtool.
|
||||
#
|
||||
ifneq ($(findstring devel,$(MAKECMDGOALS)),)
|
||||
CONFIG_FILE := unix-dev.mk
|
||||
CC := gcc
|
||||
|
||||
.PHONY: devel
|
||||
devel: setup
|
||||
@:
|
||||
else
|
||||
|
||||
# If `lcc' is the requested target, we use a special configuration
|
||||
# file named `unix-lcc.mk'. It disables libtool for LCC.
|
||||
#
|
||||
ifneq ($(findstring lcc,$(MAKECMDGOALS)),)
|
||||
CONFIG_FILE := unix-lcc.mk
|
||||
CC := lcc
|
||||
|
||||
.PHONY: lcc
|
||||
lcc: setup
|
||||
@:
|
||||
else
|
||||
|
||||
# If a Unix platform is detected, the configure script is called and
|
||||
# `unix-def.mk' together with `unix-cc.mk' is created.
|
||||
#
|
||||
# Arguments to `configure' should be in the CFG variable. Example:
|
||||
#
|
||||
# make CFG="--prefix=/usr --disable-static"
|
||||
#
|
||||
# If you need to set CFLAGS or LDFLAGS, do it here also.
|
||||
#
|
||||
# Feel free to add support for other platform specific compilers in
|
||||
# this directory (e.g. solaris.mk + changes here to detect the
|
||||
# platform).
|
||||
#
|
||||
CONFIG_FILE := unix.mk
|
||||
must_configure := 1
|
||||
|
||||
.PHONY: unix
|
||||
unix: setup
|
||||
@:
|
||||
endif
|
||||
endif
|
||||
|
||||
have_Makefile := $(wildcard $(OBJ_DIR)/Makefile)
|
||||
|
||||
setup: std_setup
|
||||
ifdef must_configure
|
||||
ifneq ($(have_Makefile),)
|
||||
# we are building FT2 not in the src tree
|
||||
$(TOP_DIR)/builds/unix/configure $(value CFG)
|
||||
else
|
||||
cd builds/unix; \
|
||||
./configure $(value CFG)
|
||||
endif
|
||||
endif
|
||||
|
||||
endif # test PLATFORM unix
|
||||
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Copyright (C) 2000-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
|
||||
# if `pkg-config' is available, use values from `freetype2.pc'
|
||||
%PKG_CONFIG% --atleast-pkgconfig-version 0.24 >/dev/null 2>&1
|
||||
if test $? -eq 0 ; then
|
||||
# note that option `--variable' is not affected by the
|
||||
# PKG_CONFIG_SYSROOT_DIR environment variable
|
||||
if test "x$SYSROOT" != "x" ; then
|
||||
PKG_CONFIG_SYSROOT_DIR="$SYSROOT"
|
||||
export PKG_CONFIG_SYSROOT_DIR
|
||||
fi
|
||||
|
||||
prefix=`%PKG_CONFIG% --variable prefix freetype2`
|
||||
exec_prefix=`%PKG_CONFIG% --variable exec_prefix freetype2`
|
||||
|
||||
includedir=`%PKG_CONFIG% --variable includedir freetype2`
|
||||
libdir=`%PKG_CONFIG% --variable libdir freetype2`
|
||||
|
||||
version=`%PKG_CONFIG% --modversion freetype2`
|
||||
|
||||
cflags=`%PKG_CONFIG% --cflags freetype2`
|
||||
dynamic_libs=`%PKG_CONFIG% --libs freetype2`
|
||||
static_libs=`%PKG_CONFIG% --static --libs freetype2`
|
||||
else
|
||||
prefix="%prefix%"
|
||||
exec_prefix="%exec_prefix%"
|
||||
|
||||
includedir="%includedir%"
|
||||
libdir="%libdir%"
|
||||
|
||||
version=%ft_version%
|
||||
|
||||
cflags="-I${SYSROOT}$includedir/freetype2"
|
||||
dynamic_libs="-lfreetype"
|
||||
static_libs="%LIBSSTATIC_CONFIG%"
|
||||
if test "${SYSROOT}$libdir" != "/usr/lib" &&
|
||||
test "${SYSROOT}$libdir" != "/usr/lib64" ; then
|
||||
libs_L="-L${SYSROOT}$libdir"
|
||||
fi
|
||||
fi
|
||||
|
||||
orig_prefix=$prefix
|
||||
orig_exec_prefix=$exec_prefix
|
||||
|
||||
orig_includedir=$includedir
|
||||
orig_libdir=$libdir
|
||||
|
||||
include_suffix=`echo $includedir | sed "s|$prefix||"`
|
||||
lib_suffix=`echo $libdir | sed "s|$exec_prefix||"`
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: freetype-config [OPTION]...
|
||||
Get FreeType compilation and linking information.
|
||||
|
||||
Options:
|
||||
--prefix display \`--prefix' value used for building the
|
||||
FreeType library
|
||||
--prefix=PREFIX override \`--prefix' value with PREFIX
|
||||
--exec-prefix display \`--exec-prefix' value used for building
|
||||
the FreeType library
|
||||
--exec-prefix=EPREFIX override \`--exec-prefix' value with EPREFIX
|
||||
--version display libtool version of the FreeType library
|
||||
--ftversion display FreeType version number
|
||||
--libs display flags for linking with the FreeType library
|
||||
--libtool display library name for linking with libtool
|
||||
--cflags display flags for compiling with the FreeType
|
||||
library
|
||||
--static make command line options display flags
|
||||
for static linking
|
||||
--help display this help and exit
|
||||
EOF
|
||||
exit $1
|
||||
}
|
||||
|
||||
|
||||
if test $# -eq 0 ; then
|
||||
usage 1 1>&2
|
||||
fi
|
||||
|
||||
|
||||
while test $# -gt 0 ; do
|
||||
case "$1" in
|
||||
-*=*)
|
||||
optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
|
||||
;;
|
||||
*)
|
||||
optarg=
|
||||
;;
|
||||
esac
|
||||
|
||||
case $1 in
|
||||
--prefix=*)
|
||||
prefix=$optarg
|
||||
local_prefix=yes
|
||||
;;
|
||||
--prefix)
|
||||
echo_prefix=yes
|
||||
;;
|
||||
--exec-prefix=*)
|
||||
exec_prefix=$optarg
|
||||
exec_prefix_set=yes
|
||||
local_prefix=yes
|
||||
;;
|
||||
--exec-prefix)
|
||||
echo_exec_prefix=yes
|
||||
;;
|
||||
--version)
|
||||
echo_version=yes
|
||||
break
|
||||
;;
|
||||
--ftversion)
|
||||
echo_ft_version=yes
|
||||
;;
|
||||
--cflags)
|
||||
echo_cflags=yes
|
||||
;;
|
||||
--libs)
|
||||
echo_libs=yes
|
||||
;;
|
||||
--libtool)
|
||||
echo_libtool=yes
|
||||
;;
|
||||
--static)
|
||||
show_static=yes
|
||||
;;
|
||||
--help)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
usage 1 1>&2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if test "$local_prefix" = "yes" ; then
|
||||
if test "$exec_prefix_set" != "yes" ; then
|
||||
exec_prefix=$prefix
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$local_prefix" = "yes" ; then
|
||||
includedir=${prefix}${include_suffix}
|
||||
if test "$exec_prefix_set" = "yes" ; then
|
||||
libdir=${exec_prefix}${lib_suffix}
|
||||
else
|
||||
libdir=${prefix}${lib_suffix}
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if test "$echo_version" = "yes" ; then
|
||||
echo $version
|
||||
fi
|
||||
|
||||
if test "$echo_prefix" = "yes" ; then
|
||||
echo ${SYSROOT}$prefix
|
||||
fi
|
||||
|
||||
if test "$echo_exec_prefix" = "yes" ; then
|
||||
echo ${SYSROOT}$exec_prefix
|
||||
fi
|
||||
|
||||
if test "$echo_ft_version" = "yes" ; then
|
||||
major=`grep define ${SYSROOT}$includedir/freetype2/freetype/freetype.h \
|
||||
| grep FREETYPE_MAJOR \
|
||||
| sed 's/.*[ ]\([0-9][0-9]*\).*/\1/'`
|
||||
minor=`grep define ${SYSROOT}$includedir/freetype2/freetype/freetype.h \
|
||||
| grep FREETYPE_MINOR \
|
||||
| sed 's/.*[ ]\([0-9][0-9]*\).*/\1/'`
|
||||
patch=`grep define ${SYSROOT}$includedir/freetype2/freetype/freetype.h \
|
||||
| grep FREETYPE_PATCH \
|
||||
| sed 's/.*[ ]\([0-9][0-9]*\).*/\1/'`
|
||||
echo $major.$minor.$patch
|
||||
fi
|
||||
|
||||
if test "$echo_cflags" = "yes" ; then
|
||||
echo $cflags | sed "s|$orig_includedir/freetype2|$includedir/freetype2|"
|
||||
fi
|
||||
|
||||
if test "$echo_libs" = "yes" ; then
|
||||
if test "$show_static" = "yes" ; then
|
||||
libs="$libs_L $static_libs"
|
||||
else
|
||||
libs="$libs_L $dynamic_libs"
|
||||
fi
|
||||
echo $libs | sed "s|$orig_libdir|$libdir|"
|
||||
fi
|
||||
|
||||
if test "$echo_libtool" = "yes" ; then
|
||||
echo ${SYSROOT}$libdir/libfreetype.la
|
||||
fi
|
||||
|
||||
# EOF
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
prefix=%prefix%
|
||||
exec_prefix=%exec_prefix%
|
||||
libdir=%libdir%
|
||||
includedir=%includedir%
|
||||
|
||||
Name: FreeType 2
|
||||
URL: https://freetype.org
|
||||
Description: A free, high-quality, and portable font engine.
|
||||
Version: %ft_version%
|
||||
Requires: %PKGCONFIG_REQUIRES%
|
||||
Requires.private: %PKGCONFIG_REQUIRES_PRIVATE%
|
||||
Libs: %PKGCONFIG_LIBS%
|
||||
Libs.private: %PKGCONFIG_LIBS_PRIVATE%
|
||||
Cflags: -I${includedir}/freetype2
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
# Configure paths for FreeType2
|
||||
# Marcelo Magallon 2001-10-26, based on `gtk.m4` by Owen Taylor
|
||||
#
|
||||
# Copyright (C) 2001-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
#
|
||||
# As a special exception to the FreeType project license, this file may be
|
||||
# distributed as part of a program that contains a configuration script
|
||||
# generated by Autoconf, under the same distribution terms as the rest of
|
||||
# that program.
|
||||
#
|
||||
# serial 6
|
||||
|
||||
# AC_CHECK_FT2([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
# Test for FreeType 2, and define FT2_CFLAGS and FT2_LIBS.
|
||||
# MINIMUM-VERSION is what libtool reports; the default is '7.0.1' (this is
|
||||
# FreeType 2.0.4).
|
||||
#
|
||||
# To make this code work with older autoconf versions, `AS_HELP_STRING` is
|
||||
# not quoted.
|
||||
#
|
||||
AC_DEFUN([AC_CHECK_FT2],
|
||||
[# Get the cflags and libraries from the freetype-config script
|
||||
#
|
||||
AC_ARG_WITH([ft-prefix],
|
||||
AS_HELP_STRING([--with-ft-prefix=PREFIX],
|
||||
[Prefix where FreeType is installed (optional)]),
|
||||
[ft_config_prefix="$withval"],
|
||||
[ft_config_prefix=""])
|
||||
|
||||
AC_ARG_WITH([ft-exec-prefix],
|
||||
AS_HELP_STRING([--with-ft-exec-prefix=PREFIX],
|
||||
[Exec prefix where FreeType is installed (optional)]),
|
||||
[ft_config_exec_prefix="$withval"],
|
||||
[ft_config_exec_prefix=""])
|
||||
|
||||
AC_ARG_ENABLE([freetypetest],
|
||||
AS_HELP_STRING([--disable-freetypetest],
|
||||
[Do not try to compile and run a test FreeType program]),
|
||||
[],
|
||||
[enable_fttest=yes])
|
||||
|
||||
if test x$ft_config_exec_prefix != x ; then
|
||||
ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
|
||||
if test x${FT2_CONFIG+set} != xset ; then
|
||||
FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$ft_config_prefix != x ; then
|
||||
ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
|
||||
if test x${FT2_CONFIG+set} != xset ; then
|
||||
FT2_CONFIG=$ft_config_prefix/bin/freetype-config
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$FT2_CONFIG" = x ; then
|
||||
AC_PATH_TOOL([FT2_CONFIG], [freetype-config], [no])
|
||||
fi
|
||||
|
||||
min_ft_version=m4_if([$1], [], [7.0.1], [$1])
|
||||
AC_MSG_CHECKING([for FreeType -- version >= $min_ft_version])
|
||||
no_ft=""
|
||||
if test "$FT2_CONFIG" = "no" ; then
|
||||
no_ft=yes
|
||||
else
|
||||
FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
|
||||
FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
|
||||
ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
ft_min_major_version=`echo $min_ft_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
ft_min_minor_version=`echo $min_ft_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
ft_min_micro_version=`echo $min_ft_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
if test x$enable_fttest = xyes ; then
|
||||
ft_config_is_lt=""
|
||||
if test $ft_config_major_version -lt $ft_min_major_version ; then
|
||||
ft_config_is_lt=yes
|
||||
else
|
||||
if test $ft_config_major_version -eq $ft_min_major_version ; then
|
||||
if test $ft_config_minor_version -lt $ft_min_minor_version ; then
|
||||
ft_config_is_lt=yes
|
||||
else
|
||||
if test $ft_config_minor_version -eq $ft_min_minor_version ; then
|
||||
if test $ft_config_micro_version -lt $ft_min_micro_version ; then
|
||||
ft_config_is_lt=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test x$ft_config_is_lt = xyes ; then
|
||||
no_ft=yes
|
||||
else
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $FT2_CFLAGS"
|
||||
LIBS="$FT2_LIBS $LIBS"
|
||||
|
||||
#
|
||||
# Sanity checks for the results of freetype-config to some extent.
|
||||
#
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_SOURCE([[
|
||||
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
FT_Library library;
|
||||
FT_Error error;
|
||||
|
||||
error = FT_Init_FreeType(&library);
|
||||
|
||||
if (error)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
FT_Done_FreeType(library);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
]])
|
||||
],
|
||||
[],
|
||||
[no_ft=yes],
|
||||
[echo $ECHO_N "cross compiling; assuming OK... $ECHO_C"])
|
||||
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi # test $ft_config_version -lt $ft_min_version
|
||||
fi # test x$enable_fttest = xyes
|
||||
fi # test "$FT2_CONFIG" = "no"
|
||||
|
||||
if test x$no_ft = x ; then
|
||||
AC_MSG_RESULT([yes])
|
||||
m4_if([$2], [], [:], [$2])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
if test "$FT2_CONFIG" = "no" ; then
|
||||
AC_MSG_WARN([
|
||||
|
||||
The freetype-config script installed by FreeType 2 could not be found.
|
||||
If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in
|
||||
your path, or set the FT2_CONFIG environment variable to the
|
||||
full path to freetype-config.
|
||||
])
|
||||
else
|
||||
if test x$ft_config_is_lt = xyes ; then
|
||||
AC_MSG_WARN([
|
||||
|
||||
Your installed version of the FreeType 2 library is too old.
|
||||
If you have different versions of FreeType 2, make sure that
|
||||
correct values for --with-ft-prefix or --with-ft-exec-prefix
|
||||
are used, or set the FT2_CONFIG environment variable to the
|
||||
full path to freetype-config.
|
||||
])
|
||||
else
|
||||
AC_MSG_WARN([
|
||||
|
||||
The FreeType test program failed to run. If your system uses
|
||||
shared libraries and they are installed outside the normal
|
||||
system library path, make sure the variable LD_LIBRARY_PATH
|
||||
(or whatever is appropriate for your system) is correctly set.
|
||||
])
|
||||
fi
|
||||
fi
|
||||
|
||||
FT2_CFLAGS=""
|
||||
FT2_LIBS=""
|
||||
m4_if([$3], [], [:], [$3])
|
||||
fi
|
||||
|
||||
AC_SUBST([FT2_CFLAGS])
|
||||
AC_SUBST([FT2_LIBS])])
|
||||
|
||||
# end of freetype2.m4
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
## FreeType specific autoconf tests
|
||||
#
|
||||
# Copyright (C) 2002-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
# serial 2
|
||||
|
||||
AC_DEFUN([FT_MUNMAP_PARAM],
|
||||
[AC_MSG_CHECKING([for munmap's first parameter type])
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_SOURCE([[
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
int munmap(void *, size_t);
|
||||
|
||||
]])
|
||||
],
|
||||
[AC_MSG_RESULT([void *])
|
||||
AC_DEFINE([MUNMAP_USES_VOIDP],
|
||||
[],
|
||||
[Define to 1 if the first argument of munmap is of type void *])],
|
||||
[AC_MSG_RESULT([char *])])
|
||||
])
|
||||
|
||||
# end of ft-munmap.m4
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftconfig.h.in
|
||||
*
|
||||
* UNIX-specific configuration file (specification only).
|
||||
*
|
||||
* Copyright (C) 1996-2022 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used,
|
||||
* modified, and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* This header file contains a number of macro definitions that are used by
|
||||
* the rest of the engine. Most of the macros here are automatically
|
||||
* determined at compile time, and you should not need to change it to port
|
||||
* FreeType, except to compile the library with a non-ANSI compiler.
|
||||
*
|
||||
* Note however that if some specific modifications are needed, we advise
|
||||
* you to place a modified copy in your build directory.
|
||||
*
|
||||
* The build directory is usually `builds/<system>`, and contains
|
||||
* system-specific files that are always included first when building the
|
||||
* library.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FTCONFIG_H_
|
||||
#define FTCONFIG_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_OPTIONS_H
|
||||
#include FT_CONFIG_STANDARD_LIBRARY_H
|
||||
|
||||
#undef HAVE_UNISTD_H
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
#include <freetype/config/integer-types.h>
|
||||
#include <freetype/config/public-macros.h>
|
||||
#include <freetype/config/mac-support.h>
|
||||
|
||||
#endif /* FTCONFIG_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
@ -0,0 +1,436 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftsystem.c
|
||||
*
|
||||
* Unix-specific FreeType low-level system interface (body).
|
||||
*
|
||||
* Copyright (C) 1996-2022 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used,
|
||||
* modified, and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
/* we use our special ftconfig.h file, not the standard one */
|
||||
#include FT_CONFIG_CONFIG_H
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/ftsystem.h>
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/fttypes.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
/* memory-mapping includes and definitions */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/mman.h>
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0x00
|
||||
#endif
|
||||
|
||||
#ifdef MUNMAP_USES_VOIDP
|
||||
#define MUNMAP_ARG_CAST void *
|
||||
#else
|
||||
#define MUNMAP_ARG_CAST char *
|
||||
#endif
|
||||
|
||||
#ifdef NEED_MUNMAP_DECL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int
|
||||
munmap( char* addr,
|
||||
int len );
|
||||
|
||||
#define MUNMAP_ARG_CAST char *
|
||||
|
||||
#endif /* NEED_DECLARATION_MUNMAP */
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* MEMORY MANAGEMENT INTERFACE
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* It is not necessary to do any error checking for the
|
||||
* allocation-related functions. This will be done by the higher level
|
||||
* routines like ft_mem_alloc() or ft_mem_realloc().
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @Function:
|
||||
* ft_alloc
|
||||
*
|
||||
* @Description:
|
||||
* The memory allocation function.
|
||||
*
|
||||
* @Input:
|
||||
* memory ::
|
||||
* A pointer to the memory object.
|
||||
*
|
||||
* size ::
|
||||
* The requested size in bytes.
|
||||
*
|
||||
* @Return:
|
||||
* The address of newly allocated block.
|
||||
*/
|
||||
FT_CALLBACK_DEF( void* )
|
||||
ft_alloc( FT_Memory memory,
|
||||
long size )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @Function:
|
||||
* ft_realloc
|
||||
*
|
||||
* @Description:
|
||||
* The memory reallocation function.
|
||||
*
|
||||
* @Input:
|
||||
* memory ::
|
||||
* A pointer to the memory object.
|
||||
*
|
||||
* cur_size ::
|
||||
* The current size of the allocated memory block.
|
||||
*
|
||||
* new_size ::
|
||||
* The newly requested size in bytes.
|
||||
*
|
||||
* block ::
|
||||
* The current address of the block in memory.
|
||||
*
|
||||
* @Return:
|
||||
* The address of the reallocated memory block.
|
||||
*/
|
||||
FT_CALLBACK_DEF( void* )
|
||||
ft_realloc( FT_Memory memory,
|
||||
long cur_size,
|
||||
long new_size,
|
||||
void* block )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
FT_UNUSED( cur_size );
|
||||
|
||||
return realloc( block, new_size );
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @Function:
|
||||
* ft_free
|
||||
*
|
||||
* @Description:
|
||||
* The memory release function.
|
||||
*
|
||||
* @Input:
|
||||
* memory ::
|
||||
* A pointer to the memory object.
|
||||
*
|
||||
* block ::
|
||||
* The address of block in memory to be freed.
|
||||
*/
|
||||
FT_CALLBACK_DEF( void )
|
||||
ft_free( FT_Memory memory,
|
||||
void* block )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
|
||||
free( block );
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* RESOURCE MANAGEMENT INTERFACE
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* The macro FT_COMPONENT is used in trace mode. It is an implicit
|
||||
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
|
||||
* messages during execution.
|
||||
*/
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT io
|
||||
|
||||
/* We use the macro STREAM_FILE for convenience to extract the */
|
||||
/* system-specific stream handle from a given FreeType stream object */
|
||||
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @Function:
|
||||
* ft_close_stream_by_munmap
|
||||
*
|
||||
* @Description:
|
||||
* The function to close a stream which is opened by mmap.
|
||||
*
|
||||
* @Input:
|
||||
* stream :: A pointer to the stream object.
|
||||
*/
|
||||
FT_CALLBACK_DEF( void )
|
||||
ft_close_stream_by_munmap( FT_Stream stream )
|
||||
{
|
||||
munmap( (MUNMAP_ARG_CAST)stream->descriptor.pointer, stream->size );
|
||||
|
||||
stream->descriptor.pointer = NULL;
|
||||
stream->size = 0;
|
||||
stream->base = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @Function:
|
||||
* ft_close_stream_by_free
|
||||
*
|
||||
* @Description:
|
||||
* The function to close a stream which is created by ft_alloc.
|
||||
*
|
||||
* @Input:
|
||||
* stream :: A pointer to the stream object.
|
||||
*/
|
||||
FT_CALLBACK_DEF( void )
|
||||
ft_close_stream_by_free( FT_Stream stream )
|
||||
{
|
||||
ft_free( stream->memory, stream->descriptor.pointer );
|
||||
|
||||
stream->descriptor.pointer = NULL;
|
||||
stream->size = 0;
|
||||
stream->base = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftobjs.h */
|
||||
|
||||
FT_BASE_DEF( FT_Error )
|
||||
FT_Stream_Open( FT_Stream stream,
|
||||
const char* filepathname )
|
||||
{
|
||||
int file;
|
||||
struct stat stat_buf;
|
||||
|
||||
|
||||
if ( !stream )
|
||||
return FT_THROW( Invalid_Stream_Handle );
|
||||
|
||||
/* open the file */
|
||||
file = open( filepathname, O_RDONLY );
|
||||
if ( file < 0 )
|
||||
{
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
||||
return FT_THROW( Cannot_Open_Resource );
|
||||
}
|
||||
|
||||
/* Here we ensure that a "fork" will _not_ duplicate */
|
||||
/* our opened input streams on Unix. This is critical */
|
||||
/* since it avoids some (possible) access control */
|
||||
/* issues and cleans up the kernel file table a bit. */
|
||||
/* */
|
||||
#ifdef F_SETFD
|
||||
#ifdef FD_CLOEXEC
|
||||
(void)fcntl( file, F_SETFD, FD_CLOEXEC );
|
||||
#else
|
||||
(void)fcntl( file, F_SETFD, 1 );
|
||||
#endif /* FD_CLOEXEC */
|
||||
#endif /* F_SETFD */
|
||||
|
||||
if ( fstat( file, &stat_buf ) < 0 )
|
||||
{
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not `fstat' file `%s'\n", filepathname ));
|
||||
goto Fail_Map;
|
||||
}
|
||||
|
||||
/* XXX: TODO -- real 64bit platform support */
|
||||
/* */
|
||||
/* `stream->size' is typedef'd to unsigned long (in `ftsystem.h'); */
|
||||
/* `stat_buf.st_size', however, is usually typedef'd to off_t */
|
||||
/* (in sys/stat.h). */
|
||||
/* On some platforms, the former is 32bit and the latter is 64bit. */
|
||||
/* To avoid overflow caused by fonts in huge files larger than */
|
||||
/* 2GB, do a test. Temporary fix proposed by Sean McBride. */
|
||||
/* */
|
||||
if ( stat_buf.st_size > LONG_MAX )
|
||||
{
|
||||
FT_ERROR(( "FT_Stream_Open: file is too big\n" ));
|
||||
goto Fail_Map;
|
||||
}
|
||||
else if ( stat_buf.st_size == 0 )
|
||||
{
|
||||
FT_ERROR(( "FT_Stream_Open: zero-length file\n" ));
|
||||
goto Fail_Map;
|
||||
}
|
||||
|
||||
/* This cast potentially truncates a 64bit to 32bit! */
|
||||
stream->size = (unsigned long)stat_buf.st_size;
|
||||
stream->pos = 0;
|
||||
stream->base = (unsigned char *)mmap( NULL,
|
||||
stream->size,
|
||||
PROT_READ,
|
||||
MAP_FILE | MAP_PRIVATE,
|
||||
file,
|
||||
0 );
|
||||
|
||||
if ( stream->base != MAP_FAILED )
|
||||
stream->close = ft_close_stream_by_munmap;
|
||||
else
|
||||
{
|
||||
ssize_t total_read_count;
|
||||
|
||||
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not `mmap' file `%s'\n", filepathname ));
|
||||
|
||||
stream->base = (unsigned char*)ft_alloc( stream->memory, stream->size );
|
||||
|
||||
if ( !stream->base )
|
||||
{
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " could not `alloc' memory\n" ));
|
||||
goto Fail_Map;
|
||||
}
|
||||
|
||||
total_read_count = 0;
|
||||
do
|
||||
{
|
||||
ssize_t read_count;
|
||||
|
||||
|
||||
read_count = read( file,
|
||||
stream->base + total_read_count,
|
||||
stream->size - total_read_count );
|
||||
|
||||
if ( read_count <= 0 )
|
||||
{
|
||||
if ( read_count == -1 && errno == EINTR )
|
||||
continue;
|
||||
|
||||
FT_ERROR(( "FT_Stream_Open:" ));
|
||||
FT_ERROR(( " error while `read'ing file `%s'\n", filepathname ));
|
||||
goto Fail_Read;
|
||||
}
|
||||
|
||||
total_read_count += read_count;
|
||||
|
||||
} while ( (unsigned long)total_read_count != stream->size );
|
||||
|
||||
stream->close = ft_close_stream_by_free;
|
||||
}
|
||||
|
||||
close( file );
|
||||
|
||||
stream->descriptor.pointer = stream->base;
|
||||
stream->pathname.pointer = (char*)filepathname;
|
||||
|
||||
stream->read = NULL;
|
||||
|
||||
FT_TRACE1(( "FT_Stream_Open:" ));
|
||||
FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
|
||||
filepathname, stream->size ));
|
||||
|
||||
return FT_Err_Ok;
|
||||
|
||||
Fail_Read:
|
||||
ft_free( stream->memory, stream->base );
|
||||
|
||||
Fail_Map:
|
||||
close( file );
|
||||
|
||||
stream->base = NULL;
|
||||
stream->size = 0;
|
||||
stream->pos = 0;
|
||||
|
||||
return FT_THROW( Cannot_Open_Stream );
|
||||
}
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_MEMORY
|
||||
|
||||
extern FT_Int
|
||||
ft_mem_debug_init( FT_Memory memory );
|
||||
|
||||
extern void
|
||||
ft_mem_debug_done( FT_Memory memory );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* documentation is in ftobjs.h */
|
||||
|
||||
FT_BASE_DEF( FT_Memory )
|
||||
FT_New_Memory( void )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
memory = (FT_Memory)malloc( sizeof ( *memory ) );
|
||||
if ( memory )
|
||||
{
|
||||
memory->user = NULL;
|
||||
memory->alloc = ft_alloc;
|
||||
memory->realloc = ft_realloc;
|
||||
memory->free = ft_free;
|
||||
#ifdef FT_DEBUG_MEMORY
|
||||
ft_mem_debug_init( memory );
|
||||
#endif
|
||||
}
|
||||
|
||||
return memory;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftobjs.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Done_Memory( FT_Memory memory )
|
||||
{
|
||||
#ifdef FT_DEBUG_MEMORY
|
||||
ft_mem_debug_done( memory );
|
||||
#endif
|
||||
memory->free( memory, memory );
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
@ -0,0 +1,541 @@
|
|||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2020-11-14.01; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS=" $tab$nl"
|
||||
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
doit=${DOITPROG-}
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
# Create dirs (including intermediate dirs) using mode 755.
|
||||
# This is like GNU 'install' as of coreutils 8.32 (2020).
|
||||
mkdir_umask=22
|
||||
|
||||
backupsuffix=
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-p pass -p to $cpprog.
|
||||
-s $stripprog installed files.
|
||||
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
|
||||
By default, rm is invoked with -f; when overridden with RMPROG,
|
||||
it's up to you to specify -f if you want it.
|
||||
|
||||
If -S is not specified, no backups are attempted.
|
||||
|
||||
Email bug reports to bug-automake@gnu.org.
|
||||
Automake home page: https://www.gnu.org/software/automake/
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-p) cpprog="$cpprog -p";;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-S) backupsuffix="$2"
|
||||
shift;;
|
||||
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
# Don't chown directories that already exist.
|
||||
if test $dstdir_status = 0; then
|
||||
chowncmd=""
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename.
|
||||
if test -d "$dst"; then
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dstbase=`basename "$src"`
|
||||
case $dst in
|
||||
*/) dst=$dst$dstbase;;
|
||||
*) dst=$dst/$dstbase;;
|
||||
esac
|
||||
dstdir_status=0
|
||||
else
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
case $dstdir in
|
||||
*/) dstdirslash=$dstdir;;
|
||||
*) dstdirslash=$dstdir/;;
|
||||
esac
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
# The $RANDOM variable is not portable (e.g., dash). Use it
|
||||
# here however when possible just to lower collision chance.
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
|
||||
trap '
|
||||
ret=$?
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
|
||||
exit $ret
|
||||
' 0
|
||||
|
||||
# Because "mkdir -p" follows existing symlinks and we likely work
|
||||
# directly in world-writeable /tmp, make sure that the '$tmpdir'
|
||||
# directory is successfully created first before we actually test
|
||||
# 'mkdir -p'.
|
||||
if (umask $mkdir_umask &&
|
||||
$mkdirprog $mkdir_mode "$tmpdir" &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
test_tmpdir="$tmpdir/a"
|
||||
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=${dstdirslash}_inst.$$_
|
||||
rmtmp=${dstdirslash}_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask &&
|
||||
{ test -z "$stripcmd" || {
|
||||
# Create $dsttmp read-write so that cp doesn't create it read-only,
|
||||
# which would cause strip to fail.
|
||||
if test -z "$doit"; then
|
||||
: >"$dsttmp" # No need to fork-exec 'touch'.
|
||||
else
|
||||
$doit touch "$dsttmp"
|
||||
fi
|
||||
}
|
||||
} &&
|
||||
$doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# If $backupsuffix is set, and the file being installed
|
||||
# already exists, attempt a backup. Don't worry if it fails,
|
||||
# e.g., if mv doesn't support -f.
|
||||
if test -n "$backupsuffix" && test -f "$dst"; then
|
||||
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
#
|
||||
# FreeType 2 installation instructions for Unix systems
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
# If you say
|
||||
#
|
||||
# make install DESTDIR=/tmp/somewhere/
|
||||
#
|
||||
# don't forget the final backslash (this command is mainly for package
|
||||
# maintainers).
|
||||
|
||||
|
||||
.PHONY: install uninstall check
|
||||
|
||||
# Unix installation and deinstallation targets.
|
||||
#
|
||||
# Note that we remove any data found in `$(includedir)/freetype2' before
|
||||
# installing new files to avoid interferences with files installed by
|
||||
# previous FreeType versions (which use slightly different locations).
|
||||
#
|
||||
# We also remove `$(includedir)/ft2build.h' for the same reason.
|
||||
#
|
||||
# Note that some header files get handled twice for simplicity; a special,
|
||||
# configured version overwrites the generic one.
|
||||
#
|
||||
install: $(PROJECT_LIBRARY)
|
||||
-$(DELDIR) $(DESTDIR)$(includedir)/freetype2
|
||||
-$(DELETE) $(DESTDIR)$(includedir)/ft2build.h
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(libdir)/pkgconfig \
|
||||
$(DESTDIR)$(includedir)/freetype2/freetype/config \
|
||||
$(DESTDIR)$(datadir)/aclocal
|
||||
ifeq ($(INSTALL_FT2_CONFIG),TRUE)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(bindir) \
|
||||
$(DESTDIR)$(mandir)/man1
|
||||
endif
|
||||
$(LIBTOOL) --mode=install $(INSTALL) \
|
||||
$(PROJECT_LIBRARY) $(DESTDIR)$(libdir)
|
||||
-for P in $(PUBLIC_H) ; do \
|
||||
$(INSTALL_DATA) \
|
||||
$$P $(DESTDIR)$(includedir)/freetype2/freetype ; \
|
||||
done
|
||||
-for P in $(CONFIG_H) ; do \
|
||||
$(INSTALL_DATA) \
|
||||
$$P $(DESTDIR)$(includedir)/freetype2/freetype/config ; \
|
||||
done
|
||||
$(INSTALL_DATA) $(TOP_DIR)/include/ft2build.h \
|
||||
$(DESTDIR)$(includedir)/freetype2/ft2build.h
|
||||
$(INSTALL_DATA) $(OBJ_BUILD)/ftconfig.h \
|
||||
$(DESTDIR)$(includedir)/freetype2/freetype/config/ftconfig.h
|
||||
$(INSTALL_DATA) $(OBJ_DIR)/ftmodule.h \
|
||||
$(DESTDIR)$(includedir)/freetype2/freetype/config/ftmodule.h
|
||||
$(INSTALL_DATA) $(OBJ_BUILD)/ftoption.h \
|
||||
$(DESTDIR)$(includedir)/freetype2/freetype/config/ftoption.h
|
||||
$(INSTALL_SCRIPT) -m 644 $(PLATFORM_DIR)/freetype2.m4 \
|
||||
$(DESTDIR)$(datadir)/aclocal/freetype2.m4
|
||||
$(INSTALL_SCRIPT) -m 644 $(OBJ_BUILD)/freetype2.pc \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/freetype2.pc
|
||||
ifeq ($(INSTALL_FT2_CONFIG),TRUE)
|
||||
$(INSTALL_SCRIPT) -m 755 $(OBJ_BUILD)/freetype-config \
|
||||
$(DESTDIR)$(bindir)/freetype-config
|
||||
$(INSTALL_DATA) $(TOP_DIR)/docs/freetype-config.1 \
|
||||
$(DESTDIR)$(mandir)/man1/freetype-config.1
|
||||
endif
|
||||
|
||||
|
||||
uninstall:
|
||||
-$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(libdir)/$(LIBRARY).$A
|
||||
-$(DELDIR) $(DESTDIR)$(includedir)/freetype2
|
||||
-$(DELETE) $(DESTDIR)$(bindir)/freetype-config
|
||||
-$(DELETE) $(DESTDIR)$(datadir)/aclocal/freetype2.m4
|
||||
-$(DELETE) $(DESTDIR)$(libdir)/pkgconfig/freetype2.pc
|
||||
-$(DELETE) $(DESTDIR)$(mandir)/man1/freetype-config.1
|
||||
|
||||
|
||||
check:
|
||||
$(info There is no validation suite for this package.)
|
||||
|
||||
|
||||
.PHONY: clean_project_unix distclean_project_unix
|
||||
|
||||
# Unix cleaning and distclean rules.
|
||||
#
|
||||
clean_project_unix:
|
||||
-$(LIBTOOL) --mode=clean $(RM) $(OBJECTS_LIST)
|
||||
-$(DELETE) $(CLEAN)
|
||||
|
||||
distclean_project_unix: clean_project_unix
|
||||
-$(LIBTOOL) --mode=clean $(RM) $(PROJECT_LIBRARY)
|
||||
-$(DELETE) *.orig *~ core *.core $(DISTCLEAN)
|
||||
|
||||
# EOF
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,199 @@
|
|||
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
# serial 1 (pkg-config-0.24)
|
||||
#
|
||||
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
|
||||
# ----------------------------------
|
||||
AC_DEFUN([PKG_PROG_PKG_CONFIG],
|
||||
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
|
||||
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
|
||||
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
|
||||
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
|
||||
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
|
||||
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
|
||||
|
||||
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
|
||||
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
|
||||
fi
|
||||
if test -n "$PKG_CONFIG"; then
|
||||
_pkg_min_version=m4_default([$1], [0.9.0])
|
||||
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
PKG_CONFIG=""
|
||||
fi
|
||||
fi[]dnl
|
||||
])# PKG_PROG_PKG_CONFIG
|
||||
|
||||
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
#
|
||||
# Check to see whether a particular set of modules exists. Similar
|
||||
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
|
||||
#
|
||||
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
# only at the first occurrence in configure.ac, so if the first place
|
||||
# it's called might be skipped (such as if it is within an "if", you
|
||||
# have to call PKG_CHECK_EXISTS manually
|
||||
# --------------------------------------------------------------
|
||||
AC_DEFUN([PKG_CHECK_EXISTS],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
|
||||
m4_default([$2], [:])
|
||||
m4_ifvaln([$3], [else
|
||||
$3])dnl
|
||||
fi])
|
||||
|
||||
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
|
||||
# ---------------------------------------------
|
||||
m4_define([_PKG_CONFIG],
|
||||
[if test -n "$$1"; then
|
||||
pkg_cv_[]$1="$$1"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
PKG_CHECK_EXISTS([$3],
|
||||
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes ],
|
||||
[pkg_failed=yes])
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi[]dnl
|
||||
])# _PKG_CONFIG
|
||||
|
||||
# _PKG_SHORT_ERRORS_SUPPORTED
|
||||
# -----------------------------
|
||||
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
||||
_pkg_short_errors_supported=yes
|
||||
else
|
||||
_pkg_short_errors_supported=no
|
||||
fi[]dnl
|
||||
])# _PKG_SHORT_ERRORS_SUPPORTED
|
||||
|
||||
|
||||
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
|
||||
# [ACTION-IF-NOT-FOUND])
|
||||
#
|
||||
#
|
||||
# Note that if there is a possibility the first call to
|
||||
# PKG_CHECK_MODULES might not happen, you should be sure to include an
|
||||
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
|
||||
#
|
||||
#
|
||||
# --------------------------------------------------------------
|
||||
AC_DEFUN([PKG_CHECK_MODULES],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
|
||||
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
|
||||
|
||||
pkg_failed=no
|
||||
AC_MSG_CHECKING([for $1])
|
||||
|
||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||
|
||||
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
|
||||
and $1[]_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details.])
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
AC_MSG_RESULT([no])
|
||||
_PKG_SHORT_ERRORS_SUPPORTED
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
|
||||
else
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
|
||||
|
||||
m4_default([$4], [AC_MSG_ERROR(
|
||||
[Package requirements ($2) were not met:
|
||||
|
||||
$$1_PKG_ERRORS
|
||||
|
||||
Consider adjusting the PKG_CONFIG_PATH environment variable if you
|
||||
installed software in a non-standard prefix.
|
||||
|
||||
_PKG_TEXT])[]dnl
|
||||
])
|
||||
elif test $pkg_failed = untried; then
|
||||
AC_MSG_RESULT([no])
|
||||
m4_default([$4], [AC_MSG_FAILURE(
|
||||
[The pkg-config script could not be found or is too old. Make sure it
|
||||
is in your PATH or set the PKG_CONFIG environment variable to the full
|
||||
path to pkg-config.
|
||||
|
||||
_PKG_TEXT
|
||||
|
||||
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
|
||||
])
|
||||
else
|
||||
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
|
||||
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
|
||||
AC_MSG_RESULT([yes])
|
||||
$3
|
||||
fi[]dnl
|
||||
])# PKG_CHECK_MODULES
|
||||
|
||||
|
||||
# PKG_INSTALLDIR(DIRECTORY)
|
||||
# -------------------------
|
||||
# Substitutes the variable pkgconfigdir as the location where a module
|
||||
# should install pkg-config .pc files. By default the directory is
|
||||
# $libdir/pkgconfig, but the default can be changed by passing
|
||||
# DIRECTORY. The user can override through the --with-pkgconfigdir
|
||||
# parameter.
|
||||
AC_DEFUN([PKG_INSTALLDIR],
|
||||
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
|
||||
m4_pushdef([pkg_description],
|
||||
[pkg-config installation directory @<:@]pkg_default[@:>@])
|
||||
AC_ARG_WITH([pkgconfigdir],
|
||||
[AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
|
||||
[with_pkgconfigdir=]pkg_default)
|
||||
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
|
||||
m4_popdef([pkg_default])
|
||||
m4_popdef([pkg_description])
|
||||
]) dnl PKG_INSTALLDIR
|
||||
|
||||
|
||||
# PKG_NOARCH_INSTALLDIR(DIRECTORY)
|
||||
# -------------------------
|
||||
# Substitutes the variable noarch_pkgconfigdir as the location where a
|
||||
# module should install arch-independent pkg-config .pc files. By
|
||||
# default the directory is $datadir/pkgconfig, but the default can be
|
||||
# changed by passing DIRECTORY. The user can override through the
|
||||
# --with-noarch-pkgconfigdir parameter.
|
||||
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
|
||||
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
|
||||
m4_pushdef([pkg_description],
|
||||
[pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
|
||||
AC_ARG_WITH([noarch-pkgconfigdir],
|
||||
[AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
|
||||
[with_noarch_pkgconfigdir=]pkg_default)
|
||||
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
|
||||
m4_popdef([pkg_default])
|
||||
m4_popdef([pkg_description])
|
||||
]) dnl PKG_NOARCH_INSTALLDIR
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
#
|
||||
# FreeType 2 template for Unix-specific compiler definitions
|
||||
#
|
||||
|
||||
# Copyright (C) 1996-2022 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
CC := @CC@
|
||||
COMPILER_SEP := $(SEP)
|
||||
FT_LIBTOOL_DIR ?= $(PLATFORM_DIR)
|
||||
|
||||
LIBTOOL := $(FT_LIBTOOL_DIR)/libtool
|
||||
|
||||
|
||||
# The object file extension (for standard and static libraries). This can be
|
||||
# .o, .tco, .obj, etc., depending on the platform.
|
||||
#
|
||||
O := lo
|
||||
SO := o
|
||||
|
||||
|
||||
# The executable file extension. Although most Unix platforms use no
|
||||
# extension, we copy the extension detected by autoconf. Useful for cross
|
||||
# building on Unix systems for non-Unix systems.
|
||||
#
|
||||
E := @EXEEXT@
|
||||
|
||||
|
||||
# The library file extension (for standard and static libraries). This can
|
||||
# be .a, .lib, etc., depending on the platform.
|
||||
#
|
||||
A := la
|
||||
SA := a
|
||||
|
||||
|
||||
# The name of the final library file. Note that the DOS-specific Makefile
|
||||
# uses a shorter (8.3) name.
|
||||
#
|
||||
LIBRARY := lib$(PROJECT)
|
||||
|
||||
|
||||
# Path inclusion flag. Some compilers use a different flag than `-I' to
|
||||
# specify an additional include path. Examples are `/i=' or `-J'.
|
||||
#
|
||||
I := -I
|
||||
|
||||
|
||||
# C flag used to define a macro before the compilation of a given source
|
||||
# object. Usually it is `-D' like in `-DDEBUG'.
|
||||
#
|
||||
D := -D
|
||||
|
||||
|
||||
# The link flag used to specify a given library file on link. Note that
|
||||
# this is only used to compile the demo programs, not the library itself.
|
||||
#
|
||||
L := -l
|
||||
|
||||
|
||||
# Target flag.
|
||||
#
|
||||
T := -o$(space)
|
||||
|
||||
|
||||
# C flags
|
||||
#
|
||||
# These should concern: debug output, optimization & warnings.
|
||||
#
|
||||
# Use the ANSIFLAGS variable to define the compiler flags used to enforce
|
||||
# ANSI compliance.
|
||||
#
|
||||
# We use our own FreeType configuration files overriding defaults.
|
||||
#
|
||||
CPPFLAGS := @CPPFLAGS@
|
||||
CFLAGS := -c @XX_CFLAGS@ @CFLAGS@ \
|
||||
$DFT_CONFIG_CONFIG_H="<ftconfig.h>" \
|
||||
$DFT_CONFIG_MODULES_H="<ftmodule.h>" \
|
||||
$DFT_CONFIG_OPTIONS_H="<ftoption.h>"
|
||||
|
||||
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
|
||||
#
|
||||
ANSIFLAGS := @XX_ANSIFLAGS@
|
||||
|
||||
# C compiler to use -- we use libtool!
|
||||
#
|
||||
# CC might be set on the command line; we store this value in `CCraw'.
|
||||
# Consequently, we use the `override' directive to ensure that the
|
||||
# libtool call is always prepended.
|
||||
#
|
||||
CCraw := $(CC)
|
||||
override CC := $(LIBTOOL) --mode=compile $(CCraw)
|
||||
|
||||
# Resource compiler to use on Cygwin/MinGW, usually windres.
|
||||
#
|
||||
RCraw := @RC@
|
||||
ifneq ($(RCraw),)
|
||||
RC := $(LIBTOOL) --tag=RC --mode=compile $(RCraw)
|
||||
endif
|
||||
|
||||
# Linker flags.
|
||||
#
|
||||
LDFLAGS := @LDFLAGS@
|
||||
|
||||
# export symbols
|
||||
#
|
||||
CCraw_build := @CC_BUILD@ # native CC of building system
|
||||
E_BUILD := @EXEEXT_BUILD@ # extension for executable on building system
|
||||
EXPORTS_LIST := $(OBJ_DIR)/ftexport.sym
|
||||
CCexe := $(CCraw_build) # used to compile `apinames' only
|
||||
|
||||
|
||||
# Library linking.
|
||||
#
|
||||
LINK_LIBRARY = $(LIBTOOL) --mode=link $(CCraw) -o $@ $(OBJECTS_LIST) \
|
||||
-rpath $(libdir) -version-info $(version_info) \
|
||||
$(LDFLAGS) -no-undefined \
|
||||
-export-symbols $(EXPORTS_LIST)
|
||||
|
||||
# For the demo programs.
|
||||
FT_DEMO_CFLAGS := @FT_DEMO_CFLAGS@
|
||||