build/rules.mk

Sun, 11 Mar 2007 00:05:36 +0100

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 11 Mar 2007 00:05:36 +0100
changeset 109
96a557abc364
parent 102
c00694dbcde8
permissions
-rw-r--r--

Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.

6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
1 ##
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
2 ## Some make rules
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
3 ##
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
4
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
5 ifdef MODULE
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
6 ifeq ($(PRELOAD_MODULES),1)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
7 MODULE_TARGETS := $(MODULE).a $(MODULE).lc
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
8 else
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
9 MODULE_TARGETS := $(MODULE).so $(MODULE).lc
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
10 endif
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
11 TARGETS := $(TARGETS) $(MODULE_TARGETS)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
12 endif
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
13
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
14 ifdef LUA_SOURCES
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
15 LUA_COMPILED := $(subst .lua,.lc, $(LUA_SOURCES))
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
16 TARGETS := $(TARGETS) $(LUA_COMPILED)
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
17 endif
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
18
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
19
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
20 # Main targets
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
21 ######################################
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
22
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
23 .PHONY: subdirs
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
24 .PHONY: subdirs-clean
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
25 .PHONY: subdirs-realclean
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
26 .PHONY: subdirs-depend
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
27 .PHONY: subdirs-install
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
28 .PHONY: _install
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
29 .PHONY: _depend
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
30
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
31 all: subdirs $(TARGETS)
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
32
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
33 clean: subdirs-clean _clean
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
34
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
35 realclean: subdirs-realclean _clean _realclean
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
36
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
37 depend: subdirs-depend _depend
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
38
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
39 install: subdirs-install _install
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
40
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
41
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
42 # Exports
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
43 ######################################
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
44
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
45 ifdef MAKE_EXPORTS
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
46
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
47 TO_CLEAN := $(TO_CLEAN) exports.c
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
48
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
49 EXPORTS_C = exports.c
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
50
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
51 exports.c: $(SOURCES)
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
52 $(MKEXPORTS) -module $(MAKE_EXPORTS) -o exports.c $(SOURCES)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
53
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
54 else # !MAKE_EXPORTS
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
55
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
56 EXPORTS_C =
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
57
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
58 endif # !MAKE_EXPORTS
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
59
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
60
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
61 # Compilation and linking
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
62 ######################################
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
63
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
64 OBJS=$(subst .c,.o,$(SOURCES) $(EXPORTS_C))
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
65
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
66 ifdef MODULE
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
67
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
68 ifneq ($(PRELOAD_MODULES),1)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
69
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
70 CC_PICFLAGS=-fPIC -DPIC
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
71 LD_SHAREDFLAGS=-shared
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
72
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
73 %.o: %.c
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
74 $(CC) $(CC_PICFLAGS) $(CFLAGS) -c $< -o $@
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
75
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
76 $(MODULE).so: $(OBJS) $(EXT_OBJS)
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
77 $(CC) $(LD_SHAREDFLAGS) $(LDFLAGS) $(OBJS) $(EXT_OBJS) -o $@
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
78
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
79
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
80 module_install: module_stub_install
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
81 $(INSTALLDIR) $(MODULEDIR)
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
82 $(INSTALL) -m $(BIN_MODE) $(MODULE).so $(MODULEDIR)
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
83
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
84 else # PRELOAD_MODULES
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
85
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
86 PICOPT=-fPIC -DPIC
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
87 LINKOPT=-shared
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
88
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
89 %.o: %.c
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
90 $(CC) $(CFLAGS) -c $< -o $@
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
91
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
92 $(MODULE).a: $(OBJS) $(EXT_OBJS)
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
93 $(AR) $(ARFLAGS) $@ $+
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
94 $(RANLIB) $@
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
95
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
96 module_install: module_stub_install
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
97
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
98 endif # PRELOAD_MODULES
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
99
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
100 module_stub_install:
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
101 $(INSTALLDIR) $(LCDIR)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
102 $(INSTALL) -m $(DATA_MODE) $(MODULE).lc $(LCDIR)
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
103
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
104 ifndef MODULE_STUB
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
105
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
106 $(MODULE).lc:
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
107 echo "ioncore.load_module('$(MODULE)')" | $(LUAC) -o $@ -
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
108 else
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
109
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
110 LUA_SOURCES += $(MODULE_STUB)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
111
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
112 endif #MODULE_STUB
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
113
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
114 else # !MODULE
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
115
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
116
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
117 %.o: %.c
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 8
diff changeset
118 $(CC) $(CFLAGS) -c $< -o $@
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
119
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
120
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
121 endif# !MODULE
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
122
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
123
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
124 # Clean rules
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
125 ######################################
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
126
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
127 _clean:
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
128 $(RM) -f $(TO_CLEAN) core $(DEPEND_FILE) $(OBJS)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
129
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
130 _realclean:
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
131 $(RM) -f $(TO_REALCLEAN) $(TARGETS)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
132
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
133 # Lua rules
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
134 ######################################
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
135
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
136 %.lc: %.lua
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
137 $(LUAC) -o $@ $<
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
138
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
139 lc_install:
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
140 $(INSTALLDIR) $(LCDIR)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
141 for i in $(LUA_COMPILED); do \
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
142 $(INSTALL) -m $(DATA_MODE) $$i $(LCDIR); \
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
143 done
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
144
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
145 etc_install:
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
146 $(INSTALLDIR) $(ETCDIR)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
147 for i in $(ETC); do \
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
148 $(INSTALL) -m $(DATA_MODE) $$i $(ETCDIR); \
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
149 done
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
150
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
151 # Dependencies
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
152 ######################################
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
153
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
154 ifdef SOURCES
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
155
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
156 _depend: $(DEPEND_DEPENDS)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
157 $(MAKE_DEPEND)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
158
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
159 ifeq ($(DEPEND_FILE),$(wildcard $(DEPEND_FILE)))
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
160 include $(DEPEND_FILE)
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
161 endif
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
162
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
163 endif
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
164
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
165 # Subdirectories
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
166 ######################################
51
2d95d77aa954 trunk: changeset 55
tuomov
parents: 29
diff changeset
167
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
168 ifdef SUBDIRS
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
169
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
170 subdirs:
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 8
diff changeset
171 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
172
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
173 subdirs-depend:
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 8
diff changeset
174 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i depend; done
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
175
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
176 subdirs-clean:
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 8
diff changeset
177 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
178
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
179 subdirs-realclean:
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 8
diff changeset
180 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
181
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
182 subdirs-install:
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 8
diff changeset
183 set -e; for i in $(INSTALL_SUBDIRS); do $(MAKE) -C $$i install; done
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
184
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
185 endif
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
186
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
187 # Localisation
6
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
188 ######################################
f73065173121 trunk: changeset 9
tuomov
parents:
diff changeset
189
82
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
190 TO_CLEAN += potfiles_c potfiles_lua
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
191
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
192 _potfiles:
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
193 echo "$(SOURCES)"|tr ' ' '\n' > potfiles_c
895f6304179d trunk: changeset 1807
tuomov
parents: 51
diff changeset
194 echo "$(LUA_SOURCES) $(ETC)"|tr ' ' '\n' > potfiles_lua

mercurial