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 LDFLAGS += $(MYLDFLAGS)
23 vpath %.c $(MYSRCPATHS)
25 # Flags to generate temporary dependency files
26 DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
27 # make temporary to final dependency files after successful compilation
28 POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d && $(TOUCH) $@
33 MYOBJS ?= $(MYSRCS:%.c=$(OBJDIR)/%.o)
34 CLEAN = $(foreach bin,$(MYLIBS) $(BINS) $(LIB_A),$(BINDIR)/$(bin))
36 all: $(foreach bin,$(MYLIBS) $(BINS) $(LIB_A),$(BINDIR)/$(bin))
40 $(Q)$(RMDIR) $(OBJDIR)
41 ifneq (,$(MYCLEANOLDPATH))
42 $(Q)$(RM) $(foreach f,$(CLEAN),$(MYCLEANOLDPATH)/$(f))
43 $(Q)$(RMDIR) $(MYCLEANOLDPATH)/$(OBJDIR)
44 $(Q)$(RMDIR_SOFT) $(MYCLEANOLDPATH) 2>/dev/null || true
48 ifneq (,$(INSTALLTOOLS))
49 $(info [@] Installing $(BINS) to $(DESTDIR)$(PREFIX)...)
50 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
51 $(Q)$(CP) $(INSTALLTOOLS) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
56 ifneq (,$(INSTALLTOOLS))
57 $(info [@] Uninstalling $(BINS) from $(DESTDIR)$(PREFIX)...)
58 $(Q)$(RM) $(foreach tool,$(INSTALLTOOLS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)$(PATHSEP)$(notdir $(tool)))
62 .PHONY: all clean install uninstall
64 $(BINDIR)/$(LIB_A): $(MYOBJS)
65 $(info [=] AR $(notdir $@))
66 $(Q)$(AR) $@ $(MYOBJS)
69 $(BINDIR)/% : $(OBJDIR)/%.o $(MYOBJS) $(MYLIBS)
70 $(info [=] LD $(notdir $@))
71 $(Q)$(LD) $(LDFLAGS) $(MYOBJS) $< -o $@ $(MYLIBS) $(MYLDLIBS)
73 $(OBJDIR)/%.o : %.c | $(OBJDIR)
75 $(Q)$(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
79 $(Q)$(MKDIR) $(OBJDIR)
81 DEPENDENCY_FILES = $(MYOBJS:%.o=%.d) $(BINS:%=$(OBJDIR)/%.d)
83 $(DEPENDENCY_FILES): ;
84 .PRECIOUS: $(DEPENDENCY_FILES)
86 -include $(DEPENDENCY_FILES)