diff --git a/doc/binary_c2.lyx b/doc/binary_c2.lyx index 3044a721fdcc04f77ae735d18012822b3fe2fa3c..95962fe7ddfbec2044334eeaacf4dca3bdd0d7c8 100644 --- a/doc/binary_c2.lyx +++ b/doc/binary_c2.lyx @@ -1560,7 +1560,7 @@ git clone gitlab@gitlab.eps.surrey.ac.uk:ri0005/libmemoize.git \begin_layout Plain Layout -cd $HOME/git/librinterpolate/src +cd $HOME/git/libmemoize/src \end_layout \begin_layout Plain Layout diff --git a/meson.build b/meson.build index 352ae0ccf32b0e8bb0737efddc1f2e1e9b87e7bd..99bdb1a6e7f9ad42fa790fe10a01f4fc753df97a 100644 --- a/meson.build +++ b/meson.build @@ -793,6 +793,70 @@ endif # We're not really interested in the static library that # results, but it gets the job done. # + +binary_c_subdir_objects = [] + +src_subdirs = run_command('meson/source_directories.sh').stdout().strip().split('\n') + +src_root_sourcefiles = run_command('meson/source_files.sh','./src').stdout().strip().split('\n') + +# build the objects from each subdir into their own static library +foreach src_subdir : src_subdirs + _target_name = 'binary_c_objects_' + src_subdir.underscorify() + #message('src subdir : ' + src_subdir) + + # count the number of source and header files in this subdir + _source_count = run_command('meson/count_source_files.sh',src_subdir).stdout().strip().to_int() + _header_count = run_command('meson/count_header_files.sh',src_subdir).stdout().strip().to_int() + + #message('source file count ' + _source_count.to_string()) + #message('header file count ' + _header_count.to_string()) + + # if we have source files, proceed + if _source_count > 0 + + # get a list of the source files for compilation + _sources = run_command('meson/source_files.sh',src_subdir).stdout().strip().split('\n') + #message('sources : ' + ' '.join(_sources)) + + # get the headers (or an empty list if there are none) + if _header_count > 0 + _headers = run_command('meson/header_files.sh',src_subdir).stdout().strip().split('\n') + else + _headers = [] + endif + #message('headers : ' + ' '.join(_sources)) + + # make the build target and append to binary_c_subdir_objects + binary_c_subdir_objects += build_target( + _target_name, + build_by_default: false, + pic : true, + target_type : 'static_library', + sources : [ + precompiled_headers, + _sources, + _headers, + ], + include_directories: include_directories(incdirs), + dependencies : [ + dependencies + ], + c_args : [ + cflags, + quoted_cflags_list, + ], + objects : data_objects, + link_args : [ + libs, + ], + link_language: 'c', + ) + endif +endforeach + +# binary_c objects references all the binary_c_subdir_objects +# as well as the src/*.c files binary_c_objects = build_target( 'binary_c_objects', build_by_default: true, @@ -800,20 +864,27 @@ binary_c_objects = build_target( target_type : 'static_library', # pretend we're a static library! sources : [ precompiled_headers, - c_sourcefiles, + src_root_sourcefiles, h_sourcefiles, ], include_directories: include_directories(incdirs), - dependencies : [ dependencies ], + dependencies : [ + dependencies, + ], c_args : [ cflags, - quoted_cflags_list, ], - objects : data_objects, + objects : [ + data_objects, + ], link_args : [ libs, ], - ) + link_with : [ + binary_c_subdir_objects, + ], + link_language: 'c', +) ############################################################ # diff --git a/meson/c_sourcefiles.sh b/meson/c_sourcefiles.sh index 5192c8132571eac2ccff124dcdc16bc02985eef9..31eb1cba5c19e13ee954cf07cb88a782fde7ba27 100755 --- a/meson/c_sourcefiles.sh +++ b/meson/c_sourcefiles.sh @@ -1,4 +1,4 @@ #!/bin/bash # list binary_c C source files for meson -ls -1 src/*.c src/*/*.c +ls -1 ./src/*.c ./src/*/*.c diff --git a/meson/count_header_files.sh b/meson/count_header_files.sh new file mode 100755 index 0000000000000000000000000000000000000000..26df06905c38a38f25cff2bc36dc234a411b43a5 --- /dev/null +++ b/meson/count_header_files.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# count .h files in $DIR +DIR="$1" +COUNT=0 +for i in "$DIR"/*.h; do [[ -e "$i" ]] && ((COUNT = COUNT+1)); done +echo $COUNT + + + diff --git a/meson/count_source_files.sh b/meson/count_source_files.sh new file mode 100755 index 0000000000000000000000000000000000000000..12d376859336446c7d6e5c67b75ae1af745c2af4 --- /dev/null +++ b/meson/count_source_files.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# count .c files in $DIR +DIR="$1" +COUNT=0 +for i in "$DIR"/*.c; do [[ -e "$i" ]] && ((COUNT = COUNT+1)); done +echo $COUNT + + diff --git a/meson/data_object_list.sh b/meson/data_object_list.sh index 2d63dfd20f6ef15f921ec50e7f616940c1c747df..e7f8a4422297dbc4f26254fdc7fd600d14780d82 100755 --- a/meson/data_object_list.sh +++ b/meson/data_object_list.sh @@ -4,6 +4,6 @@ # list them cd src || exit -env INCDIRS="-I. -I/usr/include -I/home/izzard/include -I/usr/include/libiberty " ../data_object_list.sh | sed -e s/^/src\\// | sed s/\ /\ src\\//g +env INCDIRS="-I. -I/usr/include -I/home/izzard/include -I/usr/include/libiberty " ../data_object_list.sh | sed -e s/^/src\\// |sed -e 's/[[:space:]]*$//' | sed s/\ /\ src\\//g diff --git a/meson/data_object_list_and_build.sh b/meson/data_object_list_and_build.sh index ab616ae327cff840d3b5bc14a89ba5096441c532..66ac3d88079f01dc312b7be366e511d20c8f06f1 100755 --- a/meson/data_object_list_and_build.sh +++ b/meson/data_object_list_and_build.sh @@ -10,6 +10,6 @@ ############################################################ # list them cd src || exit -env INCDIRS="-I. -I/usr/include -I/home/izzard/include -I/usr/include/libiberty " ../data_object_list.sh | sed -e s/^/src\\// | sed s/\ /\ src\\//g +env INCDIRS="-I. -I/usr/include -I/home/izzard/include -I/usr/include/libiberty " ../data_object_list.sh | sed -e s/^/src\\// |sed -e 's/[[:space:]]*$//'| sed s/\ /\ src\\//g diff --git a/meson/h_sourcefiles.sh b/meson/h_sourcefiles.sh index da72810b17943c4f88d2130e2acdb6ce7478f3dd..9a245c949f4afd2c4a24d8ceb410d175433dc074 100755 --- a/meson/h_sourcefiles.sh +++ b/meson/h_sourcefiles.sh @@ -1,4 +1,4 @@ #!/bin/bash # list binary_c header source files for meson -ls -1 src/*.h src/*/*.h +ls -1 ./src/*.h ./src/*/*.h diff --git a/meson/header_files.sh b/meson/header_files.sh new file mode 100755 index 0000000000000000000000000000000000000000..4d8d8dd17a136fc12400ffab1246c58c87ae6fc6 --- /dev/null +++ b/meson/header_files.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# list .h files in $DIR +DIR="$1" +ls "$DIR"/*.h 2>/dev/null + diff --git a/meson/source_directories.sh b/meson/source_directories.sh new file mode 100755 index 0000000000000000000000000000000000000000..2a23ba73e8ed8eac3eb7e8c3b3a363549049ec26 --- /dev/null +++ b/meson/source_directories.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# list all potential source directories +count=0 +for i in ./src/*; do test -d "$i" && echo "$i" && ((count=count+1)); done + diff --git a/meson/source_files.sh b/meson/source_files.sh new file mode 100755 index 0000000000000000000000000000000000000000..e56b0ff284c04dbd5425cb620202ed891f582509 --- /dev/null +++ b/meson/source_files.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# list .c files in $DIR +DIR="$1" +ls "$DIR"/*.c 2>/dev/null + diff --git a/src/main.c b/src/main.c index d35e5a710ce582d59062a7109686ce1bc9324120..47a60552fb02e8cc3bd478f935dccfdc5fe5ec71 100644 --- a/src/main.c +++ b/src/main.c @@ -38,6 +38,7 @@ int main (int argc, * options, make a stardata, then call binary_c main * with the stardata. */ + printf("ok\n"); #if !defined SEGFAULTS char * altstack = setup_segfaults(); #endif diff --git a/src/setup/argument_setting_functions.c b/src/setup/argument_setting_functions.c index 024554c241582698daaf3cd153b1dbc49ad621d9..4182dd1fc11d4b56e3e263a5f3032a6f83279d23 100644 --- a/src/setup/argument_setting_functions.c +++ b/src/setup/argument_setting_functions.c @@ -10,7 +10,8 @@ static char * arg_variable_default_string( void binary_c_warmup_cpu(ARG_SUBROUTINE_DECLARATION) { (*c)++; - int secs = atoi(argv[*c]); + const int secs = atoi(argv[*c]); + printf("secs warmup %d\n",secs); if(secs!=0)warmup_cpu(stardata,secs); }