No longer interpret $(..._SOURCES) relative to $(..._DIR)

This commit is contained in:
Eelco Dolstra 2013-12-16 16:49:41 +01:00
parent 4da8046513
commit a630635d7f
2 changed files with 18 additions and 8 deletions

View file

@ -6,11 +6,13 @@ libs_list :=
# - $(1)_NAME: the name of the library (e.g. libfoo); defaults to # - $(1)_NAME: the name of the library (e.g. libfoo); defaults to
# $(1). # $(1).
# #
# - $(1)_DIR: the directory containing the sources of the library, and # - $(1)_DIR: the directory where the (non-installed) library will be
# where the (non-installed) library will be placed. # placed.
# #
# - $(1)_SOURCES: the source files of the library. # - $(1)_SOURCES: the source files of the library.
# #
# - $(1)_CXXFLAGS: additional C++ compiler flags.
#
# - $(1)_LIBS: the symbolic names of other libraries on which this # - $(1)_LIBS: the symbolic names of other libraries on which this
# library depends. # library depends.
# #
@ -33,7 +35,7 @@ libs_list :=
define build-library = define build-library =
$(1)_NAME ?= $(1) $(1)_NAME ?= $(1)
_d := $$(strip $$($(1)_DIR)) _d := $$(strip $$($(1)_DIR))
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src)) _srcs := $$(foreach src, $$($(1)_SOURCES), $$(src))
$(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs))) $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
@ -89,6 +91,9 @@ define build-library =
# Propagate CXXFLAGS to the individual object files. # Propagate CXXFLAGS to the individual object files.
$$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
# Make each object file depend on the common dependencies.
$$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS)))
# Include .dep files, if they exist. # Include .dep files, if they exist.
$(1)_DEPS := $$(addsuffix .dep, $$(basename $$(_srcs))) $(1)_DEPS := $$(addsuffix .dep, $$(basename $$(_srcs)))
-include $$($(1)_DEPS) -include $$($(1)_DEPS)

View file

@ -3,8 +3,8 @@ programs_list :=
# Build a program with symbolic name $(1). The program is defined by # Build a program with symbolic name $(1). The program is defined by
# various variables prefixed by $(1)_: # various variables prefixed by $(1)_:
# #
# - $(1)_DIR: the directory containing the sources of the program, and # - $(1)_DIR: the directory where the (non-installed) program will be
# where the (non-installed) program will be placed. # placed.
# #
# - $(1)_SOURCES: the source files of the program. # - $(1)_SOURCES: the source files of the program.
# #
@ -17,7 +17,7 @@ programs_list :=
# installed; defaults to $(bindir). # installed; defaults to $(bindir).
define build-program = define build-program =
_d := $$($(1)_DIR) _d := $$($(1)_DIR)
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src)) _srcs := $$(foreach src, $$($(1)_SOURCES), $$(src))
$(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs))) $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
$(1)_PATH := $$(_d)/$(1) $(1)_PATH := $$(_d)/$(1)
@ -49,9 +49,14 @@ define build-program =
# Propagate CXXFLAGS to the individual object files. # Propagate CXXFLAGS to the individual object files.
$$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
include $$(wildcard $$(_d)/*.dep) # Make each object file depend on the common dependencies.
$$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS)))
# Include .dep files, if they exist.
$(1)_DEPS := $$(addsuffix .dep, $$(basename $$(_srcs)))
-include $$($(1)_DEPS)
programs_list += $$($(1)_PATH) programs_list += $$($(1)_PATH)
clean_files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/*.dep clean_files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/*.dep $$($(1)_DEPS) $$($(1)_OBJS)
dist_files += $$(_srcs) dist_files += $$(_srcs)
endef endef