-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.rules
64 lines (47 loc) · 1.66 KB
/
Makefile.rules
1
2
3
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
all: ${BUILDDIR}
all: ${PROJECT}
.PHONY: clean
clean:
rm -rf ${BUILDDIR}
rm -rf ${PROJECT}
rm -rf ${MAPFILE}
rm -rf ${SOURCEDIR}/MASTER.cpp
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
${BUILDDIR}:
mkdir ${BUILDDIR} -p
${BUILDDIR}/%.o: ${SOURCEDIR}/%.c
@${CC} ${CFLAGS} -c $< -o $@
@echo "CC $@"
#create dependency file to detect changes in header
#http://scottmcpeak.com/autodepend/autodepend.html is used as reference
@${CC} -MM $(CFLAGS) $< > ${@:.o=.d}
@mv -f ${@:.o=.d} ${@:.o=.d.tmp}
@sed -e 's|.*:|$@:|' < ${@:.o=.d.tmp} > ${@:.o=.d}
@sed -e 's/.*://' -e 's/\\$$//' < ${@:.o=.d.tmp} | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> ${@:.o=.d}
@rm -f ${@:.o=.d.tmp}
${BUILDDIR}/%.o: ${SOURCEDIR}/%.cpp
@${CC} ${CFLAGS} -c $< -o $@
@echo "CC $@"
#create dependency file to detect changes in header
#http://scottmcpeak.com/autodepend/autodepend.html is used as reference
@${CC} -MM $(CFLAGS) $< > ${@:.o=.d}
@mv -f ${@:.o=.d} ${@:.o=.d.tmp}
@sed -e 's|.*:|$@:|' < ${@:.o=.d.tmp} > ${@:.o=.d}
@sed -e 's/.*://' -e 's/\\$$//' < ${@:.o=.d.tmp} | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> ${@:.o=.d}
@rm -f ${@:.o=.d.tmp}
${BUILDDIR}/%.o: ${ASSEMBLYDIR}/%.S
@${AS} ${AFLAGS} -c $< -o $@
@echo "CC $@"
${BUILDDIR}/%.a:
@${AR} -cr ${@} ${^}
@echo "CC ${@}"
${PROJECT}: ${OBJECTS} ${LIBRARIES}
@${LD} ${LDFLAGS} -o ${@} $(filter %.o %.a, ${^})
@echo "LD ${@}"
#This creates a file which include all others.
${SOURCEDIR}/MASTER.cpp: ${SOURCES_}
@$(foreach file,${C_SOURCES},echo "#include \"../$(file)\"" >> ${SOURCEDIR}/MASTER.cpp;)
@$(foreach file,${CPP_SOURCES},echo "#include \"../$(file)\"" >> ${SOURCEDIR}/MASTER.cpp;)