From: Kevin Day Date: Wed, 6 May 2015 02:10:01 +0000 (-0500) Subject: Update: add support for separate build_static setting X-Git-Tag: 0.4.2 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=68438aa2e189d0c44fb32d78424c6d12554efb82;p=fll Update: add support for separate build_static setting This allows for building both shared and static libraries and programs. --- diff --git a/build/scripts/generate.sh b/build/scripts/generate.sh index f47a664..660494d 100644 --- a/build/scripts/generate.sh +++ b/build/scripts/generate.sh @@ -194,11 +194,12 @@ generate_id(){ "build_sources_headers") echo -n 10;; "build_sources_settings") echo -n 11;; "build_shared") echo -n 12;; - "flags_all") echo -n 13;; - "flags_shared") echo -n 14;; - "flags_static") echo -n 15;; - "flags_library") echo -n 16;; - "flags_program") echo -n 17;; + "build_static") echo -n 13;; + "flags_all") echo -n 14;; + "flags_shared") echo -n 15;; + "flags_static") echo -n 16;; + "flags_library") echo -n 17;; + "flags_program") echo -n 18;; esac } @@ -219,7 +220,7 @@ generate_load_settings(){ exit $failure fi - for i in project_name project_level version_major version_minor version_micro build_compiler build_linker build_libraries build_sources_library build_sources_program build_sources_headers build_sources_settings build_shared flags_all flags_shared flags_static flags_library flags_program ; do + for i in project_name project_level version_major version_minor version_micro build_compiler build_linker build_libraries build_sources_library build_sources_program build_sources_headers build_sources_settings build_shared build_static flags_all flags_shared flags_static flags_library flags_program ; do variables[$(generate_id $i)]=$(grep -s -o "^[[:space:]]*$i\>.*$" $settings_file | sed -e "s|^[[:space:]]*$i\>||" -e 's|^[[:space:]]*||') done @@ -235,7 +236,7 @@ generate_prepare_build(){ local level=${variables[$(generate_id project_level)]} local alt=$1 - mkdir -vp ${path_build}{includes,programs,libraries,settings} || failure=1 + mkdir -vp ${path_build}{includes,programs/{shared,static},libraries/{shared,static},settings} || failure=1 if [[ $failure == "" && $level != "" ]] ; then mkdir -vp ${path_build}includes/level_$level || failure=1 @@ -271,6 +272,7 @@ generate_operation_build(){ local linker=${variables[$(generate_id build_linker)]} local arguments="-I${path_build}includes -L${path_build}libraries ${variables[$(generate_id flags_all)]} ${variables[$(generate_id build_libraries)]}" local shared=${variables[$(generate_id build_shared)]} + local static=${variables[$(generate_id build_static)]} local sources_library=${variables[$(generate_id build_sources_library)]} local sources_program=${variables[$(generate_id build_sources_program)]} local sources_headers=${variables[$(generate_id build_sources_headers)]} @@ -279,6 +281,13 @@ generate_operation_build(){ local i= local alt=$1 + + if [[ $shared != "yes" && $static != "yes" ]] ;then + echo -e "${c_error}ERROR: Cannot Build, either build_shared or build_static must be set to 'yes'.$c_reset" + generate_cleanup + exit -1 + fi + if [[ $sources_settings != "" ]] ; then for i in $sources_settings ; do cp -vf $path_c$i ${path_build}settings/ || failure=1 @@ -298,12 +307,12 @@ generate_operation_build(){ sources="$sources$path_c$i " done - echo $compiler $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/lib$name.so.$major.$minor.$micro $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} - $compiler $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/lib$name.so.$major.$minor.$micro $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} || failure=1 + echo $compiler $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/shared/lib$name.so.$major.$minor.$micro $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} + $compiler $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/shared/lib$name.so.$major.$minor.$micro $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} || failure=1 if [[ $failure == "" ]] ; then - ln -vsf lib$name.so.$major.$minor.$micro ${path_build}libraries/lib$name.so.$major || failure=1 - ln -vsf lib$name.so.$major ${path_build}libraries/lib$name.so || failure=1 + ln -vsf lib$name.so.$major.$minor.$micro ${path_build}libraries/shared/lib$name.so.$major || failure=1 + ln -vsf lib$name.so.$major ${path_build}libraries/shared/lib$name.so || failure=1 fi fi @@ -319,17 +328,19 @@ generate_operation_build(){ sources="$sources$path_c$i " done - echo $compiler $sources -o ${path_build}programs/$name $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} - $compiler $sources -o ${path_build}programs/$name $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} || failure=1 + echo $compiler $sources -o ${path_build}programs/shared/$name $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} + $compiler $sources -o ${path_build}programs/shared/$name $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} || failure=1 fi - elif [[ $failure == "" ]] ; then + fi + + if [[ $failure == "" && $static == "yes" ]] ; then sources= if [[ $sources_library != "" ]] ; then for i in $sources_library ; do sources="$sources${path_build}libraries/$i.o " - echo $compiler $path_c$i -c -static -o ${path_build}libraries/$i.o $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} - $compiler $path_c$i -c -static -o ${path_build}libraries/$i.o $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} || failure=1 + echo $compiler $path_c$i -c -static -o ${path_build}libraries/static/$i.o $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} + $compiler $path_c$i -c -static -o ${path_build}libraries/static/$i.o $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} || failure=1 if [[ $failure == "1" ]] ; then break; @@ -337,8 +348,8 @@ generate_operation_build(){ done if [[ $failure == "" ]] ; then - echo $linker rcs ${path_build}libraries/lib$name.a $sources - $linker rcs ${path_build}libraries/lib$name.a $sources || failure=1 + echo $linker rcs ${path_build}libraries/static/lib$name.a $sources + $linker rcs ${path_build}libraries/static/lib$name.a $sources || failure=1 fi fi @@ -354,8 +365,8 @@ generate_operation_build(){ sources="$sources$path_c$i " done - echo $compiler -static -o ${path_build}programs/$name $sources $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} - $compiler -static -o ${path_build}programs/$name $sources $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} || failure=1 + echo $compiler -static -o ${path_build}programs/static/$name $sources $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} + $compiler -static -o ${path_build}programs/static/$name $sources $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} || failure=1 fi fi diff --git a/level_0/f_colors/data/build/settings b/level_0/f_colors/data/build/settings index 199bfed..93bde68 100644 --- a/level_0/f_colors/data/build/settings +++ b/level_0/f_colors/data/build/settings @@ -14,6 +14,7 @@ build_sources_library build_sources_program build_sources_headers colors.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_console/data/build/settings b/level_0/f_console/data/build/settings index f12247e..57f144a 100644 --- a/level_0/f_console/data/build/settings +++ b/level_0/f_console/data/build/settings @@ -14,6 +14,7 @@ build_sources_library console.c build_sources_program build_sources_headers console.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_conversion/data/build/settings b/level_0/f_conversion/data/build/settings index a3feb36..2c64c78 100644 --- a/level_0/f_conversion/data/build/settings +++ b/level_0/f_conversion/data/build/settings @@ -14,6 +14,7 @@ build_sources_library conversion.c build_sources_program build_sources_headers conversion.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_errors/data/build/settings b/level_0/f_errors/data/build/settings index cd8bbf9..98e9968 100644 --- a/level_0/f_errors/data/build/settings +++ b/level_0/f_errors/data/build/settings @@ -14,6 +14,7 @@ build_sources_library build_sources_program build_sources_headers errors.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_file/data/build/settings b/level_0/f_file/data/build/settings index 6c3d504..501e6e6 100644 --- a/level_0/f_file/data/build/settings +++ b/level_0/f_file/data/build/settings @@ -14,6 +14,7 @@ build_sources_library file.c build_sources_program build_sources_headers file.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_fss/data/build/settings b/level_0/f_fss/data/build/settings index cac2f91..d9a3afe 100644 --- a/level_0/f_fss/data/build/settings +++ b/level_0/f_fss/data/build/settings @@ -14,6 +14,7 @@ build_sources_library build_sources_program build_sources_headers fss.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_memory/data/build/settings b/level_0/f_memory/data/build/settings index 2cb0cd7..767b67c 100644 --- a/level_0/f_memory/data/build/settings +++ b/level_0/f_memory/data/build/settings @@ -14,6 +14,7 @@ build_sources_library memory.c build_sources_program build_sources_headers memory.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_paths/data/build/settings b/level_0/f_paths/data/build/settings index 5f97222..036654f 100644 --- a/level_0/f_paths/data/build/settings +++ b/level_0/f_paths/data/build/settings @@ -14,6 +14,7 @@ build_sources_library build_sources_program build_sources_headers fll_paths.h filesystem_paths.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_pipe/data/build/settings b/level_0/f_pipe/data/build/settings index 69820eb..c8530cc 100644 --- a/level_0/f_pipe/data/build/settings +++ b/level_0/f_pipe/data/build/settings @@ -14,6 +14,7 @@ build_sources_library pipe.c build_sources_program build_sources_headers pipe.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_print/data/build/settings b/level_0/f_print/data/build/settings index 84fd450..eeaa015 100644 --- a/level_0/f_print/data/build/settings +++ b/level_0/f_print/data/build/settings @@ -14,6 +14,7 @@ build_sources_library print.c build_sources_program build_sources_headers print.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_serialized/data/build/settings b/level_0/f_serialized/data/build/settings index 70ecd90..6659c44 100644 --- a/level_0/f_serialized/data/build/settings +++ b/level_0/f_serialized/data/build/settings @@ -14,6 +14,7 @@ build_sources_library build_sources_program build_sources_headers serialized.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_strings/data/build/settings b/level_0/f_strings/data/build/settings index 1d2823d..6a83655 100644 --- a/level_0/f_strings/data/build/settings +++ b/level_0/f_strings/data/build/settings @@ -14,6 +14,7 @@ build_sources_library build_sources_program build_sources_headers strings.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_0/f_types/data/build/settings b/level_0/f_types/data/build/settings index a2fd3dc..1be5c68 100644 --- a/level_0/f_types/data/build/settings +++ b/level_0/f_types/data/build/settings @@ -14,6 +14,7 @@ build_sources_library build_sources_program build_sources_headers types.h types_array.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_colors/data/build/settings b/level_1/fl_colors/data/build/settings index 892ca95..4c34fdc 100644 --- a/level_1/fl_colors/data/build/settings +++ b/level_1/fl_colors/data/build/settings @@ -14,6 +14,7 @@ build_sources_library colors.c build_sources_program build_sources_headers colors.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_console/data/build/settings b/level_1/fl_console/data/build/settings index dd13071..b95d88a 100644 --- a/level_1/fl_console/data/build/settings +++ b/level_1/fl_console/data/build/settings @@ -14,6 +14,7 @@ build_sources_library console.c build_sources_program build_sources_headers console.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_directory/data/build/settings b/level_1/fl_directory/data/build/settings index c95be94..2f017ef 100644 --- a/level_1/fl_directory/data/build/settings +++ b/level_1/fl_directory/data/build/settings @@ -14,6 +14,7 @@ build_sources_library directory.c build_sources_program build_sources_headers directory.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_errors/data/build/settings b/level_1/fl_errors/data/build/settings index 451ec89..89fffdc 100644 --- a/level_1/fl_errors/data/build/settings +++ b/level_1/fl_errors/data/build/settings @@ -14,6 +14,7 @@ build_sources_library errors.c build_sources_program build_sources_headers errors.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_file/data/build/settings b/level_1/fl_file/data/build/settings index 3035c95..dba658f 100644 --- a/level_1/fl_file/data/build/settings +++ b/level_1/fl_file/data/build/settings @@ -14,6 +14,7 @@ build_sources_library file.c build_sources_program build_sources_headers file.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_fss/data/build/settings b/level_1/fl_fss/data/build/settings index c42cb1f..44abbbe 100644 --- a/level_1/fl_fss/data/build/settings +++ b/level_1/fl_fss/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss.c fss_basic.c fss_basic_list.c fss_extended.c build_sources_program build_sources_headers fss.h fss_basic.h fss_basic_list.h fss_errors.h fss_extended.h fss_macro.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_serialized/data/build/settings b/level_1/fl_serialized/data/build/settings index 84b1b34..d80a389 100644 --- a/level_1/fl_serialized/data/build/settings +++ b/level_1/fl_serialized/data/build/settings @@ -14,6 +14,7 @@ build_sources_library serialized.c build_sources_program build_sources_headers serialized.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_1/fl_strings/data/build/settings b/level_1/fl_strings/data/build/settings index f1c1d00..a693b83 100644 --- a/level_1/fl_strings/data/build/settings +++ b/level_1/fl_strings/data/build/settings @@ -14,6 +14,7 @@ build_sources_library strings.c build_sources_program build_sources_headers strings.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_2/fll_colors/data/build/settings b/level_2/fll_colors/data/build/settings index c07a80c..452d3a3 100644 --- a/level_2/fll_colors/data/build/settings +++ b/level_2/fll_colors/data/build/settings @@ -14,6 +14,7 @@ build_sources_library colors.c build_sources_program build_sources_headers colors.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_2/fll_execute/data/build/settings b/level_2/fll_execute/data/build/settings index 29a7ec8..01c5585 100644 --- a/level_2/fll_execute/data/build/settings +++ b/level_2/fll_execute/data/build/settings @@ -14,6 +14,7 @@ build_sources_library execute.c build_sources_program build_sources_headers execute.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_2/fll_fss/data/build/settings b/level_2/fll_fss/data/build/settings index 8a18c3b..aecd169 100644 --- a/level_2/fll_fss/data/build/settings +++ b/level_2/fll_fss/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_basic.c fss_basic_list.c fss_extended.c fss_errors.c build_sources_program build_sources_headers fss_basic.h fss_basic_list.h fss_extended.h fss_errors.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/firewall/data/build/settings b/level_3/firewall/data/build/settings index 661e8cf..fd81221 100644 --- a/level_3/firewall/data/build/settings +++ b/level_3/firewall/data/build/settings @@ -14,6 +14,7 @@ build_sources_library firewall.c private-firewall.c build_sources_program main.c build_sources_headers firewall.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/fss_basic_list_read/data/build/settings b/level_3/fss_basic_list_read/data/build/settings index f12ba9b..3c878e8 100644 --- a/level_3/fss_basic_list_read/data/build/settings +++ b/level_3/fss_basic_list_read/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_basic_list_read.c build_sources_program main.c build_sources_headers fss_basic_list_read.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/fss_basic_list_write/data/build/settings b/level_3/fss_basic_list_write/data/build/settings index 4a1d422..e211017 100644 --- a/level_3/fss_basic_list_write/data/build/settings +++ b/level_3/fss_basic_list_write/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_basic_list_write.c build_sources_program main.c build_sources_headers fss_basic_list_write.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/fss_basic_read/data/build/settings b/level_3/fss_basic_read/data/build/settings index d5a374f..ca3b0ed 100644 --- a/level_3/fss_basic_read/data/build/settings +++ b/level_3/fss_basic_read/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_basic_read.c build_sources_program main.c build_sources_headers fss_basic_read.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/fss_basic_write/data/build/settings b/level_3/fss_basic_write/data/build/settings index 1b87dcb..350a4b1 100644 --- a/level_3/fss_basic_write/data/build/settings +++ b/level_3/fss_basic_write/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_basic_write.c build_sources_program main.c build_sources_headers fss_basic_write.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/fss_extended_read/data/build/settings b/level_3/fss_extended_read/data/build/settings index c4a7805..eac4c6d 100644 --- a/level_3/fss_extended_read/data/build/settings +++ b/level_3/fss_extended_read/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_extended_read.c build_sources_program main.c build_sources_headers fss_extended_read.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/fss_extended_write/data/build/settings b/level_3/fss_extended_write/data/build/settings index 283ad37..fcc6a4d 100644 --- a/level_3/fss_extended_write/data/build/settings +++ b/level_3/fss_extended_write/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_extended_write.c build_sources_program main.c build_sources_headers fss_extended_write.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/fss_return_code/data/build/settings b/level_3/fss_return_code/data/build/settings index 57697e2..c801468 100644 --- a/level_3/fss_return_code/data/build/settings +++ b/level_3/fss_return_code/data/build/settings @@ -14,6 +14,7 @@ build_sources_library fss_return_code.c build_sources_program main.c build_sources_headers fss_return_code.h build_shared yes +build_static yes flags_all -z now flags_shared diff --git a/level_3/init/data/build/settings b/level_3/init/data/build/settings new file mode 100644 index 0000000..af16465 --- /dev/null +++ b/level_3/init/data/build/settings @@ -0,0 +1,24 @@ +# fss-0000 + +project_name init +project_level 3 + +version_major 0 +version_minor 4 +version_micro 2 + +build_compiler gcc +build_linker ar +build_libraries -lfll_colors -lfll_fss -lfll_execute -lfl_directory -lfl_colors -lfl_strings -lfl_file -lfl_console -lfl_fss -lf_pipe -lf_file -lf_print -lf_conversion -lf_console -lf_memory -lc +build_sources_library init.c private-init.c +build_sources_program main.c +build_sources_headers init.h +build_shared yes +build_static yes +build_static yes + +flags_all -z now +flags_shared +flags_static +flags_library -fPIC +flags_program -fPIE -lfirewall diff --git a/level_3/return_code/data/build/settings b/level_3/return_code/data/build/settings index 35bfce1..4c4e3c9 100644 --- a/level_3/return_code/data/build/settings +++ b/level_3/return_code/data/build/settings @@ -14,6 +14,7 @@ build_sources_library return_code.c build_sources_program main.c build_sources_headers return_code.h build_shared yes +build_static yes flags_all -z now flags_shared