2010-05-06 06:04:04 +00:00
|
|
|
#! /usr/bin/python
|
2012-02-11 10:31:13 +00:00
|
|
|
# GRUB -- GRand Unified Bootloader
|
|
|
|
# Copyright (C) 2010,2011 Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# GRUB is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# GRUB is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# This is the python script used to generate Makefile.tpl
|
|
|
|
#
|
|
|
|
|
|
|
|
GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
|
2010-05-10 08:20:43 +00:00
|
|
|
"i386_multiboot", "i386_ieee1275", "x86_64_efi",
|
2011-02-19 12:18:05 +00:00
|
|
|
"mips_loongson", "sparc64_ieee1275",
|
2011-05-17 12:02:18 +00:00
|
|
|
"powerpc_ieee1275", "mips_arc", "ia64_efi",
|
|
|
|
"mips_qemu_mips" ]
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
GROUPS = {}
|
2010-08-30 13:13:38 +00:00
|
|
|
|
|
|
|
GROUPS["common"] = GRUB_PLATFORMS[:]
|
|
|
|
|
|
|
|
# Groups based on CPU
|
2010-08-21 08:57:31 +00:00
|
|
|
GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ]
|
|
|
|
GROUPS["x86_64"] = [ "x86_64_efi" ]
|
|
|
|
GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"]
|
2011-05-17 12:02:18 +00:00
|
|
|
GROUPS["mips"] = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ]
|
2010-08-21 08:57:31 +00:00
|
|
|
GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
|
|
|
|
GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
|
|
|
|
|
2010-08-30 13:13:38 +00:00
|
|
|
# Groups based on firmware
|
2010-08-31 19:47:26 +00:00
|
|
|
GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi" ]
|
2010-08-21 08:57:31 +00:00
|
|
|
GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]
|
|
|
|
|
2010-08-30 13:13:38 +00:00
|
|
|
# emu is a special case so many core functionality isn't needed on this platform
|
|
|
|
GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu")
|
|
|
|
|
|
|
|
# Groups based on hardware features
|
2011-07-05 18:24:20 +00:00
|
|
|
GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson", "mips_qemu_mips",
|
|
|
|
"sparc64_ieee1275", "powerpc_ieee1275"]
|
|
|
|
GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi")
|
2011-05-15 00:23:36 +00:00
|
|
|
GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"]
|
2010-08-30 13:13:38 +00:00
|
|
|
GROUPS["usb"] = GROUPS["pci"]
|
2010-08-21 08:57:31 +00:00
|
|
|
|
2010-08-30 13:13:38 +00:00
|
|
|
# If gfxterm is main output console integrate it into kernel
|
2011-07-05 19:00:01 +00:00
|
|
|
GROUPS["videoinkernel"] = ["mips_loongson", "mips_qemu_mips"]
|
2010-08-30 13:13:38 +00:00
|
|
|
GROUPS["videomodules"] = GRUB_PLATFORMS[:];
|
|
|
|
for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i)
|
2010-08-21 08:57:31 +00:00
|
|
|
|
2010-09-30 15:50:01 +00:00
|
|
|
# Similar for terminfo
|
2011-05-17 12:02:18 +00:00
|
|
|
GROUPS["terminfoinkernel"] = ["mips_loongson", "mips_arc", "mips_qemu_mips" ] + GROUPS["ieee1275"];
|
2010-09-30 15:50:01 +00:00
|
|
|
GROUPS["terminfomodule"] = GRUB_PLATFORMS[:];
|
|
|
|
for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
|
|
|
|
|
2010-08-30 13:13:38 +00:00
|
|
|
# Miscelaneous groups schedulded to disappear in future
|
|
|
|
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
|
|
|
|
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create platform => groups reverse map, where groups covering that
|
|
|
|
# platform are ordered by their sizes
|
|
|
|
#
|
|
|
|
RMAP = {}
|
|
|
|
for platform in GRUB_PLATFORMS:
|
|
|
|
# initialize with platform itself as a group
|
|
|
|
RMAP[platform] = [ platform ]
|
|
|
|
|
|
|
|
for k in GROUPS.keys():
|
|
|
|
v = GROUPS[k]
|
|
|
|
# skip groups that don't cover this platform
|
|
|
|
if platform not in v: continue
|
|
|
|
|
|
|
|
bigger = []
|
|
|
|
smaller = []
|
|
|
|
# partition currently known groups based on their size
|
|
|
|
for group in RMAP[platform]:
|
|
|
|
if group in GRUB_PLATFORMS: smaller.append(group)
|
|
|
|
elif len(GROUPS[group]) < len(v): smaller.append(group)
|
|
|
|
else: bigger.append(group)
|
|
|
|
# insert in the middle
|
|
|
|
RMAP[platform] = smaller + [ k ] + bigger
|
|
|
|
|
|
|
|
#
|
|
|
|
# Global variables
|
|
|
|
#
|
2010-09-24 08:48:27 +00:00
|
|
|
GVARS = set()
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
def gvar_add(var, value):
|
2010-09-24 08:48:27 +00:00
|
|
|
GVARS.add(var)
|
2010-05-06 06:04:04 +00:00
|
|
|
return var + " += " + value + "\n"
|
|
|
|
|
|
|
|
def global_variable_initializers():
|
|
|
|
r = ""
|
2010-09-24 08:48:27 +00:00
|
|
|
for var in sorted(GVARS):
|
2010-05-06 06:04:04 +00:00
|
|
|
r += var + " ?= \n"
|
|
|
|
return r
|
|
|
|
|
|
|
|
#
|
|
|
|
# Per PROGRAM/SCRIPT variables
|
|
|
|
#
|
|
|
|
|
2010-09-24 08:48:27 +00:00
|
|
|
def vars_init(*var_list):
|
|
|
|
r = "[+ IF (if (not (assoc-ref seen-vars (get \".name\"))) \"seen\") +]"
|
|
|
|
r += "[+ (out-suspend \"v\") +]"
|
|
|
|
for var in var_list:
|
|
|
|
r += var + " = \n"
|
|
|
|
r += "[+ (out-resume \"v\") +]"
|
|
|
|
r += "[+ (set! seen-vars (assoc-set! seen-vars (get \".name\") 0)) +]"
|
|
|
|
r += "[+ ENDIF +]"
|
|
|
|
return first_time(r)
|
|
|
|
|
2010-05-06 06:04:04 +00:00
|
|
|
def var_set(var, value):
|
|
|
|
return var + " = " + value + "\n"
|
|
|
|
|
|
|
|
def var_add(var, value):
|
|
|
|
return var + " += " + value + "\n"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Autogen constructs
|
|
|
|
#
|
|
|
|
|
2010-08-23 08:37:29 +00:00
|
|
|
def set_canonical_name_suffix(suffix): return "[+ % name `export cname=$(echo %s" + suffix + " | sed -e 's/[^0-9A-Za-z@_]/_/g')` +]"
|
2010-07-13 18:05:24 +00:00
|
|
|
def cname(): return "[+ % name `echo $cname` +]"
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-07-13 18:05:24 +00:00
|
|
|
def rule(target, source, cmd):
|
|
|
|
if cmd[0] == "\n":
|
|
|
|
return "\n" + target + ": " + source + cmd.replace("\n", "\n\t") + "\n"
|
|
|
|
else:
|
|
|
|
return "\n" + target + ": " + source + "\n\t" + cmd.replace("\n", "\n\t") + "\n"
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-07-14 20:32:01 +00:00
|
|
|
#
|
|
|
|
# Template for keys with platform names as values, for example:
|
|
|
|
#
|
|
|
|
# kernel = {
|
|
|
|
# nostrip = emu;
|
2010-07-16 20:02:36 +00:00
|
|
|
# ...
|
2010-07-14 20:32:01 +00:00
|
|
|
# }
|
|
|
|
#
|
|
|
|
def if_platform_tagged(platform, tag, snippet_if, snippet_else=None):
|
2010-07-13 18:05:24 +00:00
|
|
|
r = ""
|
|
|
|
r += "[+ IF " + tag + " defined +]"
|
|
|
|
r += "[+ FOR " + tag + " +][+ CASE " + tag + " +]"
|
2010-05-06 06:04:04 +00:00
|
|
|
for group in RMAP[platform]:
|
2010-07-14 20:32:01 +00:00
|
|
|
r += "[+ = \"" + group + "\" +]" + snippet_if
|
|
|
|
|
2010-08-20 05:40:42 +00:00
|
|
|
if snippet_else != None: r += "[+ * +]" + snippet_else
|
2010-07-13 18:05:24 +00:00
|
|
|
r += "[+ ESAC +][+ ENDFOR +]"
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-07-14 20:32:01 +00:00
|
|
|
if snippet_else == None:
|
2010-05-06 06:04:04 +00:00
|
|
|
r += "[+ ENDIF +]"
|
2010-07-13 18:05:24 +00:00
|
|
|
return r
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-07-14 20:32:01 +00:00
|
|
|
r += "[+ ELSE +]" + snippet_else + "[+ ENDIF +]"
|
2010-05-06 06:04:04 +00:00
|
|
|
return r
|
|
|
|
|
2010-07-14 20:32:01 +00:00
|
|
|
#
|
2010-08-21 08:57:31 +00:00
|
|
|
# Template for tagged values
|
|
|
|
#
|
|
|
|
# module = {
|
|
|
|
# extra_dist = ...
|
|
|
|
# extra_dist = ...
|
|
|
|
# ...
|
|
|
|
# };
|
|
|
|
#
|
|
|
|
def foreach_value(tag, closure):
|
|
|
|
return "[+ FOR " + tag + " +]" + closure("[+ ." + tag + " +]") + "[+ ENDFOR +]"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Template for handling best matched values for a platform, for example:
|
2010-07-14 20:32:01 +00:00
|
|
|
#
|
|
|
|
# module = {
|
|
|
|
# cflags = '-Wall';
|
|
|
|
# emu_cflags = '-Wall -DGRUB_EMU=1';
|
2010-07-16 20:02:36 +00:00
|
|
|
# ...
|
2010-07-14 20:32:01 +00:00
|
|
|
# }
|
|
|
|
#
|
2010-08-21 08:57:31 +00:00
|
|
|
def foreach_platform_specific_value(platform, suffix, nonetag, closure):
|
2010-05-06 06:04:04 +00:00
|
|
|
r = ""
|
2010-07-13 18:05:24 +00:00
|
|
|
for group in RMAP[platform]:
|
2010-07-14 20:32:01 +00:00
|
|
|
gtag = group + suffix
|
2010-07-13 18:05:24 +00:00
|
|
|
|
|
|
|
if group == RMAP[platform][0]:
|
|
|
|
r += "[+ IF " + gtag + " +]"
|
|
|
|
else:
|
|
|
|
r += "[+ ELIF " + gtag + " +]"
|
|
|
|
|
2010-07-14 20:32:01 +00:00
|
|
|
r += "[+ FOR " + gtag + " +]" + closure("[+ ." + gtag + " +]") + "[+ ENDFOR +]"
|
2010-08-21 08:57:31 +00:00
|
|
|
r += "[+ ELSE +][+ FOR " + nonetag + " +]" + closure("[+ ." + nonetag + " +]") + "[+ ENDFOR +][+ ENDIF +]"
|
|
|
|
return r
|
|
|
|
|
2011-10-01 01:49:37 +00:00
|
|
|
#
|
|
|
|
# Returns autogen code that defines an autogen macro using the
|
|
|
|
# definition given in the 'snippet'.
|
|
|
|
#
|
|
|
|
def define_autogen_macro(name, snippet):
|
|
|
|
r = ""
|
|
|
|
r += "[+ DEFINE " + name + " +]"
|
|
|
|
r += snippet
|
|
|
|
r += "[+ ENDDEF +]\n"
|
|
|
|
return r
|
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
#
|
|
|
|
# Template for handling values from sum of all groups for a platform,
|
|
|
|
# for example:
|
|
|
|
#
|
|
|
|
# module = {
|
|
|
|
# common = kern/misc.c;
|
|
|
|
# emu = kern/emu/misc.c;
|
|
|
|
# ...
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
def foreach_platform_value (platform, suffix, closure):
|
|
|
|
r = ""
|
|
|
|
for group in RMAP[platform]:
|
|
|
|
gtag = group + suffix
|
|
|
|
|
|
|
|
r += "[+ IF " + gtag + " +]"
|
|
|
|
r += "[+ FOR " + gtag + " +]" + closure("[+ ." + gtag + " +]") + "[+ ENDFOR +]"
|
|
|
|
r += "[+ ENDIF +]"
|
2010-05-06 06:04:04 +00:00
|
|
|
return r
|
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
#
|
|
|
|
# Template for gaurding with platform specific "enable" keys, for example:
|
|
|
|
#
|
|
|
|
# module = {
|
|
|
|
# name = pci;
|
|
|
|
# noemu = bus/pci.c;
|
|
|
|
# emu = bus/emu/pci.c;
|
|
|
|
# emu = commands/lspci.c;
|
|
|
|
#
|
|
|
|
# enable = emu;
|
|
|
|
# enable = i386_pc;
|
|
|
|
# enable = x86_efi;
|
|
|
|
# enable = i386_ieee1275;
|
|
|
|
# enable = i386_coreboot;
|
|
|
|
# };
|
|
|
|
#
|
|
|
|
def foreach_enabled_platform(closure):
|
2010-07-13 18:05:24 +00:00
|
|
|
r = "[+ IF - enable undefined +]"
|
|
|
|
for platform in GRUB_PLATFORMS:
|
|
|
|
r += "\nif COND_" + platform + "\n" + closure(platform) + "endif\n"
|
|
|
|
r += "[+ ELSE +]"
|
|
|
|
for platform in GRUB_PLATFORMS:
|
|
|
|
x = "\nif COND_" + platform + "\n" + closure(platform) + "endif\n"
|
2010-07-14 20:32:01 +00:00
|
|
|
r += if_platform_tagged(platform, "enable", x)
|
2010-07-13 18:05:24 +00:00
|
|
|
r += "[+ ENDIF +]"
|
2010-07-14 20:32:01 +00:00
|
|
|
return r
|
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
#
|
|
|
|
# Template for gaurding with platform specific automake conditionals,
|
|
|
|
# for example:
|
|
|
|
#
|
|
|
|
# module = {
|
|
|
|
# name = usb;
|
|
|
|
# common = bus/usb/usb.c;
|
|
|
|
# noemu = bus/usb/usbtrans.c;
|
|
|
|
# noemu = bus/usb/usbhub.c;
|
|
|
|
# enable = emu;
|
|
|
|
# enable = i386;
|
2011-02-19 12:18:05 +00:00
|
|
|
# enable = mips_loongson;
|
2010-08-21 08:57:31 +00:00
|
|
|
# emu_condition = COND_GRUB_EMU_USB;
|
|
|
|
# };
|
|
|
|
#
|
2011-10-01 01:49:37 +00:00
|
|
|
def define_macro_for_platform_conditionals_if_statement(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"if_" + p + "_conditionals",
|
|
|
|
foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "if " + cond + "\n"))
|
|
|
|
def define_macro_for_platform_conditionals_endif_statement(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"endif_" + p + "_conditionals",
|
|
|
|
foreach_platform_specific_value(platform, "_condition", "condition", lambda cond: "endif " + cond + "\n"))
|
2010-07-14 20:32:01 +00:00
|
|
|
def under_platform_specific_conditionals(platform, snippet):
|
2011-10-01 01:49:37 +00:00
|
|
|
r = "[+ if_" + platform + "_conditionals +]"
|
2010-07-14 20:32:01 +00:00
|
|
|
r += snippet
|
2011-10-01 01:49:37 +00:00
|
|
|
r += "[+ endif_" + platform + "_conditionals +]"
|
2010-07-14 20:32:01 +00:00
|
|
|
return r
|
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
def platform_specific_values(platform, suffix, nonetag):
|
|
|
|
return foreach_platform_specific_value(platform, suffix, nonetag,
|
|
|
|
lambda value: value + " ")
|
2010-07-13 18:05:24 +00:00
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
def platform_values(platform, suffix):
|
|
|
|
return foreach_platform_value(platform, suffix, lambda value: value + " ")
|
2010-07-13 18:05:24 +00:00
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
def extra_dist():
|
|
|
|
return foreach_value("extra_dist", lambda value: value + " ")
|
2010-07-13 18:05:24 +00:00
|
|
|
|
2011-10-01 01:49:37 +00:00
|
|
|
def define_macro_for_platform_sources(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_sources",
|
|
|
|
platform_values(p, ""))
|
|
|
|
def define_macro_for_platform_nodist_sources(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_nodist_sources",
|
|
|
|
platform_values(p, "_nodist"))
|
|
|
|
def define_macro_for_platform_dependencies(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_dependencies",
|
|
|
|
platform_values(p, "dependencies", "_dependencies"))
|
|
|
|
def platform_sources(p): return "[+ get_" + p + "_sources +]"
|
|
|
|
def platform_nodist_sources(p): return "[+ get_" + p + "_nodist_sources +]"
|
|
|
|
def platform_dependencies(p): return "[+ get_" + p + "_dependencies +]"
|
2010-08-21 08:57:31 +00:00
|
|
|
|
2011-10-01 01:49:37 +00:00
|
|
|
#
|
|
|
|
# Returns Autogen code which defines the autogen macros that collect
|
|
|
|
# platform specific values for cflags, ldflags, etc. tags.
|
|
|
|
#
|
|
|
|
def define_macro_for_platform_startup(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_startup",
|
|
|
|
platform_specific_values(p, "_startup", "startup"))
|
|
|
|
def define_macro_for_platform_cflags(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_cflags",
|
|
|
|
platform_specific_values(p, "_cflags", "cflags"))
|
|
|
|
def define_macro_for_platform_ldadd(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_ldadd",
|
|
|
|
platform_specific_values(p, "_ldadd", "ldadd"))
|
|
|
|
def define_macro_for_platform_ldflags(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_ldflags",
|
|
|
|
platform_specific_values(p, "_ldflags", "ldflags"))
|
|
|
|
def define_macro_for_platform_cppflags(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_cppflags",
|
|
|
|
platform_specific_values(p, "_cppflags", "cppflags"))
|
|
|
|
def define_macro_for_platform_ccasflags(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_ccasflags",
|
|
|
|
platform_specific_values(p, "_ccasflags", "ccasflags"))
|
|
|
|
def define_macro_for_platform_stripflags(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_stripflags",
|
|
|
|
platform_specific_values(p, "_stripflags", "stripflags"))
|
|
|
|
def define_macro_for_platform_objcopyflags(p):
|
|
|
|
return define_autogen_macro(
|
|
|
|
"get_" + p + "_objcopyflags",
|
|
|
|
platform_specific_values(p, "_objcopyflags", "objcopyflags"))
|
|
|
|
#
|
|
|
|
# Autogen calls to invoke the above macros.
|
|
|
|
#
|
|
|
|
def platform_startup(p): return "[+ get_" + p + "_startup +]"
|
|
|
|
def platform_ldadd(p): return "[+ get_" + p + "_ldadd +]"
|
|
|
|
def platform_cflags(p): return "[+ get_" + p + "_cflags +]"
|
|
|
|
def platform_ldflags(p): return "[+ get_" + p + "_ldflags +]"
|
|
|
|
def platform_cppflags(p): return "[+ get_" + p + "_cppflags +]"
|
|
|
|
def platform_ccasflags(p): return "[+ get_" + p + "_ccasflags +]"
|
|
|
|
def platform_stripflags(p): return "[+ get_" + p + "_stripflags +]"
|
|
|
|
def platform_objcopyflags(p): return "[+ get_" + p + "_objcopyflags +]"
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-09-24 08:48:27 +00:00
|
|
|
#
|
|
|
|
# Emit snippet only the first time through for the current name.
|
|
|
|
#
|
|
|
|
def first_time(snippet):
|
|
|
|
r = "[+ IF (if (not (assoc-ref seen-target (get \".name\"))) \"seen\") +]"
|
|
|
|
r += snippet
|
|
|
|
r += "[+ ENDIF +]"
|
|
|
|
return r
|
|
|
|
|
2010-05-06 06:04:04 +00:00
|
|
|
def module(platform):
|
2010-07-13 18:05:24 +00:00
|
|
|
r = set_canonical_name_suffix(".module")
|
|
|
|
|
2012-02-18 19:25:11 +00:00
|
|
|
r += gvar_add("platform_PROGRAMS", "[+ name +].module")
|
2010-06-07 15:58:37 +00:00
|
|
|
r += gvar_add("MODULE_FILES", "[+ name +].module$(EXEEXT)")
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-07-13 18:05:24 +00:00
|
|
|
r += var_set(cname() + "_SOURCES", platform_sources(platform) + " ## platform sources")
|
|
|
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + " ## platform nodist sources")
|
|
|
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
|
|
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_MODULE) " + platform_cflags(platform))
|
|
|
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_MODULE) " + platform_ldflags(platform))
|
|
|
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_MODULE) " + platform_cppflags(platform))
|
|
|
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_MODULE) " + platform_ccasflags(platform))
|
2010-08-06 04:31:54 +00:00
|
|
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
2010-07-13 18:05:24 +00:00
|
|
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
|
|
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
r += gvar_add("MOD_FILES", "[+ name +].mod")
|
2010-08-29 15:52:41 +00:00
|
|
|
r += gvar_add("MARKER_FILES", "[+ name +].marker")
|
|
|
|
r += gvar_add("CLEANFILES", "[+ name +].marker")
|
2010-05-06 06:04:04 +00:00
|
|
|
r += """
|
2010-08-29 15:52:41 +00:00
|
|
|
[+ name +].marker: $(""" + cname() + """_SOURCES) $(nodist_""" + cname() + """_SOURCES)
|
|
|
|
$(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname() + """_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
|
|
|
|
grep 'MARKER' $@.new > $@; rm -f $@.new
|
2010-05-06 06:04:04 +00:00
|
|
|
"""
|
|
|
|
return r
|
|
|
|
|
|
|
|
def kernel(platform):
|
2010-07-13 18:05:24 +00:00
|
|
|
r = set_canonical_name_suffix(".exec")
|
2012-02-18 19:25:11 +00:00
|
|
|
r += gvar_add("platform_PROGRAMS", "[+ name +].exec")
|
2010-08-21 08:57:31 +00:00
|
|
|
r += var_set(cname() + "_SOURCES", platform_startup(platform))
|
|
|
|
r += var_add(cname() + "_SOURCES", platform_sources(platform))
|
2010-07-13 18:05:24 +00:00
|
|
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + " ## platform nodist sources")
|
|
|
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
|
|
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_KERNEL) " + platform_cflags(platform))
|
|
|
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_KERNEL) " + platform_ldflags(platform))
|
|
|
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) " + platform_cppflags(platform))
|
|
|
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_KERNEL) " + platform_ccasflags(platform))
|
|
|
|
r += var_set(cname() + "_STRIPFLAGS", "$(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) " + platform_stripflags(platform))
|
2010-08-06 04:31:54 +00:00
|
|
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
2010-07-13 18:05:24 +00:00
|
|
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
|
|
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
r += gvar_add("platform_DATA", "[+ name +].img")
|
2010-07-13 18:05:24 +00:00
|
|
|
r += gvar_add("CLEANFILES", "[+ name +].img")
|
|
|
|
r += rule("[+ name +].img", "[+ name +].exec$(EXEEXT)",
|
2010-07-14 20:32:01 +00:00
|
|
|
if_platform_tagged(platform, "nostrip", "cp $< $@",
|
|
|
|
"$(STRIP) $(" + cname() + "_STRIPFLAGS) -o $@ $<"))
|
2010-05-06 06:04:04 +00:00
|
|
|
return r
|
|
|
|
|
|
|
|
def image(platform):
|
2010-07-13 18:05:24 +00:00
|
|
|
r = set_canonical_name_suffix(".image")
|
2012-02-18 19:25:11 +00:00
|
|
|
r += gvar_add("platform_PROGRAMS", "[+ name +].image")
|
2010-07-13 18:05:24 +00:00
|
|
|
r += var_set(cname() + "_SOURCES", platform_sources(platform))
|
|
|
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform) + "## platform nodist sources")
|
|
|
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
|
|
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_IMAGE) " + platform_cflags(platform))
|
|
|
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_IMAGE) " + platform_ldflags(platform))
|
|
|
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) " + platform_cppflags(platform))
|
|
|
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_IMAGE) " + platform_ccasflags(platform))
|
2010-07-14 20:32:01 +00:00
|
|
|
r += var_set(cname() + "_OBJCOPYFLAGS", "$(OBJCOPYFLAGS_IMAGE) " + platform_objcopyflags(platform))
|
2010-08-06 04:31:54 +00:00
|
|
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
2010-07-13 18:05:24 +00:00
|
|
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
|
|
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
r += gvar_add("platform_DATA", "[+ name +].img")
|
2010-06-03 06:22:33 +00:00
|
|
|
r += gvar_add("CLEANFILES", "[+ name +].img")
|
2010-06-07 15:58:37 +00:00
|
|
|
r += rule("[+ name +].img", "[+ name +].image$(EXEEXT)", """
|
2010-05-06 06:04:04 +00:00
|
|
|
if test x$(USE_APPLE_CC_FIXES) = xyes; then \
|
|
|
|
$(MACHO2IMG) $< $@; \
|
|
|
|
else \
|
2010-07-14 20:32:01 +00:00
|
|
|
$(OBJCOPY) $(""" + cname() + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@; \
|
2010-05-06 06:04:04 +00:00
|
|
|
fi
|
|
|
|
""")
|
|
|
|
return r
|
|
|
|
|
|
|
|
def library(platform):
|
2010-07-13 18:05:24 +00:00
|
|
|
r = set_canonical_name_suffix("")
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-09-24 08:48:27 +00:00
|
|
|
r += vars_init(cname() + "_SOURCES",
|
|
|
|
"nodist_" + cname() + "_SOURCES",
|
|
|
|
cname() + "_CFLAGS",
|
|
|
|
cname() + "_CPPFLAGS",
|
|
|
|
cname() + "_CCASFLAGS")
|
|
|
|
# cname() + "_DEPENDENCIES")
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-09-24 08:48:27 +00:00
|
|
|
r += first_time(gvar_add("noinst_LIBRARIES", "[+ name +]"))
|
|
|
|
r += var_add(cname() + "_SOURCES", platform_sources(platform))
|
|
|
|
r += var_add("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform))
|
|
|
|
r += var_add(cname() + "_CFLAGS", first_time("$(AM_CFLAGS) $(CFLAGS_LIBRARY) ") + platform_cflags(platform))
|
|
|
|
r += var_add(cname() + "_CPPFLAGS", first_time("$(AM_CPPFLAGS) $(CPPFLAGS_LIBRARY) ") + platform_cppflags(platform))
|
|
|
|
r += var_add(cname() + "_CCASFLAGS", first_time("$(AM_CCASFLAGS) $(CCASFLAGS_LIBRARY) ") + platform_ccasflags(platform))
|
|
|
|
# r += var_add(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
|
|
|
|
|
|
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
|
|
|
r += first_time(gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)"))
|
|
|
|
r += first_time(gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)"))
|
2010-05-06 06:04:04 +00:00
|
|
|
return r
|
|
|
|
|
|
|
|
def installdir(default="bin"):
|
|
|
|
return "[+ IF installdir +][+ installdir +][+ ELSE +]" + default + "[+ ENDIF +]"
|
|
|
|
|
|
|
|
def manpage():
|
|
|
|
r = "if COND_MAN_PAGES\n"
|
2010-05-10 10:07:18 +00:00
|
|
|
r += gvar_add("man_MANS", "[+ name +].[+ mansection +]\n")
|
2010-08-15 15:39:37 +00:00
|
|
|
r += rule("[+ name +].[+ mansection +]", "[+ name +]", """
|
2010-05-06 06:04:04 +00:00
|
|
|
chmod a+x [+ name +]
|
2012-02-10 17:16:27 +00:00
|
|
|
PATH=$(builddir):$$PATH pkgdatadir=$(builddir) $(HELP2MAN) --section=[+ mansection +] -i $(top_srcdir)/docs/man/[+ name +].h2m -o $@ [+ name +]
|
2010-05-06 06:04:04 +00:00
|
|
|
""")
|
|
|
|
r += gvar_add("CLEANFILES", "[+ name +].[+ mansection +]")
|
|
|
|
r += "endif\n"
|
|
|
|
return r
|
|
|
|
|
|
|
|
def program(platform, test=False):
|
2010-07-13 18:05:24 +00:00
|
|
|
r = set_canonical_name_suffix("")
|
|
|
|
|
|
|
|
r += "[+ IF testcase defined +]"
|
|
|
|
r += gvar_add("check_PROGRAMS", "[+ name +]")
|
|
|
|
r += gvar_add("TESTS", "[+ name +]")
|
|
|
|
r += "[+ ELSE +]"
|
2010-09-24 08:48:27 +00:00
|
|
|
r += var_add(installdir() + "_PROGRAMS", "[+ name +]")
|
2010-07-13 18:05:24 +00:00
|
|
|
r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
|
|
|
|
r += "[+ ENDIF +]"
|
|
|
|
|
|
|
|
r += var_set(cname() + "_SOURCES", platform_sources(platform))
|
|
|
|
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform))
|
|
|
|
r += var_set(cname() + "_LDADD", platform_ldadd(platform))
|
|
|
|
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_PROGRAM) " + platform_cflags(platform))
|
|
|
|
r += var_set(cname() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_PROGRAM) " + platform_ldflags(platform))
|
|
|
|
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM) " + platform_cppflags(platform))
|
|
|
|
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM) " + platform_ccasflags(platform))
|
2010-08-06 04:31:54 +00:00
|
|
|
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-08-21 08:57:31 +00:00
|
|
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
2010-07-13 18:05:24 +00:00
|
|
|
r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
|
|
|
|
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
|
2010-05-06 06:04:04 +00:00
|
|
|
return r
|
|
|
|
|
|
|
|
def data(platform):
|
2010-06-03 06:22:33 +00:00
|
|
|
r = gvar_add("EXTRA_DIST", platform_sources(platform))
|
2010-08-21 08:57:31 +00:00
|
|
|
r += gvar_add("EXTRA_DIST", extra_dist())
|
2010-09-24 08:48:27 +00:00
|
|
|
r += var_add(installdir() + "_DATA", platform_sources(platform))
|
2010-06-03 06:22:33 +00:00
|
|
|
return r
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-07-13 18:05:24 +00:00
|
|
|
def script(platform):
|
|
|
|
r = "[+ IF testcase defined +]"
|
|
|
|
r += gvar_add("check_SCRIPTS", "[+ name +]")
|
|
|
|
r += gvar_add ("TESTS", "[+ name +]")
|
|
|
|
r += "[+ ELSE +]"
|
2010-09-24 08:48:27 +00:00
|
|
|
r += var_add(installdir() + "_SCRIPTS", "[+ name +]")
|
2010-07-13 18:05:24 +00:00
|
|
|
r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
|
|
|
|
r += "[+ ENDIF +]"
|
2010-05-06 06:04:04 +00:00
|
|
|
|
2010-08-29 05:47:30 +00:00
|
|
|
r += rule("[+ name +]", platform_sources(platform) + " $(top_builddir)/config.status", """
|
2012-02-26 17:54:30 +00:00
|
|
|
$(top_builddir)/config.status --file=$@:$<
|
2010-05-06 06:04:04 +00:00
|
|
|
chmod a+x [+ name +]
|
|
|
|
""")
|
|
|
|
|
|
|
|
r += gvar_add("CLEANFILES", "[+ name +]")
|
2010-09-03 15:53:00 +00:00
|
|
|
r += gvar_add("dist_noinst_DATA", platform_sources(platform))
|
2010-05-06 06:04:04 +00:00
|
|
|
return r
|
|
|
|
|
2010-09-24 08:48:27 +00:00
|
|
|
def rules(target, closure):
|
|
|
|
# Create association lists for the benefit of first_time and vars_init.
|
|
|
|
r = "[+ (define seen-target '()) +]"
|
|
|
|
r += "[+ (define seen-vars '()) +]"
|
|
|
|
# Most output goes to a diversion. This allows us to emit variable
|
|
|
|
# initializations before everything else.
|
|
|
|
r += "[+ (out-push-new) +]"
|
|
|
|
|
|
|
|
r += "[+ FOR " + target + " +]"
|
|
|
|
r += foreach_enabled_platform(
|
|
|
|
lambda p: under_platform_specific_conditionals(p, closure(p)))
|
|
|
|
# Remember that we've seen this target.
|
|
|
|
r += "[+ (set! seen-target (assoc-set! seen-target (get \".name\") 0)) +]"
|
|
|
|
r += "[+ ENDFOR +]"
|
|
|
|
r += "[+ (out-pop #t) +]"
|
|
|
|
return r
|
|
|
|
|
2010-05-06 06:04:04 +00:00
|
|
|
def module_rules():
|
2010-09-24 08:48:27 +00:00
|
|
|
return rules("module", module)
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
def kernel_rules():
|
2010-09-24 08:48:27 +00:00
|
|
|
return rules("kernel", kernel)
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
def image_rules():
|
2010-09-24 08:48:27 +00:00
|
|
|
return rules("image", image)
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
def library_rules():
|
2010-09-24 08:48:27 +00:00
|
|
|
return rules("library", library)
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
def program_rules():
|
2010-09-24 08:48:27 +00:00
|
|
|
return rules("program", program)
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
def script_rules():
|
2010-09-24 08:48:27 +00:00
|
|
|
return rules("script", script)
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
def data_rules():
|
2010-09-24 08:48:27 +00:00
|
|
|
return rules("data", data)
|
2010-05-06 06:04:04 +00:00
|
|
|
|
|
|
|
a = module_rules()
|
|
|
|
b = kernel_rules()
|
|
|
|
c = image_rules()
|
|
|
|
d = library_rules()
|
|
|
|
e = program_rules()
|
|
|
|
f = script_rules()
|
|
|
|
g = data_rules()
|
|
|
|
z = global_variable_initializers()
|
|
|
|
|
2011-10-16 09:53:27 +00:00
|
|
|
print ("[+ AutoGen5 template +]\n")
|
2011-10-01 01:49:37 +00:00
|
|
|
for p in GRUB_PLATFORMS:
|
2011-10-16 09:53:27 +00:00
|
|
|
print (define_macro_for_platform_sources(p))
|
|
|
|
print (define_macro_for_platform_nodist_sources(p))
|
2011-10-01 01:49:37 +00:00
|
|
|
# print define_macro_for_platform_dependencies(p)
|
|
|
|
|
2011-10-16 09:53:27 +00:00
|
|
|
print (define_macro_for_platform_startup(p))
|
|
|
|
print (define_macro_for_platform_cflags(p))
|
|
|
|
print (define_macro_for_platform_ldadd(p))
|
|
|
|
print (define_macro_for_platform_ldflags(p))
|
|
|
|
print (define_macro_for_platform_cppflags(p))
|
|
|
|
print (define_macro_for_platform_ccasflags(p))
|
|
|
|
print (define_macro_for_platform_stripflags(p))
|
|
|
|
print (define_macro_for_platform_objcopyflags(p))
|
|
|
|
|
|
|
|
print (define_macro_for_platform_conditionals_if_statement(p))
|
|
|
|
print (define_macro_for_platform_conditionals_endif_statement(p))
|
2010-07-13 18:05:24 +00:00
|
|
|
# print z # initializer for all vars
|
2011-10-16 09:53:27 +00:00
|
|
|
print (a)
|
|
|
|
print (b)
|
|
|
|
print (c)
|
|
|
|
print (d)
|
|
|
|
print (e)
|
|
|
|
print (f)
|
|
|
|
print (g)
|