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@
|
||||
FT_DEMO_LDFLAGS := @FT_DEMO_LDFLAGS@
|
||||
|
||||
# EOF
|
|
@ -0,0 +1,163 @@
|
|||
#
|
||||
# FreeType 2 configuration rules templates for Unix + configure
|
||||
#
|
||||
|
||||
|
||||
# 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.
|
||||
|
||||
SHELL := @SHELL@
|
||||
|
||||
TOP_DIR := $(shell cd $(TOP_DIR); pwd)
|
||||
|
||||
DELETE := rm -f
|
||||
DELDIR := rm -rf
|
||||
CAT := cat
|
||||
SEP := /
|
||||
|
||||
# This is used for `make refdoc' and `make refdoc-venv'
|
||||
#
|
||||
PYTHON := @PYTHON@
|
||||
BIN := bin
|
||||
|
||||
# this is used for `make distclean' and `make install'
|
||||
OBJ_BUILD ?= $(PLATFORM_DIR)
|
||||
|
||||
# don't use `:=' here since the path stuff will be included after this file
|
||||
#
|
||||
FTSYS_SRC = @FTSYS_SRC@
|
||||
|
||||
INSTALL := @INSTALL@
|
||||
INSTALL_DATA := @INSTALL_DATA@
|
||||
INSTALL_PROGRAM := @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT := @INSTALL_SCRIPT@
|
||||
MKINSTALLDIRS := @MKDIR_P@
|
||||
|
||||
CLEAN += $(OBJ_BUILD)/freetype-config \
|
||||
$(OBJ_BUILD)/freetype2.pc
|
||||
|
||||
DISTCLEAN += $(OBJ_BUILD)/config.cache \
|
||||
$(OBJ_BUILD)/config.log \
|
||||
$(OBJ_BUILD)/config.status \
|
||||
$(OBJ_BUILD)/unix-def.mk \
|
||||
$(OBJ_BUILD)/unix-cc.mk \
|
||||
$(OBJ_BUILD)/ftconfig.h \
|
||||
$(OBJ_BUILD)/ftoption.h \
|
||||
$(LIBTOOL) \
|
||||
$(OBJ_BUILD)/Makefile
|
||||
|
||||
|
||||
# Standard installation variables.
|
||||
#
|
||||
prefix := @prefix@
|
||||
exec_prefix := @exec_prefix@
|
||||
libdir := @libdir@
|
||||
bindir := @bindir@
|
||||
includedir := @includedir@
|
||||
datarootdir := @datarootdir@
|
||||
datadir := @datadir@
|
||||
mandir := @mandir@
|
||||
|
||||
version_info := @version_info@
|
||||
|
||||
# Variables needed for `freetype-config' and `freetype.pc'.
|
||||
#
|
||||
PKG_CONFIG := @PKG_CONFIG@
|
||||
PKGCONFIG_REQUIRES := @PKGCONFIG_REQUIRES@
|
||||
PKGCONFIG_REQUIRES_PRIVATE := @PKGCONFIG_REQUIRES_PRIVATE@
|
||||
PKGCONFIG_LIBS := @PKGCONFIG_LIBS@
|
||||
PKGCONFIG_LIBS_PRIVATE := @PKGCONFIG_LIBS_PRIVATE@
|
||||
LIBSSTATIC_CONFIG := @LIBSSTATIC_CONFIG@
|
||||
build_libtool_libs := @build_libtool_libs@
|
||||
ft_version := @ft_version@
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR); however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
# The BASE_SRC macro lists all source files that should be included in
|
||||
# src/base/ftbase.c. When configure sets up CFLAGS to build ftmac.c,
|
||||
# ftmac.c should be added to BASE_SRC.
|
||||
ftmac_c := @ftmac_c@
|
||||
|
||||
# The SYSTEM_ZLIB macro is defined if the user wishes to link dynamically
|
||||
# with its system wide zlib. If SYSTEM_ZLIB is 'yes', the zlib part of the
|
||||
# ftgzip module is not compiled in.
|
||||
SYSTEM_ZLIB := @SYSTEM_ZLIB@
|
||||
|
||||
|
||||
# The NO_OUTPUT macro is appended to command lines in order to ignore
|
||||
# the output of some programs.
|
||||
#
|
||||
NO_OUTPUT := 2> /dev/null
|
||||
|
||||
|
||||
# To support calls like
|
||||
#
|
||||
# configure --includedir='${libdir}'/freetype2/include
|
||||
#
|
||||
# we generate `freetype-config' and `freetype.pc' at compile time so that
|
||||
# those variables are properly expanded.
|
||||
|
||||
$(OBJ_BUILD)/freetype-config: $(TOP_DIR)/builds/unix/freetype-config.in
|
||||
rm -f $@ $@.tmp
|
||||
sed -e 's|%LIBSSTATIC_CONFIG%|$(LIBSSTATIC_CONFIG)|' \
|
||||
-e 's|%PKG_CONFIG%|$(PKG_CONFIG)|' \
|
||||
-e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
|
||||
-e 's|%exec_prefix%|$(exec_prefix)|' \
|
||||
-e 's|%ft_version%|$(ft_version)|' \
|
||||
-e 's|%includedir%|$(includedir)|' \
|
||||
-e 's|%libdir%|$(libdir)|' \
|
||||
-e 's|%prefix%|$(prefix)|' \
|
||||
$< \
|
||||
> $@.tmp
|
||||
chmod +x $@.tmp
|
||||
chmod go-w $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
# To support directory names with spaces (as might easily happen on Windows
|
||||
# platforms), the right solution would be to surround the pkg-variables in
|
||||
# `freetype2.pc' with double quotes. However, doing so ironically disables
|
||||
# the prefix override mechanism especially written for Windows. This is a
|
||||
# bug in pkg-config version 0.28 and earlier.
|
||||
#
|
||||
# For this reason, we escape spaces with backslashes.
|
||||
|
||||
exec_prefix_x := $(subst $(space),\\$(space),$(exec_prefix))
|
||||
includedir_x := $(subst $(space),\\$(space),$(includedir))
|
||||
libdir_x := $(subst $(space),\\$(space),$(libdir))
|
||||
prefix_x := $(subst $(space),\\$(space),$(prefix))
|
||||
|
||||
$(OBJ_BUILD)/freetype2.pc: $(TOP_DIR)/builds/unix/freetype2.in
|
||||
rm -f $@ $@.tmp
|
||||
sed -e 's|%PKGCONFIG_REQUIRES%|$(PKGCONFIG_REQUIRES)|' \
|
||||
-e 's|%PKGCONFIG_REQUIRES_PRIVATE%|$(PKGCONFIG_REQUIRES_PRIVATE)|' \
|
||||
-e 's|%PKGCONFIG_LIBS%|$(PKGCONFIG_LIBS)|' \
|
||||
-e 's|%PKGCONFIG_LIBS_PRIVATE%|$(PKGCONFIG_LIBS_PRIVATE)|' \
|
||||
-e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
|
||||
-e 's|%exec_prefix%|$(exec_prefix_x)|' \
|
||||
-e 's|%ft_version%|$(ft_version)|' \
|
||||
-e 's|%includedir%|$(includedir_x)|' \
|
||||
-e 's|%libdir%|$(libdir_x)|' \
|
||||
-e 's|%prefix%|$(prefix_x)|' \
|
||||
$< \
|
||||
> $@.tmp
|
||||
chmod a-w $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
# defines whether we should install `freetype-config' or not
|
||||
INSTALL_FT2_CONFIG = @INSTALL_FT2_CONFIG@
|
||||
|
||||
all install: $(OBJ_BUILD)/freetype-config \
|
||||
$(OBJ_BUILD)/freetype2.pc
|
||||
|
||||
# EOF
|
|
@ -0,0 +1,26 @@
|
|||
#
|
||||
# FreeType 2 Configuration rules for Unix + GCC
|
||||
#
|
||||
# Development version without optimizations & libtool
|
||||
# and no installation.
|
||||
#
|
||||
|
||||
|
||||
# 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.
|
||||
|
||||
|
||||
DEVEL_DIR := $(TOP_DIR)/devel
|
||||
|
||||
include $(TOP_DIR)/builds/unix/unixddef.mk
|
||||
include $(TOP_DIR)/builds/compiler/gcc-dev.mk
|
||||
include $(TOP_DIR)/builds/link_std.mk
|
||||
|
||||
|
||||
# EOF
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# FreeType 2 Configuration rules for Unix + LCC
|
||||
#
|
||||
# Development version without optimizations & libtool
|
||||
# and no installation.
|
||||
#
|
||||
|
||||
|
||||
# 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 $(TOP_DIR)/builds/unix/unixddef.mk
|
||||
include $(TOP_DIR)/builds/compiler/unix-lcc.mk
|
||||
include $(TOP_DIR)/builds/link_std.mk
|
||||
|
||||
|
||||
# EOF
|
|
@ -0,0 +1,62 @@
|
|||
#
|
||||
# FreeType 2 configuration rules for UNIX platforms
|
||||
#
|
||||
|
||||
|
||||
# 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.
|
||||
|
||||
# We need these declarations here since unix-def.mk is a generated file.
|
||||
PLATFORM_DIR := $(TOP_DIR)/builds/unix
|
||||
PLATFORM := unix
|
||||
|
||||
have_mk := $(wildcard $(OBJ_DIR)/unix-def.mk)
|
||||
ifneq ($(have_mk),)
|
||||
# We are building FreeType 2 not in the src tree.
|
||||
include $(OBJ_DIR)/unix-def.mk
|
||||
include $(OBJ_DIR)/unix-cc.mk
|
||||
else
|
||||
include $(PLATFORM_DIR)/unix-def.mk
|
||||
include $(PLATFORM_DIR)/unix-cc.mk
|
||||
endif
|
||||
|
||||
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_unix
|
||||
distclean_project: distclean_project_unix
|
||||
|
||||
|
||||
# This final rule is used to link all object files into a single library.
|
||||
# It is part of the system-specific sub-Makefile because not all
|
||||
# librarians accept a simple syntax like
|
||||
#
|
||||
# librarian library_file {list of object files}
|
||||
#
|
||||
$(PROJECT_LIBRARY): $(OBJECTS_LIST)
|
||||
ifdef CLEAN_LIBRARY
|
||||
-$(CLEAN_LIBRARY) $(NO_OUTPUT)
|
||||
endif
|
||||
$(LINK_LIBRARY)
|
||||
|
||||
include $(TOP_DIR)/builds/unix/install.mk
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# EOF
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# FreeType 2 configuration rules templates for
|
||||
# development under Unix with no configure script (gcc 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.
|
||||
|
||||
|
||||
TOP_DIR := $(shell cd $(TOP_DIR); pwd)
|
||||
OBJ_DIR := $(shell cd $(OBJ_DIR); pwd)
|
||||
|
||||
PLATFORM := unix
|
||||
|
||||
DELETE := rm -f
|
||||
CAT := cat
|
||||
SEP := /
|
||||
|
||||
# This is used for `make refdoc' and `make refdoc-venv'
|
||||
#
|
||||
BIN := bin
|
||||
|
||||
|
||||
# library file name
|
||||
#
|
||||
LIBRARY := lib$(PROJECT)
|
||||
|
||||
|
||||
# The directory where all library files are placed.
|
||||
#
|
||||
# By default, this is the same as $(OBJ_DIR); however, this can be changed
|
||||
# to suit particular needs.
|
||||
#
|
||||
LIB_DIR := $(OBJ_DIR)
|
||||
|
||||
|
||||
NO_OUTPUT := 2> /dev/null
|
||||
|
||||
# EOF
|
|
@ -0,0 +1,270 @@
|
|||
// Copyright (c) 2019 nyorain
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef INC_DLG_DLG_H_
|
||||
#define INC_DLG_DLG_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Hosted at https://github.com/nyorain/dlg.
|
||||
// There are examples and documentation.
|
||||
// Issue reports and contributions appreciated.
|
||||
|
||||
// - CONFIG -
|
||||
// Define this macro to make all dlg macros have no effect at all
|
||||
// #define DLG_DISABLE
|
||||
|
||||
// the log/assertion levels below which logs/assertions are ignored
|
||||
// defaulted depending on the NDEBUG macro
|
||||
#ifndef DLG_LOG_LEVEL
|
||||
#ifdef NDEBUG
|
||||
#define DLG_LOG_LEVEL dlg_level_warn
|
||||
#else
|
||||
#define DLG_LOG_LEVEL dlg_level_trace
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DLG_ASSERT_LEVEL
|
||||
#ifdef NDEBUG
|
||||
#define DLG_ASSERT_LEVEL dlg_level_warn
|
||||
#else
|
||||
#define DLG_ASSERT_LEVEL dlg_level_trace
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// the assert level of dlg_assert
|
||||
#ifndef DLG_DEFAULT_ASSERT
|
||||
#define DLG_DEFAULT_ASSERT dlg_level_error
|
||||
#endif
|
||||
|
||||
// evaluated to the 'file' member in dlg_origin
|
||||
#ifndef DLG_FILE
|
||||
#define DLG_FILE dlg__strip_root_path(__FILE__, DLG_BASE_PATH)
|
||||
|
||||
// the base path stripped from __FILE__. If you don't override DLG_FILE set this to
|
||||
// the project root to make 'main.c' from '/some/bullshit/main.c'
|
||||
#ifndef DLG_BASE_PATH
|
||||
#define DLG_BASE_PATH ""
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Default tags applied to all logs/assertions (in the defining file).
|
||||
// Must be in format ```#define DLG_DEFAULT_TAGS "tag1", "tag2"```
|
||||
// or just nothing (as defaulted here)
|
||||
#ifndef DLG_DEFAULT_TAGS
|
||||
#define DLG_DEFAULT_TAGS_TERM NULL
|
||||
#else
|
||||
#define DLG_DEFAULT_TAGS_TERM DLG_DEFAULT_TAGS, NULL
|
||||
#endif
|
||||
|
||||
// The function used for formatting. Can have any signature, but must be callable with
|
||||
// the arguments the log/assertions macros are called with. Must return a const char*
|
||||
// that will not be freed by dlg, the formatting function must keep track of it.
|
||||
// The formatting function might use dlg_thread_buffer or a custom owned buffer.
|
||||
// The returned const char* has to be valid until the dlg log/assertion ends.
|
||||
// Usually a c function with ... (i.e. using va_list) or a variadic c++ template do
|
||||
// allow formatting.
|
||||
#ifndef DLG_FMT_FUNC
|
||||
#define DLG_FMT_FUNC dlg__printf_format
|
||||
#endif
|
||||
|
||||
// Only overwrite (i.e. predefine) this if you know what you are doing.
|
||||
// On windows this is used to add the dllimport specified.
|
||||
// If you are using the static version of dlg (on windows) define
|
||||
// DLG_STATIC before including dlg.h
|
||||
#ifndef DLG_API
|
||||
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(DLG_STATIC)
|
||||
#define DLG_API __declspec(dllimport)
|
||||
#else
|
||||
#define DLG_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// - utility -
|
||||
// two methods needed since cplusplus does not support compound literals
|
||||
// and c does not support uniform initialization/initializer lists
|
||||
#ifdef __cplusplus
|
||||
#include <initializer_list>
|
||||
#define DLG_CREATE_TAGS(...) std::initializer_list<const char*> \
|
||||
{DLG_DEFAULT_TAGS_TERM, __VA_ARGS__, NULL}.begin()
|
||||
#else
|
||||
#define DLG_CREATE_TAGS(...) (const char* const[]) {DLG_DEFAULT_TAGS_TERM, __VA_ARGS__, NULL}
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define DLG_PRINTF_ATTRIB(a, b) __attribute__ ((format (printf, a, b)))
|
||||
#else
|
||||
#define DLG_PRINTF_ATTRIB(a, b)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// Represents the importance of a log/assertion call.
|
||||
enum dlg_level {
|
||||
dlg_level_trace = 0, // temporary used debug, e.g. to check if control reaches function
|
||||
dlg_level_debug, // general debugging, prints e.g. all major events
|
||||
dlg_level_info, // general useful information
|
||||
dlg_level_warn, // warning, something went wrong but might have no (really bad) side effect
|
||||
dlg_level_error, // something really went wrong; expect serious issues
|
||||
dlg_level_fatal // critical error; application is likely to crash/exit
|
||||
};
|
||||
|
||||
// Holds various information associated with a log/assertion call.
|
||||
// Forwarded to the output handler.
|
||||
struct dlg_origin {
|
||||
const char* file;
|
||||
unsigned int line;
|
||||
const char* func;
|
||||
enum dlg_level level;
|
||||
const char** tags; // null-terminated
|
||||
const char* expr; // assertion expression, otherwise null
|
||||
};
|
||||
|
||||
// Type of the output handler, see dlg_set_handler.
|
||||
typedef void(*dlg_handler)(const struct dlg_origin* origin, const char* string, void* data);
|
||||
|
||||
#ifdef DLG_DISABLE
|
||||
// Tagged/Untagged logging with variable level
|
||||
// Tags must always be in the format `("tag1", "tag2")` (including brackets)
|
||||
#define dlg_log(level, ...)
|
||||
#define dlg_logt(level, tags, ...)
|
||||
|
||||
// Dynamic level assert macros in various versions for additional arguments
|
||||
#define dlg_assertl(level, expr) // assert without tags/message
|
||||
#define dlg_assertlt(level, tags, expr) // assert with tags
|
||||
#define dlg_assertlm(level, expr, ...) // assert with message
|
||||
#define dlg_assertltm(level, tags, expr, ...) // assert with tags & message
|
||||
|
||||
// Sets the handler that is responsible for formatting and outputting log calls.
|
||||
// This function is not thread safe and the handler is set globally.
|
||||
// The handler itself must not change dlg tags or call a dlg macro (if it
|
||||
// does so, the provided string or tags array in 'origin' might get invalid).
|
||||
// The handler can also be used for various other things such as dealing
|
||||
// with failed assertions or filtering calls based on the passed tags.
|
||||
// The default handler is dlg_default_output (see its doc for more info).
|
||||
// If using c++ make sure the registered handler cannot throw e.g. by
|
||||
// wrapping everything into a try-catch blog.
|
||||
inline void dlg_set_handler(dlg_handler handler, void* data) {
|
||||
(void) handler;
|
||||
(void) data;
|
||||
}
|
||||
|
||||
// Returns the currently active dlg handler and sets `data` to
|
||||
// its user data pointer. `data` must not be NULL.
|
||||
// Useful to create handler chains.
|
||||
// This function is not threadsafe, i.e. retrieving the handler while
|
||||
// changing it from another thread is unsafe.
|
||||
// See `dlg_set_handler`.
|
||||
inline dlg_handler dlg_get_handler(void** data) {
|
||||
*data = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// The default output handler.
|
||||
// Only use this to reset the output handler, prefer to use
|
||||
// dlg_generic_output (from output.h) which this function simply calls.
|
||||
// It also flushes the stream used and correctly outputs even from multiple threads.
|
||||
inline void dlg_default_output(const struct dlg_origin* o, const char* str, void* data) {
|
||||
(void) o;
|
||||
(void) str;
|
||||
(void) data;
|
||||
}
|
||||
|
||||
// Adds the given tag associated with the given function to the thread specific list.
|
||||
// If func is not NULL the tag will only applied to calls from the same function.
|
||||
// Remove the tag again calling dlg_remove_tag (with exactly the same pointers!).
|
||||
// Does not check if the tag is already present.
|
||||
inline void dlg_add_tag(const char* tag, const char* func) {
|
||||
(void) tag;
|
||||
(void) func;
|
||||
}
|
||||
|
||||
// Removes a tag added with dlg_add_tag (has no effect for tags no present).
|
||||
// The pointers must be exactly the same pointers that were supplied to dlg_add_tag,
|
||||
// this function will not check using strcmp. When the same tag/func combination
|
||||
// is added multiple times, this function remove exactly one candidate, it is
|
||||
// undefined which. Returns whether a tag was found (and removed).
|
||||
inline bool dlg_remove_tag(const char* tag, const char* func) {
|
||||
(void) tag;
|
||||
(void) func;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns the thread-specific buffer and its size for dlg.
|
||||
// The buffer should only be used by formatting functions.
|
||||
// The buffer can be reallocated and the size changed, just make sure
|
||||
// to update both values correctly.
|
||||
inline char** dlg_thread_buffer(size_t** size) {
|
||||
(void) size;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else // DLG_DISABLE
|
||||
#define dlg_log(level, ...) if(level >= DLG_LOG_LEVEL) \
|
||||
dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, \
|
||||
DLG_FMT_FUNC(__VA_ARGS__), NULL)
|
||||
#define dlg_logt(level, tags, ...) if(level >= DLG_LOG_LEVEL) \
|
||||
dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, __func__, \
|
||||
DLG_FMT_FUNC(__VA_ARGS__), NULL)
|
||||
|
||||
#define dlg_assertl(level, expr) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
|
||||
dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, NULL, #expr)
|
||||
#define dlg_assertlt(level, tags, expr) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
|
||||
dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, __func__, NULL, #expr)
|
||||
#define dlg_assertlm(level, expr, ...) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
|
||||
dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, \
|
||||
DLG_FMT_FUNC(__VA_ARGS__), #expr)
|
||||
#define dlg_assertltm(level, tags, expr, ...) if(level >= DLG_ASSERT_LEVEL && !(expr)) \
|
||||
dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, \
|
||||
__func__, DLG_FMT_FUNC(__VA_ARGS__), #expr)
|
||||
|
||||
DLG_API void dlg_set_handler(dlg_handler handler, void* data);
|
||||
DLG_API dlg_handler dlg_get_handler(void** data);
|
||||
DLG_API void dlg_default_output(const struct dlg_origin*, const char* string, void*);
|
||||
DLG_API void dlg_add_tag(const char* tag, const char* func);
|
||||
DLG_API bool dlg_remove_tag(const char* tag, const char* func);
|
||||
DLG_API char** dlg_thread_buffer(size_t** size);
|
||||
|
||||
// - Private interface: not part of the abi/api but needed in macros -
|
||||
// Formats the given format string and arguments as printf would, uses the thread buffer.
|
||||
DLG_API const char* dlg__printf_format(const char* format, ...) DLG_PRINTF_ATTRIB(1, 2);
|
||||
DLG_API void dlg__do_log(enum dlg_level lvl, const char* const*, const char*, int,
|
||||
const char*, const char*, const char*);
|
||||
DLG_API const char* dlg__strip_root_path(const char* file, const char* base);
|
||||
#endif // DLG_DISABLE
|
||||
|
||||
// Untagged leveled logging
|
||||
#define dlg_trace(...) dlg_log(dlg_level_trace, __VA_ARGS__)
|
||||
#define dlg_debug(...) dlg_log(dlg_level_debug, __VA_ARGS__)
|
||||
#define dlg_info(...) dlg_log(dlg_level_info, __VA_ARGS__)
|
||||
#define dlg_warn(...) dlg_log(dlg_level_warn, __VA_ARGS__)
|
||||
#define dlg_error(...) dlg_log(dlg_level_error, __VA_ARGS__)
|
||||
#define dlg_fatal(...) dlg_log(dlg_level_fatal, __VA_ARGS__)
|
||||
|
||||
// Tagged leveled logging
|
||||
#define dlg_tracet(tags, ...) dlg_logt(dlg_level_trace, tags, __VA_ARGS__)
|
||||
#define dlg_debugt(tags, ...) dlg_logt(dlg_level_debug, tags, __VA_ARGS__)
|
||||
#define dlg_infot(tags, ...) dlg_logt(dlg_level_info, tags, __VA_ARGS__)
|
||||
#define dlg_warnt(tags, ...) dlg_logt(dlg_level_warn, tags, __VA_ARGS__)
|
||||
#define dlg_errort(tags, ...) dlg_logt(dlg_level_error, tags, __VA_ARGS__)
|
||||
#define dlg_fatalt(tags, ...) dlg_logt(dlg_level_fatal, tags, __VA_ARGS__)
|
||||
|
||||
// Assert macros useing DLG_DEFAULT_ASSERT as level
|
||||
#define dlg_assert(expr) dlg_assertl(DLG_DEFAULT_ASSERT, expr)
|
||||
#define dlg_assertt(tags, expr) dlg_assertlt(DLG_DEFAULT_ASSERT, tags, expr)
|
||||
#define dlg_assertm(expr, ...) dlg_assertlm(DLG_DEFAULT_ASSERT, expr, __VA_ARGS__)
|
||||
#define dlg_asserttm(tags, expr, ...) dlg_assertltm(DLG_DEFAULT_ASSERT, tags, expr, __VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // header guard
|
|
@ -0,0 +1,172 @@
|
|||
// Copyright (c) 2019 nyorain
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef INC_DLG_OUTPUT_H_
|
||||
#define INC_DLG_OUTPUT_H_
|
||||
|
||||
#include <dlg/dlg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Text style
|
||||
enum dlg_text_style {
|
||||
dlg_text_style_reset = 0,
|
||||
dlg_text_style_bold = 1,
|
||||
dlg_text_style_dim = 2,
|
||||
dlg_text_style_italic = 3,
|
||||
dlg_text_style_underline = 4,
|
||||
dlg_text_style_blink = 5,
|
||||
dlg_text_style_rblink = 6,
|
||||
dlg_text_style_reversed = 7,
|
||||
dlg_text_style_conceal = 8,
|
||||
dlg_text_style_crossed = 9,
|
||||
dlg_text_style_none,
|
||||
};
|
||||
|
||||
// Text color
|
||||
enum dlg_color {
|
||||
dlg_color_black = 0,
|
||||
dlg_color_red,
|
||||
dlg_color_green,
|
||||
dlg_color_yellow,
|
||||
dlg_color_blue,
|
||||
dlg_color_magenta,
|
||||
dlg_color_cyan,
|
||||
dlg_color_gray,
|
||||
dlg_color_reset = 9,
|
||||
|
||||
dlg_color_black2 = 60,
|
||||
dlg_color_red2,
|
||||
dlg_color_green2,
|
||||
dlg_color_yellow2,
|
||||
dlg_color_blue2,
|
||||
dlg_color_magenta2,
|
||||
dlg_color_cyan2,
|
||||
dlg_color_gray2,
|
||||
|
||||
dlg_color_none = 69,
|
||||
};
|
||||
|
||||
struct dlg_style {
|
||||
enum dlg_text_style style;
|
||||
enum dlg_color fg;
|
||||
enum dlg_color bg;
|
||||
};
|
||||
|
||||
// Like fprintf but fixes utf-8 output to console on windows.
|
||||
// On non-windows sytems just uses the corresponding standard library
|
||||
// functions. On windows, if dlg was compiled with the win_console option,
|
||||
// will first try to output it in a way that allows the default console
|
||||
// to display utf-8. If that fails, will fall back to the standard
|
||||
// library functions.
|
||||
DLG_API int dlg_fprintf(FILE* stream, const char* format, ...) DLG_PRINTF_ATTRIB(2, 3);
|
||||
DLG_API int dlg_vfprintf(FILE* stream, const char* format, va_list list);
|
||||
|
||||
// Like dlg_printf, but also applies the given style to this output.
|
||||
// The style will always be applied (using escape sequences), independent of the given stream.
|
||||
// On windows escape sequences don't work out of the box, see dlg_win_init_ansi().
|
||||
DLG_API int dlg_styled_fprintf(FILE* stream, struct dlg_style style,
|
||||
const char* format, ...) DLG_PRINTF_ATTRIB(3, 4);
|
||||
|
||||
// Features to output from the generic output handler.
|
||||
// Some features might have only an effect in the specializations.
|
||||
enum dlg_output_feature {
|
||||
dlg_output_tags = 1, // output tags list
|
||||
dlg_output_time = 2, // output time of log call (hour:minute:second)
|
||||
dlg_output_style = 4, // whether to use the supplied styles
|
||||
dlg_output_func = 8, // output function
|
||||
dlg_output_file_line = 16, // output file:line,
|
||||
dlg_output_newline = 32, // output a newline at the end
|
||||
dlg_output_threadsafe = 64, // locks stream before printing
|
||||
dlg_output_time_msecs = 128 // output micro seconds (ms on windows)
|
||||
};
|
||||
|
||||
// The default level-dependent output styles. The array values represent the styles
|
||||
// to be used for the associated level (i.e. [0] for trace level).
|
||||
DLG_API extern const struct dlg_style dlg_default_output_styles[6];
|
||||
|
||||
// Generic output function. Used by the default output handler and might be useful
|
||||
// for custom output handlers (that don't want to manually format the output).
|
||||
// Will call the given output func with the given data (and format + args to print)
|
||||
// for everything it has to print in printf format.
|
||||
// See also the *_stream and *_buf specializations for common usage.
|
||||
// The given output function must not be NULL.
|
||||
typedef void(*dlg_generic_output_handler)(void* data, const char* format, ...);
|
||||
DLG_API void dlg_generic_output(dlg_generic_output_handler output, void* data,
|
||||
unsigned int features, const struct dlg_origin* origin, const char* string,
|
||||
const struct dlg_style styles[6]);
|
||||
|
||||
// Generic output function, using a format string instead of feature flags.
|
||||
// Use following conversion characters:
|
||||
// %h - output the time in H:M:S format
|
||||
// %m - output the time in milliseconds
|
||||
// %t - output the full list of tags, comma separated
|
||||
// %f - output the function name noted in the origin
|
||||
// %o - output the file:line of the origin
|
||||
// %s - print the appropriate style escape sequence.
|
||||
// %r - print the escape sequence to reset the style.
|
||||
// %c - The content of the log/assert
|
||||
// %% - print the '%' character
|
||||
// Only the above specified conversion characters are valid, the rest are
|
||||
// written as it is.
|
||||
DLG_API void dlg_generic_outputf(dlg_generic_output_handler output, void* data,
|
||||
const char* format_string, const struct dlg_origin* origin,
|
||||
const char* string, const struct dlg_style styles[6]);
|
||||
|
||||
// Generic output function. Used by the default output handler and might be useful
|
||||
// for custom output handlers (that don't want to manually format the output).
|
||||
// If stream is NULL uses stdout.
|
||||
// Automatically uses dlg_fprintf to assure correct utf-8 even on windows consoles.
|
||||
// Locks the stream (i.e. assures threadsafe access) when the associated feature
|
||||
// is passed (note that stdout/stderr might still mix from multiple threads).
|
||||
DLG_API void dlg_generic_output_stream(FILE* stream, unsigned int features,
|
||||
const struct dlg_origin* origin, const char* string,
|
||||
const struct dlg_style styles[6]);
|
||||
DLG_API void dlg_generic_outputf_stream(FILE* stream, const char* format_string,
|
||||
const struct dlg_origin* origin, const char* string,
|
||||
const struct dlg_style styles[6], bool lock_stream);
|
||||
|
||||
// Generic output function (see dlg_generic_output) that uses a buffer instead of
|
||||
// a stream. buf must at least point to *size bytes. Will set *size to the number
|
||||
// of bytes written (capped to the given size), if buf == NULL will set *size
|
||||
// to the needed size. The size parameter must not be NULL.
|
||||
DLG_API void dlg_generic_output_buf(char* buf, size_t* size, unsigned int features,
|
||||
const struct dlg_origin* origin, const char* string,
|
||||
const struct dlg_style styles[6]);
|
||||
DLG_API void dlg_generic_outputf_buf(char* buf, size_t* size, const char* format_string,
|
||||
const struct dlg_origin* origin, const char* string,
|
||||
const struct dlg_style styles[6]);
|
||||
|
||||
// Returns if the given stream is a tty. Useful for custom output handlers
|
||||
// e.g. to determine whether to use color.
|
||||
// NOTE: Due to windows limitations currently returns false for wsl ttys.
|
||||
DLG_API bool dlg_is_tty(FILE* stream);
|
||||
|
||||
// Returns the null-terminated escape sequence for the given style into buf.
|
||||
// Undefined behvaiour if any member of style has a value outside its enum range (will
|
||||
// probably result in a buffer overflow or garbage being printed).
|
||||
// If all member of style are 'none' will simply nullterminate the first buf char.
|
||||
DLG_API void dlg_escape_sequence(struct dlg_style style, char buf[12]);
|
||||
|
||||
// The reset style escape sequence.
|
||||
DLG_API extern const char* const dlg_reset_sequence;
|
||||
|
||||
// Just returns true without other effect on non-windows systems or if dlg
|
||||
// was compiled without the win_console option.
|
||||
// On windows tries to set the console mode to ansi to make escape sequences work.
|
||||
// This works only on newer windows 10 versions. Returns false on error.
|
||||
// Only the first call to it will have an effect, following calls just return the result.
|
||||
// The function is threadsafe. Automatically called by the default output handler.
|
||||
// This will only be able to set the mode for the stdout and stderr consoles, so
|
||||
// other streams to consoles will still not work.
|
||||
DLG_API bool dlg_win_init_ansi(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // header guard
|
|
@ -0,0 +1,51 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftconfig.h
|
||||
*
|
||||
* ANSI-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.
|
||||
*
|
||||
* This ANSI version should stay in `include/config/`.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FTCONFIG_H_
|
||||
#define FTCONFIG_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_OPTIONS_H
|
||||
#include FT_CONFIG_STANDARD_LIBRARY_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,836 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftheader.h
|
||||
*
|
||||
* Build macros of the FreeType 2 library.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FTHEADER_H_
|
||||
#define FTHEADER_H_
|
||||
|
||||
|
||||
/*@***********************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_BEGIN_HEADER */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro is used in association with @FT_END_HEADER in header */
|
||||
/* files to ensure that the declarations within are properly */
|
||||
/* encapsulated in an `extern "C" { .. }` block when included from a */
|
||||
/* C++ compiler. */
|
||||
/* */
|
||||
#ifndef FT_BEGIN_HEADER
|
||||
# ifdef __cplusplus
|
||||
# define FT_BEGIN_HEADER extern "C" {
|
||||
# else
|
||||
# define FT_BEGIN_HEADER /* nothing */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*@***********************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_END_HEADER */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro is used in association with @FT_BEGIN_HEADER in header */
|
||||
/* files to ensure that the declarations within are properly */
|
||||
/* encapsulated in an `extern "C" { .. }` block when included from a */
|
||||
/* C++ compiler. */
|
||||
/* */
|
||||
#ifndef FT_END_HEADER
|
||||
# ifdef __cplusplus
|
||||
# define FT_END_HEADER }
|
||||
# else
|
||||
# define FT_END_HEADER /* nothing */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Aliases for the FreeType 2 public and configuration files.
|
||||
*
|
||||
*/
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* header_file_macros
|
||||
*
|
||||
* @title:
|
||||
* Header File Macros
|
||||
*
|
||||
* @abstract:
|
||||
* Macro definitions used to `#include` specific header files.
|
||||
*
|
||||
* @description:
|
||||
* In addition to the normal scheme of including header files like
|
||||
*
|
||||
* ```
|
||||
* #include <freetype/freetype.h>
|
||||
* #include <freetype/ftmm.h>
|
||||
* #include <freetype/ftglyph.h>
|
||||
* ```
|
||||
*
|
||||
* it is possible to used named macros instead. They can be used
|
||||
* directly in `#include` statements as in
|
||||
*
|
||||
* ```
|
||||
* #include FT_FREETYPE_H
|
||||
* #include FT_MULTIPLE_MASTERS_H
|
||||
* #include FT_GLYPH_H
|
||||
* ```
|
||||
*
|
||||
* These macros were introduced to overcome the infamous 8.3~naming rule
|
||||
* required by DOS (and `FT_MULTIPLE_MASTERS_H` is a lot more meaningful
|
||||
* than `ftmm.h`).
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* configuration files */
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_CONFIG_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* FreeType~2 configuration data.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_CONFIG_H
|
||||
#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_STANDARD_LIBRARY_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* FreeType~2 interface to the standard C library functions.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_STANDARD_LIBRARY_H
|
||||
#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_OPTIONS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* FreeType~2 project-specific configuration options.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_OPTIONS_H
|
||||
#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_MODULES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* list of FreeType~2 modules that are statically linked to new library
|
||||
* instances in @FT_Init_FreeType.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_MODULES_H
|
||||
#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h>
|
||||
#endif
|
||||
|
||||
/* */
|
||||
|
||||
/* public headers */
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_FREETYPE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* base FreeType~2 API.
|
||||
*
|
||||
*/
|
||||
#define FT_FREETYPE_H <freetype/freetype.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ERRORS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* list of FreeType~2 error codes (and messages).
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_ERRORS_H <freetype/fterrors.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MODULE_ERRORS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* list of FreeType~2 module error offsets (and messages).
|
||||
*
|
||||
*/
|
||||
#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SYSTEM_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 interface to low-level operations (i.e., memory management
|
||||
* and stream i/o).
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_SYSTEM_H <freetype/ftsystem.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IMAGE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing type
|
||||
* definitions related to glyph images (i.e., bitmaps, outlines,
|
||||
* scan-converter parameters).
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_IMAGE_H <freetype/ftimage.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TYPES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* basic data types defined by FreeType~2.
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_TYPES_H <freetype/fttypes.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_LIST_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* list management API of FreeType~2.
|
||||
*
|
||||
* (Most applications will never need to include this file.)
|
||||
*
|
||||
*/
|
||||
#define FT_LIST_H <freetype/ftlist.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_OUTLINE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* scalable outline management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_OUTLINE_H <freetype/ftoutln.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SIZES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* API which manages multiple @FT_Size objects per face.
|
||||
*
|
||||
*/
|
||||
#define FT_SIZES_H <freetype/ftsizes.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MODULE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* module management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_MODULE_H <freetype/ftmodapi.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_RENDER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* renderer module management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_RENDER_H <freetype/ftrender.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* structures and macros related to the driver modules.
|
||||
*
|
||||
*/
|
||||
#define FT_DRIVER_H <freetype/ftdriver.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_AUTOHINTER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* structures and macros related to the auto-hinting module.
|
||||
*
|
||||
* Deprecated since version~2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_AUTOHINTER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CFF_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* structures and macros related to the CFF driver module.
|
||||
*
|
||||
* Deprecated since version~2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_CFF_DRIVER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* structures and macros related to the TrueType driver module.
|
||||
*
|
||||
* Deprecated since version~2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_DRIVER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_PCF_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing
|
||||
* structures and macros related to the PCF driver module.
|
||||
*
|
||||
* Deprecated since version~2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_PCF_DRIVER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TYPE1_TABLES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* types and API specific to the Type~1 format.
|
||||
*
|
||||
*/
|
||||
#define FT_TYPE1_TABLES_H <freetype/t1tables.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_IDS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* enumeration values which identify name strings, languages, encodings,
|
||||
* etc. This file really contains a _large_ set of constant macro
|
||||
* definitions, taken from the TrueType and OpenType specifications.
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_TABLES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* types and API specific to the TrueType (as well as OpenType) format.
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_TABLES_H <freetype/tttables.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_TAGS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* definitions of TrueType four-byte 'tags' which identify blocks in
|
||||
* SFNT-based font formats (i.e., TrueType and OpenType).
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_TAGS_H <freetype/tttags.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BDF_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* definitions of an API which accesses BDF-specific strings from a face.
|
||||
*
|
||||
*/
|
||||
#define FT_BDF_H <freetype/ftbdf.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CID_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* definitions of an API which access CID font information from a face.
|
||||
*
|
||||
*/
|
||||
#define FT_CID_H <freetype/ftcid.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GZIP_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* definitions of an API which supports gzip-compressed files.
|
||||
*
|
||||
*/
|
||||
#define FT_GZIP_H <freetype/ftgzip.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_LZW_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* definitions of an API which supports LZW-compressed files.
|
||||
*
|
||||
*/
|
||||
#define FT_LZW_H <freetype/ftlzw.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BZIP2_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* definitions of an API which supports bzip2-compressed files.
|
||||
*
|
||||
*/
|
||||
#define FT_BZIP2_H <freetype/ftbzip2.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_WINFONTS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* definitions of an API which supports Windows FNT files.
|
||||
*
|
||||
*/
|
||||
#define FT_WINFONTS_H <freetype/ftwinfnt.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GLYPH_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* API of the optional glyph management component.
|
||||
*
|
||||
*/
|
||||
#define FT_GLYPH_H <freetype/ftglyph.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BITMAP_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* API of the optional bitmap conversion component.
|
||||
*
|
||||
*/
|
||||
#define FT_BITMAP_H <freetype/ftbitmap.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BBOX_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* API of the optional exact bounding box computation routines.
|
||||
*
|
||||
*/
|
||||
#define FT_BBOX_H <freetype/ftbbox.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CACHE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* API of the optional FreeType~2 cache sub-system.
|
||||
*
|
||||
*/
|
||||
#define FT_CACHE_H <freetype/ftcache.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MAC_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* Macintosh-specific FreeType~2 API. The latter is used to access fonts
|
||||
* embedded in resource forks.
|
||||
*
|
||||
* This header file must be explicitly included by client applications
|
||||
* compiled on the Mac (note that the base API still works though).
|
||||
*
|
||||
*/
|
||||
#define FT_MAC_H <freetype/ftmac.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MULTIPLE_MASTERS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* optional multiple-masters management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SFNT_NAMES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* optional FreeType~2 API which accesses embedded 'name' strings in
|
||||
* SFNT-based font formats (i.e., TrueType and OpenType).
|
||||
*
|
||||
*/
|
||||
#define FT_SFNT_NAMES_H <freetype/ftsnames.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_OPENTYPE_VALIDATE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* optional FreeType~2 API which validates OpenType tables ('BASE',
|
||||
* 'GDEF', 'GPOS', 'GSUB', 'JSTF').
|
||||
*
|
||||
*/
|
||||
#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GX_VALIDATE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* optional FreeType~2 API which validates TrueTypeGX/AAT tables ('feat',
|
||||
* 'mort', 'morx', 'bsln', 'just', 'kern', 'opbd', 'trak', 'prop').
|
||||
*
|
||||
*/
|
||||
#define FT_GX_VALIDATE_H <freetype/ftgxval.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_PFR_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which accesses PFR-specific data.
|
||||
*
|
||||
*/
|
||||
#define FT_PFR_H <freetype/ftpfr.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_STROKER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which provides functions to stroke outline paths.
|
||||
*/
|
||||
#define FT_STROKER_H <freetype/ftstroke.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SYNTHESIS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which performs artificial obliquing and emboldening.
|
||||
*/
|
||||
#define FT_SYNTHESIS_H <freetype/ftsynth.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_FONT_FORMATS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which provides functions specific to font formats.
|
||||
*/
|
||||
#define FT_FONT_FORMATS_H <freetype/ftfntfmt.h>
|
||||
|
||||
/* deprecated */
|
||||
#define FT_XFREE86_H FT_FONT_FORMATS_H
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRIGONOMETRY_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which performs trigonometric computations (e.g.,
|
||||
* cosines and arc tangents).
|
||||
*/
|
||||
#define FT_TRIGONOMETRY_H <freetype/fttrigon.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_LCD_FILTER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which performs color filtering for subpixel rendering.
|
||||
*/
|
||||
#define FT_LCD_FILTER_H <freetype/ftlcdfil.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_INCREMENTAL_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which performs incremental glyph loading.
|
||||
*/
|
||||
#define FT_INCREMENTAL_H <freetype/ftincrem.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GASP_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which returns entries from the TrueType GASP table.
|
||||
*/
|
||||
#define FT_GASP_H <freetype/ftgasp.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ADVANCES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which returns individual and ranged glyph advances.
|
||||
*/
|
||||
#define FT_ADVANCES_H <freetype/ftadvanc.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_COLOR_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which handles the OpenType 'CPAL' table.
|
||||
*/
|
||||
#define FT_COLOR_H <freetype/ftcolor.h>
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_OTSVG_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in `#include` statements to name the file containing the
|
||||
* FreeType~2 API which handles the OpenType 'SVG~' glyphs.
|
||||
*/
|
||||
#define FT_OTSVG_H <freetype/otsvg.h>
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
/* These header files don't need to be included by the user. */
|
||||
#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
|
||||
#define FT_PARAMETER_TAGS_H <freetype/ftparams.h>
|
||||
|
||||
/* Deprecated macros. */
|
||||
#define FT_UNPATENTED_HINTING_H <freetype/ftparams.h>
|
||||
#define FT_TRUETYPE_UNPATENTED_H <freetype/ftparams.h>
|
||||
|
||||
/* `FT_CACHE_H` is the only header file needed for the cache subsystem. */
|
||||
#define FT_CACHE_IMAGE_H FT_CACHE_H
|
||||
#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H
|
||||
#define FT_CACHE_CHARMAP_H FT_CACHE_H
|
||||
|
||||
/* The internals of the cache sub-system are no longer exposed. We */
|
||||
/* default to `FT_CACHE_H` at the moment just in case, but we know */
|
||||
/* of no rogue client that uses them. */
|
||||
/* */
|
||||
#define FT_CACHE_MANAGER_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_MANAGER_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_CACHE_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_GLYPH_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_IMAGE_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_SBITS_H FT_CACHE_H
|
||||
|
||||
/* TODO(david): Move this section below to a different header */
|
||||
#ifdef FT2_BUILD_LIBRARY
|
||||
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
|
||||
|
||||
/* We disable the warning `conditional expression is constant' here */
|
||||
/* in order to compile cleanly with the maximum level of warnings. */
|
||||
/* In particular, the warning complains about stuff like `while(0)' */
|
||||
/* which is very useful in macro definitions. There is no benefit */
|
||||
/* in having it enabled. */
|
||||
#pragma warning( disable : 4127 )
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* FT2_BUILD_LIBRARY */
|
||||
|
||||
#endif /* FTHEADER_H_ */
|
||||
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* This file registers the FreeType modules compiled into the library.
|
||||
*
|
||||
* If you use GNU make, this file IS NOT USED! Instead, it is created in
|
||||
* the objects directory (normally `<topdir>/objs/`) based on information
|
||||
* from `<topdir>/modules.cfg`.
|
||||
*
|
||||
* Please read `docs/INSTALL.ANY` and `docs/CUSTOMIZE` how to compile
|
||||
* FreeType without GNU make.
|
||||
*
|
||||
*/
|
||||
|
||||
FT_USE_MODULE( FT_Module_Class, autofit_module_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
|
||||
FT_USE_MODULE( FT_Module_Class, psaux_module_class )
|
||||
FT_USE_MODULE( FT_Module_Class, psnames_module_class )
|
||||
FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
|
||||
FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_bitmap_sdf_renderer_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_svg_renderer_class )
|
||||
|
||||
/* EOF */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,185 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftstdlib.h
|
||||
*
|
||||
* ANSI-specific library and header configuration file (specification
|
||||
* only).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* This file is used to group all `#includes` to the ANSI~C library that
|
||||
* FreeType normally requires. It also defines macros to rename the
|
||||
* standard functions within the FreeType source code.
|
||||
*
|
||||
* Load a file which defines `FTSTDLIB_H_` before this one to override it.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FTSTDLIB_H_
|
||||
#define FTSTDLIB_H_
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ft_ptrdiff_t ptrdiff_t
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* integer limits
|
||||
*
|
||||
* `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of
|
||||
* `int` and `long` in bytes at compile-time. So far, this works for all
|
||||
* platforms the library has been tested on. We also check `ULLONG_MAX`
|
||||
* to see whether we can use 64-bit `long long` later on.
|
||||
*
|
||||
* Note that on the extremely rare platforms that do not provide integer
|
||||
* types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where
|
||||
* `int` is 36~bits), we do not make any guarantee about the correct
|
||||
* behaviour of FreeType~2 with all fonts.
|
||||
*
|
||||
* In these cases, `ftconfig.h` will refuse to compile anyway with a
|
||||
* message like 'couldn't find 32-bit type' or something similar.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define FT_CHAR_BIT CHAR_BIT
|
||||
#define FT_USHORT_MAX USHRT_MAX
|
||||
#define FT_INT_MAX INT_MAX
|
||||
#define FT_INT_MIN INT_MIN
|
||||
#define FT_UINT_MAX UINT_MAX
|
||||
#define FT_LONG_MIN LONG_MIN
|
||||
#define FT_LONG_MAX LONG_MAX
|
||||
#define FT_ULONG_MAX ULONG_MAX
|
||||
#ifdef LLONG_MAX
|
||||
#define FT_LLONG_MAX LLONG_MAX
|
||||
#endif
|
||||
#ifdef LLONG_MIN
|
||||
#define FT_LLONG_MIN LLONG_MIN
|
||||
#endif
|
||||
#ifdef ULLONG_MAX
|
||||
#define FT_ULLONG_MAX ULLONG_MAX
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* character and string processing
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define ft_memchr memchr
|
||||
#define ft_memcmp memcmp
|
||||
#define ft_memcpy memcpy
|
||||
#define ft_memmove memmove
|
||||
#define ft_memset memset
|
||||
#define ft_strcat strcat
|
||||
#define ft_strcmp strcmp
|
||||
#define ft_strcpy strcpy
|
||||
#define ft_strlen strlen
|
||||
#define ft_strncmp strncmp
|
||||
#define ft_strncpy strncpy
|
||||
#define ft_strrchr strrchr
|
||||
#define ft_strstr strstr
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* file handling
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define FT_FILE FILE
|
||||
#define ft_fclose fclose
|
||||
#define ft_fopen fopen
|
||||
#define ft_fread fread
|
||||
#define ft_fseek fseek
|
||||
#define ft_ftell ftell
|
||||
#define ft_sprintf sprintf
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* sorting
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ft_qsort qsort
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* memory allocation
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define ft_scalloc calloc
|
||||
#define ft_sfree free
|
||||
#define ft_smalloc malloc
|
||||
#define ft_srealloc realloc
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* miscellaneous
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define ft_strtol strtol
|
||||
#define ft_getenv getenv
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* execution control
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
|
||||
/* `jmp_buf` is defined as a macro */
|
||||
/* on certain platforms */
|
||||
|
||||
#define ft_longjmp longjmp
|
||||
#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
|
||||
|
||||
|
||||
/* The following is only used for debugging purposes, i.e., if */
|
||||
/* `FT_DEBUG_LEVEL_ERROR` or `FT_DEBUG_LEVEL_TRACE` are defined. */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#endif /* FTSTDLIB_H_ */
|
||||
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,250 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* config/integer-types.h
|
||||
*
|
||||
* FreeType integer types 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.
|
||||
*
|
||||
*/
|
||||
#ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_
|
||||
#define FREETYPE_CONFIG_INTEGER_TYPES_H_
|
||||
|
||||
/* There are systems (like the Texas Instruments 'C54x) where a `char` */
|
||||
/* has 16~bits. ANSI~C says that `sizeof(char)` is always~1. Since an */
|
||||
/* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which */
|
||||
/* is probably unexpected. */
|
||||
/* */
|
||||
/* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */
|
||||
/* `char` type. */
|
||||
|
||||
#ifndef FT_CHAR_BIT
|
||||
#define FT_CHAR_BIT CHAR_BIT
|
||||
#endif
|
||||
|
||||
#ifndef FT_SIZEOF_INT
|
||||
|
||||
/* The size of an `int` type. */
|
||||
#if FT_UINT_MAX == 0xFFFFUL
|
||||
#define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT )
|
||||
#elif FT_UINT_MAX == 0xFFFFFFFFUL
|
||||
#define FT_SIZEOF_INT ( 32 / FT_CHAR_BIT )
|
||||
#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
|
||||
#define FT_SIZEOF_INT ( 64 / FT_CHAR_BIT )
|
||||
#else
|
||||
#error "Unsupported size of `int' type!"
|
||||
#endif
|
||||
|
||||
#endif /* !defined(FT_SIZEOF_INT) */
|
||||
|
||||
#ifndef FT_SIZEOF_LONG
|
||||
|
||||
/* The size of a `long` type. A five-byte `long` (as used e.g. on the */
|
||||
/* DM642) is recognized but avoided. */
|
||||
#if FT_ULONG_MAX == 0xFFFFFFFFUL
|
||||
#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
|
||||
#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
|
||||
#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT )
|
||||
#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
|
||||
#define FT_SIZEOF_LONG ( 64 / FT_CHAR_BIT )
|
||||
#else
|
||||
#error "Unsupported size of `long' type!"
|
||||
#endif
|
||||
|
||||
#endif /* !defined(FT_SIZEOF_LONG) */
|
||||
|
||||
#ifndef FT_SIZEOF_LONG_LONG
|
||||
|
||||
/* The size of a `long long` type if available */
|
||||
#if defined( FT_ULLONG_MAX ) && FT_ULLONG_MAX >= 0xFFFFFFFFFFFFFFFFULL
|
||||
#define FT_SIZEOF_LONG_LONG ( 64 / FT_CHAR_BIT )
|
||||
#else
|
||||
#define FT_SIZEOF_LONG_LONG 0
|
||||
#endif
|
||||
|
||||
#endif /* !defined(FT_SIZEOF_LONG_LONG) */
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* basic_types
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Int16
|
||||
*
|
||||
* @description:
|
||||
* A typedef for a 16bit signed integer type.
|
||||
*/
|
||||
typedef signed short FT_Int16;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_UInt16
|
||||
*
|
||||
* @description:
|
||||
* A typedef for a 16bit unsigned integer type.
|
||||
*/
|
||||
typedef unsigned short FT_UInt16;
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/* this #if 0 ... #endif clause is for documentation purposes */
|
||||
#if 0
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Int32
|
||||
*
|
||||
* @description:
|
||||
* A typedef for a 32bit signed integer type. The size depends on the
|
||||
* configuration.
|
||||
*/
|
||||
typedef signed XXX FT_Int32;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_UInt32
|
||||
*
|
||||
* A typedef for a 32bit unsigned integer type. The size depends on the
|
||||
* configuration.
|
||||
*/
|
||||
typedef unsigned XXX FT_UInt32;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Int64
|
||||
*
|
||||
* A typedef for a 64bit signed integer type. The size depends on the
|
||||
* configuration. Only defined if there is real 64bit support;
|
||||
* otherwise, it gets emulated with a structure (if necessary).
|
||||
*/
|
||||
typedef signed XXX FT_Int64;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_UInt64
|
||||
*
|
||||
* A typedef for a 64bit unsigned integer type. The size depends on the
|
||||
* configuration. Only defined if there is real 64bit support;
|
||||
* otherwise, it gets emulated with a structure (if necessary).
|
||||
*/
|
||||
typedef unsigned XXX FT_UInt64;
|
||||
|
||||
/* */
|
||||
|
||||
#endif
|
||||
|
||||
#if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT )
|
||||
|
||||
typedef signed int FT_Int32;
|
||||
typedef unsigned int FT_UInt32;
|
||||
|
||||
#elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
|
||||
|
||||
typedef signed long FT_Int32;
|
||||
typedef unsigned long FT_UInt32;
|
||||
|
||||
#else
|
||||
#error "no 32bit type found -- please check your configuration files"
|
||||
#endif
|
||||
|
||||
|
||||
/* look up an integer type that is at least 32~bits */
|
||||
#if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT )
|
||||
|
||||
typedef int FT_Fast;
|
||||
typedef unsigned int FT_UFast;
|
||||
|
||||
#elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT )
|
||||
|
||||
typedef long FT_Fast;
|
||||
typedef unsigned long FT_UFast;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* determine whether we have a 64-bit integer type */
|
||||
#if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
|
||||
|
||||
#define FT_INT64 long
|
||||
#define FT_UINT64 unsigned long
|
||||
|
||||
#elif FT_SIZEOF_LONG_LONG >= ( 64 / FT_CHAR_BIT )
|
||||
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* A 64-bit data type may create compilation problems if you compile in
|
||||
* strict ANSI mode. To avoid them, we disable other 64-bit data types if
|
||||
* `__STDC__` is defined. You can however ignore this rule by defining the
|
||||
* `FT_CONFIG_OPTION_FORCE_INT64` configuration macro.
|
||||
*/
|
||||
#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
|
||||
|
||||
#if defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
|
||||
|
||||
/* this compiler provides the `__int64` type */
|
||||
#define FT_INT64 __int64
|
||||
#define FT_UINT64 unsigned __int64
|
||||
|
||||
#elif defined( __BORLANDC__ ) /* Borland C++ */
|
||||
|
||||
/* XXXX: We should probably check the value of `__BORLANDC__` in order */
|
||||
/* to test the compiler version. */
|
||||
|
||||
/* this compiler provides the `__int64` type */
|
||||
#define FT_INT64 __int64
|
||||
#define FT_UINT64 unsigned __int64
|
||||
|
||||
#elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1100 /* Watcom C++ */
|
||||
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
|
||||
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
#elif defined( __GNUC__ )
|
||||
|
||||
/* GCC provides the `long long` type */
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
#endif /* !__STDC__ */
|
||||
|
||||
#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
|
||||
|
||||
#ifdef FT_INT64
|
||||
typedef FT_INT64 FT_Int64;
|
||||
typedef FT_UINT64 FT_UInt64;
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */
|
|
@ -0,0 +1,49 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* config/mac-support.h
|
||||
*
|
||||
* Mac/OS X support configuration header.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef FREETYPE_CONFIG_MAC_SUPPORT_H_
|
||||
#define FREETYPE_CONFIG_MAC_SUPPORT_H_
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Mac support
|
||||
*
|
||||
* This is the only necessary change, so it is defined here instead
|
||||
* providing a new configuration file.
|
||||
*/
|
||||
#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
|
||||
/* No Carbon frameworks for 64bit 10.4.x. */
|
||||
/* `AvailabilityMacros.h` is available since Mac OS X 10.2, */
|
||||
/* so guess the system version by maximum errno before inclusion. */
|
||||
#include <errno.h>
|
||||
#ifdef ECANCELED /* defined since 10.2 */
|
||||
#include "AvailabilityMacros.h"
|
||||
#endif
|
||||
#if defined( __LP64__ ) && \
|
||||
( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
|
||||
#undef FT_MACINTOSH
|
||||
#endif
|
||||
|
||||
#elif defined( __SC__ ) || defined( __MRC__ )
|
||||
/* Classic MacOS compilers */
|
||||
#include "ConditionalMacros.h"
|
||||
#if TARGET_OS_MAC
|
||||
#define FT_MACINTOSH 1
|
||||
#endif
|
||||
|
||||
#endif /* Mac support */
|
||||
|
||||
#endif /* FREETYPE_CONFIG_MAC_SUPPORT_H_ */
|
|
@ -0,0 +1,138 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* config/public-macros.h
|
||||
*
|
||||
* Define a set of compiler macros used in public FreeType headers.
|
||||
*
|
||||
* Copyright (C) 2020-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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The definitions in this file are used by the public FreeType headers
|
||||
* and thus should be considered part of the public API.
|
||||
*
|
||||
* Other compiler-specific macro definitions that are not exposed by the
|
||||
* FreeType API should go into
|
||||
* `include/freetype/internal/compiler-macros.h` instead.
|
||||
*/
|
||||
#ifndef FREETYPE_CONFIG_PUBLIC_MACROS_H_
|
||||
#define FREETYPE_CONFIG_PUBLIC_MACROS_H_
|
||||
|
||||
/*
|
||||
* `FT_BEGIN_HEADER` and `FT_END_HEADER` might have already been defined
|
||||
* by `freetype/config/ftheader.h`, but we don't want to include this
|
||||
* header here, so redefine the macros here only when needed. Their
|
||||
* definition is very stable, so keeping them in sync with the ones in the
|
||||
* header should not be a maintenance issue.
|
||||
*/
|
||||
#ifndef FT_BEGIN_HEADER
|
||||
#ifdef __cplusplus
|
||||
#define FT_BEGIN_HEADER extern "C" {
|
||||
#else
|
||||
#define FT_BEGIN_HEADER /* empty */
|
||||
#endif
|
||||
#endif /* FT_BEGIN_HEADER */
|
||||
|
||||
#ifndef FT_END_HEADER
|
||||
#ifdef __cplusplus
|
||||
#define FT_END_HEADER }
|
||||
#else
|
||||
#define FT_END_HEADER /* empty */
|
||||
#endif
|
||||
#endif /* FT_END_HEADER */
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/*
|
||||
* Mark a function declaration as public. This ensures it will be
|
||||
* properly exported to client code. Place this before a function
|
||||
* declaration.
|
||||
*
|
||||
* NOTE: This macro should be considered an internal implementation
|
||||
* detail, and not part of the FreeType API. It is only defined here
|
||||
* because it is needed by `FT_EXPORT`.
|
||||
*/
|
||||
|
||||
/* Visual C, mingw */
|
||||
#if defined( _WIN32 )
|
||||
|
||||
#if defined( FT2_BUILD_LIBRARY ) && defined( DLL_EXPORT )
|
||||
#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllexport )
|
||||
#elif defined( DLL_IMPORT )
|
||||
#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllimport )
|
||||
#endif
|
||||
|
||||
/* gcc, clang */
|
||||
#elif ( defined( __GNUC__ ) && __GNUC__ >= 4 ) || defined( __clang__ )
|
||||
#define FT_PUBLIC_FUNCTION_ATTRIBUTE \
|
||||
__attribute__(( visibility( "default" ) ))
|
||||
|
||||
/* Sun */
|
||||
#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550
|
||||
#define FT_PUBLIC_FUNCTION_ATTRIBUTE __global
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef FT_PUBLIC_FUNCTION_ATTRIBUTE
|
||||
#define FT_PUBLIC_FUNCTION_ATTRIBUTE /* empty */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Define a public FreeType API function. This ensures it is properly
|
||||
* exported or imported at build time. The macro parameter is the
|
||||
* function's return type as in:
|
||||
*
|
||||
* FT_EXPORT( FT_Bool )
|
||||
* FT_Object_Method( FT_Object obj,
|
||||
* ... );
|
||||
*
|
||||
* NOTE: This requires that all `FT_EXPORT` uses are inside
|
||||
* `FT_BEGIN_HEADER ... FT_END_HEADER` blocks. This guarantees that the
|
||||
* functions are exported with C linkage, even when the header is included
|
||||
* by a C++ source file.
|
||||
*/
|
||||
#define FT_EXPORT( x ) FT_PUBLIC_FUNCTION_ATTRIBUTE extern x
|
||||
|
||||
|
||||
/*
|
||||
* `FT_UNUSED` indicates that a given parameter is not used -- this is
|
||||
* only used to get rid of unpleasant compiler warnings.
|
||||
*
|
||||
* Technically, this was not meant to be part of the public API, but some
|
||||
* third-party code depends on it.
|
||||
*/
|
||||
#ifndef FT_UNUSED
|
||||
#define FT_UNUSED( arg ) ( (arg) = (arg) )
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Support for casts in both C and C++.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#define FT_STATIC_CAST( type, var ) static_cast<type>(var)
|
||||
#define FT_REINTERPRET_CAST( type, var ) reinterpret_cast<type>(var)
|
||||
|
||||
#define FT_STATIC_BYTE_CAST( type, var ) \
|
||||
static_cast<type>( static_cast<unsigned char>( var ) )
|
||||
#else
|
||||
#define FT_STATIC_CAST( type, var ) (type)(var)
|
||||
#define FT_REINTERPRET_CAST( type, var ) (type)(var)
|
||||
|
||||
#define FT_STATIC_BYTE_CAST( type, var ) (type)(unsigned char)(var)
|
||||
#endif
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FREETYPE_CONFIG_PUBLIC_MACROS_H_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,188 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftadvanc.h
|
||||
*
|
||||
* Quick computation of advance widths (specification only).
|
||||
*
|
||||
* Copyright (C) 2008-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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FTADVANC_H_
|
||||
#define FTADVANC_H_
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* quick_advance
|
||||
*
|
||||
* @title:
|
||||
* Quick retrieval of advance values
|
||||
*
|
||||
* @abstract:
|
||||
* Retrieve horizontal and vertical advance values without processing
|
||||
* glyph outlines, if possible.
|
||||
*
|
||||
* @description:
|
||||
* This section contains functions to quickly extract advance values
|
||||
* without handling glyph outlines, if possible.
|
||||
*
|
||||
* @order:
|
||||
* FT_Get_Advance
|
||||
* FT_Get_Advances
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_ADVANCE_FLAG_FAST_ONLY
|
||||
*
|
||||
* @description:
|
||||
* A bit-flag to be OR-ed with the `flags` parameter of the
|
||||
* @FT_Get_Advance and @FT_Get_Advances functions.
|
||||
*
|
||||
* If set, it indicates that you want these functions to fail if the
|
||||
* corresponding hinting mode or font driver doesn't allow for very quick
|
||||
* advance computation.
|
||||
*
|
||||
* Typically, glyphs that are either unscaled, unhinted, bitmapped, or
|
||||
* light-hinted can have their advance width computed very quickly.
|
||||
*
|
||||
* Normal and bytecode hinted modes that require loading, scaling, and
|
||||
* hinting of the glyph outline, are extremely slow by comparison.
|
||||
*/
|
||||
#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_Advance
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the advance value of a given glyph outline in an @FT_Face.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* The source @FT_Face handle.
|
||||
*
|
||||
* gindex ::
|
||||
* The glyph index.
|
||||
*
|
||||
* load_flags ::
|
||||
* A set of bit flags similar to those used when calling
|
||||
* @FT_Load_Glyph, used to determine what kind of advances you need.
|
||||
*
|
||||
* @output:
|
||||
* padvance ::
|
||||
* The advance value. If scaling is performed (based on the value of
|
||||
* `load_flags`), the advance value is in 16.16 format. Otherwise, it
|
||||
* is in font units.
|
||||
*
|
||||
* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the vertical advance
|
||||
* corresponding to a vertical layout. Otherwise, it is the horizontal
|
||||
* advance in a horizontal layout.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0 means success.
|
||||
*
|
||||
* @note:
|
||||
* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if
|
||||
* the corresponding font backend doesn't have a quick way to retrieve
|
||||
* the advances.
|
||||
*
|
||||
* A scaled advance is returned in 16.16 format but isn't transformed by
|
||||
* the affine transformation specified by @FT_Set_Transform.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Advance( FT_Face face,
|
||||
FT_UInt gindex,
|
||||
FT_Int32 load_flags,
|
||||
FT_Fixed *padvance );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_Advances
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the advance values of several glyph outlines in an @FT_Face.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* The source @FT_Face handle.
|
||||
*
|
||||
* start ::
|
||||
* The first glyph index.
|
||||
*
|
||||
* count ::
|
||||
* The number of advance values you want to retrieve.
|
||||
*
|
||||
* load_flags ::
|
||||
* A set of bit flags similar to those used when calling
|
||||
* @FT_Load_Glyph.
|
||||
*
|
||||
* @output:
|
||||
* padvance ::
|
||||
* The advance values. This array, to be provided by the caller, must
|
||||
* contain at least `count` elements.
|
||||
*
|
||||
* If scaling is performed (based on the value of `load_flags`), the
|
||||
* advance values are in 16.16 format. Otherwise, they are in font
|
||||
* units.
|
||||
*
|
||||
* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the vertical advances
|
||||
* corresponding to a vertical layout. Otherwise, they are the
|
||||
* horizontal advances in a horizontal layout.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0 means success.
|
||||
*
|
||||
* @note:
|
||||
* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if
|
||||
* the corresponding font backend doesn't have a quick way to retrieve
|
||||
* the advances.
|
||||
*
|
||||
* Scaled advances are returned in 16.16 format but aren't transformed by
|
||||
* the affine transformation specified by @FT_Set_Transform.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Advances( FT_Face face,
|
||||
FT_UInt start,
|
||||
FT_UInt count,
|
||||
FT_Int32 load_flags,
|
||||
FT_Fixed *padvances );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTADVANC_H_ */
|
||||
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,101 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ftbbox.h
|
||||
*
|
||||
* FreeType exact bbox computation (specification).
|
||||
*
|
||||
* 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 component has a _single_ role: to compute exact outline bounding
|
||||
* boxes.
|
||||
*
|
||||
* It is separated from the rest of the engine for various technical
|
||||
* reasons. It may well be integrated in 'ftoutln' later.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FTBBOX_H_
|
||||
#define FTBBOX_H_
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* outline_processing
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Outline_Get_BBox
|
||||
*
|
||||
* @description:
|
||||
* Compute the exact bounding box of an outline. This is slower than
|
||||
* computing the control box. However, it uses an advanced algorithm
|
||||
* that returns _very_ quickly when the two boxes coincide. Otherwise,
|
||||
* the outline Bezier arcs are traversed to extract their extrema.
|
||||
*
|
||||
* @input:
|
||||
* outline ::
|
||||
* A pointer to the source outline.
|
||||
*
|
||||
* @output:
|
||||
* abbox ::
|
||||
* The outline's exact bounding box.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* If the font is tricky and the glyph has been loaded with
|
||||
* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get
|
||||
* reasonable values for the BBox it is necessary to load the glyph at a
|
||||
* large ppem value (so that the hinting instructions can properly shift
|
||||
* and scale the subglyphs), then extracting the BBox, which can be
|
||||
* eventually converted back to font units.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Get_BBox( FT_Outline* outline,
|
||||
FT_BBox *abbox );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTBBOX_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* coding: utf-8 */
|
||||
/* End: */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue