From 0cfd73304764c3e78f190f03bb02749dbf1b0a38 Mon Sep 17 00:00:00 2001 From: Daniel Olivier Date: Mon, 3 Jul 2017 08:21:52 -0400 Subject: [PATCH 1/2] Implement out-of-source gmake build New variables are TOP (location of root makefile) and $(1)_RELDIR, the relative path to the source file (which is used as the relative output path) --- .gitignore | 73 ++++-------------------- Makefile | 61 ++++++++++---------- doc/manual/local.mk | 23 ++++++-- local.mk | 12 +++- mk/functions.mk | 3 + mk/jars.mk | 3 + mk/lib.mk | 53 +++++++++++------ mk/libraries.mk | 24 ++++++-- mk/patterns.mk | 2 +- mk/programs.mk | 9 ++- src/boost/format/local.mk | 1 + src/build-remote/local.mk | 1 + src/buildenv/local.mk | 1 + src/libexpr/local.mk | 19 +++--- src/libmain/local.mk | 1 + src/libstore/local.mk | 1 + src/libutil/local.mk | 1 + src/nix-build/local.mk | 1 + src/nix-channel/local.mk | 1 + src/nix-collect-garbage/local.mk | 1 + src/nix-copy-closure/local.mk | 1 + src/nix-daemon/local.mk | 1 + src/nix-env/local.mk | 1 + src/nix-instantiate/local.mk | 1 + src/nix-prefetch-url/local.mk | 1 + src/nix-store/local.mk | 1 + src/nix/local.mk | 3 +- src/nix/repl.cc | 2 +- src/resolve-system-dependencies/local.mk | 1 + 29 files changed, 166 insertions(+), 137 deletions(-) diff --git a/.gitignore b/.gitignore index 6163087384d..206708cd072 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ Makefile.config -perl/Makefile.config +#perl/Makefile.config # / /aclocal.m4 @@ -13,16 +13,6 @@ perl/Makefile.config /corepkgs/config.nix -# /corepkgs/buildenv/ -/corepkgs/buildenv/builder.pl - -# /corepkgs/channels/ -/corepkgs/channels/unpack.sh - -# /corepkgs/nar/ -/corepkgs/nar/nar.sh -/corepkgs/nar/unnar.sh - # /doc/manual/ /doc/manual/manual.html /doc/manual/manual.xmli @@ -45,42 +35,11 @@ perl/Makefile.config /src/libexpr/parser-tab.cc /src/libexpr/parser-tab.hh /src/libexpr/parser-tab.output -/src/libexpr/nix.tbl +#/src/libexpr/nix.tbl # /src/libstore/ /src/libstore/*.gen.hh -/src/nix/nix - -# /src/nix-env/ -/src/nix-env/nix-env - -# /src/nix-instantiate/ -/src/nix-instantiate/nix-instantiate - -# /src/nix-store/ -/src/nix-store/nix-store - -/src/nix-prefetch-url/nix-prefetch-url - -# /src/nix-daemon/ -/src/nix-daemon/nix-daemon - -/src/nix-collect-garbage/nix-collect-garbage - -# /src/nix-channel/ -/src/nix-channel/nix-channel - -# /src/buildenv/ -/src/buildenv/buildenv - -# /src/nix-build/ -/src/nix-build/nix-build - -/src/nix-copy-closure/nix-copy-closure - -/src/build-remote/build-remote - # /tests/ /tests/test-tmp /tests/common.sh @@ -88,30 +47,22 @@ perl/Makefile.config /tests/result* # /tests/lang/ -/tests/lang/*.out -/tests/lang/*.out.xml -/tests/lang/*.ast +#/tests/lang/*.out +#/tests/lang/*.out.xml +#/tests/lang/*.ast -/perl/lib/Nix/Config.pm +#/perl/lib/Nix/Config.pm /perl/lib/Nix/Store.cc /misc/systemd/nix-daemon.service /misc/systemd/nix-daemon.socket /misc/upstart/nix-daemon.conf -inst/ - -*.a -*.o -*.so -*.dll -*.exe -*.dep -*~ *.pc -# GNU Global -GPATH -GRTAGS -GSYMS -GTAGS +/build*/ +/tmp.* +/lang/ +/logs/ + +tmp.*/ diff --git a/Makefile b/Makefile index 40ac4e72dbc..86ac52fd5b8 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,36 @@ -makefiles = \ - local.mk \ - src/boost/format/local.mk \ - src/libutil/local.mk \ - src/libstore/local.mk \ - src/libmain/local.mk \ - src/libexpr/local.mk \ - src/nix/local.mk \ - src/nix-store/local.mk \ - src/nix-instantiate/local.mk \ - src/nix-env/local.mk \ - src/nix-daemon/local.mk \ - src/nix-collect-garbage/local.mk \ - src/nix-copy-closure/local.mk \ - src/nix-prefetch-url/local.mk \ - src/buildenv/local.mk \ - src/resolve-system-dependencies/local.mk \ - src/nix-channel/local.mk \ - src/nix-build/local.mk \ - src/build-remote/local.mk \ - scripts/local.mk \ - corepkgs/local.mk \ - misc/systemd/local.mk \ - misc/launchd/local.mk \ - misc/upstart/local.mk \ - misc/emacs/local.mk \ - doc/manual/local.mk \ - tests/local.mk +TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + +makefiles += local.mk +makefiles += src/boost/format/local.mk +makefiles += src/libutil/local.mk +makefiles += src/libstore/local.mk +makefiles += src/libmain/local.mk +makefiles += src/libexpr/local.mk +makefiles += src/nix/local.mk +makefiles += src/nix-store/local.mk +makefiles += src/nix-instantiate/local.mk +makefiles += src/nix-env/local.mk +makefiles += src/nix-daemon/local.mk +makefiles += src/nix-collect-garbage/local.mk +makefiles += src/nix-copy-closure/local.mk +makefiles += src/nix-prefetch-url/local.mk +makefiles += src/buildenv/local.mk +makefiles += src/resolve-system-dependencies/local.mk +makefiles += src/nix-channel/local.mk +makefiles += src/nix-build/local.mk +makefiles += src/build-remote/local.mk +makefiles += scripts/local.mk +makefiles += corepkgs/local.mk +makefiles += misc/systemd/local.mk +makefiles += misc/launchd/local.mk +makefiles += misc/upstart/local.mk +makefiles += misc/emacs/local.mk +makefiles += doc/manual/local.mk +makefiles += tests/local.mk GLOBAL_CXXFLAGS += -std=c++14 -g -Wall -include config.h --include Makefile.config +-include $(TOP)/Makefile.config OPTIMIZE = 1 @@ -38,4 +39,4 @@ ifeq ($(OPTIMIZE), 1) GLOBAL_CXXFLAGS += -O3 endif -include mk/lib.mk +include $(TOP)/mk/lib.mk diff --git a/doc/manual/local.mk b/doc/manual/local.mk index 4376c3644d3..d7af44d5c27 100644 --- a/doc/manual/local.mk +++ b/doc/manual/local.mk @@ -1,7 +1,11 @@ ifeq ($(doc_generate),yes) -XSLTPROC = $(xsltproc) --nonet $(xmlflags) \ +NONET ?= 0 +NONET_FLAGS_1 = --nonet +NONET_FLAGS = $(NONET_FLAGS_$(NONET)) + +XSLTPROC = $(xsltproc) $(NONET_flag) $(xmlflags) \ --param section.autolabel 1 \ --param section.label.includes.component.label 1 \ --param html.stylesheet \'style.css\' \ @@ -13,15 +17,24 @@ XSLTPROC = $(xsltproc) --nonet $(xmlflags) \ --stringparam generate.toc "book toc" \ --param keep.relative.image.uris 0 -docbookxsl = http://docbook.sourceforge.net/release/xsl-ns/current -docbookrng = http://docbook.org/xml/5.0/rng/docbook.rng +ifeq ($(NONET),0) + docbookxsl = /usr/share/xml/docbook/stylesheet/docbook-xsl + docbookrng = $(docbookxsl)/slides/schema/relaxng/docbook.rng + profile_xsl= $(docbookxsl)/profiling/profile.xsl + docbook_xsl= $(docbookxsl)/manpages/profile-docbook.xsl +else + docbookrng = "http://docbook.org/xml/5.0/rng/docbook.rng" + docbookxsl = "http://docbook.sourceforge.net/release/xsl-ns/current" + profile_xsl= $(docbookxsl)/profiling/profile.xsl + docbook_xsl= $(docbookxsl)/manpages/docbook.xsl +endif MANUAL_SRCS := $(call rwildcard, $(d), *.xml) # Do XInclude processing / RelaxNG validation $(d)/manual.xmli: $(d)/manual.xml $(MANUAL_SRCS) $(d)/version.txt - $(trace-gen) $(xmllint) --nonet --xinclude $< -o $@.tmp + $(trace-gen) $(xmllint) $(NONET_FLAGS) --xinclude $< -o $@.tmp @mv $@.tmp $@ $(d)/version.txt: @@ -31,7 +44,7 @@ $(d)/version.txt: $(d)/manual.is-valid: $(d)/manual.xmli $(trace-gen) $(XSLTPROC) --novalid --stringparam profile.condition manual \ $(docbookxsl)/profiling/profile.xsl $< 2> /dev/null | \ - $(xmllint) --nonet --noout --relaxng $(docbookrng) - + $(xmllint) $(NONET_FLAGS) --noout --relaxng $(docbookrng) - @touch $@ clean-files += $(d)/manual.xmli $(d)/version.txt $(d)/manual.is-valid diff --git a/local.mk b/local.mk index 0a225423741..31320ee198f 100644 --- a/local.mk +++ b/local.mk @@ -3,13 +3,19 @@ ifeq ($(MAKECMDGOALS), dist) dist-files += $(shell git --git-dir=.git ls-files || find * -type f) endif -dist-files += configure config.h.in nix.spec perl/configure +dist-files += configure $(TOP)/config.h.in nix.spec perl/configure clean-files += Makefile.config -GLOBAL_CXXFLAGS += -I . -I src -I src/libutil -I src/libstore -I src/libmain -I src/libexpr +GLOBAL_CXXFLAGS += -I $(TOP)/. +GLOBAL_CXXFLAGS += -I $(TOP)/src +GLOBAL_CXXFLAGS += -I $(TOP)/src/libutil +GLOBAL_CXXFLAGS += -I $(TOP)/src/libstore +GLOBAL_CXXFLAGS += -I $(TOP)/src/libmain +GLOBAL_CXXFLAGS += -I $(TOP)/src/libexpr $(foreach i, config.h $(call rwildcard, src/lib*, *.hh), \ $(eval $(call install-file-in, $(i), $(includedir)/nix, 0644))) -$(foreach i, $(call rwildcard, src/boost, *.hpp), $(eval $(call install-file-in, $(i), $(includedir)/nix/$(patsubst src/%/,%,$(dir $(i))), 0644))) +$(foreach i, $(call rwildcard, src/boost, *.hpp), \ + $(eval $(call install-file-in, $(i), $(includedir)/nix/$(patsubst src/%/,%,$(dir $(i))), 0644))) diff --git a/mk/functions.mk b/mk/functions.mk index c48775db8c3..eadb24b4c08 100644 --- a/mk/functions.mk +++ b/mk/functions.mk @@ -6,6 +6,9 @@ rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst # (e.g. ‘foo/bar.o’ becomes ‘foo/.bar.o.dep’). filename-to-dep = $(dir $1).$(notdir $1).dep +src-to-obj = $(addsuffix .o,/$(notdir $(basename $1))) +srcs-to-objs = $(sort $(foreach src,$1,$(call src-to-obj,$(src)))) + # Return the full path to a program by looking it up in $PATH, or the # empty string if not found. find-program = $(shell for i in $$(IFS=: ; echo $$PATH); do p=$$i/$(strip $1); if [ -e $$p ]; then echo $$p; break; fi; done) diff --git a/mk/jars.mk b/mk/jars.mk index c8513e664ed..b52b409a7c4 100644 --- a/mk/jars.mk +++ b/mk/jars.mk @@ -10,6 +10,8 @@ define build-jar _jars := $$(foreach jar, $$($(1)_JARS), $$($$(jar)_PATH)) + .PHONY: $(1) + $(1) : $$($(1)_PATH) $$($(1)_PATH): $$($(1)_SOURCES) $$(_jars) $$($(1)_EXTRA_DEPS)| $$($(1)_ORDER_AFTER) @rm -rf $$($(1)_TMPDIR) @mkdir -p $$($(1)_TMPDIR) @@ -29,6 +31,7 @@ define build-jar install: $$($(1)_INSTALL_PATH) + jars-list-no_path += $(1) jars-list += $$($(1)_PATH) clean-files += $$($(1)_PATH) diff --git a/mk/lib.mk b/mk/lib.mk index 1da51d87973..7b46880b28b 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -42,7 +42,7 @@ mandir ?= $(prefix)/share/man builddir ?= ifdef builddir - buildprefix = $(builddir)/ + buildprefix = $(builddir) else buildprefix = endif @@ -79,30 +79,47 @@ ifeq ($(BUILD_DEBUG), 1) endif -include mk/functions.mk -include mk/tracing.mk -include mk/clean.mk -include mk/install.mk -include mk/libraries.mk -include mk/programs.mk -include mk/jars.mk -include mk/patterns.mk -include mk/templates.mk -include mk/tests.mk +include $(TOP)/mk/functions.mk +include $(TOP)/mk/tracing.mk +include $(TOP)/mk/clean.mk +include $(TOP)/mk/install.mk +include $(TOP)/mk/libraries.mk +include $(TOP)/mk/programs.mk +include $(TOP)/mk/jars.mk +include $(TOP)/mk/patterns.mk +include $(TOP)/mk/templates.mk +include $(TOP)/mk/tests.mk # Include all sub-Makefiles. define include-sub-makefile - d := $$(patsubst %/,%,$$(dir $(1))) - include $(1) +d := $$(patsubst %/,%,$(TOP)/$$(dir $(1))) +reldir := $$(patsubst %/,%,$$(dir $(1))) +$(1)_DIR := $(d) +$(1)_RELDIR := $(reldir) +include $(TOP)/$(1) +undefine d +undefine reldir endef -$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile, $(mf)))) +$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile,$(mf)))) +define print-target-vars +$(1)_NAME = $($(1)_NAME) +$(1)_DIR = $($(1)_DIR) +$(1)_RELDIR = $($(1)_RELDIR) +$(1)_OUT = $($(1)_OUT) +$(1)_OBJS = $($(1)_OBJS) + +endef # Instantiate stuff. $(foreach lib, $(libraries), $(eval $(call build-library,$(lib)))) +#$(foreach lib, $(libraries), $(info $(call print-target-vars,$(lib)))) + $(foreach prog, $(programs), $(eval $(call build-program,$(prog)))) +#$(foreach prog, $(programs), $(info $(call print-target-vars,$(prog)))) + $(foreach jar, $(jars), $(eval $(call build-jar,$(jar)))) $(foreach script, $(bin-scripts), $(eval $(call install-program-in,$(script),$(bindir)))) $(foreach script, $(bin-scripts), $(eval programs-list += $(script))) @@ -112,7 +129,7 @@ $(foreach test, $(install-tests), $(eval $(call run-install-test,$(test)))) $(foreach file, $(man-pages), $(eval $(call install-data-in, $(file), $(mandir)/man$(patsubst .%,%,$(suffix $(file)))))) -include mk/dist.mk +include $(TOP)/mk/dist.mk .PHONY: default all man help @@ -134,19 +151,19 @@ ifdef programs-list @echo "" @echo "The following programs can be built:" @echo "" - @for i in $(programs-list); do echo " $$i"; done + @for i in $(programs-list-no-path); do echo " $$i"; done endif ifdef libs-list @echo "" @echo "The following libraries can be built:" @echo "" - @for i in $(libs-list); do echo " $$i"; done + @for i in $(libs-list-no-path); do echo " $$i"; done endif ifdef jars-list @echo "" @echo "The following JARs can be built:" @echo "" - @for i in $(jars-list); do echo " $$i"; done + @for i in $(jars-list-no-path); do echo " $$i"; done endif @echo "" @echo "The following variables control the build:" diff --git a/mk/libraries.mk b/mk/libraries.mk index 3cd7a53107b..74ed4c5344e 100644 --- a/mk/libraries.mk +++ b/mk/libraries.mk @@ -1,4 +1,5 @@ libs-list := +libs-list-no-path := ifeq ($(OS), Darwin) SO_EXT = dylib @@ -49,9 +50,10 @@ endif # built, otherwise a static library. define build-library $(1)_NAME ?= $(1) - _d := $(buildprefix)$$(strip $$($(1)_DIR)) - _srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src))) - $(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs)))) + _d := $$(buildprefix)$$($(1)_RELDIR) + $(1)_OUT := $$(_d)/ + _objs := $$(foreach src, $$($(1)_SOURCES),$$(call src-to-obj,$$(src))) + $(1)_OBJS := $$(addprefix $$(_d),$$(_objs)) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) ifeq (CYGWIN,$(findstring CYGWIN,$(OS))) @@ -86,7 +88,13 @@ define build-library $(1)_PATH := $$(_d)/$$($(1)_NAME).$(SO_EXT) $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/ - $$(trace-ld) $(CXX) -o $$(abspath $$@) -shared $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $$($(1)_LDFLAGS_UNINSTALLED) + $$(trace-ld) $(CXX) -o $$(abspath $$@) \ + -shared $$(GLOBAL_LDFLAGS) \ + $$($(1)_OBJS) \ + $$($(1)_LDFLAGS) \ + $$($(1)_LDFLAGS_PROPAGATED) \ + $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) \ + $$($(1)_LDFLAGS_UNINSTALLED) ifneq ($(OS), Darwin) $(1)_LDFLAGS_USE += -Wl,-rpath,$$(abspath $$(_d)) @@ -100,7 +108,12 @@ define build-library $$(eval $$(call create-dir, $$($(1)_INSTALL_DIR))) $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)/ - $$(trace-ld) $(CXX) -o $$@ -shared $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED)) + $$(trace-ld) $(CXX) -o $$@ \ + -shared $$(GLOBAL_LDFLAGS) \ + $$($(1)_OBJS) \ + $$($(1)_LDFLAGS) \ + $$($(1)_LDFLAGS_PROPAGATED) \ + $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED)) $(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME))) ifneq ($(OS), Darwin) @@ -149,6 +162,7 @@ define build-library $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) -include $$($(1)_DEPS) + libs-list-no-path += $(1) libs-list += $$($(1)_PATH) clean-files += $$(_d)/*.a $$(_d)/*.$(SO_EXT) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS) dist-files += $$(_srcs) diff --git a/mk/patterns.mk b/mk/patterns.mk index 3219d9629fb..b64f520c96a 100644 --- a/mk/patterns.mk +++ b/mk/patterns.mk @@ -8,4 +8,4 @@ $(buildprefix)%.o: %.cpp $(buildprefix)%.o: %.c @mkdir -p "$(dir $@)" - $(trace-cc) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP + $(trace-cc) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP diff --git a/mk/programs.mk b/mk/programs.mk index 3ac64494e3a..5b8d6656859 100644 --- a/mk/programs.mk +++ b/mk/programs.mk @@ -1,4 +1,5 @@ programs-list := +programs-list-no-path := # Build a program with symbolic name $(1). The program is defined by # various variables prefixed by ‘$(1)_’: @@ -23,9 +24,10 @@ programs-list := # - $(1)_INSTALL_DIR: the directory where the program will be # installed; defaults to $(bindir). define build-program - _d := $(buildprefix)$$($(1)_DIR) - _srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src))) - $(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs)))) + _d := $$(buildprefix)$$($(1)_RELDIR) + $(1)_OUT := $$(_d)/ + _objs := $$(foreach src, $$($(1)_SOURCES), $$(call src-to-obj,$$(src))) + $(1)_OBJS := $$(addprefix $$(_d), $$(_objs)) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) $(1)_PATH := $$(_d)/$(1) @@ -73,6 +75,7 @@ define build-program $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) -include $$($(1)_DEPS) + programs-list-no-path += $(1) programs-list += $$($(1)_PATH) clean-files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS) dist-files += $$(_srcs) diff --git a/src/boost/format/local.mk b/src/boost/format/local.mk index 3776eff382f..9b11071c14e 100644 --- a/src/boost/format/local.mk +++ b/src/boost/format/local.mk @@ -3,5 +3,6 @@ libraries += libformat libformat_NAME = libnixformat libformat_DIR := $(d) +libformat_RELDIR := $(reldir) libformat_SOURCES := $(wildcard $(d)/*.cc) diff --git a/src/build-remote/local.mk b/src/build-remote/local.mk index 64368a43ff7..06fee782689 100644 --- a/src/build-remote/local.mk +++ b/src/build-remote/local.mk @@ -1,6 +1,7 @@ programs += build-remote build-remote_DIR := $(d) +build-remote_RELDIR := $(reldir) build-remote_INSTALL_DIR := $(libexecdir)/nix diff --git a/src/buildenv/local.mk b/src/buildenv/local.mk index 17ec13b235f..809f75cab9e 100644 --- a/src/buildenv/local.mk +++ b/src/buildenv/local.mk @@ -1,6 +1,7 @@ programs += buildenv buildenv_DIR := $(d) +buildenv_RELDIR := $(reldir) buildenv_INSTALL_DIR := $(libexecdir)/nix diff --git a/src/libexpr/local.mk b/src/libexpr/local.mk index daa3258f0d3..fc1b7dc7e40 100644 --- a/src/libexpr/local.mk +++ b/src/libexpr/local.mk @@ -3,8 +3,9 @@ libraries += libexpr libexpr_NAME = libnixexpr libexpr_DIR := $(d) +libexpr_RELDIR := $(reldir) -libexpr_SOURCES := $(wildcard $(d)/*.cc) $(wildcard $(d)/primops/*.cc) $(d)/lexer-tab.cc $(d)/parser-tab.cc +libexpr_SOURCES := $(wildcard $(libexpr_DIR)/*.cc) $(wildcard $(libexpr_DIR)/primops/*.cc) $(libexpr_DIR)/lexer-tab.cc $(libexpr_DIR)/parser-tab.cc libexpr_LIBS = libutil libstore libformat @@ -18,16 +19,16 @@ endif # because inline functions in libexpr's header files call libgc. libexpr_LDFLAGS_PROPAGATED = $(BDW_GC_LIBS) -libexpr_ORDER_AFTER := $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh +libexpr_ORDER_AFTER := $(addprefix $(libexpr_DIR)/,parser-tab.cc parser-tab.hh lexer-tab.cc lexer-tab.hh) -$(d)/parser-tab.cc $(d)/parser-tab.hh: $(d)/parser.y - $(trace-gen) bison -v -o $(libexpr_DIR)/parser-tab.cc $< -d +$(libexpr_DIR)/parser-tab.cc $(libexpr_DIR)/parser-tab.hh: $(libexpr_DIR)/parser.y + $(trace-gen) cd $(libexpr_DIR) && bison -o parser-tab.cc $< -d -$(d)/lexer-tab.cc $(d)/lexer-tab.hh: $(d)/lexer.l - $(trace-gen) flex --outfile $(libexpr_DIR)/lexer-tab.cc --header-file=$(libexpr_DIR)/lexer-tab.hh $< +$(libexpr_DIR)/lexer-tab.cc $(libexpr_DIR)/lexer-tab.hh: $(libexpr_DIR)/lexer.l + $(trace-gen) cd $(libexpr_DIR)/ && flex --outfile lexer-tab.cc --header-file=lexer-tab.hh $< -clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh +clean-files += $(addprefix $(libexpr_DIR)/,parser-tab.cc parser-tab.hh lexer-tab.cc lexer-tab.hh) -dist-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh +dist-files += $(addprefix $(libexpr_DIR)/,parser-tab.cc parser-tab.hh lexer-tab.cc lexer-tab.hh) -$(eval $(call install-file-in, $(d)/nix-expr.pc, $(prefix)/lib/pkgconfig, 0644)) +$(eval $(call install-file-in, $(libexpr_DIR)/nix-expr.pc, $(prefix)/lib/pkgconfig, 0644)) diff --git a/src/libmain/local.mk b/src/libmain/local.mk index f1fd3eb7242..fe7e76b83fa 100644 --- a/src/libmain/local.mk +++ b/src/libmain/local.mk @@ -3,6 +3,7 @@ libraries += libmain libmain_NAME = libnixmain libmain_DIR := $(d) +libmain_RELDIR := $(reldir) libmain_SOURCES := $(wildcard $(d)/*.cc) diff --git a/src/libstore/local.mk b/src/libstore/local.mk index 36b270f2e07..ce1b878b6a8 100644 --- a/src/libstore/local.mk +++ b/src/libstore/local.mk @@ -3,6 +3,7 @@ libraries += libstore libstore_NAME = libnixstore libstore_DIR := $(d) +libstore_RELDIR := $(reldir) libstore_SOURCES := $(wildcard $(d)/*.cc) diff --git a/src/libutil/local.mk b/src/libutil/local.mk index 0721b21c208..1136d0850e1 100644 --- a/src/libutil/local.mk +++ b/src/libutil/local.mk @@ -3,6 +3,7 @@ libraries += libutil libutil_NAME = libnixutil libutil_DIR := $(d) +libutil_RELDIR := $(reldir) libutil_SOURCES := $(wildcard $(d)/*.cc) diff --git a/src/nix-build/local.mk b/src/nix-build/local.mk index 91532411a50..9e162ed0da5 100644 --- a/src/nix-build/local.mk +++ b/src/nix-build/local.mk @@ -1,6 +1,7 @@ programs += nix-build nix-build_DIR := $(d) +nix-build_RELDIR := $(reldir) nix-build_SOURCES := $(d)/nix-build.cc diff --git a/src/nix-channel/local.mk b/src/nix-channel/local.mk index 49fc105c6f7..06c7e18fd9c 100644 --- a/src/nix-channel/local.mk +++ b/src/nix-channel/local.mk @@ -1,6 +1,7 @@ programs += nix-channel nix-channel_DIR := $(d) +nix-channel_RELDIR := $(reldir) nix-channel_LIBS = libmain libutil libformat libstore diff --git a/src/nix-collect-garbage/local.mk b/src/nix-collect-garbage/local.mk index 02d14cf6219..57d14d5fe73 100644 --- a/src/nix-collect-garbage/local.mk +++ b/src/nix-collect-garbage/local.mk @@ -1,6 +1,7 @@ programs += nix-collect-garbage nix-collect-garbage_DIR := $(d) +nix-collect-garbage_RELDIR := $(reldir) nix-collect-garbage_SOURCES := $(d)/nix-collect-garbage.cc diff --git a/src/nix-copy-closure/local.mk b/src/nix-copy-closure/local.mk index 42bb34dd820..dacaa0dee06 100644 --- a/src/nix-copy-closure/local.mk +++ b/src/nix-copy-closure/local.mk @@ -1,6 +1,7 @@ programs += nix-copy-closure nix-copy-closure_DIR := $(d) +nix-copy-closure_RELDIR := $(reldir) nix-copy-closure_LIBS = libmain libutil libformat libstore diff --git a/src/nix-daemon/local.mk b/src/nix-daemon/local.mk index 5a4474465b3..18db1046147 100644 --- a/src/nix-daemon/local.mk +++ b/src/nix-daemon/local.mk @@ -1,6 +1,7 @@ programs += nix-daemon nix-daemon_DIR := $(d) +nix-daemon_RELDIR := $(reldir) nix-daemon_SOURCES := $(d)/nix-daemon.cc diff --git a/src/nix-env/local.mk b/src/nix-env/local.mk index e80719cd76f..6f055469694 100644 --- a/src/nix-env/local.mk +++ b/src/nix-env/local.mk @@ -1,6 +1,7 @@ programs += nix-env nix-env_DIR := $(d) +nix-env_RELDIR := $(reldir) nix-env_SOURCES := $(wildcard $(d)/*.cc) diff --git a/src/nix-instantiate/local.mk b/src/nix-instantiate/local.mk index 7d1bc5ec9df..33e5ab33628 100644 --- a/src/nix-instantiate/local.mk +++ b/src/nix-instantiate/local.mk @@ -1,6 +1,7 @@ programs += nix-instantiate nix-instantiate_DIR := $(d) +nix-instantiate_RELDIR := $(reldir) nix-instantiate_SOURCES := $(d)/nix-instantiate.cc diff --git a/src/nix-prefetch-url/local.mk b/src/nix-prefetch-url/local.mk index 3e7735406af..98967f7a568 100644 --- a/src/nix-prefetch-url/local.mk +++ b/src/nix-prefetch-url/local.mk @@ -1,6 +1,7 @@ programs += nix-prefetch-url nix-prefetch-url_DIR := $(d) +nix-prefetch-url_RELDIR := $(reldir) nix-prefetch-url_SOURCES := $(d)/nix-prefetch-url.cc diff --git a/src/nix-store/local.mk b/src/nix-store/local.mk index ade0b233adf..07a2fd03a71 100644 --- a/src/nix-store/local.mk +++ b/src/nix-store/local.mk @@ -1,6 +1,7 @@ programs += nix-store nix-store_DIR := $(d) +nix-store_RELDIR := $(reldir) nix-store_SOURCES := $(wildcard $(d)/*.cc) diff --git a/src/nix/local.mk b/src/nix/local.mk index c7d2d328aab..30d50744101 100644 --- a/src/nix/local.mk +++ b/src/nix/local.mk @@ -1,8 +1,9 @@ programs += nix nix_DIR := $(d) +nix_RELDIR := $(reldir) -nix_SOURCES := $(wildcard $(d)/*.cc) src/linenoise/linenoise.c +nix_SOURCES := $(wildcard $(d)/*.cc) $(TOP)/src/linenoise/linenoise.c nix_LIBS = libexpr libmain libstore libutil libformat diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 437c7903ed4..328b64f606f 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -15,7 +15,7 @@ #include "command.hh" #include "finally.hh" -#include "src/linenoise/linenoise.h" +#include "linenoise/linenoise.h" namespace nix { diff --git a/src/resolve-system-dependencies/local.mk b/src/resolve-system-dependencies/local.mk index 8792a4a252f..0410622c066 100644 --- a/src/resolve-system-dependencies/local.mk +++ b/src/resolve-system-dependencies/local.mk @@ -3,6 +3,7 @@ ifeq ($(OS), Darwin) endif resolve-system-dependencies_DIR := $(d) +resolve-system-dependencies_RELDIR := $(reldir) resolve-system-dependencies_INSTALL_DIR := $(libexecdir)/nix From 76f17fd665c214d01942aa357020d2672f670347 Mon Sep 17 00:00:00 2001 From: Daniel Olivier Date: Mon, 3 Jul 2017 11:53:02 -0400 Subject: [PATCH 2/2] Fix many more bugs - Find source files from TOP with vpath directives - $(1)_SOURCES now refers to files relative to their own directory (reldir) - Fix collection of sources with wildcard function - sort function must be used for source lists with possible duplicates (generated files in source tree) - .ONESHELL is global and if the 1st command in a rule starts with @, then the following lines will not be echoed either - Fix documentation - Fix install stage --- Makefile | 6 +++- doc/manual/local.mk | 37 ++++++++++++++---------- local.mk | 7 +++-- mk/functions.mk | 3 +- mk/lib.mk | 5 ++-- mk/libraries.mk | 4 +-- mk/patterns.mk | 5 ++++ mk/programs.mk | 2 +- perl/local.mk | 2 +- src/boost/format/local.mk | 2 +- src/build-remote/local.mk | 2 +- src/buildenv/local.mk | 2 +- src/libexpr/local.mk | 6 +++- src/libmain/local.mk | 2 +- src/libstore/local.mk | 2 +- src/libutil/local.mk | 2 +- src/nix-build/local.mk | 2 +- src/nix-channel/local.mk | 2 +- src/nix-collect-garbage/local.mk | 2 +- src/nix-copy-closure/local.mk | 2 +- src/nix-daemon/local.mk | 2 +- src/nix-env/local.mk | 2 +- src/nix-instantiate/local.mk | 2 +- src/nix-prefetch-url/local.mk | 2 +- src/nix-store/local.mk | 2 +- src/nix/local.mk | 3 +- src/resolve-system-dependencies/local.mk | 2 +- 27 files changed, 66 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index 86ac52fd5b8..e3c82cfa127 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,11 @@ makefiles += misc/emacs/local.mk makefiles += doc/manual/local.mk makefiles += tests/local.mk -GLOBAL_CXXFLAGS += -std=c++14 -g -Wall -include config.h +GLOBAL_CXXFLAGS += -std=c++14 -Wall -include config.h +ifeq ($(BUILD_DEBUG), 1) + GLOBAL_CXXFLAGS += -g +endif + -include $(TOP)/Makefile.config diff --git a/doc/manual/local.mk b/doc/manual/local.mk index d7af44d5c27..9b10aa6e281 100644 --- a/doc/manual/local.mk +++ b/doc/manual/local.mk @@ -31,26 +31,30 @@ endif MANUAL_SRCS := $(call rwildcard, $(d), *.xml) +# save $(d) for use *inside* rules +doc_manual_DIR := $(d) +doc_manual_OUT := $(buildprefix)$(reldir) # Do XInclude processing / RelaxNG validation -$(d)/manual.xmli: $(d)/manual.xml $(MANUAL_SRCS) $(d)/version.txt - $(trace-gen) $(xmllint) $(NONET_FLAGS) --xinclude $< -o $@.tmp +$(doc_manual_OUT)/manual.xmli: $(d)/manual.xml $(MANUAL_SRCS) $(d)/version.txt + @echo reldir=$(doc_manual_OUT) + @mkdir -p $(doc_manual_OUT) + $(trace-gen) (cd $(doc_manual_DIR) && $(xmllint) $(NONET_FLAGS) --xinclude manual.xml) > $@.tmp @mv $@.tmp $@ $(d)/version.txt: $(trace-gen) echo -n $(PACKAGE_VERSION) > $@ # Note: RelaxNG validation requires xmllint >= 2.7.4. -$(d)/manual.is-valid: $(d)/manual.xmli +$(doc_manual_OUT)/manual.is-valid: $(doc_manual_OUT)/manual.xmli $(trace-gen) $(XSLTPROC) --novalid --stringparam profile.condition manual \ $(docbookxsl)/profiling/profile.xsl $< 2> /dev/null | \ $(xmllint) $(NONET_FLAGS) --noout --relaxng $(docbookrng) - @touch $@ -clean-files += $(d)/manual.xmli $(d)/version.txt $(d)/manual.is-valid - -dist-files += $(d)/manual.xmli $(d)/version.txt $(d)/manual.is-valid +clean-files += $(doc_manual_OUT)/manual.xmli version.txt $(doc_manual_OUT)/manual.is-valid +dist-files += $(doc_manual_OUT)/manual.xmli version.txt $(doc_manual_OUT)/manual.is-valid # Generate man pages. man-pages := $(foreach n, \ @@ -59,42 +63,43 @@ man-pages := $(foreach n, \ nix-prefetch-url.1 nix-channel.1 \ nix-hash.1 nix-copy-closure.1 \ nix.conf.5 nix-daemon.8, \ - $(d)/$(n)) + $(doc_manual_OUT)/$(n)) -$(firstword $(man-pages)): $(d)/manual.xmli $(d)/manual.is-valid +$(firstword $(man-pages)): $(doc_manual_OUT)/manual.xmli $(doc_manual_OUT)/manual.is-valid + @mkdir -p $(doc_manual_OUT) $(trace-gen) $(XSLTPROC) --novalid --stringparam profile.condition manpage \ $(docbookxsl)/profiling/profile.xsl $< 2> /dev/null | \ - (cd doc/manual && $(XSLTPROC) $(docbookxsl)/manpages/docbook.xsl -) + (cd $(doc_manual_OUT) && $(XSLTPROC) $(docbookxsl)/manpages/docbook.xsl -) $(wordlist 2, $(words $(man-pages)), $(man-pages)): $(firstword $(man-pages)) -clean-files += $(d)/*.1 $(d)/*.5 $(d)/*.8 +clean-files += $(doc_manual_OUT)/*.1 $(doc_manual_OUT)/*.5 $(doc_manual_OUT)/*.8 dist-files += $(man-pages) # Generate the HTML manual. -$(d)/manual.html: $(d)/manual.xml $(MANUAL_SRCS) $(d)/manual.is-valid +$(doc_manual_OUT)/manual.html: $(d)/manual.xml $(MANUAL_SRCS) $(doc_manual_OUT)/manual.is-valid $(trace-gen) $(XSLTPROC) --xinclude --stringparam profile.condition manual \ $(docbookxsl)/profiling/profile.xsl $< | \ $(XSLTPROC) --output $@ $(docbookxsl)/xhtml/docbook.xsl - -$(foreach file, $(d)/manual.html $(d)/style.css, $(eval $(call install-data-in, $(file), $(docdir)/manual))) +$(foreach file, $(doc_manual_OUT)/manual.html $(d)/style.css, $(eval $(call install-data-in, $(file), $(docdir)/manual))) $(foreach file, $(wildcard $(d)/figures/*.png), $(eval $(call install-data-in, $(file), $(docdir)/manual/figures))) $(foreach file, $(wildcard $(d)/images/callouts/*.gif), $(eval $(call install-data-in, $(file), $(docdir)/manual/images/callouts))) -$(eval $(call install-symlink, manual.html, $(docdir)/manual/index.html)) +$(eval $(call install-symlink, $(doc_manual_OUT)/manual.html, $(docdir)/manual/index.html)) -all: $(d)/manual.html +all: $(doc_manual_OUT)/manual.html -clean-files += $(d)/manual.html +clean-files += $(doc_manual_OUT)/manual.html -dist-files += $(d)/manual.html +dist-files += $(doc_manual_OUT)/manual.html endif diff --git a/local.mk b/local.mk index 31320ee198f..587a0d68f40 100644 --- a/local.mk +++ b/local.mk @@ -14,8 +14,9 @@ GLOBAL_CXXFLAGS += -I $(TOP)/src/libstore GLOBAL_CXXFLAGS += -I $(TOP)/src/libmain GLOBAL_CXXFLAGS += -I $(TOP)/src/libexpr -$(foreach i, config.h $(call rwildcard, src/lib*, *.hh), \ +$(foreach i, config.h $(call rwildcard, $(TOP)/src/lib*, *.hh), \ $(eval $(call install-file-in, $(i), $(includedir)/nix, 0644))) -$(foreach i, $(call rwildcard, src/boost, *.hpp), \ - $(eval $(call install-file-in, $(i), $(includedir)/nix/$(patsubst src/%/,%,$(dir $(i))), 0644))) +$(foreach i, $(call rwildcard, $(TOP)/src/boost, *.hpp), \ + $(eval $(call install-file-in, $(i), \ + $(includedir)/nix/$(subst $(TOP)/src,,$(dir $(i))), 0644))) diff --git a/mk/functions.mk b/mk/functions.mk index eadb24b4c08..7040ee9d75d 100644 --- a/mk/functions.mk +++ b/mk/functions.mk @@ -6,7 +6,8 @@ rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst # (e.g. ‘foo/bar.o’ becomes ‘foo/.bar.o.dep’). filename-to-dep = $(dir $1).$(notdir $1).dep -src-to-obj = $(addsuffix .o,/$(notdir $(basename $1))) +# src-to-obj doesn't use $(notdir ...), to preserve relative directory prefix +src-to-obj = $(addsuffix .o,/$(basename $1)) srcs-to-objs = $(sort $(foreach src,$1,$(call src-to-obj,$(src)))) # Return the full path to a program by looking it up in $PATH, or the diff --git a/mk/lib.mk b/mk/lib.mk index 7b46880b28b..75c333d28dd 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -47,7 +47,6 @@ else buildprefix = endif - # Pass -fPIC if we're building dynamic libraries. BUILD_SHARED_LIBS ?= 1 @@ -95,8 +94,8 @@ include $(TOP)/mk/tests.mk define include-sub-makefile d := $$(patsubst %/,%,$(TOP)/$$(dir $(1))) reldir := $$(patsubst %/,%,$$(dir $(1))) -$(1)_DIR := $(d) -$(1)_RELDIR := $(reldir) +#$(1)_DIR := $(d) +#$(1)_RELDIR := $(reldir) include $(TOP)/$(1) undefine d undefine reldir diff --git a/mk/libraries.mk b/mk/libraries.mk index 74ed4c5344e..c1ef7b6bfb4 100644 --- a/mk/libraries.mk +++ b/mk/libraries.mk @@ -52,7 +52,7 @@ define build-library $(1)_NAME ?= $(1) _d := $$(buildprefix)$$($(1)_RELDIR) $(1)_OUT := $$(_d)/ - _objs := $$(foreach src, $$($(1)_SOURCES),$$(call src-to-obj,$$(src))) + _objs := $$(call srcs-to-objs,$$($(1)_SOURCES)) $(1)_OBJS := $$(addprefix $$(_d),$$(_objs)) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) @@ -88,7 +88,7 @@ define build-library $(1)_PATH := $$(_d)/$$($(1)_NAME).$(SO_EXT) $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/ - $$(trace-ld) $(CXX) -o $$(abspath $$@) \ + $$(trace-ld) $(CXX) -o $$@ \ -shared $$(GLOBAL_LDFLAGS) \ $$($(1)_OBJS) \ $$($(1)_LDFLAGS) \ diff --git a/mk/patterns.mk b/mk/patterns.mk index b64f520c96a..32bcb8ecdd8 100644 --- a/mk/patterns.mk +++ b/mk/patterns.mk @@ -1,3 +1,8 @@ +vpath +vpath %.cc $(TOP) +vpath %.cpp $(TOP) +vpath %.c $(TOP) + $(buildprefix)%.o: %.cc @mkdir -p "$(dir $@)" $(trace-cxx) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(GLOBAL_CXXFLAGS_PCH) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP diff --git a/mk/programs.mk b/mk/programs.mk index 5b8d6656859..3bf35fa6bcc 100644 --- a/mk/programs.mk +++ b/mk/programs.mk @@ -26,7 +26,7 @@ programs-list-no-path := define build-program _d := $$(buildprefix)$$($(1)_RELDIR) $(1)_OUT := $$(_d)/ - _objs := $$(foreach src, $$($(1)_SOURCES), $$(call src-to-obj,$$(src))) + _objs := $$(call srcs-to-objs,$$($(1)_SOURCES)) $(1)_OBJS := $$(addprefix $$(_d), $$(_objs)) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) $(1)_PATH := $$(_d)/$(1) diff --git a/perl/local.mk b/perl/local.mk index b13d4c0d639..f6e4478ddae 100644 --- a/perl/local.mk +++ b/perl/local.mk @@ -17,7 +17,7 @@ libraries += Store Store_DIR := lib/Nix -Store_SOURCES := $(Store_DIR)/Store.cc +Store_SOURCES := Store.cc Store_CXXFLAGS = \ $(NIX_CFLAGS) \ diff --git a/src/boost/format/local.mk b/src/boost/format/local.mk index 9b11071c14e..db4c8412a51 100644 --- a/src/boost/format/local.mk +++ b/src/boost/format/local.mk @@ -5,4 +5,4 @@ libformat_NAME = libnixformat libformat_DIR := $(d) libformat_RELDIR := $(reldir) -libformat_SOURCES := $(wildcard $(d)/*.cc) +libformat_SOURCES := $(subst $(d)/,,$(wildcard $(d)/*.cc)) diff --git a/src/build-remote/local.mk b/src/build-remote/local.mk index 06fee782689..fa5171bd65d 100644 --- a/src/build-remote/local.mk +++ b/src/build-remote/local.mk @@ -7,4 +7,4 @@ build-remote_INSTALL_DIR := $(libexecdir)/nix build-remote_LIBS = libmain libutil libformat libstore -build-remote_SOURCES := $(d)/build-remote.cc +build-remote_SOURCES := build-remote.cc diff --git a/src/buildenv/local.mk b/src/buildenv/local.mk index 809f75cab9e..2a410103a4d 100644 --- a/src/buildenv/local.mk +++ b/src/buildenv/local.mk @@ -7,4 +7,4 @@ buildenv_INSTALL_DIR := $(libexecdir)/nix buildenv_LIBS = libmain libstore libutil libformat -buildenv_SOURCES := $(d)/buildenv.cc +buildenv_SOURCES := buildenv.cc diff --git a/src/libexpr/local.mk b/src/libexpr/local.mk index fc1b7dc7e40..5f7fe6cd321 100644 --- a/src/libexpr/local.mk +++ b/src/libexpr/local.mk @@ -5,7 +5,11 @@ libexpr_NAME = libnixexpr libexpr_DIR := $(d) libexpr_RELDIR := $(reldir) -libexpr_SOURCES := $(wildcard $(libexpr_DIR)/*.cc) $(wildcard $(libexpr_DIR)/primops/*.cc) $(libexpr_DIR)/lexer-tab.cc $(libexpr_DIR)/parser-tab.cc +srcs = $(subst $(d)/,,$(wildcard $(d)/*.cc)) +srcs += $(subst $(d)/,,$(wildcard $(d)/primops/*.cc)) +srcs += lexer-tab.cc +srcs += parser-tab.cc +libexpr_SOURCES := $(sort $(srcs)) # remove possible duplicate libexpr_LIBS = libutil libstore libformat diff --git a/src/libmain/local.mk b/src/libmain/local.mk index fe7e76b83fa..0f7f0425e67 100644 --- a/src/libmain/local.mk +++ b/src/libmain/local.mk @@ -5,7 +5,7 @@ libmain_NAME = libnixmain libmain_DIR := $(d) libmain_RELDIR := $(reldir) -libmain_SOURCES := $(wildcard $(d)/*.cc) +libmain_SOURCES := $(subst $(d)/,,$(wildcard $(d)/*.cc)) libmain_LDFLAGS = $(OPENSSL_LIBS) diff --git a/src/libstore/local.mk b/src/libstore/local.mk index ce1b878b6a8..86576b7b8db 100644 --- a/src/libstore/local.mk +++ b/src/libstore/local.mk @@ -5,7 +5,7 @@ libstore_NAME = libnixstore libstore_DIR := $(d) libstore_RELDIR := $(reldir) -libstore_SOURCES := $(wildcard $(d)/*.cc) +libstore_SOURCES := $(subst $(d)/,,$(wildcard $(d)/*.cc)) libstore_LIBS = libutil libformat diff --git a/src/libutil/local.mk b/src/libutil/local.mk index 1136d0850e1..eddfd1eeb0e 100644 --- a/src/libutil/local.mk +++ b/src/libutil/local.mk @@ -5,7 +5,7 @@ libutil_NAME = libnixutil libutil_DIR := $(d) libutil_RELDIR := $(reldir) -libutil_SOURCES := $(wildcard $(d)/*.cc) +libutil_SOURCES := $(subst $(d)/,,$(wildcard $(d)/*.cc)) libutil_LDFLAGS = $(LIBLZMA_LIBS) -lbz2 -pthread $(OPENSSL_LIBS) diff --git a/src/nix-build/local.mk b/src/nix-build/local.mk index 9e162ed0da5..ba2ad48d215 100644 --- a/src/nix-build/local.mk +++ b/src/nix-build/local.mk @@ -3,7 +3,7 @@ programs += nix-build nix-build_DIR := $(d) nix-build_RELDIR := $(reldir) -nix-build_SOURCES := $(d)/nix-build.cc +nix-build_SOURCES := nix-build.cc nix-build_LIBS = libmain libstore libutil libformat diff --git a/src/nix-channel/local.mk b/src/nix-channel/local.mk index 06c7e18fd9c..06e882e2e76 100644 --- a/src/nix-channel/local.mk +++ b/src/nix-channel/local.mk @@ -5,4 +5,4 @@ nix-channel_RELDIR := $(reldir) nix-channel_LIBS = libmain libutil libformat libstore -nix-channel_SOURCES := $(d)/nix-channel.cc +nix-channel_SOURCES := nix-channel.cc diff --git a/src/nix-collect-garbage/local.mk b/src/nix-collect-garbage/local.mk index 57d14d5fe73..b243e3971ae 100644 --- a/src/nix-collect-garbage/local.mk +++ b/src/nix-collect-garbage/local.mk @@ -3,6 +3,6 @@ programs += nix-collect-garbage nix-collect-garbage_DIR := $(d) nix-collect-garbage_RELDIR := $(reldir) -nix-collect-garbage_SOURCES := $(d)/nix-collect-garbage.cc +nix-collect-garbage_SOURCES := nix-collect-garbage.cc nix-collect-garbage_LIBS = libmain libstore libutil libformat diff --git a/src/nix-copy-closure/local.mk b/src/nix-copy-closure/local.mk index dacaa0dee06..d26260a76cc 100644 --- a/src/nix-copy-closure/local.mk +++ b/src/nix-copy-closure/local.mk @@ -5,4 +5,4 @@ nix-copy-closure_RELDIR := $(reldir) nix-copy-closure_LIBS = libmain libutil libformat libstore -nix-copy-closure_SOURCES := $(d)/nix-copy-closure.cc +nix-copy-closure_SOURCES := nix-copy-closure.cc diff --git a/src/nix-daemon/local.mk b/src/nix-daemon/local.mk index 18db1046147..199f8317f25 100644 --- a/src/nix-daemon/local.mk +++ b/src/nix-daemon/local.mk @@ -3,7 +3,7 @@ programs += nix-daemon nix-daemon_DIR := $(d) nix-daemon_RELDIR := $(reldir) -nix-daemon_SOURCES := $(d)/nix-daemon.cc +nix-daemon_SOURCES := nix-daemon.cc nix-daemon_LIBS = libmain libstore libutil libformat diff --git a/src/nix-env/local.mk b/src/nix-env/local.mk index 6f055469694..794e2781eac 100644 --- a/src/nix-env/local.mk +++ b/src/nix-env/local.mk @@ -3,6 +3,6 @@ programs += nix-env nix-env_DIR := $(d) nix-env_RELDIR := $(reldir) -nix-env_SOURCES := $(wildcard $(d)/*.cc) +nix-env_SOURCES := $(subst $(d)/,,$(wildcard $(d)/*.cc)) nix-env_LIBS = libexpr libmain libstore libutil libformat diff --git a/src/nix-instantiate/local.mk b/src/nix-instantiate/local.mk index 33e5ab33628..5a63b51d6d9 100644 --- a/src/nix-instantiate/local.mk +++ b/src/nix-instantiate/local.mk @@ -3,6 +3,6 @@ programs += nix-instantiate nix-instantiate_DIR := $(d) nix-instantiate_RELDIR := $(reldir) -nix-instantiate_SOURCES := $(d)/nix-instantiate.cc +nix-instantiate_SOURCES := nix-instantiate.cc nix-instantiate_LIBS = libexpr libmain libstore libutil libformat diff --git a/src/nix-prefetch-url/local.mk b/src/nix-prefetch-url/local.mk index 98967f7a568..137962fbc67 100644 --- a/src/nix-prefetch-url/local.mk +++ b/src/nix-prefetch-url/local.mk @@ -3,6 +3,6 @@ programs += nix-prefetch-url nix-prefetch-url_DIR := $(d) nix-prefetch-url_RELDIR := $(reldir) -nix-prefetch-url_SOURCES := $(d)/nix-prefetch-url.cc +nix-prefetch-url_SOURCES := nix-prefetch-url.cc nix-prefetch-url_LIBS = libmain libexpr libstore libutil libformat diff --git a/src/nix-store/local.mk b/src/nix-store/local.mk index 07a2fd03a71..fedd4a15c13 100644 --- a/src/nix-store/local.mk +++ b/src/nix-store/local.mk @@ -3,7 +3,7 @@ programs += nix-store nix-store_DIR := $(d) nix-store_RELDIR := $(reldir) -nix-store_SOURCES := $(wildcard $(d)/*.cc) +nix-store_SOURCES := $(subst $(d)/,,$(wildcard $(d)/*.cc)) nix-store_LIBS = libmain libstore libutil libformat diff --git a/src/nix/local.mk b/src/nix/local.mk index 30d50744101..539ffb6788d 100644 --- a/src/nix/local.mk +++ b/src/nix/local.mk @@ -3,7 +3,8 @@ programs += nix nix_DIR := $(d) nix_RELDIR := $(reldir) -nix_SOURCES := $(wildcard $(d)/*.cc) $(TOP)/src/linenoise/linenoise.c +nix_SOURCES := $(subst $(d)/,,$(wildcard $(d)/*.cc)) +nix_SOURCES += ../linenoise/linenoise.c nix_LIBS = libexpr libmain libstore libutil libformat diff --git a/src/resolve-system-dependencies/local.mk b/src/resolve-system-dependencies/local.mk index 0410622c066..d27c953cdc2 100644 --- a/src/resolve-system-dependencies/local.mk +++ b/src/resolve-system-dependencies/local.mk @@ -9,4 +9,4 @@ resolve-system-dependencies_INSTALL_DIR := $(libexecdir)/nix resolve-system-dependencies_LIBS := libstore libmain libutil libformat -resolve-system-dependencies_SOURCES := $(d)/resolve-system-dependencies.cc +resolve-system-dependencies_SOURCES := resolve-system-dependencies.cc