Build pakrd as shared object instead of static

This commit is contained in:
Abdelrahman Said 2023-11-05 00:19:22 +00:00
parent 2f3d8106ea
commit fb1d1697f1
2 changed files with 7 additions and 9 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
.cache
compile_commands.json
pckr
libpakrd.a
libpakrd.so
dist

14
compile
View File

@ -21,7 +21,6 @@ FG_BR_CYAN="\033[96"
FG_BR_WHITE="\033[97"
CC=gcc
AR=ar
CFLAGS="-Wall -Werror -pedantic -Iinclude -Iintern/c-cpp-aliases -Iintern/cpath/include "
PCKR_SRC="\
@ -38,7 +37,7 @@ PAKRD_SRC="\
src/io.c \
src/darr.c \
src/pak.c"
PAKRD_FLAGS="-c -fPIC"
PAKRD_FLAGS="-fPIC -rdynamic -shared "
PCKR_TEST_SRC="\
intern/cpath/src/cpath.c \
@ -74,13 +73,13 @@ done
if [[ $BUILD_TYPE == "debug" ]]; then
CFLAGS+="-g "
PCKR_OUT="pckr"
PAKRD_OUT="libpakrd.a"
PAKRD_OUT="libpakrd.so"
else
mkdir -p dist
cp ./include/pak.h dist
CFLAGS+="-O3 -g "
CFLAGS+="-O3 "
PCKR_OUT="dist/pckr"
PAKRD_OUT="dist/libpakrd.a"
PAKRD_OUT="dist/libpakrd.so"
fi
@ -88,9 +87,8 @@ fi
(set -x ; $CC $CFLAGS $PCKR_SRC -o $PCKR_OUT)
# Build pakrd static library
(set -x ; $CC $CFLAGS $PAKRD_FLAGS $PAKRD_SRC ; $AR r $PAKRD_OUT *.o)
rm *.o
# Build pakrd shared library
(set -x ; $CC $CFLAGS $PAKRD_FLAGS $PAKRD_SRC -o $PAKRD_OUT)
# Build pckr_test executable