|
|
|
@ -5,6 +5,7 @@ |
|
|
|
# -h, --help Show this help |
|
|
|
# -h, --help Show this help |
|
|
|
# --clean Clean before build |
|
|
|
# --clean Clean before build |
|
|
|
# --full Full rebuild (autoreconf + configure + make) |
|
|
|
# --full Full rebuild (autoreconf + configure + make) |
|
|
|
|
|
|
|
# --asan Build with AddressSanitizer (debug) |
|
|
|
# -j[N] Build with N parallel jobs (default: 4) |
|
|
|
# -j[N] Build with N parallel jobs (default: 4) |
|
|
|
|
|
|
|
|
|
|
|
set -e # Exit on error |
|
|
|
set -e # Exit on error |
|
|
|
@ -21,6 +22,7 @@ fi |
|
|
|
# Parse arguments |
|
|
|
# Parse arguments |
|
|
|
CLEAN=0 |
|
|
|
CLEAN=0 |
|
|
|
FULL_REBUILD=0 |
|
|
|
FULL_REBUILD=0 |
|
|
|
|
|
|
|
USE_ASAN=0 |
|
|
|
JOBS="-j4" |
|
|
|
JOBS="-j4" |
|
|
|
MAKE_ARGS="" |
|
|
|
MAKE_ARGS="" |
|
|
|
|
|
|
|
|
|
|
|
@ -32,6 +34,7 @@ while [[ $# -gt 0 ]]; do |
|
|
|
echo " -h, --help Show this help" |
|
|
|
echo " -h, --help Show this help" |
|
|
|
echo " --clean Clean before build" |
|
|
|
echo " --clean Clean before build" |
|
|
|
echo " --full Full rebuild (autoreconf + configure + make)" |
|
|
|
echo " --full Full rebuild (autoreconf + configure + make)" |
|
|
|
|
|
|
|
echo " --asan Build with AddressSanitizer" |
|
|
|
echo " -j[N] Build with N parallel jobs (default: 4)" |
|
|
|
echo " -j[N] Build with N parallel jobs (default: 4)" |
|
|
|
exit 0 |
|
|
|
exit 0 |
|
|
|
;; |
|
|
|
;; |
|
|
|
@ -43,6 +46,10 @@ while [[ $# -gt 0 ]]; do |
|
|
|
FULL_REBUILD=1 |
|
|
|
FULL_REBUILD=1 |
|
|
|
shift |
|
|
|
shift |
|
|
|
;; |
|
|
|
;; |
|
|
|
|
|
|
|
--asan) |
|
|
|
|
|
|
|
USE_ASAN=1 |
|
|
|
|
|
|
|
shift |
|
|
|
|
|
|
|
;; |
|
|
|
-j*) |
|
|
|
-j*) |
|
|
|
JOBS="$1" |
|
|
|
JOBS="$1" |
|
|
|
shift |
|
|
|
shift |
|
|
|
@ -126,16 +133,29 @@ fi |
|
|
|
if [ ! -f Makefile ]; then |
|
|
|
if [ ! -f Makefile ]; then |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
echo "Running ./configure..." |
|
|
|
echo "Running ./configure..." |
|
|
|
./configure |
|
|
|
if [ "$USE_ASAN" -eq 1 ]; then |
|
|
|
|
|
|
|
./configure CFLAGS="-g -Og -fsanitize=address -fno-omit-frame-pointer -fno-pie" LDFLAGS="-no-pie" |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
./configure |
|
|
|
|
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Build (all .o files go to build/ directory, binary copied to project root) |
|
|
|
# Build (all .o files go to build/ directory, binary copied to project root) |
|
|
|
echo "" |
|
|
|
echo "" |
|
|
|
echo "Compiling with $JOBS..." |
|
|
|
echo "Compiling with $JOBS..." |
|
|
|
BUILD_SUCCESS=0 |
|
|
|
BUILD_SUCCESS=0 |
|
|
|
make $JOBS $MAKE_ARGS 2>&1 | tee build.log |
|
|
|
if [ "$USE_ASAN" -eq 1 ]; then |
|
|
|
if [ ${PIPESTATUS[0]} -eq 0 ]; then |
|
|
|
echo "(AddressSanitizer enabled — lib/ and src/ only, skipping tests)" |
|
|
|
|
|
|
|
AF="-fsanitize=address -fno-omit-frame-pointer -g -Og" |
|
|
|
|
|
|
|
AL="-fsanitize=address" |
|
|
|
|
|
|
|
(cd lib && make clean $JOBS $MAKE_ARGS 2>&1 && make "CFLAGS+=$AF" "LDFLAGS+=$AL" $JOBS $MAKE_ARGS 2>&1) || { echo "lib build failed"; exit 1; } |
|
|
|
|
|
|
|
(cd src && make clean $JOBS $MAKE_ARGS 2>&1 && make "CFLAGS+=$AF" "LDFLAGS+=$AL" $JOBS $MAKE_ARGS 2>&1) || { echo "src build failed"; exit 1; } |
|
|
|
BUILD_SUCCESS=1 |
|
|
|
BUILD_SUCCESS=1 |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
make $JOBS $MAKE_ARGS 2>&1 | tee build.log |
|
|
|
|
|
|
|
if [ ${PIPESTATUS[0]} -eq 0 ]; then |
|
|
|
|
|
|
|
BUILD_SUCCESS=1 |
|
|
|
|
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ $BUILD_SUCCESS -eq 1 ]; then |
|
|
|
if [ $BUILD_SUCCESS -eq 1 ]; then |
|
|
|
|