2 # genscripts.sh - generate the ld-emulation-target specific files
4 # Usage: genscripts.sh srcdir libdir host_alias target_alias \
5 # default_emulation this_emulation
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
19 # Include the emulation-specific parameters:
20 . ${srcdir}/emulparams/${EMULATION_NAME}.sh
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.
26 # The format is the usual list of colon-separated directories.
27 # To force a logically empty LIB_PATH, do LIBPATH=":".
29 if [ "x${LIB_PATH}" = "x" ] ; then
30 if [ "x${host_alias}" = "x${target_alias}" ] ; then
32 LIB_PATH=/lib:/usr/lib:${libdir}
33 if [ "${libdir}" != /usr/local/lib ] ; then
34 LIB_PATH=${LIB_PATH}:/usr/local/lib
41 LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'`
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.)
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).
54 SEGMENT_SIZE=${SEGMENT_SIZE-${PAGE_SIZE}}
56 # Determine DATA_ALIGNMENT for the 5 variants, using
57 # values specified in the emulparams/<emulation>.sh file or default.
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}}"
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
72 DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
74 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
75 ldscripts/${EMULATION_NAME}.xu
78 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
80 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
81 ldscripts/${EMULATION_NAME}.x
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
90 DATA_ALIGNMENT=${DATA_ALIGNMENT_N}
91 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
92 ldscripts/${EMULATION_NAME}.xbn
94 # Generate em_${EMULATION_NAME}.c.
95 . ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em