]> git.neil.brown.name Git - TABS.git/blob - MakeRules
Terminal Alocation and Booking System - June 2006
[TABS.git] / MakeRules
1
2 ThisMake := $(lastword $(MAKEFILE_LIST))
3 TOP := $(dir $(ThisMake))
4 ifeq ($(S),)
5 %:
6         mkdir -p $(TOP)$(ObjDir) ; $(MAKE) -C $(TOP)$(ObjDir) VPATH=.. S=../ -f ../Makefile $*
7
8 all:
9
10 else
11
12 # This is included at the end of each subdir makefile
13 # We need to make each target from its objs
14 all :
15
16
17 $(if $(HaveCommon),,$(eval include $(D)../MakeCommon))
18
19 D2 := $(if $(D),$(D),nothing)
20 define TargetTemplate
21  all : targets/$(1)
22  targets/$(1) : $(D)$(1)
23         mkdir -p targets ; cp $(D)$(1) targets/$(1)
24  toclean += $(D)$(1)
25  $(D)$(1) : $(patsubst $(D2)../%,%, $(addprefix $(D),$(obj-$(1))))
26         $$(CC) -o $$@ $$^ $$(LDLIBS) $$(lib-$(1))
27  -include  $(patsubst %.o,$(D)%.c.d,$(filter %.o,$(obj-$(1))))
28
29 endef
30
31 $(foreach t,$(target),$(eval $(call TargetTemplate,$(t))))
32
33
34 define LibraryTemplate
35  all : $(D)$(1)
36  toclean += $(D)$(1)
37  $(D)$(1) : $(patsubst $(D2)../%,%,$(addprefix $(D),$(obj-$(1))))
38         $$(AR) cr $$@ $$^
39 endef
40
41 $(foreach l,$(lib),$(eval $(call LibraryTemplate,$(l))))
42
43
44 define DirTemplate
45  D := $(1)
46  include $$(S)$$(D)Makefile
47  tocleandirs += $(1)
48 endef
49
50 dtmp := $(dirs-y)
51 dirs-y := 
52 $(foreach dir,$(dtmp),$(eval $(call DirTemplate,$(dir))))
53
54 target :=
55 lib :=
56 endif