]>
Commit | Line | Data |
---|---|---|
8c411768 BC |
1 | #! /usr/bin/python |
2 | ||
3 | # | |
4 | # This is the python script used to generate Makefile.tpl | |
5 | # | |
6 | ||
7 | GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", | |
062cdbc1 BC |
8 | "i386_multiboot", "i386_ieee1275", "x86_64_efi", |
9 | "mips_yeeloong", "sparc64_ieee1275", | |
8c411768 BC |
10 | "powerpc_ieee1275" ] |
11 | ||
12 | GROUPS = {} | |
eefe8abd VS |
13 | |
14 | GROUPS["common"] = GRUB_PLATFORMS[:] | |
15 | ||
16 | # Groups based on CPU | |
8427685f BC |
17 | GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ] |
18 | GROUPS["x86_64"] = [ "x86_64_efi" ] | |
19 | GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"] | |
8427685f BC |
20 | GROUPS["mips"] = [ "mips_yeeloong" ] |
21 | GROUPS["sparc64"] = [ "sparc64_ieee1275" ] | |
22 | GROUPS["powerpc"] = [ "powerpc_ieee1275" ] | |
23 | ||
eefe8abd VS |
24 | # Groups based on firmware |
25 | GROUPS["x86_efi"] = [ "i386_efi", "x86_64_efi" ] | |
8427685f | 26 | GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ] |
8427685f | 27 | |
eefe8abd VS |
28 | # emu is a special case so many core functionality isn't needed on this platform |
29 | GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu") | |
30 | ||
31 | # Groups based on hardware features | |
32 | GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_yeeloong"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi") | |
02c9030a | 33 | GROUPS["pci"] = GROUPS["x86"] + GROUPS["mips"] |
eefe8abd | 34 | GROUPS["usb"] = GROUPS["pci"] |
8427685f | 35 | |
eefe8abd VS |
36 | # If gfxterm is main output console integrate it into kernel |
37 | GROUPS["videoinkernel"] = ["mips_yeeloong"] | |
38 | GROUPS["videomodules"] = GRUB_PLATFORMS[:]; | |
39 | for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i) | |
8427685f | 40 | |
eefe8abd VS |
41 | # Miscelaneous groups schedulded to disappear in future |
42 | GROUPS["nosparc64"] = GRUB_PLATFORMS[:]; GROUPS["nosparc64"].remove("sparc64_ieee1275") | |
43 | GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"] | |
44 | GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc") | |
8c411768 BC |
45 | |
46 | # | |
47 | # Create platform => groups reverse map, where groups covering that | |
48 | # platform are ordered by their sizes | |
49 | # | |
50 | RMAP = {} | |
51 | for platform in GRUB_PLATFORMS: | |
52 | # initialize with platform itself as a group | |
53 | RMAP[platform] = [ platform ] | |
54 | ||
55 | for k in GROUPS.keys(): | |
56 | v = GROUPS[k] | |
57 | # skip groups that don't cover this platform | |
58 | if platform not in v: continue | |
59 | ||
60 | bigger = [] | |
61 | smaller = [] | |
62 | # partition currently known groups based on their size | |
63 | for group in RMAP[platform]: | |
64 | if group in GRUB_PLATFORMS: smaller.append(group) | |
65 | elif len(GROUPS[group]) < len(v): smaller.append(group) | |
66 | else: bigger.append(group) | |
67 | # insert in the middle | |
68 | RMAP[platform] = smaller + [ k ] + bigger | |
69 | ||
70 | # | |
71 | # Global variables | |
72 | # | |
73 | GVARS = [] | |
74 | ||
75 | def gvar_add(var, value): | |
76 | if var not in GVARS: | |
77 | GVARS.append(var) | |
78 | return var + " += " + value + "\n" | |
79 | ||
80 | def global_variable_initializers(): | |
81 | r = "" | |
82 | for var in GVARS: | |
83 | r += var + " ?= \n" | |
84 | return r | |
85 | ||
86 | # | |
87 | # Per PROGRAM/SCRIPT variables | |
88 | # | |
89 | ||
90 | def var_set(var, value): | |
91 | return var + " = " + value + "\n" | |
92 | ||
93 | def var_add(var, value): | |
94 | return var + " += " + value + "\n" | |
95 | ||
96 | # | |
97 | # Autogen constructs | |
98 | # | |
99 | ||
9e860d54 | 100 | def set_canonical_name_suffix(suffix): return "[+ % name `export cname=$(echo %s" + suffix + " | sed -e 's/[^0-9A-Za-z@_]/_/g')` +]" |
911bd640 | 101 | def cname(): return "[+ % name `echo $cname` +]" |
8c411768 | 102 | |
911bd640 BC |
103 | def rule(target, source, cmd): |
104 | if cmd[0] == "\n": | |
105 | return "\n" + target + ": " + source + cmd.replace("\n", "\n\t") + "\n" | |
106 | else: | |
107 | return "\n" + target + ": " + source + "\n\t" + cmd.replace("\n", "\n\t") + "\n" | |
8c411768 | 108 | |
d9b78bce BC |
109 | # |
110 | # Template for keys with platform names as values, for example: | |
111 | # | |
112 | # kernel = { | |
113 | # nostrip = emu; | |
f6023b61 | 114 | # ... |
d9b78bce BC |
115 | # } |
116 | # | |
117 | def if_platform_tagged(platform, tag, snippet_if, snippet_else=None): | |
911bd640 BC |
118 | r = "" |
119 | r += "[+ IF " + tag + " defined +]" | |
120 | r += "[+ FOR " + tag + " +][+ CASE " + tag + " +]" | |
8c411768 | 121 | for group in RMAP[platform]: |
d9b78bce BC |
122 | r += "[+ = \"" + group + "\" +]" + snippet_if |
123 | ||
02a6605e | 124 | if snippet_else != None: r += "[+ * +]" + snippet_else |
911bd640 | 125 | r += "[+ ESAC +][+ ENDFOR +]" |
8c411768 | 126 | |
d9b78bce | 127 | if snippet_else == None: |
8c411768 | 128 | r += "[+ ENDIF +]" |
911bd640 | 129 | return r |
8c411768 | 130 | |
d9b78bce | 131 | r += "[+ ELSE +]" + snippet_else + "[+ ENDIF +]" |
8c411768 BC |
132 | return r |
133 | ||
d9b78bce | 134 | # |
8427685f BC |
135 | # Template for tagged values |
136 | # | |
137 | # module = { | |
138 | # extra_dist = ... | |
139 | # extra_dist = ... | |
140 | # ... | |
141 | # }; | |
142 | # | |
143 | def foreach_value(tag, closure): | |
144 | return "[+ FOR " + tag + " +]" + closure("[+ ." + tag + " +]") + "[+ ENDFOR +]" | |
145 | ||
146 | # | |
147 | # Template for handling best matched values for a platform, for example: | |
d9b78bce BC |
148 | # |
149 | # module = { | |
150 | # cflags = '-Wall'; | |
151 | # emu_cflags = '-Wall -DGRUB_EMU=1'; | |
f6023b61 | 152 | # ... |
d9b78bce BC |
153 | # } |
154 | # | |
8427685f | 155 | def foreach_platform_specific_value(platform, suffix, nonetag, closure): |
8c411768 | 156 | r = "" |
911bd640 | 157 | for group in RMAP[platform]: |
d9b78bce | 158 | gtag = group + suffix |
911bd640 BC |
159 | |
160 | if group == RMAP[platform][0]: | |
161 | r += "[+ IF " + gtag + " +]" | |
162 | else: | |
163 | r += "[+ ELIF " + gtag + " +]" | |
164 | ||
d9b78bce | 165 | r += "[+ FOR " + gtag + " +]" + closure("[+ ." + gtag + " +]") + "[+ ENDFOR +]" |
8427685f BC |
166 | r += "[+ ELSE +][+ FOR " + nonetag + " +]" + closure("[+ ." + nonetag + " +]") + "[+ ENDFOR +][+ ENDIF +]" |
167 | return r | |
168 | ||
169 | # | |
170 | # Template for handling values from sum of all groups for a platform, | |
171 | # for example: | |
172 | # | |
173 | # module = { | |
174 | # common = kern/misc.c; | |
175 | # emu = kern/emu/misc.c; | |
176 | # ... | |
177 | # } | |
178 | # | |
179 | def foreach_platform_value (platform, suffix, closure): | |
180 | r = "" | |
181 | for group in RMAP[platform]: | |
182 | gtag = group + suffix | |
183 | ||
184 | r += "[+ IF " + gtag + " +]" | |
185 | r += "[+ FOR " + gtag + " +]" + closure("[+ ." + gtag + " +]") + "[+ ENDFOR +]" | |
186 | r += "[+ ENDIF +]" | |
8c411768 BC |
187 | return r |
188 | ||
8427685f BC |
189 | # |
190 | # Template for gaurding with platform specific "enable" keys, for example: | |
191 | # | |
192 | # module = { | |
193 | # name = pci; | |
194 | # noemu = bus/pci.c; | |
195 | # emu = bus/emu/pci.c; | |
196 | # emu = commands/lspci.c; | |
197 | # | |
198 | # enable = emu; | |
199 | # enable = i386_pc; | |
200 | # enable = x86_efi; | |
201 | # enable = i386_ieee1275; | |
202 | # enable = i386_coreboot; | |
203 | # }; | |
204 | # | |
205 | def foreach_enabled_platform(closure): | |
911bd640 BC |
206 | r = "[+ IF - enable undefined +]" |
207 | for platform in GRUB_PLATFORMS: | |
208 | r += "\nif COND_" + platform + "\n" + closure(platform) + "endif\n" | |
209 | r += "[+ ELSE +]" | |
210 | for platform in GRUB_PLATFORMS: | |
211 | x = "\nif COND_" + platform + "\n" + closure(platform) + "endif\n" | |
d9b78bce | 212 | r += if_platform_tagged(platform, "enable", x) |
911bd640 | 213 | r += "[+ ENDIF +]" |
d9b78bce BC |
214 | return r |
215 | ||
8427685f BC |
216 | # |
217 | # Template for gaurding with platform specific automake conditionals, | |
218 | # for example: | |
219 | # | |
220 | # module = { | |
221 | # name = usb; | |
222 | # common = bus/usb/usb.c; | |
223 | # noemu = bus/usb/usbtrans.c; | |
224 | # noemu = bus/usb/usbhub.c; | |
225 | # enable = emu; | |
226 | # enable = i386; | |
227 | # enable = mips_yeeloong; | |
228 | # emu_condition = COND_GRUB_EMU_USB; | |
229 | # }; | |
230 | # | |
d9b78bce | 231 | def under_platform_specific_conditionals(platform, snippet): |
8427685f | 232 | r = foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "if " + cond + "\n") |
d9b78bce | 233 | r += snippet |
8427685f | 234 | r += foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "endif " + cond + "\n") |
d9b78bce BC |
235 | return r |
236 | ||
8427685f BC |
237 | def platform_specific_values(platform, suffix, nonetag): |
238 | return foreach_platform_specific_value(platform, suffix, nonetag, | |
239 | lambda value: value + " ") | |
911bd640 | 240 | |
8427685f BC |
241 | def platform_values(platform, suffix): |
242 | return foreach_platform_value(platform, suffix, lambda value: value + " ") | |
911bd640 | 243 | |
8427685f BC |
244 | def extra_dist(): |
245 | return foreach_value("extra_dist", lambda value: value + " ") | |
911bd640 | 246 | |
8427685f BC |
247 | def platform_sources(p): return platform_values(p, "") |
248 | def platform_nodist_sources(p): return platform_values(p, "_nodist") | |
249 | def platform_dependencies(p): return platform_values(p, "dependencies", "_dependencies") | |
250 | ||
251 | def platform_startup(p): return platform_specific_values(p, "_startup", "startup") | |
252 | def platform_ldadd(p): return platform_specific_values(p, "_ldadd", "ldadd") | |
253 | def platform_cflags(p): return platform_specific_values(p, "_cflags", "cflags") | |
254 | def platform_ldflags(p): return platform_specific_values(p, "_ldflags", "ldflags") | |
255 | def platform_cppflags(p): return platform_specific_values(p, "_cppflags", "cppflags") | |
256 | def platform_ccasflags(p): return platform_specific_values(p, "_ccasflags", "ccasflags") | |
257 | def platform_stripflags(p): return platform_specific_values(p, "_stripflags", "stripflags") | |
258 | def platform_objcopyflags(p): return platform_specific_values(p, "_objcopyflags", "objcopyflags") | |
8c411768 BC |
259 | |
260 | def module(platform): | |
911bd640 BC |
261 | r = set_canonical_name_suffix(".module") |
262 | ||
263 | r += gvar_add("noinst_PROGRAMS", "[+ name +].module") | |
e235a228 | 264 | r += gvar_add("MODULE_FILES", "[+ name +].module$(EXEEXT)") |
8c411768 | 265 | |
911bd640 | 266 | r += var_set(cname() + "_SOURCES", platform_sources(platform) + " ## platform sources") |
911bd640 | 267 | r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + " ## platform nodist sources") |
911bd640 BC |
268 | r += var_set(cname() + "_LDADD", platform_ldadd(platform)) |
269 | r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_MODULE) " + platform_cflags(platform)) | |
270 | r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_MODULE) " + platform_ldflags(platform)) | |
271 | r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_MODULE) " + platform_cppflags(platform)) | |
272 | r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_MODULE) " + platform_ccasflags(platform)) | |
02c9030a | 273 | # r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform)) |
8c411768 | 274 | |
8427685f | 275 | r += gvar_add("EXTRA_DIST", extra_dist()) |
911bd640 BC |
276 | r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)") |
277 | r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)") | |
8c411768 | 278 | |
8c411768 | 279 | r += gvar_add("MOD_FILES", "[+ name +].mod") |
6568636e BC |
280 | r += gvar_add("MARKER_FILES", "[+ name +].marker") |
281 | r += gvar_add("CLEANFILES", "[+ name +].marker") | |
8c411768 | 282 | r += """ |
6568636e BC |
283 | [+ name +].marker: $(""" + cname() + """_SOURCES) $(nodist_""" + cname() + """_SOURCES) |
284 | $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname() + """_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1) | |
285 | grep 'MARKER' $@.new > $@; rm -f $@.new | |
8c411768 BC |
286 | """ |
287 | return r | |
288 | ||
8c411768 | 289 | def kernel(platform): |
911bd640 BC |
290 | r = set_canonical_name_suffix(".exec") |
291 | r += gvar_add("noinst_PROGRAMS", "[+ name +].exec") | |
8427685f BC |
292 | r += var_set(cname() + "_SOURCES", platform_startup(platform)) |
293 | r += var_add(cname() + "_SOURCES", platform_sources(platform)) | |
911bd640 | 294 | r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + " ## platform nodist sources") |
911bd640 BC |
295 | r += var_set(cname() + "_LDADD", platform_ldadd(platform)) |
296 | r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_KERNEL) " + platform_cflags(platform)) | |
297 | r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_KERNEL) " + platform_ldflags(platform)) | |
298 | r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) " + platform_cppflags(platform)) | |
299 | r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_KERNEL) " + platform_ccasflags(platform)) | |
300 | r += var_set(cname() + "_STRIPFLAGS", "$(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) " + platform_stripflags(platform)) | |
02c9030a | 301 | # r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform)) |
8c411768 | 302 | |
8427685f | 303 | r += gvar_add("EXTRA_DIST", extra_dist()) |
911bd640 BC |
304 | r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)") |
305 | r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)") | |
8c411768 BC |
306 | |
307 | r += gvar_add("platform_DATA", "[+ name +].img") | |
911bd640 BC |
308 | r += gvar_add("CLEANFILES", "[+ name +].img") |
309 | r += rule("[+ name +].img", "[+ name +].exec$(EXEEXT)", | |
d9b78bce BC |
310 | if_platform_tagged(platform, "nostrip", "cp $< $@", |
311 | "$(STRIP) $(" + cname() + "_STRIPFLAGS) -o $@ $<")) | |
8c411768 BC |
312 | return r |
313 | ||
314 | def image(platform): | |
911bd640 BC |
315 | r = set_canonical_name_suffix(".image") |
316 | r += gvar_add("noinst_PROGRAMS", "[+ name +].image") | |
317 | r += var_set(cname() + "_SOURCES", platform_sources(platform)) | |
911bd640 | 318 | r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + "## platform nodist sources") |
911bd640 BC |
319 | r += var_set(cname() + "_LDADD", platform_ldadd(platform)) |
320 | r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_IMAGE) " + platform_cflags(platform)) | |
321 | r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_IMAGE) " + platform_ldflags(platform)) | |
322 | r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) " + platform_cppflags(platform)) | |
323 | r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_IMAGE) " + platform_ccasflags(platform)) | |
d9b78bce | 324 | r += var_set(cname() + "_OBJCOPYFLAGS", "$(OBJCOPYFLAGS_IMAGE) " + platform_objcopyflags(platform)) |
02c9030a | 325 | # r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform)) |
8c411768 | 326 | |
8427685f | 327 | r += gvar_add("EXTRA_DIST", extra_dist()) |
911bd640 BC |
328 | r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)") |
329 | r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)") | |
8c411768 BC |
330 | |
331 | r += gvar_add("platform_DATA", "[+ name +].img") | |
a60f6ee1 | 332 | r += gvar_add("CLEANFILES", "[+ name +].img") |
e235a228 | 333 | r += rule("[+ name +].img", "[+ name +].image$(EXEEXT)", """ |
8c411768 BC |
334 | if test x$(USE_APPLE_CC_FIXES) = xyes; then \ |
335 | $(MACHO2IMG) $< $@; \ | |
336 | else \ | |
d9b78bce | 337 | $(OBJCOPY) $(""" + cname() + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@; \ |
8c411768 BC |
338 | fi |
339 | """) | |
340 | return r | |
341 | ||
342 | def library(platform): | |
911bd640 BC |
343 | r = set_canonical_name_suffix("") |
344 | r += gvar_add("noinst_LIBRARIES", "[+ name +]") | |
345 | r += var_set(cname() + "_SOURCES", platform_sources(platform)) | |
911bd640 | 346 | r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform)) |
911bd640 BC |
347 | r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_LIBRARY) " + platform_cflags(platform)) |
348 | r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_LIBRARY) " + platform_cppflags(platform)) | |
349 | r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_LIBRARY) " + platform_ccasflags(platform)) | |
02c9030a | 350 | # r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform)) |
8c411768 | 351 | |
8427685f | 352 | r += gvar_add("EXTRA_DIST", extra_dist()) |
911bd640 BC |
353 | r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)") |
354 | r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)") | |
8c411768 BC |
355 | |
356 | return r | |
357 | ||
358 | def installdir(default="bin"): | |
359 | return "[+ IF installdir +][+ installdir +][+ ELSE +]" + default + "[+ ENDIF +]" | |
360 | ||
361 | def manpage(): | |
362 | r = "if COND_MAN_PAGES\n" | |
2e33ae0d | 363 | r += gvar_add("man_MANS", "[+ name +].[+ mansection +]\n") |
0a4fc180 | 364 | r += rule("[+ name +].[+ mansection +]", "[+ name +]", """ |
8c411768 | 365 | chmod a+x [+ name +] |
297f0c2b | 366 | PATH=$(builddir):$$PATH $(HELP2MAN) --section=[+ mansection +] -i $(top_srcdir)/docs/man/[+ name +].h2m -o $@ [+ name +] |
8c411768 BC |
367 | """) |
368 | r += gvar_add("CLEANFILES", "[+ name +].[+ mansection +]") | |
369 | r += "endif\n" | |
370 | return r | |
371 | ||
372 | def program(platform, test=False): | |
911bd640 BC |
373 | r = set_canonical_name_suffix("") |
374 | ||
375 | r += "[+ IF testcase defined +]" | |
376 | r += gvar_add("check_PROGRAMS", "[+ name +]") | |
377 | r += gvar_add("TESTS", "[+ name +]") | |
378 | r += "[+ ELSE +]" | |
379 | r += gvar_add(installdir() + "_PROGRAMS", "[+ name +]") | |
380 | r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]" | |
381 | r += "[+ ENDIF +]" | |
382 | ||
383 | r += var_set(cname() + "_SOURCES", platform_sources(platform)) | |
911bd640 | 384 | r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform)) |
911bd640 BC |
385 | r += var_set(cname() + "_LDADD", platform_ldadd(platform)) |
386 | r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_PROGRAM) " + platform_cflags(platform)) | |
387 | r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_PROGRAM) " + platform_ldflags(platform)) | |
388 | r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM) " + platform_cppflags(platform)) | |
389 | r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM) " + platform_ccasflags(platform)) | |
02c9030a | 390 | # r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform)) |
8c411768 | 391 | |
8427685f | 392 | r += gvar_add("EXTRA_DIST", extra_dist()) |
911bd640 BC |
393 | r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)") |
394 | r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)") | |
8c411768 BC |
395 | return r |
396 | ||
8c411768 | 397 | def data(platform): |
a60f6ee1 | 398 | r = gvar_add("EXTRA_DIST", platform_sources(platform)) |
8427685f | 399 | r += gvar_add("EXTRA_DIST", extra_dist()) |
a60f6ee1 BC |
400 | r += gvar_add(installdir() + "_DATA", platform_sources(platform)) |
401 | return r | |
8c411768 | 402 | |
911bd640 BC |
403 | def script(platform): |
404 | r = "[+ IF testcase defined +]" | |
405 | r += gvar_add("check_SCRIPTS", "[+ name +]") | |
406 | r += gvar_add ("TESTS", "[+ name +]") | |
407 | r += "[+ ELSE +]" | |
408 | r += gvar_add(installdir() + "_SCRIPTS", "[+ name +]") | |
409 | r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]" | |
410 | r += "[+ ENDIF +]" | |
8c411768 | 411 | |
0d4552fa BC |
412 | r += rule("[+ name +]", platform_sources(platform) + " $(top_builddir)/config.status", """ |
413 | $(top_builddir)/config.status --file=-:$< | sed -e 's,@pkglib_DATA@,$(pkglib_DATA),g' > $@ | |
8c411768 BC |
414 | chmod a+x [+ name +] |
415 | """) | |
416 | ||
417 | r += gvar_add("CLEANFILES", "[+ name +]") | |
6556eba9 | 418 | r += gvar_add("dist_noinst_DATA", platform_sources(platform)) |
8c411768 BC |
419 | return r |
420 | ||
8c411768 | 421 | def module_rules(): |
8427685f | 422 | return "[+ FOR module +]" + foreach_enabled_platform( |
d9b78bce | 423 | lambda p: under_platform_specific_conditionals(p, module(p))) + "[+ ENDFOR +]" |
8c411768 BC |
424 | |
425 | def kernel_rules(): | |
8427685f | 426 | return "[+ FOR kernel +]" + foreach_enabled_platform( |
d9b78bce | 427 | lambda p: under_platform_specific_conditionals(p, kernel(p))) + "[+ ENDFOR +]" |
8c411768 BC |
428 | |
429 | def image_rules(): | |
8427685f | 430 | return "[+ FOR image +]" + foreach_enabled_platform( |
d9b78bce | 431 | lambda p: under_platform_specific_conditionals(p, image(p))) + "[+ ENDFOR +]" |
8c411768 BC |
432 | |
433 | def library_rules(): | |
8427685f | 434 | return "[+ FOR library +]" + foreach_enabled_platform( |
d9b78bce | 435 | lambda p: under_platform_specific_conditionals(p, library(p))) + "[+ ENDFOR +]" |
8c411768 BC |
436 | |
437 | def program_rules(): | |
8427685f | 438 | return "[+ FOR program +]" + foreach_enabled_platform( |
d9b78bce | 439 | lambda p: under_platform_specific_conditionals(p, program(p))) + "[+ ENDFOR +]" |
8c411768 BC |
440 | |
441 | def script_rules(): | |
8427685f | 442 | return "[+ FOR script +]" + foreach_enabled_platform( |
d9b78bce | 443 | lambda p: under_platform_specific_conditionals(p, script(p))) + "[+ ENDFOR +]" |
8c411768 BC |
444 | |
445 | def data_rules(): | |
8427685f | 446 | return "[+ FOR data +]" + foreach_enabled_platform( |
d9b78bce | 447 | lambda p: under_platform_specific_conditionals(p, data(p))) + "[+ ENDFOR +]" |
8c411768 BC |
448 | |
449 | print "[+ AutoGen5 template +]\n" | |
450 | a = module_rules() | |
451 | b = kernel_rules() | |
452 | c = image_rules() | |
453 | d = library_rules() | |
454 | e = program_rules() | |
455 | f = script_rules() | |
456 | g = data_rules() | |
8c411768 BC |
457 | z = global_variable_initializers() |
458 | ||
911bd640 | 459 | # print z # initializer for all vars |
8c411768 BC |
460 | print a |
461 | print b | |
462 | print c | |
463 | print d | |
464 | print e | |
465 | print f | |
466 | print g |