Allow for ergnomically putting Unix-only files in subdirs by creating INLCUDE_$(pkg) vars

Separate platform-specific files will allow avoiding a lot of CPP.
This commit is contained in:
John Ericson 2023-09-02 17:10:28 -04:00
parent 4a61827d2d
commit 77205b2042
14 changed files with 33 additions and 19 deletions

View file

@ -7,4 +7,4 @@ $(foreach i, config.h $(wildcard src/lib*/*.hh), \
$(GCH): src/libutil/util.hh config.h $(GCH): src/libutil/util.hh config.h
GCH_CXXFLAGS = -I src/libutil GCH_CXXFLAGS = $(INCLUDE_libutil)

View file

@ -6,7 +6,7 @@ libcmd_DIR := $(d)
libcmd_SOURCES := $(wildcard $(d)/*.cc) libcmd_SOURCES := $(wildcard $(d)/*.cc)
libcmd_CXXFLAGS += -I src/libutil -I src/libstore -I src/libexpr -I src/libmain -I src/libfetchers libcmd_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) $(INCLUDE_libfetchers) $(INCLUDE_libexpr) -I src/libmain
libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) $(THREAD_LDFLAGS) libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) $(THREAD_LDFLAGS)

View file

@ -11,8 +11,11 @@ libexpr_SOURCES := \
$(wildcard $(d)/flake/*.cc) \ $(wildcard $(d)/flake/*.cc) \
$(d)/lexer-tab.cc \ $(d)/lexer-tab.cc \
$(d)/parser-tab.cc $(d)/parser-tab.cc
# Not just for this library itself, but also for downstream libraries using this library
libexpr_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libmain -I src/libexpr INCLUDE_libexpr := -I $(d)
libexpr_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) $(INCLUDE_libfetchers) -I src/libmain $(INCLUDE_libexpr)
libexpr_LIBS = libutil libstore libfetchers libexpr_LIBS = libutil libstore libfetchers

View file

@ -6,7 +6,11 @@ libfetchers_DIR := $(d)
libfetchers_SOURCES := $(wildcard $(d)/*.cc) libfetchers_SOURCES := $(wildcard $(d)/*.cc)
libfetchers_CXXFLAGS += -I src/libutil -I src/libstore # Not just for this library itself, but also for downstream libraries using this library
INCLUDE_libfetchers := -I $(d)
libfetchers_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) $(INCLUDE_libfetchers)
libfetchers_LDFLAGS += $(THREAD_LDFLAGS) $(LIBGIT2_LIBS) -larchive libfetchers_LDFLAGS += $(THREAD_LDFLAGS) $(LIBGIT2_LIBS) -larchive

View file

@ -6,7 +6,7 @@ libmain_DIR := $(d)
libmain_SOURCES := $(wildcard $(d)/*.cc) libmain_SOURCES := $(wildcard $(d)/*.cc)
libmain_CXXFLAGS += -I src/libutil -I src/libstore libmain_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore)
libmain_LDFLAGS += $(OPENSSL_LIBS) libmain_LDFLAGS += $(OPENSSL_LIBS)

View file

@ -10,7 +10,7 @@ libstore_LIBS = libutil
libstore_LDFLAGS += $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(THREAD_LDFLAGS) libstore_LDFLAGS += $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(THREAD_LDFLAGS)
ifdef HOST_LINUX ifdef HOST_LINUX
libstore_LDFLAGS += -ldl libstore_LDFLAGS += -ldl
endif endif
$(foreach file,$(libstore_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/sandbox))) $(foreach file,$(libstore_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/sandbox)))
@ -27,8 +27,12 @@ ifeq ($(HAVE_SECCOMP), 1)
libstore_LDFLAGS += $(LIBSECCOMP_LIBS) libstore_LDFLAGS += $(LIBSECCOMP_LIBS)
endif endif
# Not just for this library itself, but also for downstream libraries using this library
INCLUDE_libstore := -I $(d) -I $(d)/build
libstore_CXXFLAGS += \ libstore_CXXFLAGS += \
-I src/libutil -I src/libstore -I src/libstore/build \ $(INCLUDE_libutil) $(INCLUDE_libstore) $(INCLUDE_libstore) \
-DNIX_PREFIX=\"$(prefix)\" \ -DNIX_PREFIX=\"$(prefix)\" \
-DNIX_STORE_DIR=\"$(storedir)\" \ -DNIX_STORE_DIR=\"$(storedir)\" \
-DNIX_DATA_DIR=\"$(datadir)\" \ -DNIX_DATA_DIR=\"$(datadir)\" \

View file

@ -6,7 +6,10 @@ libutil_DIR := $(d)
libutil_SOURCES := $(wildcard $(d)/*.cc $(d)/signature/*.cc) libutil_SOURCES := $(wildcard $(d)/*.cc $(d)/signature/*.cc)
libutil_CXXFLAGS += -I src/libutil # Not just for this library itself, but also for downstream libraries using this library
INCLUDE_libutil := -I $(d)
libutil_CXXFLAGS += $(INCLUDE_libutil)
libutil_LDFLAGS += $(THREAD_LDFLAGS) $(LIBCURL_LIBS) $(SODIUM_LIBS) $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(LIBARCHIVE_LIBS) $(BOOST_LDFLAGS) -lboost_context libutil_LDFLAGS += $(THREAD_LDFLAGS) $(LIBCURL_LIBS) $(SODIUM_LIBS) $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(LIBARCHIVE_LIBS) $(BOOST_LDFLAGS) -lboost_context

View file

@ -14,7 +14,7 @@ nix_SOURCES := \
$(wildcard src/nix-instantiate/*.cc) \ $(wildcard src/nix-instantiate/*.cc) \
$(wildcard src/nix-store/*.cc) \ $(wildcard src/nix-store/*.cc) \
nix_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libexpr -I src/libmain -I src/libcmd -I doc/manual nix_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) $(INCLUDE_libfetchers) $(INCLUDE_libexpr) -I src/libmain -I src/libcmd -I doc/manual
nix_LIBS = libexpr libmain libfetchers libstore libutil libcmd nix_LIBS = libexpr libmain libfetchers libstore libutil libcmd

View file

@ -6,7 +6,7 @@ resolve-system-dependencies_DIR := $(d)
resolve-system-dependencies_INSTALL_DIR := $(libexecdir)/nix resolve-system-dependencies_INSTALL_DIR := $(libexecdir)/nix
resolve-system-dependencies_CXXFLAGS += -I src/libutil -I src/libstore -I src/libmain resolve-system-dependencies_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore) -I src/libmain
resolve-system-dependencies_LIBS := libstore libmain libutil resolve-system-dependencies_LIBS := libstore libmain libutil

View file

@ -8,4 +8,4 @@ libplugintest_ALLOW_UNDEFINED := 1
libplugintest_EXCLUDE_FROM_LIBRARY_LIST := 1 libplugintest_EXCLUDE_FROM_LIBRARY_LIST := 1
libplugintest_CXXFLAGS := -I src/libutil -I src/libstore -I src/libexpr -I src/libfetchers libplugintest_CXXFLAGS := $(INCLUDE_libutil) $(INCLUDE_libstore) $(INCLUDE_libexpr) $(INCLUDE_libfetchers)

View file

@ -8,7 +8,7 @@ test-libstoreconsumer_INSTALL_DIR :=
test-libstoreconsumer_SOURCES := \ test-libstoreconsumer_SOURCES := \
$(wildcard $(d)/*.cc) \ $(wildcard $(d)/*.cc) \
test-libstoreconsumer_CXXFLAGS += -I src/libutil -I src/libstore test-libstoreconsumer_CXXFLAGS += $(INCLUDE_libutil) $(INCLUDE_libstore)
test-libstoreconsumer_LIBS = libstore libutil test-libstoreconsumer_LIBS = libstore libutil

View file

@ -23,10 +23,10 @@ libexpr-tests_EXTRA_INCLUDES = \
-I tests/unit/libexpr-support \ -I tests/unit/libexpr-support \
-I tests/unit/libstore-support \ -I tests/unit/libstore-support \
-I tests/unit/libutil-support \ -I tests/unit/libutil-support \
-I src/libexpr \ $(INCLUDE_libexpr) \
-I src/libfetchers \ $(INCLUDE_libfetchers) \
-I src/libstore \ $(INCLUDE_libstore) \
-I src/libutil $(INCLUDE_libutil)
libexpr-tests_CXXFLAGS += $(libexpr-tests_EXTRA_INCLUDES) libexpr-tests_CXXFLAGS += $(libexpr-tests_EXTRA_INCLUDES)

View file

@ -19,8 +19,8 @@ libstore-tests_SOURCES := $(wildcard $(d)/*.cc)
libstore-tests_EXTRA_INCLUDES = \ libstore-tests_EXTRA_INCLUDES = \
-I tests/unit/libstore-support \ -I tests/unit/libstore-support \
-I tests/unit/libutil-support \ -I tests/unit/libutil-support \
-I src/libstore \ $(INCLUDE_libstore) \
-I src/libutil $(INCLUDE_libutil)
libstore-tests_CXXFLAGS += $(libstore-tests_EXTRA_INCLUDES) libstore-tests_CXXFLAGS += $(libstore-tests_EXTRA_INCLUDES)

View file

@ -18,7 +18,7 @@ libutil-tests_SOURCES := $(wildcard $(d)/*.cc)
libutil-tests_EXTRA_INCLUDES = \ libutil-tests_EXTRA_INCLUDES = \
-I tests/unit/libutil-support \ -I tests/unit/libutil-support \
-I src/libutil $(INCLUDE_libutil)
libutil-tests_CXXFLAGS += $(libutil-tests_EXTRA_INCLUDES) libutil-tests_CXXFLAGS += $(libutil-tests_EXTRA_INCLUDES)