# for each target.SRCS, generate target.OBJS, target.a and add target.OBJS to all $(foreach V,$(filter %.SRCS, ${.VARIABLES}),\ $(eval $(V:%.SRCS=%.OBJS) += $(foreach f,$($(V)),$(addsuffix .o,$(basename $(f))))) \ $(eval $(V:%.SRCS=%.a): $($(V:%.SRCS=%.OBJS))) \ $(eval all: $($(V:%.SRCS=%.OBJS))) \ ) # extra flags CFLAGS += -isysteminclude -I../lib # Suffix rules %.a: @echo ' AR $@' @${AR} ${ARFLAGS} $@ $(filter %.o,$^) .SUFFIXES: .s .S .c .o .s.o: @echo ' AS $^' @$(AS) $(ASFLAGS) -c -o $@ $^ .S.o: @echo ' CC $^' @$(CC) $(CFLAGS) -c -o $@ $^ .c.o: @echo ' CC $^' @$(CC) $(CFLAGS) -c -o $@ $^ # Test rules tst/test_%: tst/%.cc @echo ' CXX $@' @${CXX} $< -o $@ $(GTEST) $(GMOCK) # clean target .PHONY: clean FORCE clean: @$(foreach V,$(filter %.OBJS, ${.VARIABLES}), rm -rf $($(V))) @rm -rf include @rm -rf tst/test_* FORCE: