[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
176/376: Add support for using a build directory
From: |
Ludovic Courtès |
Subject: |
176/376: Add support for using a build directory |
Date: |
Wed, 28 Jan 2015 22:04:51 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 075cfe3b97bf0e90577bb7e842ba467524fad0ef
Author: Eelco Dolstra <address@hidden>
Date: Fri Sep 5 14:17:05 2014 +0200
Add support for using a build directory
---
functions.mk | 2 +-
lib.mk | 10 ++++++++++
libraries.mk | 4 ++--
patterns.mk | 9 ++++++---
programs.mk | 4 ++--
5 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/functions.mk b/functions.mk
index 45d9173..c48775d 100644
--- a/functions.mk
+++ b/functions.mk
@@ -10,5 +10,5 @@ filename-to-dep = $(dir $1).$(notdir $1).dep
# 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)
-# Remove trailing slash.
+# Ensure that the given string ends in a single slash.
add-trailing-slash = $(patsubst %/,%,$(1))/
diff --git a/lib.mk b/lib.mk
index 8b109e2..aa92d8d 100644
--- a/lib.mk
+++ b/lib.mk
@@ -25,6 +25,16 @@ sysconfdir ?= $(prefix)/etc
mandir ?= $(prefix)/share/man
+# Initialise support for build directories.
+builddir ?=
+
+ifdef builddir
+ buildprefix = $(builddir)/
+else
+ buildprefix =
+endif
+
+
# Pass -fPIC if we're building dynamic libraries.
BUILD_SHARED_LIBS ?= 1
diff --git a/libraries.mk b/libraries.mk
index 3b91c69..2064819 100644
--- a/libraries.mk
+++ b/libraries.mk
@@ -45,9 +45,9 @@ endif
# built, otherwise a static library.
define build-library
$(1)_NAME ?= $(1)
- _d := $$(strip $$($(1)_DIR))
+ _d := $(buildprefix)$$(strip $$($(1)_DIR))
_srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src)))
- $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
+ $(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename
$$(_srcs))))
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
$(1)_INSTALL_DIR ?= $$(libdir)
diff --git a/patterns.mk b/patterns.mk
index 6b2cfd0..3219d96 100644
--- a/patterns.mk
+++ b/patterns.mk
@@ -1,8 +1,11 @@
-%.o: %.cc
+$(buildprefix)%.o: %.cc
+ @mkdir -p "$(dir $@)"
$(trace-cxx) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS)
$(GLOBAL_CXXFLAGS_PCH) $(CXXFLAGS) $(address@hidden) -MMD -MF $(call
filename-to-dep, $@) -MP
-%.o: %.cpp
+$(buildprefix)%.o: %.cpp
+ @mkdir -p "$(dir $@)"
$(trace-cxx) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS)
$(GLOBAL_CXXFLAGS_PCH) $(CXXFLAGS) $(address@hidden) -MMD -MF $(call
filename-to-dep, $@) -MP
-%.o: %.c
+$(buildprefix)%.o: %.c
+ @mkdir -p "$(dir $@)"
$(trace-cc) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS)
$(address@hidden) -MMD -MF $(call filename-to-dep, $@) -MP
diff --git a/programs.mk b/programs.mk
index 72afdf9..3ac6449 100644
--- a/programs.mk
+++ b/programs.mk
@@ -23,9 +23,9 @@ programs-list :=
# - $(1)_INSTALL_DIR: the directory where the program will be
# installed; defaults to $(bindir).
define build-program
- _d := $$($(1)_DIR)
+ _d := $(buildprefix)$$($(1)_DIR)
_srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src)))
- $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
+ $(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename
$$(_srcs))))
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
$(1)_PATH := $$(_d)/$(1)
- 151/376: Use pager for more commands, (continued)
- 151/376: Use pager for more commands, Ludovic Courtès, 2015/01/28
- 153/376: Fix a segfault in ‘nix-env -qa’, Ludovic Courtès, 2015/01/28
- 164/376: allowedRequisites: Drop stdenv mention, Ludovic Courtès, 2015/01/28
- 160/376: Fix building with Clang, Ludovic Courtès, 2015/01/28
- 170/376: Fix dependency ordering, Ludovic Courtès, 2015/01/28
- 169/376: Hack for supporting Boost on Homebrew, Ludovic Courtès, 2015/01/28
- 166/376: Shut up "Wide character" warnings in Perl scripts, Ludovic Courtès, 2015/01/28
- 167/376: Add an 'optimiseStore' remote procedure call., Ludovic Courtès, 2015/01/28
- 171/376: Fix build-remote.pl, Ludovic Courtès, 2015/01/28
- 172/376: tests/remote-builds.nix: Time out faster, Ludovic Courtès, 2015/01/28
- 176/376: Add support for using a build directory,
Ludovic Courtès <=
- 178/376: Support specifying a JAR manifest, Ludovic Courtès, 2015/01/28
- 181/376: Add some hyperlinks between NIXPATH and -I, Ludovic Courtès, 2015/01/28
- 165/376: Add disallowedReferences / disallowedRequisites, Ludovic Courtès, 2015/01/28
- 173/376: Tweak, Ludovic Courtès, 2015/01/28
- 168/376: Fix boost::too_many_args error, Ludovic Courtès, 2015/01/28
- 174/376: build-remote.pl: UTF-8-decode errors, Ludovic Courtès, 2015/01/28
- 180/376: Don't rely on process substitution, Ludovic Courtès, 2015/01/28
- 177/376: Improved support for building JARs, Ludovic Courtès, 2015/01/28
- 187/376: Drop reference to FreeBSD, Ludovic Courtès, 2015/01/28
- 189/376: Tweak some chapter titles, Ludovic Courtès, 2015/01/28