1 # This Makefile might have been called from various subdirs, trying to find our Makefile.defs
2 ifeq ($(DEFSBEENHERE),)
5 ifeq ($(DEFSBEENHERE),)
6 -include ../Makefile.defs
8 ifeq ($(DEFSBEENHERE),)
9 -include ../../Makefile.defs
11 ifeq ($(DEFSBEENHERE),)
12 -include ../../../Makefile.defs
14 ifeq ($(DEFSBEENHERE),)
15 $(error Can't find Makefile.defs)
18 CFLAGS ?= $(DEFCFLAGS)
19 CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES)
20 CXXFLAGS ?= $(DEFCXXFLAGS)
21 CXXFLAGS += $(MYDEFS) $(MYCXXFLAGS) $(MYINCLUDES)
22 LDFLAGS ?= $(DEFLDFLAGS)
23 LDFLAGS += $(MYLDFLAGS)
26 vpath %.c $(MYSRCPATHS)
28 # Flags to generate temporary dependency files
29 DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
30 # make temporary to final dependency files after successful compilation
31 POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d && $(TOUCH) $@
36 MYOBJS ?= $(MYSRCS:%.c=$(OBJDIR)/%.o)
37 MYCXXOBJS ?= $(MYCXXSRCS:%.cpp=$(OBJDIR)/%.o)
38 CLEAN = $(foreach bin,$(MYLIBS) $(BINS) $(LIB_A),$(BINDIR)/$(bin))
40 all: $(foreach bin,$(MYLIBS) $(BINS) $(LIB_A),$(BINDIR)/$(bin))
44 $(Q)$(RMDIR) $(OBJDIR)
45 ifneq (,$(MYCLEANOLDPATH))
46 $(Q)$(RM) $(foreach f,$(CLEAN),$(MYCLEANOLDPATH)/$(f))
47 $(Q)$(RMDIR) $(MYCLEANOLDPATH)/$(OBJDIR)
48 $(Q)$(RMDIR_SOFT) $(MYCLEANOLDPATH) 2>/dev/null || true
52 ifneq (,$(INSTALLTOOLS))
53 $(info [@] Installing $(BINS) to $(DESTDIR)$(PREFIX)...)
54 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
55 $(Q)$(CP) $(INSTALLTOOLS) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
60 ifneq (,$(INSTALLTOOLS))
61 $(info [@] Uninstalling $(BINS) from $(DESTDIR)$(PREFIX)...)
62 $(Q)$(RM) $(foreach tool,$(INSTALLTOOLS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)$(PATHSEP)$(notdir $(tool)))
66 .PHONY: all clean install uninstall
68 $(BINDIR)/$(LIB_A): $(MYOBJS) $(MYCXXOBJS)
69 $(info [=] AR $(notdir $@))
70 $(Q)$(AR) $@ $(MYOBJS) $(MYCXXOBJS)
73 $(BINDIR)/% : $(OBJDIR)/%.o $(MYOBJS) $(MYCXXOBJS) $(MYLIBS)
74 $(info [=] LD $(notdir $@))
75 $(Q)$(LD) $(LDFLAGS) $(MYOBJS) $(MYCXXOBJS) $< -o $@ $(MYLIBS) $(MYLDLIBS)
78 $(OBJDIR)/%.o : %.c $(OBJDIR)/%.d | $(OBJDIR)
80 $(Q)$(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
84 $(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d | $(OBJDIR)
86 $(Q)$(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
90 $(Q)$(MKDIR) $(OBJDIR)
92 DEPENDENCY_FILES = $(MYOBJS:%.o=%.d) $(MYCXXOBJS:%.o=%.d) $(BINS:%=$(OBJDIR)/%.d)
94 $(DEPENDENCY_FILES): ;
95 .PRECIOUS: $(DEPENDENCY_FILES)
97 -include $(DEPENDENCY_FILES)