aboutsummaryrefslogtreecommitdiffstats
path: root/grub-core/genmod.sh.in
diff options
context:
space:
mode:
authorJames <james.mckenzie@citrix.com>2012-11-16 10:41:01 +0000
committerJames <james.mckenzie@citrix.com>2012-11-16 10:41:01 +0000
commit041d1ea37802bf7178a31a53f96c26efa6b8fb7b (patch)
treec193e84ad1237f25a79d0f6a267722e44c73f56a /grub-core/genmod.sh.in
downloadgrub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.tar.gz
grub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.tar.bz2
grub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.zip
fish
Diffstat (limited to 'grub-core/genmod.sh.in')
-rw-r--r--grub-core/genmod.sh.in73
1 files changed, 73 insertions, 0 deletions
diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in
new file mode 100644
index 0000000..023cd10
--- /dev/null
+++ b/grub-core/genmod.sh.in
@@ -0,0 +1,73 @@
+#! /bin/sh -e
+#
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+#
+# Example:
+#
+# genmod.sh moddep.lst normal.module normal.mod
+#
+
+moddep=$1
+infile=$2
+outfile=$3
+
+tmpfile=${outfile}.tmp
+modname=`echo $infile | sed -e 's@\.module.*$@@'`
+
+if ! grep ^$modname: $moddep >/dev/null; then
+ echo "warning: moddep.lst has no dependencies for $modname" >&2
+ exit 0
+fi
+
+deps=`grep ^$modname: $moddep | sed s@^.*:@@`
+
+# remove old files if any
+rm -f $tmpfile $outfile
+
+# stripout .modname and .moddeps sections from input module
+@OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
+
+# Attach .modname and .moddeps sections
+t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+printf "$modname\0" >$t1
+
+t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+for dep in $deps; do printf "$dep\0" >> $t2; done
+
+if test -n "$deps"; then
+ @OBJCOPY@ --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
+else
+ @OBJCOPY@ --add-section .modname=$t1 $tmpfile
+fi
+rm -f $t1 $t2
+
+if test x@TARGET_APPLE_CC@ != x1; then
+ if ! test -z "${TARGET_OBJ2ELF}"; then
+ ./${TARGET_OBJ2ELF} $tmpfile || exit 1
+ fi
+ if test x@platform@ != xemu; then
+ @STRIP@ --strip-unneeded \
+ -K grub_mod_init -K grub_mod_fini \
+ -K _grub_mod_init -K _grub_mod_fini \
+ -R .note -R .comment $tmpfile || exit 1
+ fi
+else
+# XXX Test these Apple CC fixes
+ cp $tmpfile $tmpfile.bin
+ @OBJCONV@ -f@TARGET_MODULE_FORMAT@ \
+ -nr:_grub_mod_init:grub_mod_init \
+ -nr:_grub_mod_fini:grub_mod_fini \
+ -wd1106 -ew2030 -ew2050 -nu -nd $tmpfile.bin $tmpfile || exit 1
+ rm -f $name.bin
+fi
+mv $tmpfile $outfile