This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / ld / genscripts.sh
1 #!/bin/sh
2 # genscripts.sh - generate the ld-emulation-target specific files
3 #
4 # Usage: genscripts.sh srcdir libdir host_alias target_alias \
5 # default_emulation this_emulation
6 #
7 # Sample usage:
8 # genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib sparc-sun-sunos4.1.3 \
9 # sparc-sun-sunos4.1.3 sun4 sun3
10 # produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c
11
12 srcdir=$1
13 libdir=$2
14 host_alias=$3
15 target_alias=$4
16 DEFAULT_EMULATION=$5
17 EMULATION_NAME=$6
18
19 # Include the emulation-specific parameters:
20 . ${srcdir}/emulparams/${EMULATION_NAME}.sh
21
22 # Set the library search path, for libraries named by -lfoo.
23 # If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
24 # Otherwise, the default is set here.
25 #
26 # The format is the usual list of colon-separated directories.
27 # To force a logically empty LIB_PATH, do LIBPATH=":".
28
29 if [ "x${LIB_PATH}" = "x" ] ; then
30 if [ "x${host_alias}" = "x${target_alias}" ] ; then
31 # Native.
32 LIB_PATH=/lib:/usr/lib:${libdir}
33 if [ "${libdir}" != /usr/local/lib ] ; then
34 LIB_PATH=${LIB_PATH}:/usr/local/lib
35 fi
36 else
37 # Cross.
38 LIB_PATH=:
39 fi
40 fi
41 LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'`
42
43 # Generate 5 script files from a master script template in
44 # ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 script files
45 # is actually used depends on command line options given to ld.
46 # (SCRIPT_NAME was set in the emulparams_file.)
47 #
48 # A .x script file is the default script.
49 # A .xr script is for linking without relocation (-r flag).
50 # A .xu script is like .xr, but *do* create constructors (-Ur flag).
51 # A .xn script is for linking with -n flag (mix text and data on same page).
52 # A .xbn script is for linking with -N flag (mix text and data on same page).
53
54 SEGMENT_SIZE=${SEGMENT_SIZE-${PAGE_SIZE}}
55
56 # Determine DATA_ALIGNMENT for the 5 variants, using
57 # values specified in the emulparams/<emulation>.sh file or default.
58
59 DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}"
60 DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}"
61 DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}"
62 DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}"
63 DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
64
65 LD_FLAG=r
66 DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
67 DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
68 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
69 ldscripts/${EMULATION_NAME}.xr
70
71 LD_FLAG=u
72 DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
73 CONSTRUCTING=
74 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
75 ldscripts/${EMULATION_NAME}.xu
76
77 LD_FLAG=
78 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
79 RELOCATING=
80 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
81 ldscripts/${EMULATION_NAME}.x
82
83 LD_FLAG=n
84 DATA_ALIGNMENT=${DATA_ALIGNMENT_n}
85 TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}}
86 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
87 ldscripts/${EMULATION_NAME}.xn
88
89 LD_FLAG=N
90 DATA_ALIGNMENT=${DATA_ALIGNMENT_N}
91 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
92 ldscripts/${EMULATION_NAME}.xbn
93
94 # Generate em_${EMULATION_NAME}.c.
95 . ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
This page took 0.032997 seconds and 5 git commands to generate.