3 # sort out sources, objects and dependencies
7 # see http://www.gnu.org/software/make/manual/html_chapter/make_8.html#SEC91
10 $(foreach ARCHIVE, $(ARCHIVES), \
11 $(eval SRCS += $($(subst .,_,$(subst -,_,$(ARCHIVE)))_SRCS)) \
12 $(eval $(subst .,_,$(subst -,_,$(ARCHIVE)))_OBJS := \
13 $(addsuffix .o, $(basename $($(subst .,_,$(subst -,_,$(ARCHIVE)))_SRCS)))) \
14 $(eval OBJS += $($(subst .,_,$(subst -,_,$(ARCHIVE)))_OBJS)) \
17 $(foreach LARCHIVE, $(LARCHIVES), \
18 $(eval SRCS += $($(subst .,_,$(subst -,_,$(LARCHIVE)))_SRCS)) \
19 $(eval $(subst .,_,$(subst -,_,$(LARCHIVE)))_OBJS := \
20 $(addsuffix .lo, $(basename $($(subst .,_,$(subst -,_,$(LARCHIVE)))_SRCS)))) \
21 $(eval OBJS += $($(subst .,_,$(subst -,_,$(LARCHIVE)))_OBJS)) \
24 $(foreach PROGRAM, $(PROGRAMS), \
25 $(eval SRCS += $($(subst .,_,$(subst -,_,$(PROGRAM))_SRCS))) \
26 $(eval $(subst .,_,$(subst -,_,$(PROGRAM)))_OBJS := \
27 $(addsuffix .o, $(basename $($(subst .,_,$(subst -,_,$(PROGRAM)))_SRCS)))) \
28 $(eval OBJS += $($(subst .,_,$(subst -,_,$(PROGRAM)))_OBJS)) \
31 $(foreach LIBRARY, $(LIBRARIES), \
32 $(eval SRCS += $($(subst .,_,$(subst -,_,$(LIBRARY)))_SRCS)) \
33 $(eval $(subst .,_,$(subst -,_,$(LIBRARY)))_OBJS := \
34 $(addsuffix .lo, $(basename $($(subst .,_,$(subst -,_,$(LIBRARY)))_SRCS)))) \
35 $(eval OBJS += $($(subst .,_,$(subst -,_,$(LIBRARY)))_OBJS)) \
38 DEPS = $(addsuffix .d, $(basename $(SRCS)))
45 # sub-directory traversal
46 .PHONY: subdirs $(subdirs)
50 $(Q)$(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
53 .SUFFIXES: .o .lo .a .al .so .d
56 all: subdirs $(OBJS) $(ARCHIVES) $(LARCHIVES) $(LIBRARIES) $(PROGRAMS)
63 $(Q)$(CC) -MM $(1) $< > $@.$$$$; \
64 sed -e 's,\($*\)\.o[ :]*,\1.o $@ : ,g' \
65 -e 's,$(shell basename $@),$@,g' < $@.$$$$ > $(subst .c,.d,$<); \
71 $(Q)$(CC) $(1) -c -o $@ $<
75 $(call mkdep,$(CPPFLAGS) $(INCLUDES) $(DEFS))
76 $(call compile,$(CFLAGS) $(DEFS) $(INCLUDES))
79 $(call mkdep,$(CPPFLAGS) $(INCLUDES) $(DEFS))
80 $(call compile,$(CFLAGS) $(DEFS) $(INCLUDES) $(PICFLAGS))
82 #############################################################################
92 # the -Xlinker -rpath mangling is needed to find those libraries during
93 # linking for other objects
96 $(Q)$(CC) -shared $(LDFLAGS) $(patsubst -L%, -Xlinker -rpath %, $(filter -L%, $(LIBS))) \
103 $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(1)
109 $(Q)$(RM) -v $(OBJS) $(DEPS) $(PROGRAMS) $(CLEANFILES)
110 $(Q)list="$(LIBRARIES) $(LARCHIVES) $(ARCHIVES)"; for each in $$list; do \
115 distclean: clean subdirs
116 $(Q)$(RM) -v $(wildcard *~) core $(DISTCLEAN_FILES)