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