diff --git a/meson.build b/meson.build index 6ed1e42e204fcf231d11ddb59480476073ca1689..ee348ce9e0a6ea3971f6e8b4d667cbd95313735a 100644 --- a/meson.build +++ b/meson.build @@ -10,8 +10,8 @@ ############################################################ # TODO: # -# fix precompiled headers (meson seems broken with these) -# shared_library build +# automate symlink of libbinary_c.so +# # 'accurate', 'generic', 'gprof'/'gcov' builds # test non-debug version (meson builds generic by default) # profile-guided optimization @@ -25,7 +25,7 @@ project( 'binary_c','c', version : '2.1.3', default_options : [ - 'c_std=gnu99' + 'c_std=gnu99', ] ) compiler = meson.get_compiler('c') @@ -277,19 +277,9 @@ data_objects = run_command('meson/data_object_list.sh').stdout().strip().split(' ############################################################ # source files -sourcefiles = run_command('meson/sourcefiles.sh',).stdout().strip().split('\n') +c_sourcefiles = run_command('meson/c_sourcefiles.sh',).stdout().strip().split('\n') +h_sourcefiles = run_command('meson/h_sourcefiles.sh',).stdout().strip().split('\n') -############################################################ -# precompile headers -# -##### BROKEN! ##### -# -############################################################ -if compiler.get_id() == 'clang' - pch_flags = '-MF binary_c.h.gch.d binary_c.h -o binary_c.h.pch' -else - pch_flags = '-MF binary_c.h.gch.d -x c-header binary_c.h' -endif ############################################################ # full list of libraries with which we wish to link @@ -326,23 +316,82 @@ foreach _arg : ['all','format','strict-prototypes','format-signedness'] endforeach cflags += warn_flags + ############################################################ -# make executable -executable = executable( - 'binary_c', - sources : sourcefiles, - #c_pch : 'pch/binary_c_pch.h', - include_directories: include_directories(incdirs), - dependencies : [libgsl_dep], - c_args : [ cflags, quoted_cflags_list ], - link_args : libs, - objects : data_objects, -) +# make precompiled headers + +if compiler.get_id() == 'clang' + pch_cflags = [ ] + pch_sourcefiles = [ 'binary_c.h.pch' ] +else + pch_cflags = [ '-x', 'c-header' ] + pch_sourcefiles = [ 'binary_c.h.gch' ] +endif + +pch_cflags_array = cflags + pch_cflags + +pch_compiler = compiler.cmd_array() + pch_cflags_array + +precompiled_headers = custom_target( + 'binary_c.h.gch', + build_by_default : true, + input : ['src/binary_c.h'], + output : pch_sourcefiles, + command : [ pch_compiler, '-gdwarf-2', '@INPUT@' ], + depend_files : [h_sourcefiles], + ) ############################################################ -# TODO: +# symlink shared_library to binary_c/src directory + +libbinary_c_symlink = custom_target( + 'symlink_libbinary_c', + build_by_default: false, + output: [ 'libbinary_c_symlink' ], + command: [ 'sh', '-c', '../meson/symlink_libbinary_c.sh' ], + ) + +############################################################ # # make shared library # -# shared_library('binary_c') +binary_c_shared_library = shared_library( + 'binary_c', + build_by_default : false, + install: true, + #install_dir: binary_c_src, + sources : [c_sourcefiles, h_sourcefiles, precompiled_headers], + include_directories: include_directories(incdirs), + dependencies : [ libgsl_dep ], + c_args : [ cflags, quoted_cflags_list, '-fvisibility=hidden','-H' ], + link_args : libs, + objects : data_objects, + ) + + + +############################################################ +# make executable + +binary_c_executable = executable( + 'binary_c', + install: true, + sources : [c_sourcefiles, h_sourcefiles, precompiled_headers], + include_directories: include_directories(incdirs), + dependencies : [ libgsl_dep ], + c_args : [ cflags, quoted_cflags_list, '-H' ], + link_args : libs, + objects : data_objects, + ) + + +############################################################ +# symlink executable to binary_c directory + +binary_c_symlink = custom_target('symlink_binary_c', + build_by_default: true, + output: ['binary_c_symlinked'], + command: [ 'sh', '-c', '../meson/symlink_binary_c.sh' ], + depends : [ binary_c_executable ], + ) diff --git a/meson/c_sourcefiles.sh b/meson/c_sourcefiles.sh new file mode 100755 index 0000000000000000000000000000000000000000..01dc0f584f55cf9577bdce971aa34fe1431239d6 --- /dev/null +++ b/meson/c_sourcefiles.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# list binary_c C source files for meson +ls src/*.c src/*/*.c diff --git a/meson/h_sourcefiles.sh b/meson/h_sourcefiles.sh new file mode 100755 index 0000000000000000000000000000000000000000..a1707077f5599cc26db497408964ceb193ce8f9c --- /dev/null +++ b/meson/h_sourcefiles.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# list binary_c header source files for meson +ls src/*.h src/*/*.h diff --git a/meson/sourcefiles.sh b/meson/sourcefiles.sh deleted file mode 100755 index 16edb1d941172828fd4e65a9e4b92ad391bc4336..0000000000000000000000000000000000000000 --- a/meson/sourcefiles.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# list binary_c source files for meson -ls src/*.c -ls src/*/*.c diff --git a/meson/symlink_binary_c.sh b/meson/symlink_binary_c.sh new file mode 100755 index 0000000000000000000000000000000000000000..b6af22eb090b5f2b6ea24d546a965a6f8aa52fc8 --- /dev/null +++ b/meson/symlink_binary_c.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# script to symlink a completed binary_c executable +# to the binary_c root directory. + +ln -sfr binary_c ../ diff --git a/meson/symlink_libbinary_c.sh b/meson/symlink_libbinary_c.sh new file mode 100755 index 0000000000000000000000000000000000000000..77d48f462e63f5ee2a31163150c3fd11ee04dc39 --- /dev/null +++ b/meson/symlink_libbinary_c.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# script to symlink a completed binary_c executable +# to the binary_c root directory. + +ln -sfr libbinary_c.so ../src/ diff --git a/src/buffering/binary_c_buffered_printf.c b/src/buffering/binary_c_buffered_printf.c index 3d6e65ea4ffa81dc0b144205be2ef708fd283200..cfc2e7ed2271bc836439fea2d0e2d45ea02a5a94 100644 --- a/src/buffering/binary_c_buffered_printf.c +++ b/src/buffering/binary_c_buffered_printf.c @@ -1,4 +1,3 @@ -#define _GNU_SOURCE #include "../binary_c.h" #include "buffering_macros.h"