diff --git a/Makefile b/Makefile index 303b86a..e8435ee 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,11 @@ build_test: build_test_dbg: @build_scripts/build_configurations/build_test_dbg.sh -build_lib: - @build_scripts/build_configurations/build_lib.sh +build_shared_lib: + @build_scripts/build_configurations/build_shared_lib.sh + +build_static_lib: + @build_scripts/build_configurations/build_static_lib.sh ###### Testing tasks ####### test: build_test diff --git a/build_scripts/build_configurations/build_lib.sh b/build_scripts/build_configurations/build_lib.sh deleted file mode 100644 index e0c7f55..0000000 --- a/build_scripts/build_configurations/build_lib.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -source build_scripts/init.sh - -print "${CYAN}=============[build_lib]==============\n" -clear_dir "$OUTDIR" -clear_dir "$OBJDIR" -compile_c "$BUILD_LIB_C_ARGS" "$SRC_C tests/test_marshalling.c" -compile_cpp "$BUILD_LIB_CPP_ARGS" "$SRC_CPP" -link "$BUILD_LIB_CPP_ARGS $BUILD_LIB_LINKER_ARGS" "$LIB_FILE" diff --git a/build_scripts/build_configurations/build_shared_lib.sh b/build_scripts/build_configurations/build_shared_lib.sh new file mode 100644 index 0000000..dbe33c9 --- /dev/null +++ b/build_scripts/build_configurations/build_shared_lib.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +source build_scripts/init.sh + +print "${CYAN}==========[build_shared_lib]==========\n" +clear_dir "$OUTDIR" +clear_dir "$OBJDIR" +compile_c "$BUILD_SHARED_LIB_C_ARGS" "$SRC_C tests/test_marshalling.c" +compile_cpp "$BUILD_SHARED_LIB_CPP_ARGS" "$SRC_CPP" +link "$BUILD_SHARED_LIB_CPP_ARGS $BUILD_SHARED_LIB_LINKER_ARGS" "$SHARED_LIB_FILE" diff --git a/build_scripts/build_configurations/build_static_lib.sh b/build_scripts/build_configurations/build_static_lib.sh new file mode 100644 index 0000000..16bc357 --- /dev/null +++ b/build_scripts/build_configurations/build_static_lib.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +source build_scripts/init.sh + +print "${CYAN}==========[build_shared_lib]==========\n" +clear_dir "$OUTDIR" +clear_dir "$OBJDIR" +compile_c "$BUILD_STATIC_LIB_C_ARGS" "$SRC_C tests/test_marshalling.c" +compile_cpp "$BUILD_STATIC_LIB_CPP_ARGS" "$SRC_CPP" +pack_static_lib "$STATIC_LIB_FILE" diff --git a/build_scripts/default.config.sh b/build_scripts/default.config.sh index fdc6b2e..4094377 100644 --- a/build_scripts/default.config.sh +++ b/build_scripts/default.config.sh @@ -14,12 +14,6 @@ TESTS_C="$( find tests -name '*.c')" TESTS_CPP="$(find tests -name '*.cpp')" VALGRIND_ARGS="-s --log-file=valgrind.log --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ --leak-check=full --show-leak-kinds=all" -# build_lib -LIB_FILE=kerep.so -BUILD_LIB_C_ARGS="-O2 -fpic -flto -shared" -BUILD_LIB_CPP_ARGS="$BUILD_LIB_C_ARGS" -BUILD_LIB_LINKER_ARGS="-Wl,-soname,$LIB_FILE" - # build_test TEST_FILE=kerep.com BUILD_TEST_C_ARGS="-O2" @@ -31,3 +25,15 @@ TEST_DBG_FILE=$TEST_FILE BUILD_TEST_DBG_C_ARGS="-O0 -g" BUILD_TEST_DBG_CPP_ARGS="$BUILD_TEST_DBG_C_ARGS" BUILD_TEST_DBG_LINKER_ARGS="" + +# build_shared_lib +SHARED_LIB_FILE=kerep.so +BUILD_SHARED_LIB_C_ARGS="-O2 -fpic -flto -shared" +BUILD_SHARED_LIB_CPP_ARGS="$BUILD_SHARED_LIB_C_ARGS" +BUILD_SHARED_LIB_LINKER_ARGS="-Wl,-soname,$SHARED_LIB_FILE" + + +# build_STATIC_LIB +STATIC_LIB_FILE=kerep.a +BUILD_STATIC_LIB_C_ARGS="-O2 -fpic" +BUILD_STATIC_LIB_CPP_ARGS="$BUILD_STATIC_LIB_C_ARGS" diff --git a/build_scripts/functions.sh b/build_scripts/functions.sh index 0e09cc3..a2486e0 100644 --- a/build_scripts/functions.sh +++ b/build_scripts/functions.sh @@ -70,3 +70,20 @@ function link { exit 1 fi } + +# (outfile) +function pack_static_lib { + print "${CYAN}----------------[link]----------------\n" + local outfile=$OUTDIR/$1 + print "${BLUE}outfile: ${GRAY}$outfile\n" + local objects="$(find $OBJDIR -name *.o)" + print "${BLUE}objects: ${GRAY}$objects\n" + if ar rcs $outfile $(echo $objects | tr '\n' ' ') + then + print "${GREEN}file $CYAN$outfile ${GREEN}created\n" + rm -rf $OBJDIR + else + print "${RED}some error happened\n" + exit 1 + fi +} \ No newline at end of file