Rename $(here) to $(d) for brevity, and remove trailing slash

This commit is contained in:
Eelco Dolstra 2013-11-22 16:45:52 +00:00
parent 9a14d5e2f3
commit 754c05ed6c
12 changed files with 49 additions and 39 deletions

View File

@ -1,3 +1,15 @@
default: all
# Include all sub-Makefiles.
define include_sub_makefile =
d := $$(patsubst %/, %, $$(dir $(1)))
include $(1)
endef
$(foreach mf, $(SUBS), $(eval $(call include_sub_makefile, $(mf))))
# Include Autoconf variables.
Makefile.config: Makefile.config.in
./config.status
@ -22,10 +34,10 @@ libs_list :=
define LIBS_template =
_d := $$($(1)_DIR)
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(src))
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src))
_objs := $$(addsuffix .o, $$(basename $$(_srcs)))
_libs := $$(foreach lib, $$($(1)_LIBS), $$(lib).a)
_lib := $$(_d)$(1).a
_lib := $$(_d)/$(1).a
$$(_lib): $$(_objs)
$(QUIET) ar crs $$@ $$?
@ -36,7 +48,7 @@ define LIBS_template =
include $$(wildcard $$(_d)/*.dep)
libs_list += $$(_lib)
clean_list += $$(_d)*.a $$(_d)*.o $$(_d)*.dep
clean_list += $$(_d)/*.a $$(_d)/*.o $$(_d)/*.dep
dist_files += $$(_srcs)
endef
@ -48,10 +60,10 @@ programs_list :=
define PROGRAMS_template =
_d := $$($(1)_DIR)
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(src))
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src))
_objs := $$(addsuffix .o, $$(basename $$(_srcs)))
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_DIR)$$(lib).a)
_prog := $$(_d)$(1)
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_DIR)/$$(lib).a)
_prog := $$(_d)/$(1)
$$(_prog): $$(_objs) $$(_libs)
$(QUIET) g++ -o $$@ $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS))
@ -62,7 +74,7 @@ define PROGRAMS_template =
include $$(wildcard $$(_d)/*.dep)
programs_list += $$(_prog)
clean_list += $$(_prog) $$(_d)*.o $$(_d)*.dep
clean_list += $$(_prog) $$(_d)/*.o $$(_d)/*.dep
dist_files += $$(_srcs)
endef

View File

@ -1,18 +1,15 @@
default: all
here = $(dir $(lastword $(MAKEFILE_LIST)))
include src/boost/format/Makefile.new
include src/libutil/Makefile.new
include src/libstore/Makefile.new
include src/libmain/Makefile.new
include src/libexpr/Makefile.new
include src/nix-hash/Makefile.new
include src/nix-store/Makefile.new
include src/nix-instantiate/Makefile.new
include src/nix-env/Makefile.new
include src/nix-daemon/Makefile.new
SUBS = \
src/boost/format/Makefile.new \
src/libutil/Makefile.new \
src/libstore/Makefile.new \
src/libmain/Makefile.new \
src/libexpr/Makefile.new \
src/nix-hash/Makefile.new \
src/nix-store/Makefile.new \
src/nix-instantiate/Makefile.new \
src/nix-env/Makefile.new \
src/nix-daemon/Makefile.new
include Makefile.lib
CXXFLAGS += -I . -I src -I src/libutil -I src/libstore -I src/libmain -I src/libexpr
CXXFLAGS += -I . -I src -I src/libutil -I src/libstore -I src/libmain -I src/libexpr -O0

View File

@ -1,5 +1,5 @@
LIBS += libformat
libformat_DIR := $(here)
libformat_DIR := $(d)
libformat_SOURCES = format_implementation.cc free_funcs.cc parsing.cc

View File

@ -1,14 +1,14 @@
LIBS += libexpr
libexpr_DIR := $(here)
libexpr_DIR := $(d)
libexpr_SOURCES = \
nixexpr.cc eval.cc primops.cc lexer-tab.cc parser-tab.cc \
get-drvs.cc attr-path.cc value-to-xml.cc value-to-json.cc \
common-opts.cc names.cc
$(here)parser-tab.cc $(here)parser-tab.hh: $(here)parser.y
bison -v -o $(here)parser-tab.cc $< -d
$(d)/parser-tab.cc $(d)/parser-tab.hh: $(d)/parser.y
bison -v -o $(libexpr_DIR)/parser-tab.cc $< -d
$(here)lexer-tab.cc $(here)lexer-tab.hh: $(here)lexer.l
flex --outfile $(here)lexer-tab.cc --header-file=$(here)lexer-tab.hh $<
$(d)/lexer-tab.cc $(d)/lexer-tab.hh: $(d)/lexer.l
flex --outfile $(libexpr_DIR)/lexer-tab.cc --header-file=$(libexpr_DIR)/lexer-tab.hh $<

View File

@ -1,6 +1,6 @@
LIBS += libmain
libmain_DIR := $(here)
libmain_DIR := $(d)
libmain_SOURCES = shared.cc stack.cc

View File

@ -1,6 +1,6 @@
LIBS += libstore
libstore_DIR := $(here)
libstore_DIR := $(d)
libstore_SOURCES = \
store-api.cc local-store.cc remote-store.cc derivations.cc build.cc misc.cc \

View File

@ -1,10 +1,11 @@
LIBS += libutil
libutil_DIR := $(here)
libutil_DIR := $(d)
libutil_SOURCES = util.cc hash.cc serialise.cc archive.cc xml-writer.cc affinity.cc \
md5.c sha1.c sha256.c
libutil_SOURCES = util.cc hash.cc serialise.cc archive.cc xml-writer.cc affinity.cc
# FIXME: md5.c et al. should only be built when we don't have OpenSSL.
ifneq ($(HAVE_OPENSSL), 1)
libutil_SOURCES += md5.c sha1.c sha256.c
endif
libutil_LIBS = src/boost/format/libformat

View File

@ -1,6 +1,6 @@
PROGRAMS += nix-daemon
nix-daemon_DIR := $(here)
nix-daemon_DIR := $(d)
nix-daemon_SOURCES = nix-daemon.cc

View File

@ -1,6 +1,6 @@
PROGRAMS += nix-env
nix-env_DIR := $(here)
nix-env_DIR := $(d)
nix-env_SOURCES = nix-env.cc profiles.cc profiles.hh user-env.cc user-env.hh

View File

@ -1,6 +1,6 @@
PROGRAMS += nix-hash
nix-hash_DIR := $(here)
nix-hash_DIR := $(d)
nix-hash_SOURCES = nix-hash.cc

View File

@ -1,6 +1,6 @@
PROGRAMS += nix-instantiate
nix-instantiate_DIR := $(here)
nix-instantiate_DIR := $(d)
nix-instantiate_SOURCES = nix-instantiate.cc

View File

@ -1,6 +1,6 @@
PROGRAMS += nix-store
nix-store_DIR := $(here)
nix-store_DIR := $(d)
nix-store_SOURCES = nix-store.cc dotgraph.cc xmlgraph.cc