Re-enable grub-extras.

* autogen.sh: Create symlinks to ${GRUB_CONTRIB} if necessary to
avoid confusing Automake.  Run autogen only twice, once for the top
level and once for grub-core.  Add Makefile.util.def and
Makefile.core.def from extra modules to the appropriate autogen
invocations.  If Makefile.common exists in an extra module, include
it in both Makefile.util.am and grub-core/Makefile.core.am;
similarly, include any Makefile.util.common file in Makefile.util.am
and any Makefile.core.common file in grub-core/Makefile.core.am.
* conf/Makefile.common ($(top_srcdir)/grub-core/Makefile.core.am):
Depend on $(top_srcdir)/grub-core/Makefile.gcry.def.
($(top_srcdir)/grub-core/Makefile.gcry.def): Remove.
* grub-core/Makefile.am: Remove inclusion of Makefile.gcry.am.
* gentpl.py (gvar_add): Turn GVARS into a set.
(global_variable_initializers): Sort global variables on output.
(vars_init): New function.
(first_time): Likewise.
(library): Ensure that non-global variable initialisations are
emitted before the first time we emit code for a library block.
Append to variables rather than setting them.  Only emit
noinst_LIBRARIES, BUILT_SOURCES, and CLEANFILES the first time for
each conditional path.
(program): installdir() emits an Autogen macro, so must be passed to
var_add rather than gvar_add.
(data): Likewise.
(script): Likewise.
(rules): New function, centralising handling for different target
types.  Set up Guile association lists for first_time and vars_init,
and send most output to a diversion so that variable initialisations
can be emitted first.
(module_rules): Use new rules function.
(kernel_rules): Likewise.
(image_rules): Likewise.
(library_rules): Likewise.
(program_rules): Likewise.
(script_rules): Likewise.
(data_rules): Likewise.
* configure.ac: Add AC_PROG_LN_S, for the benefit of ntldr-img.
* .bzrignore: Add contrib and grub-core/contrib.  Remove
grub-core/Makefile.gcry.am.
This commit is contained in:
Colin Watson 2010-09-24 09:48:27 +01:00
parent 1d12cf2947
commit e1fd193905
7 changed files with 163 additions and 43 deletions

View file

@ -104,9 +104,10 @@ grub-core/lib/libgcrypt-grub
**/.deps-core
**/.dirstamp
Makefile.util.am
contrib
grub-core/Makefile.core.am
grub-core/Makefile.gcry.am
grub-core/Makefile.gcry.def
grub-core/contrib
grub-core/genmod.sh
grub-core/gensyminfo.sh
grub-core/*.module

View file

@ -1,3 +1,50 @@
2010-09-24 Colin Watson <cjwatson@ubuntu.com>
Re-enable grub-extras.
* autogen.sh: Create symlinks to ${GRUB_CONTRIB} if necessary to
avoid confusing Automake. Run autogen only twice, once for the top
level and once for grub-core. Add Makefile.util.def and
Makefile.core.def from extra modules to the appropriate autogen
invocations. If Makefile.common exists in an extra module, include
it in both Makefile.util.am and grub-core/Makefile.core.am;
similarly, include any Makefile.util.common file in Makefile.util.am
and any Makefile.core.common file in grub-core/Makefile.core.am.
* conf/Makefile.common ($(top_srcdir)/grub-core/Makefile.core.am):
Depend on $(top_srcdir)/grub-core/Makefile.gcry.def.
($(top_srcdir)/grub-core/Makefile.gcry.def): Remove.
* grub-core/Makefile.am: Remove inclusion of Makefile.gcry.am.
* gentpl.py (gvar_add): Turn GVARS into a set.
(global_variable_initializers): Sort global variables on output.
(vars_init): New function.
(first_time): Likewise.
(library): Ensure that non-global variable initialisations are
emitted before the first time we emit code for a library block.
Append to variables rather than setting them. Only emit
noinst_LIBRARIES, BUILT_SOURCES, and CLEANFILES the first time for
each conditional path.
(program): installdir() emits an Autogen macro, so must be passed to
var_add rather than gvar_add.
(data): Likewise.
(script): Likewise.
(rules): New function, centralising handling for different target
types. Set up Guile association lists for first_time and vars_init,
and send most output to a diversion so that variable initialisations
can be emitted first.
(module_rules): Use new rules function.
(kernel_rules): Likewise.
(image_rules): Likewise.
(library_rules): Likewise.
(program_rules): Likewise.
(script_rules): Likewise.
(data_rules): Likewise.
* configure.ac: Add AC_PROG_LN_S, for the benefit of ntldr-img.
* .bzrignore: Add contrib and grub-core/contrib. Remove
grub-core/Makefile.gcry.am.
2010-09-24 Yves Blusseau <blusseau@zetam.org>
* grub-core/lib/LzFind.c: Add missing include.

View file

@ -14,9 +14,50 @@ echo "Creating Makefile.tpl..."
python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
echo "Running autogen..."
autogen -T Makefile.tpl Makefile.util.def | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
autogen -T Makefile.tpl grub-core/Makefile.core.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
autogen -T Makefile.tpl grub-core/Makefile.gcry.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.gcry.am
# Automake doesn't like including files from a path outside the project.
rm -f contrib grub-core/contrib
if [ "x${GRUB_CONTRIB}" != x ]; then
[ "${GRUB_CONTRIB}" = contrib ] || ln -s "${GRUB_CONTRIB}" contrib
[ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
fi
UTIL_DEFS=Makefile.util.def
CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
for extra in contrib/*/Makefile.util.def; do
if test -e "$extra"; then
UTIL_DEFS="$UTIL_DEFS $extra"
fi
done
for extra in contrib/*/Makefile.core.def; do
if test -e "$extra"; then
CORE_DEFS="$CORE_DEFS $extra"
fi
done
cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
for extra in contrib/*/Makefile.common; do
if test -e "$extra"; then
echo "include $extra" >> Makefile.util.am
echo "include $extra" >> grub-core/Makefile.core.am
fi
done
for extra in contrib/*/Makefile.util.common; do
if test -e "$extra"; then
echo "include $extra" >> Makefile.util.am
fi
done
for extra in contrib/*/Makefile.core.common; do
if test -e "$extra"; then
echo "include $extra" >> grub-core/Makefile.core.am
fi
done
echo "Saving timestamps..."
echo timestamp > stamp-h.in

View file

@ -146,11 +146,7 @@ $(top_srcdir)/Makefile.util.am: $(top_srcdir)/Makefile.util.def $(top_srcdir)/Ma
mv $@.new $@
.PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/Makefile.tpl
autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@
.PRECIOUS: $(top_srcdir)/grub-core/Makefile.gcry.am
$(top_srcdir)/grub-core/Makefile.gcry.am: $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi
autogen -T $(top_srcdir)/Makefile.tpl $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
mv $@.new $@

View file

@ -235,6 +235,7 @@ AC_PROG_LEX
AC_PROG_YACC
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
AC_PROG_LN_S
if test "x$LEX" = "x:"; then
AC_MSG_ERROR([flex is not found])

View file

@ -70,16 +70,15 @@ for platform in GRUB_PLATFORMS:
#
# Global variables
#
GVARS = []
GVARS = set()
def gvar_add(var, value):
if var not in GVARS:
GVARS.append(var)
GVARS.add(var)
return var + " += " + value + "\n"
def global_variable_initializers():
r = ""
for var in GVARS:
for var in sorted(GVARS):
r += var + " ?= \n"
return r
@ -87,6 +86,16 @@ def global_variable_initializers():
# Per PROGRAM/SCRIPT variables
#
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)
def var_set(var, value):
return var + " = " + value + "\n"
@ -257,6 +266,15 @@ def platform_ccasflags(p): return platform_specific_values(p, "_ccasflags", "cca
def platform_stripflags(p): return platform_specific_values(p, "_stripflags", "stripflags")
def platform_objcopyflags(p): return platform_specific_values(p, "_objcopyflags", "objcopyflags")
#
# 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
def module(platform):
r = set_canonical_name_suffix(".module")
@ -341,18 +359,25 @@ fi
def library(platform):
r = set_canonical_name_suffix("")
r += gvar_add("noinst_LIBRARIES", "[+ name +]")
r += var_set(cname() + "_SOURCES", platform_sources(platform))
r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform))
r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_LIBRARY) " + platform_cflags(platform))
r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_LIBRARY) " + platform_cppflags(platform))
r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_LIBRARY) " + platform_ccasflags(platform))
# r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
r += vars_init(cname() + "_SOURCES",
"nodist_" + cname() + "_SOURCES",
cname() + "_CFLAGS",
cname() + "_CPPFLAGS",
cname() + "_CCASFLAGS")
# cname() + "_DEPENDENCIES")
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 += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
r += first_time(gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)"))
r += first_time(gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)"))
return r
def installdir(default="bin"):
@ -376,7 +401,7 @@ def program(platform, test=False):
r += gvar_add("check_PROGRAMS", "[+ name +]")
r += gvar_add("TESTS", "[+ name +]")
r += "[+ ELSE +]"
r += gvar_add(installdir() + "_PROGRAMS", "[+ name +]")
r += var_add(installdir() + "_PROGRAMS", "[+ name +]")
r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
r += "[+ ENDIF +]"
@ -397,7 +422,7 @@ def program(platform, test=False):
def data(platform):
r = gvar_add("EXTRA_DIST", platform_sources(platform))
r += gvar_add("EXTRA_DIST", extra_dist())
r += gvar_add(installdir() + "_DATA", platform_sources(platform))
r += var_add(installdir() + "_DATA", platform_sources(platform))
return r
def script(platform):
@ -405,7 +430,7 @@ def script(platform):
r += gvar_add("check_SCRIPTS", "[+ name +]")
r += gvar_add ("TESTS", "[+ name +]")
r += "[+ ELSE +]"
r += gvar_add(installdir() + "_SCRIPTS", "[+ name +]")
r += var_add(installdir() + "_SCRIPTS", "[+ name +]")
r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
r += "[+ ENDIF +]"
@ -418,33 +443,43 @@ chmod a+x [+ name +]
r += gvar_add("dist_noinst_DATA", platform_sources(platform))
return r
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
def module_rules():
return "[+ FOR module +]" + foreach_enabled_platform(
lambda p: under_platform_specific_conditionals(p, module(p))) + "[+ ENDFOR +]"
return rules("module", module)
def kernel_rules():
return "[+ FOR kernel +]" + foreach_enabled_platform(
lambda p: under_platform_specific_conditionals(p, kernel(p))) + "[+ ENDFOR +]"
return rules("kernel", kernel)
def image_rules():
return "[+ FOR image +]" + foreach_enabled_platform(
lambda p: under_platform_specific_conditionals(p, image(p))) + "[+ ENDFOR +]"
return rules("image", image)
def library_rules():
return "[+ FOR library +]" + foreach_enabled_platform(
lambda p: under_platform_specific_conditionals(p, library(p))) + "[+ ENDFOR +]"
return rules("library", library)
def program_rules():
return "[+ FOR program +]" + foreach_enabled_platform(
lambda p: under_platform_specific_conditionals(p, program(p))) + "[+ ENDFOR +]"
return rules("program", program)
def script_rules():
return "[+ FOR script +]" + foreach_enabled_platform(
lambda p: under_platform_specific_conditionals(p, script(p))) + "[+ ENDFOR +]"
return rules("script", script)
def data_rules():
return "[+ FOR data +]" + foreach_enabled_platform(
lambda p: under_platform_specific_conditionals(p, data(p))) + "[+ ENDFOR +]"
return rules("data", data)
print "[+ AutoGen5 template +]\n"
a = module_rules()

View file

@ -51,7 +51,6 @@ grub_script.yy.c: grub_script.yy.h
CLEANFILES += grub_script.yy.c grub_script.yy.h
include $(srcdir)/Makefile.core.am
include $(srcdir)/Makefile.gcry.am
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h