StdRules 1.29 KB
Newer Older
1
# Makefile fragment for defining standard rules for various tools
Ben Avison's avatar
Ben Avison committed
2 3

INCLUDED_STDRULES = YES
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

# $(call make-depend,source,object,depend)
define make-depend
	@${CC} ${CFLAGS} -M $1 > $3 2> /dev/null
	@${SED} -i -e 's,$(basename $2).o *:,$2:,' $3
endef

# $(call make-depend,source,object,depend)
ifeq (GNU,${TOOLCHAIN})
define make-cpp-depend
	@${C++} ${C++FLAGS} -M $1 > $3 2> /dev/null
	@${SED} -i -e 's,$(basename $2).o *:,$2:,' $3
endef
else
define make-cpp-depend
endef
endif

.SUFFIXES: .o .oz .s .c .h .c++ .cpp

# C source files -> object files
.c.o:
	${CC} ${CFLAGS} -o $@ $<
	$(call make-depend,$<,$@,$(subst .o,.d,$@))
.c.oz:
	${CC} ${CFLAGS} ${C_MODULE} -o $@ $<
	$(call make-depend,$<,$@,$(subst .oz,.dz,$@))

# C++ source files -> object files
.c++.o:
	${C++} ${C++FLAGS} -o $@ $<
	$(call make-cpp-depend,$<,$@,$(subst .o,.d,$@))
.cpp.o:
	${C++} ${C++FLAGS} -o $@ $<
	$(call make-cpp-depend,$<,$@,$(subst .o,.d,$@))
.c++.oz:
	${C++} ${C++FLAGS} ${C_MODULE} -o $@ $<
	$(call make-cpp-depend,$<,$@,$(subst .oz,.dz,$@))
.cpp.oz:
	${C++} ${C++FLAGS} ${C_MODULE} -o $@ $<
44
	$(call make-cpp-depend,$<,$@,$(subst .oz,.dz,$@))
45 46 47 48 49 50 51 52 53

# Assembler source files -> object files
.s.o:
	${AS} ${ASFLAGS} -depend $(subst .o,.d,$@) -o $@ $<
.s.oz:
	${AS} ${ASFLAGS} -depend $(subst .oz,.dz,$@) -pd "zM SETL {TRUE}" -o $@ $<


# EOF