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
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
15 # Include the emulation-specific parameters:
16 . ${srcdir}/emulparams/$6
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.
22 # The format is the usual list of colon-separated directories.
23 # To force a logically empty LIB_PATH, do LIBPATH=":".
25 if [ "x${LIB_PATH}" = "x" ] ; then
26 if [ "x${host_alias}" = "x${target_alias}" ] ; then
28 LIB_PATH=/lib:/usr/lib:${tooldirlib}:${libdir}
29 if [ "${libdir}" != /usr/local/lib ] ; then
30 LIB_PATH=${LIB_PATH}:/usr/local/lib
34 LIB_PATH=${tooldirlib}
37 LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'`
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.
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).
49 SEGMENT_SIZE=${SEGMENT_SIZE-${PAGE_SIZE}}
51 # Determine DATA_ALIGNMENT for the 5 variants, using
52 # values specified in the emulparams/<emulation>.sh file or default.
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}}"
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
67 DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
69 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
70 ldscripts/${EMULATION_NAME}.xu
73 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
75 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
76 ldscripts/${EMULATION_NAME}.x
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
85 DATA_ALIGNMENT=${DATA_ALIGNMENT_N}
86 (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
87 ldscripts/${EMULATION_NAME}.xbn
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
93 # Generate em_${EMULATION_NAME}.c.
94 . ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em