2019-08-31 04:10:06 +08:00
|
|
|
# This Makefile might have been called from various subdirs, trying to find our Makefile.defs
|
|
|
|
ifeq ($(DEFSBEENHERE),)
|
|
|
|
-include Makefile.defs
|
|
|
|
endif
|
|
|
|
ifeq ($(DEFSBEENHERE),)
|
|
|
|
-include ../Makefile.defs
|
|
|
|
endif
|
|
|
|
ifeq ($(DEFSBEENHERE),)
|
|
|
|
-include ../../Makefile.defs
|
|
|
|
endif
|
2020-01-23 00:39:51 +08:00
|
|
|
ifeq ($(DEFSBEENHERE),)
|
|
|
|
-include ../../../Makefile.defs
|
|
|
|
endif
|
2019-08-31 04:10:06 +08:00
|
|
|
ifeq ($(DEFSBEENHERE),)
|
|
|
|
$(error Can't find Makefile.defs)
|
2019-08-18 05:40:38 +08:00
|
|
|
endif
|
|
|
|
|
2020-05-04 01:25:14 +08:00
|
|
|
CFLAGS ?= $(DEFCFLAGS)
|
2019-08-18 05:40:38 +08:00
|
|
|
CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES)
|
2020-05-15 19:07:27 +08:00
|
|
|
LDFLAGS += $(MYLDFLAGS)
|
|
|
|
LDLIBS += $(MYLDLIBS)
|
2019-08-18 05:40:38 +08:00
|
|
|
|
|
|
|
vpath %.c $(MYSRCPATHS)
|
|
|
|
|
|
|
|
# Flags to generate temporary dependency files
|
|
|
|
DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
|
|
|
|
# make temporary to final dependency files after successful compilation
|
2019-08-23 03:05:45 +08:00
|
|
|
POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d && $(TOUCH) $@
|
2019-08-18 05:40:38 +08:00
|
|
|
|
|
|
|
BINDIR := .
|
|
|
|
OBJDIR := obj
|
|
|
|
|
2020-04-19 01:39:55 +08:00
|
|
|
MYOBJS ?= $(MYSRCS:%.c=$(OBJDIR)/%.o)
|
2019-08-18 05:40:38 +08:00
|
|
|
CLEAN = $(foreach bin,$(MYLIBS) $(BINS) $(LIB_A),$(BINDIR)/$(bin))
|
|
|
|
|
|
|
|
all: $(foreach bin,$(MYLIBS) $(BINS) $(LIB_A),$(BINDIR)/$(bin))
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(Q)$(RM) $(CLEAN)
|
|
|
|
$(Q)$(RMDIR) $(OBJDIR)
|
2020-04-21 07:44:31 +08:00
|
|
|
ifneq (,$(MYCLEANOLDPATH))
|
|
|
|
$(Q)$(RM) $(foreach f,$(CLEAN),$(MYCLEANOLDPATH)/$(f))
|
|
|
|
$(Q)$(RMDIR) $(MYCLEANOLDPATH)/$(OBJDIR)
|
2020-04-21 07:47:43 +08:00
|
|
|
$(Q)$(RMDIR_SOFT) $(MYCLEANOLDPATH) 2>/dev/null || true
|
2020-04-21 07:44:31 +08:00
|
|
|
endif
|
2019-08-18 05:40:38 +08:00
|
|
|
|
2019-08-31 03:44:40 +08:00
|
|
|
install: all
|
2019-08-31 03:55:13 +08:00
|
|
|
ifneq (,$(INSTALLTOOLS))
|
|
|
|
$(info [@] Installing $(BINS) to $(DESTDIR)$(PREFIX)...)
|
2019-09-06 05:20:46 +08:00
|
|
|
$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
|
|
|
|
$(Q)$(CP) $(INSTALLTOOLS) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
|
2019-08-31 03:55:13 +08:00
|
|
|
endif
|
2019-08-31 03:44:40 +08:00
|
|
|
@true
|
|
|
|
|
|
|
|
uninstall:
|
2019-08-31 03:55:13 +08:00
|
|
|
ifneq (,$(INSTALLTOOLS))
|
|
|
|
$(info [@] Uninstalling $(BINS) from $(DESTDIR)$(PREFIX)...)
|
2019-09-06 05:20:46 +08:00
|
|
|
$(Q)$(RM) $(foreach tool,$(INSTALLTOOLS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)$(PATHSEP)$(notdir $(tool)))
|
2019-08-31 03:55:13 +08:00
|
|
|
endif
|
2019-08-31 03:44:40 +08:00
|
|
|
@true
|
|
|
|
|
|
|
|
.PHONY: all clean install uninstall
|
2019-08-18 05:40:38 +08:00
|
|
|
|
|
|
|
$(BINDIR)/$(LIB_A): $(MYOBJS)
|
|
|
|
$(info [=] AR $(notdir $@))
|
|
|
|
$(Q)$(AR) $@ $(MYOBJS)
|
|
|
|
$(Q)$(RANLIB) $@
|
|
|
|
|
|
|
|
$(BINDIR)/% : $(OBJDIR)/%.o $(MYOBJS) $(MYLIBS)
|
|
|
|
$(info [=] LD $(notdir $@))
|
2020-05-15 19:07:27 +08:00
|
|
|
$(Q)$(LD) $(LDFLAGS) $(MYOBJS) $< -o $@ $(MYLIBS) $(MYLDLIBS)
|
2019-08-18 05:40:38 +08:00
|
|
|
|
|
|
|
$(OBJDIR)/%.o : %.c | $(OBJDIR)
|
|
|
|
$(info [-] CC $<)
|
|
|
|
$(Q)$(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
|
|
|
|
$(Q)$(POSTCOMPILE)
|
|
|
|
|
|
|
|
$(OBJDIR):
|
|
|
|
$(Q)$(MKDIR) $(OBJDIR)
|
|
|
|
|
|
|
|
DEPENDENCY_FILES = $(MYOBJS:%.o=%.d) $(BINS:%=$(OBJDIR)/%.d)
|
|
|
|
|
|
|
|
$(DEPENDENCY_FILES): ;
|
|
|
|
.PRECIOUS: $(DEPENDENCY_FILES)
|
|
|
|
|
|
|
|
-include $(DEPENDENCY_FILES)
|