]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
Unify configuration includes, use meson-generated configuration data
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 12 Oct 2021 06:42:28 +0000 (14:42 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Tue, 12 Oct 2021 08:21:25 +0000 (16:21 +0800)
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 <jk@codeconstruct.com.au>
configure
meson.build
src/Makefile

index feb39caa4ce9756a3189924df8495dbfc7de70f5..5e0e042051d642b1c52c163d0a6a46db6f1a61b0 100755 (executable)
--- 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 <<EOF
+# Print configure header at the top of $config_h
+cat > $config_h <<EOF
 /*
  * Automatically generated by configure - do not modify
  * Configured with:
@@ -172,7 +172,7 @@ output_mak() {
 
 output_sym() {
   output_mak "$1" "y"
-  echo "#define $1" >> $config_host_h
+  echo "#define $1" >> $config_h
 }
 
 print_and_output_mak() {
index b53ad4b8d563decc50e33d73d6757ab7ac096509..c4092cd64fb7831a7fd00d0ee27f0b23a01cbd61 100644 (file)
@@ -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')
index 40744d4265aae524f580c24dcaa8c8a527e2991a..0a8cee0818d90a0abd8bdf1a4bb4cd79d004b4c0 100644 (file)
@@ -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