Use TARGET_STRIP instead of STRIP. Needed on OS X.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / genmod.sh.in
blob0cb512bd39e6c4fecde4b79e550032c68d1258df
1 #! /bin/sh -e
3 # Copyright (C) 2010 Free Software Foundation, Inc.
5 # This gensymlist.sh is free software; the author
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
15 # Example:
17 # genmod.sh moddep.lst normal.module normal.mod
20 moddep=$1
21 infile=$2
22 outfile=$3
24 grub_utildir=@abs_top_builddir@
26 tmpfile=${outfile}.tmp
27 modname=`echo $infile | sed -e 's@\.module.*$@@'`
29 if ! grep ^$modname: $moddep >/dev/null; then
30 echo "warning: moddep.lst has no dependencies for $modname" >&2
31 exit 0
34 deps=`grep ^$modname: $moddep | sed s@^.*:@@`
36 # remove old files if any
37 rm -f $tmpfile $outfile
39 # stripout .modname and .moddeps sections from input module
40 @OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
42 # Attach .modname and .moddeps sections
43 t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
44 printf "$modname\0" >$t1
46 t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
47 for dep in $deps; do printf "$dep\0" >> $t2; done
49 if test -n "$deps"; then
50 @OBJCOPY@ --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
51 else
52 @OBJCOPY@ --add-section .modname=$t1 $tmpfile
54 rm -f $t1 $t2
56 if test x@TARGET_APPLE_CC@ != x1; then
57 if ! test -z "@TARGET_OBJ2ELF@"; then
58 @TARGET_OBJ2ELF@ $tmpfile || exit 1
60 if test x@platform@ != xemu; then
61 @TARGET_STRIP@ --strip-unneeded \
62 -K grub_mod_init -K grub_mod_fini \
63 -K _grub_mod_init -K _grub_mod_fini \
64 -R .note -R .comment $tmpfile || exit 1
66 else
67 # XXX Test these Apple CC fixes
68 cp $tmpfile $tmpfile.bin
69 @OBJCONV@ -f@TARGET_MODULE_FORMAT@ \
70 -nr:_grub_mod_init:grub_mod_init \
71 -nr:_grub_mod_fini:grub_mod_fini \
72 -wd1106 -ew2030 -ew2050 -nu -nd $tmpfile.bin $tmpfile || exit 1
73 rm -f $name.bin
75 mv $tmpfile $outfile