2025-07-29 21:04:07 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
# Configure script by blankhex
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Default values
|
|
|
|
|
cc=${CC:-gcc}
|
|
|
|
|
ld=${LD:-gcc}
|
|
|
|
|
ar=${AR:-ar}
|
|
|
|
|
source_path="$(dirname "$0")"
|
|
|
|
|
prefix_path=${PREFIX:-/usr/local}
|
|
|
|
|
enable_shared="no"
|
2025-07-30 18:54:45 +03:00
|
|
|
enable_mt="yes"
|
2025-07-29 21:04:07 +03:00
|
|
|
enable_lfs="no"
|
2025-07-30 18:54:45 +03:00
|
|
|
enable_tests="yes"
|
2025-10-12 10:20:09 +03:00
|
|
|
enable_benchmarks="no"
|
2025-09-02 10:24:05 +03:00
|
|
|
enable_pic="yes"
|
2025-10-12 23:16:00 +03:00
|
|
|
enable_lto="no"
|
2025-07-29 21:04:07 +03:00
|
|
|
use_clock_gettime="no"
|
2025-10-12 10:20:09 +03:00
|
|
|
use_short_limbs="no"
|
2025-09-02 10:24:05 +03:00
|
|
|
arflags=${ARFLAGS:-cr}
|
|
|
|
|
cflags=${CFLAGS}
|
|
|
|
|
ldflags=${LDFLAGS}
|
|
|
|
|
ldlibs=${LDLIBS}
|
|
|
|
|
ldshared=${LDSHARED:--shared}
|
2025-09-06 16:19:50 +03:00
|
|
|
cflagsmt=${CFLAGSMT:--pthread}
|
|
|
|
|
ldflagsmt=${LDFLAGSMT:--pthread}
|
|
|
|
|
ldlibsmt=${LDLIBSMT}
|
2025-09-02 10:24:05 +03:00
|
|
|
platform=""
|
|
|
|
|
display_help="no"
|
|
|
|
|
|
|
|
|
|
# Parse arguments
|
2025-07-29 21:04:07 +03:00
|
|
|
for option do
|
|
|
|
|
case $option in
|
2025-09-02 10:24:05 +03:00
|
|
|
--cc=*) cc="${option#--cc=}" ;;
|
|
|
|
|
--ar=*) ar="${option#--ar=}" ;;
|
|
|
|
|
--ld=*) ld="${option#--ld=}" ;;
|
|
|
|
|
--arflags=*) arflags="${option#--arflags=}" ;;
|
|
|
|
|
--cflags=*) cflags="${option#--cflags=}" ;;
|
|
|
|
|
--ldflags=*) ldflags="${option#--ldflags=}" ;;
|
|
|
|
|
--ldlibs=*) ldlibs="${option#--ldlibs=}" ;;
|
|
|
|
|
--ldshared=*) ldshared="${option#--ldshared=}" ;;
|
2025-09-06 16:19:50 +03:00
|
|
|
--cflagsmt=*) cflagsmt="${option#--cflagsmt=}" ;;
|
|
|
|
|
--ldflagsmt=*) ldflagsmt="${option#--ldflagsmt=}" ;;
|
|
|
|
|
--ldlibsmt=*) ldlibsmt="${option#--ldlibsmt=}" ;;
|
2025-09-02 10:24:05 +03:00
|
|
|
--platform=*) platform="${option#--platform=}" ;;
|
|
|
|
|
--prefix=*) prefix_path="${option#--prefix=}" ;;
|
|
|
|
|
--enable-shared|--enable-shared=yes) enable_shared="yes" ;;
|
|
|
|
|
--enable-shared=no) enable_shared="no" ;;
|
|
|
|
|
--enable-mt|--enable-mt=yes) enable_mt="yes" ;;
|
|
|
|
|
--enable-mt=no) enable_mt="no" ;;
|
|
|
|
|
--enable-lfs|--enable-lfs=yes) enable_lfs="yes" ;;
|
|
|
|
|
--enable-lfs=no) enable_lfs="no" ;;
|
|
|
|
|
--enable-tests|--enable-tests=yes) enable_tests="yes" ;;
|
|
|
|
|
--enable-tests=no) enable_tests="no" ;;
|
2025-10-12 10:20:09 +03:00
|
|
|
--enable-benchmarks|--enable-benchmarks=yes) enable_benchmarks="yes" ;;
|
|
|
|
|
--enable-benchmarks=no) enable_benchmarks="no" ;;
|
2025-09-02 10:24:05 +03:00
|
|
|
--use-clock_gettime|--use-clock_gettime=yes) use_clock_gettime="yes" ;;
|
|
|
|
|
--use-clock_gettime=no) use_clock_gettime="no" ;;
|
2025-10-12 10:20:09 +03:00
|
|
|
--use-short-limbs|--use-short-limbs=yes) use_short_limbs="yes" ;;
|
|
|
|
|
--use-short-limbs=no) use_short_limbs="no" ;;
|
2025-09-02 10:24:05 +03:00
|
|
|
--source=*) source_path="${option#--source=}" ;;
|
2025-10-12 23:16:00 +03:00
|
|
|
--enable-pic|--enable-pic=yes) enable_pic="yes" ;;
|
2025-09-02 10:24:05 +03:00
|
|
|
--enable-pic=no) enable_pic="no" ;;
|
2025-10-12 23:16:00 +03:00
|
|
|
--enable-lto|--enable-lto=yes) enable_lto="yes" ;;
|
|
|
|
|
--enable-lto=no) enable_lto="no" ;;
|
2025-09-02 10:24:05 +03:00
|
|
|
--help|-h) display_help="yes" ;;
|
|
|
|
|
*) echo "configure: WARNING unrecognized option $option" ;;
|
2025-07-29 21:04:07 +03:00
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
if [ "$display_help" = "yes" ]; then
|
|
|
|
|
cat << EOF
|
2025-07-29 21:04:07 +03:00
|
|
|
Usage: configure [OPTIONS]
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
--help Print this message
|
2025-07-29 21:29:22 +03:00
|
|
|
--source= Path to the source code
|
2025-07-29 21:04:07 +03:00
|
|
|
--cc=CC C compiler
|
2025-09-02 10:24:05 +03:00
|
|
|
--ld=LD Linker
|
2025-07-29 21:04:07 +03:00
|
|
|
--ar=AR Library archiver
|
2025-09-02 10:24:05 +03:00
|
|
|
--arflags= Archiver flags
|
|
|
|
|
--cflags= Compiler flags
|
|
|
|
|
--ldflags= Linker flags
|
2025-09-06 16:19:50 +03:00
|
|
|
--ldlibs= Linker libraries
|
2025-09-02 10:24:05 +03:00
|
|
|
--ldshared= Linker flags for shared libraries
|
2025-09-06 16:19:50 +03:00
|
|
|
--cflagsmt= Compiler flags for multithreading
|
|
|
|
|
--ldflagsmt= Linker flags for multithreading
|
|
|
|
|
--ldlibsmt= Linker libraries for multithreading
|
2025-07-29 21:04:07 +03:00
|
|
|
--platform=[Posix|Win32|Dummy] Specify target platform
|
2025-09-02 10:24:05 +03:00
|
|
|
--prefix= Install prefix
|
|
|
|
|
--enable-shared[=yes|no] Make shared library
|
|
|
|
|
--enable-pic[=yes|no] Enable position independent code (PIC)
|
2025-10-12 23:16:00 +03:00
|
|
|
--enable-lto[=yes|no] Enable link time optimizations
|
2025-07-29 21:04:07 +03:00
|
|
|
--enable-mt[=yes|no] Enable multithreading support
|
|
|
|
|
--enable-lfs[=yes|no] Enable large file support
|
|
|
|
|
--enable-tests[=yes|no] Enable unit tests
|
2025-10-12 10:20:09 +03:00
|
|
|
--enable-benchmarks[=yes|no] Enable benchmarks
|
2025-07-29 21:04:07 +03:00
|
|
|
--use-clock_gettime[=yes|no] Use of clock_gettime regardless of the support
|
2025-10-12 10:20:09 +03:00
|
|
|
--use-short-limbs[=yes|no] Use shorter limbs in big integers
|
2025-07-29 21:04:07 +03:00
|
|
|
EOF
|
2025-09-02 10:24:05 +03:00
|
|
|
exit 1
|
2025-07-30 18:52:38 +03:00
|
|
|
fi
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Ensure that source_path ends on /
|
|
|
|
|
case "$source_path" in
|
|
|
|
|
*/) ;;
|
|
|
|
|
*) source_path="$source_path/" ;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
# Detect and validate OS
|
2025-07-29 21:04:07 +03:00
|
|
|
os="Unknown"
|
2025-09-02 10:24:05 +03:00
|
|
|
case "${platform:-$(uname)}" in
|
|
|
|
|
Posix|Win32|Dummy) ;;
|
|
|
|
|
Darwin*) os="MacOS"; platform="Posix" ;;
|
|
|
|
|
Linux*) os="Linux"; platform="Posix" ;;
|
|
|
|
|
*BSD) os="BSD"; platform="Posix" ;;
|
|
|
|
|
CYGWIN*|MINGW*|MSYS*) os="Windows"; platform="Win32" ;;
|
|
|
|
|
*) platform="Dummy" ;;
|
|
|
|
|
esac
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
case "$platform" in
|
|
|
|
|
Posix|Win32|Dummy) ;;
|
|
|
|
|
*) echo "configure: WARNING: unsupported platform '$platform'"; platform="Dummy" ;;
|
2025-07-29 21:04:07 +03:00
|
|
|
esac
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Platform-specific settings
|
|
|
|
|
exe_suffix=""
|
|
|
|
|
dll_prefix="libbh"
|
|
|
|
|
dll_suffix=".so"
|
|
|
|
|
if [ "$platform" = "Win32" ]; then
|
|
|
|
|
exe_suffix=".exe"
|
|
|
|
|
dll_prefix="bh"
|
|
|
|
|
dll_suffix=".dll"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Build flags
|
|
|
|
|
cflags="-I${source_path}include -I. $cflags"
|
|
|
|
|
ldlibs="-lm $ldlibs"
|
|
|
|
|
|
|
|
|
|
if [ "$enable_pic" = "yes" ]; then
|
|
|
|
|
cflags="$cflags -fPIC"
|
2025-07-29 21:04:07 +03:00
|
|
|
fi
|
|
|
|
|
|
2025-10-12 23:16:00 +03:00
|
|
|
if [ "$enable_lto" = "yes" ]; then
|
|
|
|
|
cflags="$cflags -flto"
|
|
|
|
|
ldflags="$ldflags -flto"
|
|
|
|
|
fi
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
if [ "$enable_pic" = "no" ] && [ "$enable_shared" = "yes" ]; then
|
|
|
|
|
echo "configure: WARNING: requested shared library while PIC is disabled"
|
|
|
|
|
echo "configure: WARNING: expect build failure"
|
|
|
|
|
fi
|
|
|
|
|
|
2025-09-06 16:19:50 +03:00
|
|
|
if [ "$enable_mt" = "yes" ]; then
|
|
|
|
|
cflags="$cflags $cflagsmt"
|
|
|
|
|
ldflags="$ldflags $ldflagsmt"
|
|
|
|
|
ldlibs="$ldlibs $ldlibsmt"
|
2025-07-29 21:04:07 +03:00
|
|
|
fi
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Create directories
|
|
|
|
|
mkdir src src/Platform src/Math src/String 2>/dev/null
|
|
|
|
|
mkdir src/Platform/Posix src/Platform/Win32 src/Platform/Dummy 2>/dev/null
|
|
|
|
|
if [ "$enable_tests" = "yes" ]; then
|
2025-10-12 10:20:09 +03:00
|
|
|
mkdir test test/src test/tests 2>/dev/null
|
|
|
|
|
fi
|
|
|
|
|
if [ "$enable_benchmarks" = "yes" ]; then
|
|
|
|
|
mkdir bench bench/src bench/tests 2>/dev/null
|
2025-09-02 10:24:05 +03:00
|
|
|
fi
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
library=""
|
|
|
|
|
add_source() { library="${library}${library:+:}$1"; }
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Main source
|
|
|
|
|
for file in "${source_path}"src/*.c; do
|
|
|
|
|
add_source "$file"
|
|
|
|
|
done
|
|
|
|
|
for file in "${source_path}"src/Math/*.c; do
|
|
|
|
|
add_source "$file"
|
|
|
|
|
done
|
|
|
|
|
for file in "${source_path}"src/String/*.c; do
|
|
|
|
|
add_source "$file"
|
2025-07-29 21:04:07 +03:00
|
|
|
done
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Platform specific code
|
|
|
|
|
add_source "${source_path}src/Platform/Spinlock.c"
|
|
|
|
|
|
|
|
|
|
case "$platform" in
|
2025-09-21 22:07:54 +03:00
|
|
|
Posix) add_source "${source_path}src/Platform/Posix/File.c" ;
|
|
|
|
|
add_source "${source_path}src/Platform/Posix/Timer.c" ;;
|
|
|
|
|
Win32) add_source "${source_path}src/Platform/Win32/File.c" ;
|
|
|
|
|
add_source "${source_path}src/Platform/Win32/Timer.c" ;;
|
|
|
|
|
*) add_source "${source_path}src/Platform/Dummy/File.c" ;
|
|
|
|
|
add_source "${source_path}src/Platform/Dummy/Timer.c" ;;
|
2025-09-02 10:24:05 +03:00
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [ "$enable_mt" = "yes" ]; then
|
|
|
|
|
case "$platform" in
|
|
|
|
|
Posix)
|
|
|
|
|
for item in Condition Mutex Semaphore Thread Tss; do
|
|
|
|
|
add_source "${source_path}src/Platform/Posix/${item}.c"
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
Win32)
|
|
|
|
|
for item in Condition Mutex Semaphore Thread Tss; do
|
|
|
|
|
add_source "${source_path}src/Platform/Win32/${item}.c"
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
for item in Condition Mutex Semaphore Thread Tss; do
|
|
|
|
|
add_source "${source_path}src/Platform/Dummy/${item}.c"
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
for item in Condition Mutex Semaphore Thread Tss; do
|
|
|
|
|
add_source "${source_path}src/Platform/Dummy/${item}.c"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2025-07-29 21:04:07 +03:00
|
|
|
# Tests
|
2025-09-02 10:24:05 +03:00
|
|
|
tests=""
|
|
|
|
|
unit=""
|
|
|
|
|
add_test() { tests="${tests}${tests:+:}$1"; }
|
|
|
|
|
|
2025-07-29 21:04:07 +03:00
|
|
|
if [ "$enable_tests" = "yes" ]; then
|
2025-10-12 10:20:09 +03:00
|
|
|
unit="${source_path}test/src/Unit.c"
|
|
|
|
|
for file in "${source_path}"test/tests/*.c; do
|
2025-09-02 10:24:05 +03:00
|
|
|
add_test "$file"
|
2025-07-29 21:04:07 +03:00
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-12 10:20:09 +03:00
|
|
|
# Benchamarks
|
|
|
|
|
btests=""
|
|
|
|
|
bench=""
|
|
|
|
|
add_bench() { btests="${btests}${btests:+:}$1"; }
|
|
|
|
|
|
|
|
|
|
if [ "$enable_benchmarks" = "yes" ]; then
|
|
|
|
|
bench="${source_path}bench/src/Bench.c"
|
|
|
|
|
for file in "${source_path}"bench/tests/*.c; do
|
|
|
|
|
add_bench "$file"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Generate Makefile
|
2025-07-30 18:25:33 +03:00
|
|
|
{
|
|
|
|
|
echo "CC=$cc"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "LD=$ld"
|
2025-07-30 18:25:33 +03:00
|
|
|
echo "AR=$ar"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "ARFLAGS=$arflags"
|
2025-07-30 18:25:33 +03:00
|
|
|
echo "CFLAGS=$cflags"
|
|
|
|
|
echo "LDFLAGS=$ldflags"
|
2025-08-28 16:49:59 +03:00
|
|
|
echo "LDLIBS=$ldlibs"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "LDSHARED=$ldshared"
|
|
|
|
|
echo "PREFIX=$prefix_path"
|
|
|
|
|
echo "STATICLIB=libbh.a"
|
|
|
|
|
|
|
|
|
|
# Shared library
|
|
|
|
|
if [ "$enable_shared" = "yes" ]; then
|
|
|
|
|
printf "SHAREDLIB=${dll_prefix}${dll_suffix}\n"
|
|
|
|
|
printf "\nall: static shared\n"
|
|
|
|
|
printf "\nshared: \${SHAREDLIB}\n"
|
|
|
|
|
|
|
|
|
|
printf "\n\$(SHAREDLIB): "
|
|
|
|
|
( IFS=":"; for item in $library; do item="${item#$source_path}"; printf "%s " "${item%.c}.o"; done; )
|
|
|
|
|
printf "\n\t\$(LD) \$(LDFLAGS) \$(LDSHARED) -o \$@ "
|
|
|
|
|
( IFS=":"; for item in $library; do item="${item#$source_path}"; printf "%s " "${item%.c}.o"; done; )
|
|
|
|
|
printf "\$(LDLIBS)\n"
|
2025-07-30 18:25:33 +03:00
|
|
|
else
|
2025-09-02 10:24:05 +03:00
|
|
|
printf "\nall: static\n"
|
2025-07-30 18:25:33 +03:00
|
|
|
fi
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Static library
|
|
|
|
|
printf "\nstatic: \${STATICLIB}\n"
|
|
|
|
|
printf "\n\$(STATICLIB): "
|
|
|
|
|
( IFS=":"; for item in $library; do item="${item#$source_path}"; printf "%s " "${item%.c}.o"; done; )
|
|
|
|
|
printf "\n\t\$(AR) \$(ARFLAGS) \$@ "
|
|
|
|
|
( IFS=":"; for item in $library; do item="${item#$source_path}"; printf "%s " "${item%.c}.o"; done; )
|
|
|
|
|
printf "\n"
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Compile sources
|
2025-07-30 18:25:33 +03:00
|
|
|
(
|
2025-09-02 10:24:05 +03:00
|
|
|
IFS=":";
|
|
|
|
|
for item in $library; do
|
|
|
|
|
object="${item#$source_path}"
|
|
|
|
|
printf "\n%s: %s\n" "${object%.c}.o" "$item"
|
|
|
|
|
printf "\t\$(CC) \$(CFLAGS) -c -o \$@ %s\n" "$item"
|
2025-07-30 18:25:33 +03:00
|
|
|
done
|
|
|
|
|
)
|
2025-09-02 10:24:05 +03:00
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
|
if [ "$enable_tests" = "yes" ]; then
|
|
|
|
|
(
|
|
|
|
|
unit_obj="${unit#$source_path}"
|
|
|
|
|
printf "\n%s: %s\n" "${unit_obj%.c}.o" "$unit"
|
2025-10-12 10:20:09 +03:00
|
|
|
printf "\t\$(CC) \$(CFLAGS) -I${source_path}test/include -c -o \$@ %s\n" "$unit"
|
2025-09-02 10:24:05 +03:00
|
|
|
|
|
|
|
|
IFS=":";
|
|
|
|
|
for item in $tests; do
|
|
|
|
|
object="${item#$source_path}"
|
|
|
|
|
printf "\n%s: %s %s \$(STATICLIB)\n" "${object%.c}${exe_suffix}" "${object%.c}.o" "${unit_obj%.c}.o"
|
|
|
|
|
printf "\t\$(LD) \$(LDFLAGS) -o \$@ %s %s \$(STATICLIB) \$(LDLIBS)\n" "${object%.c}.o" "${unit_obj%.c}.o"
|
|
|
|
|
|
|
|
|
|
printf "\n%s: %s\n" "${object%.c}.o" "$item"
|
2025-10-12 10:20:09 +03:00
|
|
|
printf "\t\$(CC) \$(CFLAGS) -I${source_path}test/include -c -o \$@ %s\n" "$item"
|
2025-09-02 10:24:05 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
printf "\ntest: "
|
|
|
|
|
for item in $tests; do
|
|
|
|
|
object="${item#$source_path}"
|
|
|
|
|
printf "%s " "${object%.c}${exe_suffix}"
|
|
|
|
|
done
|
|
|
|
|
echo
|
|
|
|
|
for item in $tests; do
|
|
|
|
|
object="${item#$source_path}"
|
|
|
|
|
printf "\t./%s\n" "${object%.c}${exe_suffix}"
|
|
|
|
|
done
|
|
|
|
|
echo
|
|
|
|
|
)
|
2025-07-30 18:25:33 +03:00
|
|
|
fi
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-10-12 10:20:09 +03:00
|
|
|
# Benchmarks
|
|
|
|
|
if [ "$enable_benchmarks" = "yes" ]; then
|
|
|
|
|
(
|
|
|
|
|
bench_obj="${bench#$source_path}"
|
|
|
|
|
printf "\n%s: %s\n" "${bench_obj%.c}.o" "$bench"
|
|
|
|
|
printf "\t\$(CC) \$(CFLAGS) -I${source_path}bench/include -c -o \$@ %s\n" "$bench"
|
|
|
|
|
|
|
|
|
|
IFS=":";
|
|
|
|
|
for item in $btests; do
|
|
|
|
|
object="${item#$source_path}"
|
|
|
|
|
printf "\n%s: %s %s \$(STATICLIB)\n" "${object%.c}${exe_suffix}" "${object%.c}.o" "${bench_obj%.c}.o"
|
|
|
|
|
printf "\t\$(LD) \$(LDFLAGS) -o \$@ %s %s \$(STATICLIB) \$(LDLIBS)\n" "${object%.c}.o" "${bench_obj%.c}.o"
|
|
|
|
|
|
|
|
|
|
printf "\n%s: %s\n" "${object%.c}.o" "$item"
|
|
|
|
|
printf "\t\$(CC) \$(CFLAGS) -I${source_path}bench/include -c -o \$@ %s\n" "$item"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
printf "\nbenchmarks: "
|
|
|
|
|
for item in $btests; do
|
|
|
|
|
object="${item#$source_path}"
|
|
|
|
|
printf "%s " "${object%.c}${exe_suffix}"
|
|
|
|
|
done
|
|
|
|
|
echo
|
|
|
|
|
)
|
|
|
|
|
fi
|
|
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Clean
|
|
|
|
|
printf "\nclean:\n"
|
|
|
|
|
printf "\t-rm -f %s\n" "\$(STATICLIB)"
|
|
|
|
|
if [ "$enable_shared" = "yes" ]; then
|
|
|
|
|
printf "\t-rm -f %s\n" "\$(SHAREDLIB)"
|
|
|
|
|
fi
|
2025-07-30 18:25:33 +03:00
|
|
|
(
|
|
|
|
|
IFS=":"
|
2025-09-02 10:24:05 +03:00
|
|
|
for item in $library; do
|
|
|
|
|
item="${item#$source_path}";
|
|
|
|
|
printf "\t-rm -f %s\n" "${item%.c}.o"
|
2025-07-30 18:25:33 +03:00
|
|
|
done
|
2025-09-02 10:24:05 +03:00
|
|
|
|
|
|
|
|
if [ "$enable_tests" = "yes" ]; then
|
|
|
|
|
unit_obj="${unit#$source_path}"
|
|
|
|
|
printf "\t-rm -f %s\n" "${unit_obj%.c}.o"
|
|
|
|
|
for item in $tests; do
|
|
|
|
|
item="${item#$source_path}"
|
|
|
|
|
printf "\t-rm -f %s\n" "${item%.c}.o"
|
|
|
|
|
printf "\t-rm -f %s\n" "${item%.c}${exe_suffix}"
|
|
|
|
|
done
|
|
|
|
|
fi
|
2025-10-12 10:20:09 +03:00
|
|
|
|
|
|
|
|
if [ "$enable_benchmarks" = "yes" ]; then
|
|
|
|
|
bench_obj="${bench#$source_path}"
|
|
|
|
|
printf "\t-rm -f %s\n" "${bench_obj%.c}.o"
|
|
|
|
|
for item in $btests; do
|
|
|
|
|
item="${item#$source_path}"
|
|
|
|
|
printf "\t-rm -f %s\n" "${item%.c}.o"
|
|
|
|
|
printf "\t-rm -f %s\n" "${item%.c}${exe_suffix}"
|
|
|
|
|
done
|
|
|
|
|
fi
|
2025-07-30 18:25:33 +03:00
|
|
|
)
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Install
|
|
|
|
|
printf "\ninstall: \$(STATICLIB) "
|
|
|
|
|
if [ "$enable_shared" = "yes" ]; then
|
|
|
|
|
printf "\$(SHAREDLIB)"
|
|
|
|
|
fi
|
|
|
|
|
printf "\n\tinstall -d \$(DESTDIR)\$(PREFIX)/lib/\n"
|
|
|
|
|
printf "\tinstall -d \$(DESTDIR)\$(PREFIX)/include/BH/Math\n"
|
|
|
|
|
printf "\tinstall -m 644 \$(STATICLIB) \$(DESTDIR)\$(PREFIX)/lib\n"
|
|
|
|
|
if [ "$enable_shared" = "yes" ]; then
|
|
|
|
|
printf "\tinstall -m 644 \$(SHAREDLIB) \$(DESTDIR)\$(PREFIX)/lib\n"
|
2025-07-30 18:25:33 +03:00
|
|
|
fi
|
2025-09-02 10:24:05 +03:00
|
|
|
for file in "${source_path}"include/BH/*.h; do
|
|
|
|
|
printf "\tinstall -m 644 \"%s\" \$(DESTDIR)\$(PREFIX)/include/BH\n" "$file"
|
|
|
|
|
done
|
|
|
|
|
for file in "${source_path}"include/BH/Math/*.h; do
|
|
|
|
|
printf "\tinstall -m 644 \"%s\" \$(DESTDIR)\$(PREFIX)/include/BH/Math\n" "$file"
|
|
|
|
|
done
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Uninstall
|
|
|
|
|
printf "\nuninstall:\n"
|
|
|
|
|
printf "\trm -rf \$(DESTDIR)\$(PREFIX)/include/BH\n"
|
|
|
|
|
printf "\trm -rf \$(DESTDIR)\$(PREFIX)/lib/\$(STATICLIB)\n"
|
|
|
|
|
if [ "$enabled_shared" = "yes" ]; then
|
|
|
|
|
printf "\trm -rf \$(DESTDIR)\$(PREFIX)/lib/\$(SHAREDLIB)\n"
|
2025-07-30 18:25:33 +03:00
|
|
|
fi
|
2025-09-02 10:24:05 +03:00
|
|
|
|
2025-07-30 18:25:33 +03:00
|
|
|
} > Makefile
|
2025-07-29 21:04:07 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
# Generate Config.h
|
2025-07-30 18:25:33 +03:00
|
|
|
{
|
2025-09-02 10:24:05 +03:00
|
|
|
printf "#ifndef BH_SRC_CONFIG_H\n"
|
|
|
|
|
printf "#define BH_SRC_CONFIG_H\n\n"
|
|
|
|
|
if [ "$use_clock_gettime" = "yes" ]; then
|
|
|
|
|
printf "#define BH_USE_CLOCK_GETTIME\n";
|
|
|
|
|
fi
|
|
|
|
|
if [ "$enable_lfs" = "yes" ]; then
|
|
|
|
|
printf "#define BH_ENABLE_LFS\n";
|
|
|
|
|
fi
|
2025-10-12 10:20:09 +03:00
|
|
|
if [ "$use_short_limbs" = "yes" ]; then
|
|
|
|
|
printf "#define BH_USE_SHORT_LIMBS\n";
|
|
|
|
|
fi
|
2025-07-30 18:25:33 +03:00
|
|
|
printf "\n#endif /* BH_SRC_CONFIG_H */\n"
|
|
|
|
|
} > Config.h
|
2025-08-28 16:49:59 +03:00
|
|
|
|
2025-09-02 10:24:05 +03:00
|
|
|
echo " --- General information --- "
|
2025-08-28 16:49:59 +03:00
|
|
|
echo "OS: $os"
|
|
|
|
|
echo "Platform: $platform"
|
|
|
|
|
echo "Source path: $source_path"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo
|
|
|
|
|
echo " --- Makefile variables --- "
|
2025-08-28 16:49:59 +03:00
|
|
|
echo "CC: $cc"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "LD: $ld"
|
2025-08-28 16:49:59 +03:00
|
|
|
echo "AR: $ar"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "ARFLAGS: $arflags"
|
2025-08-28 16:49:59 +03:00
|
|
|
echo "CFLAGS: $cflags"
|
|
|
|
|
echo "LDFLAGS: $ldflags"
|
|
|
|
|
echo "LDLIBS: $ldlibs"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "LDSHARED: $ldshared"
|
|
|
|
|
echo "PREFIX: $prefix_path"
|
|
|
|
|
echo
|
|
|
|
|
echo " --- Enabled options --- "
|
2025-08-28 16:49:59 +03:00
|
|
|
echo "Enable multithreading: $enable_mt"
|
|
|
|
|
echo "Enable long file support: $enable_lfs"
|
|
|
|
|
echo "Enable tests: $enable_tests"
|
2025-10-12 10:20:09 +03:00
|
|
|
echo "Enable benchmarks: $enable_benchmarks"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "Enable PIC: $enable_pic"
|
2025-10-12 23:16:00 +03:00
|
|
|
echo "Enable LTO: $enable_lto"
|
2025-09-02 10:24:05 +03:00
|
|
|
echo "Build shared library: $enable_shared"
|
2025-08-28 16:49:59 +03:00
|
|
|
echo "Use clock_gettime: $use_clock_gettime"
|
2025-10-12 10:20:09 +03:00
|
|
|
echo "Use short limbs: $use_short_limbs"
|