|
| 1 | +############################################### |
| 2 | +### Begin user-specific portion of Makefile ### |
| 3 | +############################################### |
| 4 | + |
| 5 | +# Add directories here that appear under the <top level>/src folder that should not be compiled |
| 6 | +SUBSRCDIRSTOFILTER = |
| 7 | + |
| 8 | +# If the build target name is non-standard, enter the standard build target found in libraries here to override. |
| 9 | +# Leave this blank if this build target has a standard name. |
| 10 | +EXTERNALTARGETNAME = |
| 11 | + |
| 12 | +# If the source code requires a minimum version of a compiler build, then enter it here. This value must be an integer! |
| 13 | +# Leave this blank if the source can be built with any compiler version. |
| 14 | +export MINCOMPILERBUILD = |
| 15 | + |
| 16 | +############################################# |
| 17 | +### End user-specific portion of Makefile ### |
| 18 | +############################################# |
| 19 | + |
| 20 | +# Functions needed by this makefile and the one that builds the source libraries (MakefileSrc) |
| 21 | +export ECHO = @echo |
| 22 | +export RM = rm |
| 23 | +export SED = sed |
| 24 | +export MKDIR = mkdir |
| 25 | +export TR = tr |
| 26 | +export BLACKHOLE = /dev/null |
| 27 | +export PWD = pwd |
| 28 | +export CD = cd |
| 29 | +export LS = ls |
| 30 | + |
| 31 | +# Name for this build target |
| 32 | +export TARGETNAME := $(shell $(PWD) | $(SED) -e 's_/.*/__' | $(SED) -e 's_\S.*\\__') |
| 33 | + |
| 34 | +# Name for external build target |
| 35 | +ifeq ($(EXTERNALTARGETNAME),) |
| 36 | +EXTERNALTARGETNAMELCL = $(TARGETNAME) |
| 37 | +else |
| 38 | +EXTERNALTARGETNAMELCL = $(EXTERNALTARGETNAME) |
| 39 | +endif |
| 40 | + |
| 41 | +# Directories related to the library and location of the local source tree |
| 42 | +TOPLEVELREL = .. |
| 43 | +LIBNAME := $(shell $(CD) .. && $(PWD) | $(SED) -e 's_/.*/__' | $(SED) -e 's_\S.*\\__' && $(CD) $(TARGETNAME)) |
| 44 | +TARGETTOSRCDIRREL = $(TOPLEVELREL)/src |
| 45 | +SRCTOTARGETDIRREL = ../$(TARGETNAME) |
| 46 | +LOCALSRCRELTOTARGET = ../../$(TARGETNAME) |
| 47 | + |
| 48 | +# Include directories (outside this folder) that the sub makes need to know about |
| 49 | +EXTERNLIBS = $(filter-out $(LIBNAME),$(filter lib_%,$(subst /.,,$(strip $(shell $(CD) ../.. && $(LS) -d */. && $(CD) $(LIBNAME)/$(TARGETNAME)))))) |
| 50 | +export EXTERNINCDIRS = $(foreach dir,$(EXTERNLIBS),../../$(dir)/include ../../$(dir)/$(EXTERNALTARGETNAMELCL)/include) |
| 51 | + |
| 52 | +# Directories related to the build process of the target |
| 53 | +export TARGETDIR = $(TARGETNAME) |
| 54 | +export TARGETLIBDIRREL = lib |
| 55 | +export TARGETOBJDIRREL = obj |
| 56 | +export TARGETDEPDIRREL = dep |
| 57 | +export TARGETSRCMAKEFILE = $(LOCALSRCRELTOTARGET)/MakefileSrc |
| 58 | +export TARGETRELTOSUBSRCREL = ../../$(TARGETNAME) |
| 59 | + |
| 60 | +# Directories inside the local source tree |
| 61 | +SUBSRCDIRSRAW := $(subst /.,,$(strip $(shell $(CD) $(TARGETTOSRCDIRREL) && $(LS) -d */. && $(CD) $(SRCTOTARGETDIRREL)))) |
| 62 | +ifeq ($(SUBSRCDIRSRAW),) |
| 63 | +$(error There are no source directories to clean/build) |
| 64 | +endif |
| 65 | +SUBSRCDIRSRAWFILT := $(filter-out $(SUBSRCDIRSTOFILTER),$(SUBSRCDIRSRAW)) |
| 66 | +ifeq ($(SUBSRCDIRSRAWFILT),) |
| 67 | +$(error There are available source directories to clean/build, but they have been filtered out by SUBSRCDIRSTOFILTER) |
| 68 | +endif |
| 69 | +SUBSRCDIRS := $(foreach dir,$(SUBSRCDIRSRAWFILT),$(TARGETTOSRCDIRREL)/$(dir)) |
| 70 | + |
| 71 | + |
| 72 | +all: |
| 73 | + $(ECHO) |
| 74 | + $(ECHO) "Building target '$(TARGETNAME)' for library collection '$(LIBNAME)'" |
| 75 | + @$(MAKE) $(SUBSRCDIRS) |
| 76 | + $(ECHO) |
| 77 | + $(ECHO) "Finished building target '$(TARGETNAME)' for library collection '$(LIBNAME)'" |
| 78 | + |
| 79 | +$(SUBSRCDIRS): |
| 80 | + $(ECHO) |
| 81 | + $(ECHO) "Building library '$(@F)'" |
| 82 | + $(MAKE) -C $@ all |
| 83 | + $(ECHO) "Finished building library '$(@F)'" |
| 84 | + |
| 85 | +clean: |
| 86 | + $(ECHO) |
| 87 | + $(ECHO) "Cleaning target '$(TARGETNAME)' for library '$(LIBNAME)'" |
| 88 | + $(if $(TARGETLIBDIRREL),$(RM) -rf $(TARGETLIBDIRREL)/*) |
| 89 | + $(if $(TARGETOBJDIRREL),$(RM) -rf $(TARGETOBJDIRREL)/*) |
| 90 | + $(if $(TARGETDEPDIRREL),$(RM) -rf $(TARGETDEPDIRREL)/*) |
| 91 | + $(ECHO) "Finished cleaning target '$(TARGETNAME)' for library '$(LIBNAME)'" |
| 92 | + |
| 93 | +.PHONY: $(SUBSRCDIRS) |
0 commit comments