Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gmake out-of-source #1439

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 12 additions & 61 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Makefile.config
perl/Makefile.config
#perl/Makefile.config

# /
/aclocal.m4
Expand All @@ -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
Expand All @@ -45,73 +35,34 @@ 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
/tests/dummy
/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.*/
67 changes: 36 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
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))))

GLOBAL_CXXFLAGS += -std=c++14 -g -Wall -include config.h
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

-include Makefile.config
GLOBAL_CXXFLAGS += -std=c++14 -Wall -include config.h
ifeq ($(BUILD_DEBUG), 1)
GLOBAL_CXXFLAGS += -g
endif


-include $(TOP)/Makefile.config

OPTIMIZE = 1

Expand All @@ -38,4 +43,4 @@ ifeq ($(OPTIMIZE), 1)
GLOBAL_CXXFLAGS += -O3
endif

include mk/lib.mk
include $(TOP)/mk/lib.mk
58 changes: 38 additions & 20 deletions doc/manual/local.mk
Original file line number Diff line number Diff line change
@@ -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\' \
Expand All @@ -13,31 +17,44 @@ 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)

# 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 --xinclude $< -o [email protected]
$(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) > [email protected]
@mv [email protected] $@

$(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 --noout --relaxng $(docbookrng) -
$(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, \
Expand All @@ -46,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
15 changes: 11 additions & 4 deletions local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ 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), \
$(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)))
4 changes: 4 additions & 0 deletions mk/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ 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 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
# 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)
Expand Down
3 changes: 3 additions & 0 deletions mk/jars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -29,6 +31,7 @@ define build-jar

install: $$($(1)_INSTALL_PATH)

jars-list-no_path += $(1)
jars-list += $$($(1)_PATH)

clean-files += $$($(1)_PATH)
Expand Down
Loading