diff --git a/MANUAL b/MANUAL index 1c7ffe7..0f30666 100644 --- a/MANUAL +++ b/MANUAL @@ -147,11 +147,21 @@ TARGET_DIR Default value: . (make's working directory; aka project root) +TGT_CC +------ + Specifies the program to be used for compiling C sources. If this option is + not specified, CC is used. + TGT_CFLAGS ---------- Like SRC_CFLAGS, but applies to all sources belonging to the current target, not just sources in the current submakefile. +TGT_CXX +------- + Specifies the program to be used for compiling C++ sources. If this option + is not specified, CXX is used. + TGT_CXXFLAGS ------------ Like SRC_CXXFLAGS, but applies to all sources belonging to the current diff --git a/Makefile b/Makefile index 8375cfc..3fd0f15 100644 --- a/Makefile +++ b/Makefile @@ -139,7 +139,9 @@ define INCLUDE_SUBMAKEFILE # Initialize all variables that can be defined by a makefile fragment, then # include the specified makefile fragment. TARGET := + TGT_CC := TGT_CFLAGS := + TGT_CXX := TGT_CXXFLAGS := TGT_DEFS := TGT_INCDIRS := @@ -185,7 +187,9 @@ define INCLUDE_SUBMAKEFILE # makefile apply to this new target. Initialize the target's variables. TGT := $$(strip $${TARGET}) ALL_TGTS += $${TGT} + $${TGT}_CC := $${TGT_CC} $${TGT}_CFLAGS := $${TGT_CFLAGS} + $${TGT}_CXX := $${TGT_CXX} $${TGT}_CXXFLAGS := $${TGT_CXXFLAGS} $${TGT}_DEFS := $${TGT_DEFS} $${TGT}_DEPS := @@ -247,6 +251,8 @@ define INCLUDE_SUBMAKEFILE # variables that were defined. $${TGT}_OBJS += $${OBJS} $${TGT}_DEPS += $${OBJS:%.o=%.P} + $${OBJS}: CC := $$(if $${$${TGT}_CC},$${$${TGT}_CC},$${CC}) + $${OBJS}: CXX := $$(if $${$${TGT}_CXX},$${$${TGT}_CXX},$${CXX}) $${OBJS}: SRC_CFLAGS := $${$${TGT}_CFLAGS} $${SRC_CFLAGS} $${OBJS}: SRC_CXXFLAGS := $${$${TGT}_CXXFLAGS} $${SRC_CXXFLAGS} $${OBJS}: SRC_DEFS := $$(addprefix -D,$${$${TGT}_DEFS} $${SRC_DEFS})