From: Jeremy Kerr Date: Tue, 12 Oct 2021 06:42:28 +0000 (+0800) Subject: Unify configuration includes, use meson-generated configuration data X-Git-Tag: v1.0-rc0~86^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=71048b4a965934f12e800a7d1c4ed13252d5a103;p=users%2Fsagi%2Flibnvme.git Unify configuration includes, use meson-generated configuration data Currently, we have two separate configuration includes: ccan/config.h and config-host.h. The first is generated by the ccan configurator, the second by the configuration step (either ./configure, or meson). This change unifies these into a top-level config.h include. For the meson case, we can use the meson configuration file to provide all data. For the configure case, we still use the ccan configurator, but include the resulting file from the top-level config.h This allows us to cross-compile with meson. Signed-off-by: Jeremy Kerr --- diff --git a/configure b/configure index feb39caa..5e0e0420 100755 --- a/configure +++ b/configure @@ -76,16 +76,16 @@ exit 0 fi config_host_mak="config-host.mak" -config_host_h="config-host.h" +config_h="config.h" rm -rf $config_host_mak -rm -rf $config_host_h +rm -rf $config_h fatal() { echo $@ echo "Configure failed, check config.log and/or the above output" rm -rf $config_host_mak - rm -rf $config_host_h + rm -rf $config_h exit 1 } @@ -95,12 +95,12 @@ print_config() { } # Default CFLAGS -CFLAGS="-D_GNU_SOURCE -include config-host.h" +CFLAGS="-D_GNU_SOURCE -include config.h" BUILD_CFLAGS="" cmdstr=$(printf " '%s'" "$0" "$@") -# Print configure header at the top of $config_host_h -cat > $config_host_h < $config_h <> $config_host_h + echo "#define $1" >> $config_h } print_and_output_mak() { diff --git a/meson.build b/meson.build index b53ad4b8..c4092cd6 100644 --- a/meson.build +++ b/meson.build @@ -185,8 +185,8 @@ conf.set10( description: 'Is isblank() available?' ) -configure_file( - output: 'config-host.h', +config_h = configure_file( + output: 'config.h', configuration: conf ) @@ -214,12 +214,11 @@ pkg.generate( ) ################################################################################ -add_project_arguments('-include', 'config-host.h', language : 'c') +add_project_arguments('-include', 'config.h', language : 'c') add_global_arguments(['-fomit-frame-pointer', '-D_GNU_SOURCE'], language : 'c') -incdir = include_directories(['ccan', 'src']) +incdir = include_directories(['.', 'ccan', 'src']) ################################################################################ -subdir('ccan') subdir('src') subdir('pynvme') subdir('test') diff --git a/src/Makefile b/src/Makefile index 40744d42..0a8cee08 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,7 +12,7 @@ libdir ?= $(prefix)/lib CCANDIR=../ccan/ -CFLAGS ?= -g -fomit-frame-pointer -O2 -I/usr/include -Invme/ -I$(CCANDIR) -include ../config-host.h -D_GNU_SOURCE +CFLAGS ?= -g -fomit-frame-pointer -O2 -I/usr/include -Invme/ -I$(CCANDIR) -I.. -include ../config.h -D_GNU_SOURCE override CFLAGS += -Wall -fPIC SO_CFLAGS=-shared $(CFLAGS) L_CFLAGS=$(CFLAGS) @@ -36,15 +36,16 @@ include ../Makefile.quiet all: $(all_targets) -$(CCANDIR)config.h: $(CCANDIR)tools/configurator/configurator +$(CCANDIR)ccan-config.h: $(CCANDIR)tools/configurator/configurator $< > $@ +$(CCANDIR)tools/configurator/configurator: CFLAGS = -D_GNU_SOURCE libccan_headers := $(wildcard $(CCANDIR)ccan/*/*.h) libccan_srcs := $(wildcard $(CCANDIR)ccan/*/*.c) libccan_objs := $(patsubst %.c,%.ol,$(libccan_srcs)) libccan_sobjs := $(patsubst %.c,%.os,$(libccan_srcs)) -$(libccan_objs) $(libccan_sobjs): $(libccan_headers) $(CCANDIR)config.h +$(libccan_objs) $(libccan_sobjs): $(libccan_headers) $(CCANDIR)ccan-config.h libnvme_priv := nvme/private.h libnvme_api := libnvme.h nvme/types.h nvme/ioctl.h nvme/filters.h nvme/tree.h nvme/util.h nvme/fabrics.h nvme/log.h @@ -84,10 +85,10 @@ ifeq ($(ENABLE_SHARED),1) endif $(libnvme_objs): $(libnvme_api) $(libnvme_private) -$(libccan_objs): $(libccan_headers) $(CCANDIR)config.h +$(libccan_objs): $(libccan_headers) $(CCANDIR)ccan-config.h clean: rm -f $(all_targets) $(libnvme_objs) $(libnvme_sobjs) $(libccan_objs) $(libccan_sobjs) $(soname).new - rm -f $(CCANDIR)config.h + rm -f $(CCANDIR)ccan-config.h rm -f $(CCANDIR)tools/configurator/configurator rm -f *.so* *.a *.o