1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| source-to-object = $(subst .c,.o,$(filter %.c,$1)) \ $(subst .y,.o,$(filter %.y,$1)) \ $(subst .l,.o,$(filter %.l,$1))
subdirectory = $(patsubst %/module.mk,%, \ $(word \ $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
define make-library libraries += $1 sources += $2 $1: $(call source-to-object,$2) $(AR) $(ARFLAGS) $$@ $$^
endef
generated-source = $(subst .y,.c,$(filter %.y,$1)) \ $(subst .y,.h,$(filter %.y,$1)) \ $(subst .l,.c,$(filter %.l,$1))
modules := lib/codec lib/db lib/ui app/player programs := libraries := sources :=
objects = $(call source-to-object,$(sources)) dependencies = $(subst .o,.d,$(objects))
include_dirs := lib include CPPFLAGS += $(addprefix -I ,$(include_dirs)) vpath %.h $(include_dirs)
MV := mv -f RM := rm -f SED := sed
all:
include $(addsuffix /module.mk,$(modules))
.PHONY: all all: $(programs)
.PHONY: libraries libraries: $(libraries)
.PHONY: clean clean: $(RM) $(objects) $(programs) $(libraries) $(dependencies) \ $(call generated-source, $(sources)) ifneq "$(MAKECMDGOALS)" "clean" include $(dependencies) endif
%.c %.h: %.y $(YACC.y) --defines $< $(MV) y.tab.c $*.c $(MV) y.tab.h $*.h %.d: %.c $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M $< | \ $(SED) 's,\($(notdir $*)\.o\) *:,$(dir $@)\1 $@: ,' > $@.tmp $(MV) $@.tmp $@
|