From 92bacdf8f5d39bc2156f04e76e5353149403b19a Mon Sep 17 00:00:00 2001 From: Alexander van der Grinten Date: Sun, 6 Jan 2019 13:11:12 +0100 Subject: [PATCH] meson: Support headers-only installation --- meson.build | 91 ++++---- meson_options.txt | 2 +- options/ansi/meson.build | 419 ++++++++++++++++++----------------- sysdeps/managarm/meson.build | 18 +- sysdeps/qword/meson.build | 18 +- 5 files changed, 280 insertions(+), 268 deletions(-) diff --git a/meson.build b/meson.build index 5e4c1fdb..215e124f 100644 --- a/meson.build +++ b/meson.build @@ -1,25 +1,9 @@ -project('mlibc', 'c', 'cpp') - -cxxshim_dep = subproject('cxxshim').get_variable('cxxshim_dep') -frigg_dep = subproject('frigg').get_variable('frigg_dep') - -c_compiler = meson.get_compiler('c') - -gccdir = run_command('/bin/sh', '-c', - ''.join(c_compiler.cmd_array()) + ' -print-search-dirs | sed -n -e "s/install: \(.*\)/\\1/p"', - check: true).stdout().strip() - -add_project_arguments('-nostdinc', '-fno-builtin', language: ['c', 'cpp']) -add_project_arguments('-std=c++17', language: 'cpp') -add_project_arguments('-fno-rtti', '-fno-exceptions', language: 'cpp') -add_project_link_arguments('-nostdlib', language: ['c', 'cpp']) +project('mlibc') rtdl_include_dirs = [ - include_directories(gccdir + '/include'), include_directories('options/internal/include'), ] libc_include_dirs = [ - include_directories(gccdir + '/include'), include_directories('options/internal/include'), include_directories('options/elf/include'), include_directories('options/lsb/include'), @@ -30,11 +14,33 @@ rtdl_sources = [ ] libc_sources = [ ] libc_sublibs = [ ] +headers_only = get_option('headers_only') disable_ansi_option = false disable_posix_option = false disable_linux_option = false internal_conf = configuration_data() +if not headers_only + cxxshim_dep = subproject('cxxshim').get_variable('cxxshim_dep') + frigg_dep = subproject('frigg').get_variable('frigg_dep') + + add_languages('c', 'cpp') + c_compiler = meson.get_compiler('c') + + add_project_arguments('-nostdinc', '-fno-builtin', language: ['c', 'cpp']) + add_project_arguments('-std=c++17', language: 'cpp') + add_project_arguments('-fno-rtti', '-fno-exceptions', language: 'cpp') + add_project_link_arguments('-nostdlib', language: ['c', 'cpp']) + + gccdir = run_command('/bin/sh', '-c', + ''.join(c_compiler.cmd_array()) + + ' -print-search-dirs | sed -n -e "s/install: \(.*\)/\\1/p"', + check: true).stdout().strip() + + rtdl_include_dirs += include_directories(gccdir + '/include') + libc_include_dirs += include_directories(gccdir + '/include') +endif + internal_conf.set('MLIBC_MAP_DSO_SEGMENTS', true) #---------------------------------------------------------------------------------------- @@ -130,30 +136,31 @@ subdir('options/lsb') subdir('options/glibc') subdir('options/linux') -ldso_lib = shared_library('ld', rtdl_sources, - name_prefix: '', - cpp_args: ['-fvisibility=hidden', '-DMLIBC_BUILDING_RTDL', '-DFRIGG_HAVE_LIBC'], - include_directories: rtdl_include_dirs, - dependencies: [cxxshim_dep, frigg_dep], - install: true) +if not headers_only + ldso_lib = shared_library('ld', rtdl_sources, + name_prefix: '', + cpp_args: ['-fvisibility=hidden', '-DMLIBC_BUILDING_RTDL', '-DFRIGG_HAVE_LIBC'], + include_directories: rtdl_include_dirs, + dependencies: [cxxshim_dep, frigg_dep], + install: true) -shared_library('c', - [ - libc_sources, - internal_sources, - ansi_sources, - lsb_sources, - ], - cpp_args: ['-DFRIGG_HAVE_LIBC'], - include_directories: libc_include_dirs, - dependencies: [cxxshim_dep, frigg_dep], - link_with: [ldso_lib], - link_whole: libc_sublibs, - install: true) - -shared_library('dl', 'libdl/src/dummy.cpp', install: true) -shared_library('m', 'libm/src/dummy.cpp', install: true) -shared_library('pthread', 'libpthread/src/dummy.cpp', install: true) -shared_library('rt', 'librt/src/dummy.cpp', install: true) -shared_library('util', 'libutil/src/dummy.cpp', install: true) + shared_library('c', + [ + libc_sources, + internal_sources, + ansi_sources, + lsb_sources, + ], + cpp_args: ['-DFRIGG_HAVE_LIBC'], + include_directories: libc_include_dirs, + dependencies: [cxxshim_dep, frigg_dep], + link_with: [ldso_lib], + link_whole: libc_sublibs, + install: true) + shared_library('dl', 'libdl/src/dummy.cpp', install: true) + shared_library('m', 'libm/src/dummy.cpp', install: true) + shared_library('pthread', 'libpthread/src/dummy.cpp', install: true) + shared_library('rt', 'librt/src/dummy.cpp', install: true) + shared_library('util', 'libutil/src/dummy.cpp', install: true) +endif diff --git a/meson_options.txt b/meson_options.txt index 8b137891..f24e2f76 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1 @@ - +option('headers_only', type : 'boolean', value : false) diff --git a/options/ansi/meson.build b/options/ansi/meson.build index 1830a709..10730311 100644 --- a/options/ansi/meson.build +++ b/options/ansi/meson.build @@ -48,212 +48,213 @@ install_headers( subdir: 'bits/ansi' ) -libc_sublibs += static_library('mlibc-musl-math', - 'musl-generic-math/acos.c', - 'musl-generic-math/acosf.c', - 'musl-generic-math/acosh.c', - 'musl-generic-math/acoshf.c', - 'musl-generic-math/acoshl.c', - 'musl-generic-math/acosl.c', - 'musl-generic-math/asin.c', - 'musl-generic-math/asinf.c', - 'musl-generic-math/asinh.c', - 'musl-generic-math/asinhf.c', - 'musl-generic-math/asinhl.c', - 'musl-generic-math/asinl.c', - 'musl-generic-math/atan2.c', - 'musl-generic-math/atan2f.c', - 'musl-generic-math/atan2l.c', - 'musl-generic-math/atan.c', - 'musl-generic-math/atanf.c', - 'musl-generic-math/atanh.c', - 'musl-generic-math/atanhf.c', - 'musl-generic-math/atanhl.c', - 'musl-generic-math/atanl.c', - 'musl-generic-math/cbrt.c', - 'musl-generic-math/cbrtf.c', - 'musl-generic-math/cbrtl.c', - 'musl-generic-math/ceil.c', - 'musl-generic-math/ceilf.c', - 'musl-generic-math/ceill.c', - 'musl-generic-math/copysign.c', - 'musl-generic-math/copysignf.c', - 'musl-generic-math/copysignl.c', - 'musl-generic-math/__cos.c', - 'musl-generic-math/cos.c', - 'musl-generic-math/__cosdf.c', - 'musl-generic-math/cosf.c', - 'musl-generic-math/cosh.c', - 'musl-generic-math/coshf.c', - 'musl-generic-math/coshl.c', - 'musl-generic-math/__cosl.c', - 'musl-generic-math/cosl.c', - 'musl-generic-math/erf.c', - 'musl-generic-math/erff.c', - 'musl-generic-math/erfl.c', - 'musl-generic-math/exp10.c', - 'musl-generic-math/exp10f.c', - 'musl-generic-math/exp10l.c', - 'musl-generic-math/exp2.c', - 'musl-generic-math/exp2f.c', - 'musl-generic-math/exp2l.c', - 'musl-generic-math/exp.c', - 'musl-generic-math/expf.c', - 'musl-generic-math/expl.c', - 'musl-generic-math/expm1.c', - 'musl-generic-math/expm1f.c', - 'musl-generic-math/expm1l.c', - 'musl-generic-math/__expo2.c', - 'musl-generic-math/__expo2f.c', - 'musl-generic-math/fabs.c', - 'musl-generic-math/fabsf.c', - 'musl-generic-math/fabsl.c', - 'musl-generic-math/fdim.c', - 'musl-generic-math/fdimf.c', - 'musl-generic-math/fdiml.c', - 'musl-generic-math/finite.c', - 'musl-generic-math/finitef.c', - 'musl-generic-math/floor.c', - 'musl-generic-math/floorf.c', - 'musl-generic-math/floorl.c', - 'musl-generic-math/fma.c', - 'musl-generic-math/fmax.c', - 'musl-generic-math/fmaxf.c', - 'musl-generic-math/fmaxl.c', - 'musl-generic-math/fmin.c', - 'musl-generic-math/fminf.c', - 'musl-generic-math/fminl.c', - 'musl-generic-math/fmod.c', - 'musl-generic-math/fmodf.c', - 'musl-generic-math/fmodl.c', - 'musl-generic-math/__fpclassify.c', - 'musl-generic-math/__fpclassifyf.c', - 'musl-generic-math/__fpclassifyl.c', - 'musl-generic-math/frexp.c', - 'musl-generic-math/frexpf.c', - 'musl-generic-math/frexpl.c', - 'musl-generic-math/hypot.c', - 'musl-generic-math/hypotf.c', - 'musl-generic-math/hypotl.c', - 'musl-generic-math/ilogb.c', - 'musl-generic-math/ilogbf.c', - 'musl-generic-math/ilogbl.c', - 'musl-generic-math/__invtrigl.c', - 'musl-generic-math/j0.c', - 'musl-generic-math/j0f.c', - 'musl-generic-math/j1.c', - 'musl-generic-math/j1f.c', - 'musl-generic-math/jn.c', - 'musl-generic-math/jnf.c', - 'musl-generic-math/ldexp.c', - 'musl-generic-math/ldexpf.c', - 'musl-generic-math/ldexpl.c', - 'musl-generic-math/lgamma.c', - 'musl-generic-math/lgammaf.c', - 'musl-generic-math/lgammaf_r.c', - 'musl-generic-math/lgammal.c', - 'musl-generic-math/lgamma_r.c', - 'musl-generic-math/llrint.c', - 'musl-generic-math/llrintf.c', - 'musl-generic-math/llround.c', - 'musl-generic-math/llroundf.c', - 'musl-generic-math/llroundl.c', - 'musl-generic-math/log10.c', - 'musl-generic-math/log10f.c', - 'musl-generic-math/log10l.c', - 'musl-generic-math/log1p.c', - 'musl-generic-math/log1pf.c', - 'musl-generic-math/log1pl.c', - 'musl-generic-math/log2.c', - 'musl-generic-math/log2f.c', - 'musl-generic-math/log2l.c', - 'musl-generic-math/logb.c', - 'musl-generic-math/logbf.c', - 'musl-generic-math/logbl.c', - 'musl-generic-math/log.c', - 'musl-generic-math/logf.c', - 'musl-generic-math/logl.c', - 'musl-generic-math/lrintf.c', - 'musl-generic-math/lround.c', - 'musl-generic-math/lroundf.c', - 'musl-generic-math/lroundl.c', - 'musl-generic-math/modf.c', - 'musl-generic-math/modff.c', - 'musl-generic-math/modfl.c', - 'musl-generic-math/nan.c', - 'musl-generic-math/nanf.c', - 'musl-generic-math/nanl.c', - 'musl-generic-math/nextafter.c', - 'musl-generic-math/nextafterf.c', - 'musl-generic-math/nextafterl.c', - 'musl-generic-math/nexttoward.c', - 'musl-generic-math/nexttowardf.c', - 'musl-generic-math/nexttowardl.c', - 'musl-generic-math/__polevll.c', - 'musl-generic-math/pow.c', - 'musl-generic-math/powf.c', - 'musl-generic-math/powl.c', - 'musl-generic-math/remainder.c', - 'musl-generic-math/remainderf.c', - 'musl-generic-math/remainderl.c', - 'musl-generic-math/__rem_pio2.c', - 'musl-generic-math/__rem_pio2f.c', - 'musl-generic-math/__rem_pio2_large.c', - 'musl-generic-math/__rem_pio2l.c', - 'musl-generic-math/remquo.c', - 'musl-generic-math/remquof.c', - 'musl-generic-math/remquol.c', - 'musl-generic-math/rint.c', - 'musl-generic-math/rintf.c', - 'musl-generic-math/rintl.c', - 'musl-generic-math/round.c', - 'musl-generic-math/roundf.c', - 'musl-generic-math/roundl.c', - 'musl-generic-math/scalb.c', - 'musl-generic-math/scalbf.c', - 'musl-generic-math/scalbln.c', - 'musl-generic-math/scalblnf.c', - 'musl-generic-math/scalblnl.c', - 'musl-generic-math/scalbn.c', - 'musl-generic-math/scalbnf.c', - 'musl-generic-math/scalbnl.c', - 'musl-generic-math/__signbit.c', - 'musl-generic-math/__signbitf.c', - 'musl-generic-math/__signbitl.c', - 'musl-generic-math/signgam.c', - 'musl-generic-math/significand.c', - 'musl-generic-math/significandf.c', - 'musl-generic-math/__sin.c', - 'musl-generic-math/sin.c', - 'musl-generic-math/sincos.c', - 'musl-generic-math/sincosf.c', - 'musl-generic-math/sincosl.c', - 'musl-generic-math/__sindf.c', - 'musl-generic-math/sinf.c', - 'musl-generic-math/sinh.c', - 'musl-generic-math/sinhf.c', - 'musl-generic-math/sinhl.c', - 'musl-generic-math/__sinl.c', - 'musl-generic-math/sinl.c', - 'musl-generic-math/sqrt.c', - 'musl-generic-math/sqrtf.c', - 'musl-generic-math/sqrtl.c', - 'musl-generic-math/__tan.c', - 'musl-generic-math/tan.c', - 'musl-generic-math/__tandf.c', - 'musl-generic-math/tanf.c', - 'musl-generic-math/tanh.c', - 'musl-generic-math/tanhf.c', - 'musl-generic-math/tanhl.c', - 'musl-generic-math/__tanl.c', - 'musl-generic-math/tanl.c', - 'musl-generic-math/tgamma.c', - 'musl-generic-math/tgammaf.c', - 'musl-generic-math/tgammal.c', - 'musl-generic-math/trunc.c', - 'musl-generic-math/truncf.c', - 'musl-generic-math/truncl.c', - pic: true, - include_directories: libc_include_dirs, - c_args: ['-Wno-unused', '-Wno-implicit', '-Wno-parentheses']) - +if not headers_only + libc_sublibs += static_library('mlibc-musl-math', + 'musl-generic-math/acos.c', + 'musl-generic-math/acosf.c', + 'musl-generic-math/acosh.c', + 'musl-generic-math/acoshf.c', + 'musl-generic-math/acoshl.c', + 'musl-generic-math/acosl.c', + 'musl-generic-math/asin.c', + 'musl-generic-math/asinf.c', + 'musl-generic-math/asinh.c', + 'musl-generic-math/asinhf.c', + 'musl-generic-math/asinhl.c', + 'musl-generic-math/asinl.c', + 'musl-generic-math/atan2.c', + 'musl-generic-math/atan2f.c', + 'musl-generic-math/atan2l.c', + 'musl-generic-math/atan.c', + 'musl-generic-math/atanf.c', + 'musl-generic-math/atanh.c', + 'musl-generic-math/atanhf.c', + 'musl-generic-math/atanhl.c', + 'musl-generic-math/atanl.c', + 'musl-generic-math/cbrt.c', + 'musl-generic-math/cbrtf.c', + 'musl-generic-math/cbrtl.c', + 'musl-generic-math/ceil.c', + 'musl-generic-math/ceilf.c', + 'musl-generic-math/ceill.c', + 'musl-generic-math/copysign.c', + 'musl-generic-math/copysignf.c', + 'musl-generic-math/copysignl.c', + 'musl-generic-math/__cos.c', + 'musl-generic-math/cos.c', + 'musl-generic-math/__cosdf.c', + 'musl-generic-math/cosf.c', + 'musl-generic-math/cosh.c', + 'musl-generic-math/coshf.c', + 'musl-generic-math/coshl.c', + 'musl-generic-math/__cosl.c', + 'musl-generic-math/cosl.c', + 'musl-generic-math/erf.c', + 'musl-generic-math/erff.c', + 'musl-generic-math/erfl.c', + 'musl-generic-math/exp10.c', + 'musl-generic-math/exp10f.c', + 'musl-generic-math/exp10l.c', + 'musl-generic-math/exp2.c', + 'musl-generic-math/exp2f.c', + 'musl-generic-math/exp2l.c', + 'musl-generic-math/exp.c', + 'musl-generic-math/expf.c', + 'musl-generic-math/expl.c', + 'musl-generic-math/expm1.c', + 'musl-generic-math/expm1f.c', + 'musl-generic-math/expm1l.c', + 'musl-generic-math/__expo2.c', + 'musl-generic-math/__expo2f.c', + 'musl-generic-math/fabs.c', + 'musl-generic-math/fabsf.c', + 'musl-generic-math/fabsl.c', + 'musl-generic-math/fdim.c', + 'musl-generic-math/fdimf.c', + 'musl-generic-math/fdiml.c', + 'musl-generic-math/finite.c', + 'musl-generic-math/finitef.c', + 'musl-generic-math/floor.c', + 'musl-generic-math/floorf.c', + 'musl-generic-math/floorl.c', + 'musl-generic-math/fma.c', + 'musl-generic-math/fmax.c', + 'musl-generic-math/fmaxf.c', + 'musl-generic-math/fmaxl.c', + 'musl-generic-math/fmin.c', + 'musl-generic-math/fminf.c', + 'musl-generic-math/fminl.c', + 'musl-generic-math/fmod.c', + 'musl-generic-math/fmodf.c', + 'musl-generic-math/fmodl.c', + 'musl-generic-math/__fpclassify.c', + 'musl-generic-math/__fpclassifyf.c', + 'musl-generic-math/__fpclassifyl.c', + 'musl-generic-math/frexp.c', + 'musl-generic-math/frexpf.c', + 'musl-generic-math/frexpl.c', + 'musl-generic-math/hypot.c', + 'musl-generic-math/hypotf.c', + 'musl-generic-math/hypotl.c', + 'musl-generic-math/ilogb.c', + 'musl-generic-math/ilogbf.c', + 'musl-generic-math/ilogbl.c', + 'musl-generic-math/__invtrigl.c', + 'musl-generic-math/j0.c', + 'musl-generic-math/j0f.c', + 'musl-generic-math/j1.c', + 'musl-generic-math/j1f.c', + 'musl-generic-math/jn.c', + 'musl-generic-math/jnf.c', + 'musl-generic-math/ldexp.c', + 'musl-generic-math/ldexpf.c', + 'musl-generic-math/ldexpl.c', + 'musl-generic-math/lgamma.c', + 'musl-generic-math/lgammaf.c', + 'musl-generic-math/lgammaf_r.c', + 'musl-generic-math/lgammal.c', + 'musl-generic-math/lgamma_r.c', + 'musl-generic-math/llrint.c', + 'musl-generic-math/llrintf.c', + 'musl-generic-math/llround.c', + 'musl-generic-math/llroundf.c', + 'musl-generic-math/llroundl.c', + 'musl-generic-math/log10.c', + 'musl-generic-math/log10f.c', + 'musl-generic-math/log10l.c', + 'musl-generic-math/log1p.c', + 'musl-generic-math/log1pf.c', + 'musl-generic-math/log1pl.c', + 'musl-generic-math/log2.c', + 'musl-generic-math/log2f.c', + 'musl-generic-math/log2l.c', + 'musl-generic-math/logb.c', + 'musl-generic-math/logbf.c', + 'musl-generic-math/logbl.c', + 'musl-generic-math/log.c', + 'musl-generic-math/logf.c', + 'musl-generic-math/logl.c', + 'musl-generic-math/lrintf.c', + 'musl-generic-math/lround.c', + 'musl-generic-math/lroundf.c', + 'musl-generic-math/lroundl.c', + 'musl-generic-math/modf.c', + 'musl-generic-math/modff.c', + 'musl-generic-math/modfl.c', + 'musl-generic-math/nan.c', + 'musl-generic-math/nanf.c', + 'musl-generic-math/nanl.c', + 'musl-generic-math/nextafter.c', + 'musl-generic-math/nextafterf.c', + 'musl-generic-math/nextafterl.c', + 'musl-generic-math/nexttoward.c', + 'musl-generic-math/nexttowardf.c', + 'musl-generic-math/nexttowardl.c', + 'musl-generic-math/__polevll.c', + 'musl-generic-math/pow.c', + 'musl-generic-math/powf.c', + 'musl-generic-math/powl.c', + 'musl-generic-math/remainder.c', + 'musl-generic-math/remainderf.c', + 'musl-generic-math/remainderl.c', + 'musl-generic-math/__rem_pio2.c', + 'musl-generic-math/__rem_pio2f.c', + 'musl-generic-math/__rem_pio2_large.c', + 'musl-generic-math/__rem_pio2l.c', + 'musl-generic-math/remquo.c', + 'musl-generic-math/remquof.c', + 'musl-generic-math/remquol.c', + 'musl-generic-math/rint.c', + 'musl-generic-math/rintf.c', + 'musl-generic-math/rintl.c', + 'musl-generic-math/round.c', + 'musl-generic-math/roundf.c', + 'musl-generic-math/roundl.c', + 'musl-generic-math/scalb.c', + 'musl-generic-math/scalbf.c', + 'musl-generic-math/scalbln.c', + 'musl-generic-math/scalblnf.c', + 'musl-generic-math/scalblnl.c', + 'musl-generic-math/scalbn.c', + 'musl-generic-math/scalbnf.c', + 'musl-generic-math/scalbnl.c', + 'musl-generic-math/__signbit.c', + 'musl-generic-math/__signbitf.c', + 'musl-generic-math/__signbitl.c', + 'musl-generic-math/signgam.c', + 'musl-generic-math/significand.c', + 'musl-generic-math/significandf.c', + 'musl-generic-math/__sin.c', + 'musl-generic-math/sin.c', + 'musl-generic-math/sincos.c', + 'musl-generic-math/sincosf.c', + 'musl-generic-math/sincosl.c', + 'musl-generic-math/__sindf.c', + 'musl-generic-math/sinf.c', + 'musl-generic-math/sinh.c', + 'musl-generic-math/sinhf.c', + 'musl-generic-math/sinhl.c', + 'musl-generic-math/__sinl.c', + 'musl-generic-math/sinl.c', + 'musl-generic-math/sqrt.c', + 'musl-generic-math/sqrtf.c', + 'musl-generic-math/sqrtl.c', + 'musl-generic-math/__tan.c', + 'musl-generic-math/tan.c', + 'musl-generic-math/__tandf.c', + 'musl-generic-math/tanf.c', + 'musl-generic-math/tanh.c', + 'musl-generic-math/tanhf.c', + 'musl-generic-math/tanhl.c', + 'musl-generic-math/__tanl.c', + 'musl-generic-math/tanl.c', + 'musl-generic-math/tgamma.c', + 'musl-generic-math/tgammaf.c', + 'musl-generic-math/tgammal.c', + 'musl-generic-math/trunc.c', + 'musl-generic-math/truncf.c', + 'musl-generic-math/truncl.c', + pic: true, + include_directories: libc_include_dirs, + c_args: ['-Wno-unused', '-Wno-implicit', '-Wno-parentheses']) +endif diff --git a/sysdeps/managarm/meson.build b/sysdeps/managarm/meson.build index bd063539..7edc8625 100644 --- a/sysdeps/managarm/meson.build +++ b/sysdeps/managarm/meson.build @@ -52,12 +52,14 @@ install_headers( subdir: 'abi-bits' ) -custom_target('crt0', - build_by_default: true, - command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], - input: 'crt-src/crt0.S', - output: 'crt0.o', - install: true, - install_dir: get_option('libdir') -) +if not headers_only + custom_target('crt0', + build_by_default: true, + command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], + input: 'crt-src/crt0.S', + output: 'crt0.o', + install: true, + install_dir: get_option('libdir') + ) +endif diff --git a/sysdeps/qword/meson.build b/sysdeps/qword/meson.build index 70148361..c2c4a47f 100644 --- a/sysdeps/qword/meson.build +++ b/sysdeps/qword/meson.build @@ -14,12 +14,14 @@ install_headers( subdir: 'abi-bits' ) -custom_target('crt0', - build_by_default: true, - command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], - input: 'crt-x86_64/crt0.S', - output: 'crt0.o', - install: true, - install_dir: get_option('libdir') -) +if not headers_only + custom_target('crt0', + build_by_default: true, + command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], + input: 'crt-x86_64/crt0.S', + output: 'crt0.o', + install: true, + install_dir: get_option('libdir') + ) +endif