2 # genscripts.sh - generate the ld-emulation-target specific files
4 # Usage: genscripts.sh srcdir libdir exec_prefix \
5 # host target target_alias default_emulation \
6 # native_lib_dirs this_emulation tool_dir
9 # genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib /usr/local \
10 # sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sun4 \
11 # "" sun3 sparc-sun-sunos4.1.3
12 # produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c
24 # Can't use ${1:-$target_alias} here due to an Ultrix shell bug.
25 if [ "x$1" = "x" ] ; then
26 tool_lib
=${exec_prefix}/${target_alias}/lib
28 tool_lib
=${exec_prefix}/$1/lib
31 # Include the emulation-specific parameters:
32 .
${srcdir}/emulparams
/${EMULATION_NAME}.sh
34 if test -d ldscripts
; then
40 # Set the library search path, for libraries named by -lfoo.
41 # If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
42 # Otherwise, the default is set here.
44 # The format is the usual list of colon-separated directories.
45 # To force a logically empty LIB_PATH, do LIBPATH=":".
47 if [ "x${LIB_PATH}" = "x" ] ; then
48 # Cross, or native non-default emulation not requesting LIB_PATH.
51 if [ "x${host}" = "x${target}" ] ; then
52 case " $EMULATION_LIBPATH " in
53 *" ${EMULATION_NAME} "*)
54 # Native, and default or emulation requesting LIB_PATH.
55 LIB_PATH
=/lib
:/usr
/lib
56 if [ -n "${NATIVE_LIB_DIRS}" ]; then
57 LIB_PATH
=${LIB_PATH}:${NATIVE_LIB_DIRS}
59 if [ "${libdir}" != /usr
/lib
]; then
60 LIB_PATH
=${LIB_PATH}:${libdir}
62 if [ "${libdir}" != /usr
/local
/lib
] ; then
63 LIB_PATH
=${LIB_PATH}:/usr
/local
/lib
69 # Always search $(tooldir)/lib, aka /usr/local/TARGET/lib.
70 LIB_PATH
=${LIB_PATH}:${tool_lib}
72 LIB_SEARCH_DIRS
=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'`
74 # Generate 5 or 6 script files from a master script template in
75 # ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 or 6
76 # script files is actually used depends on command line options given
77 # to ld. (SCRIPT_NAME was set in the emulparams_file.)
79 # A .x script file is the default script.
80 # A .xr script is for linking without relocation (-r flag).
81 # A .xu script is like .xr, but *do* create constructors (-Ur flag).
82 # A .xn script is for linking with -n flag (mix text and data on same page).
83 # A .xbn script is for linking with -N flag (mix text and data on same page).
84 # A .xs script is for generating a shared library with the --shared
85 # flag; it is only generated if $GENERATE_SHLIB_SCRIPT is set by the
86 # emulation parameters.
88 SEGMENT_SIZE
=${SEGMENT_SIZE-${TARGET_PAGE_SIZE}}
90 # Determine DATA_ALIGNMENT for the 5 variants, using
91 # values specified in the emulparams/<emulation>.sh file or default.
93 DATA_ALIGNMENT_
="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}"
94 DATA_ALIGNMENT_n
="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}"
95 DATA_ALIGNMENT_N
="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}"
96 DATA_ALIGNMENT_r
="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}"
97 DATA_ALIGNMENT_u
="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
100 DATA_ALIGNMENT
=${DATA_ALIGNMENT_r}
101 DEFAULT_DATA_ALIGNMENT
="ALIGN(${SEGMENT_SIZE})"
102 (.
${srcdir}/scripttempl
/${SCRIPT_NAME}.sc
) |
sed -e '/^ *$/d' > \
103 ldscripts
/${EMULATION_NAME}.xr
106 DATA_ALIGNMENT
=${DATA_ALIGNMENT_u}
108 (.
${srcdir}/scripttempl
/${SCRIPT_NAME}.sc
) |
sed -e '/^ *$/d' > \
109 ldscripts
/${EMULATION_NAME}.xu
112 DATA_ALIGNMENT
=${DATA_ALIGNMENT_}
114 (.
${srcdir}/scripttempl
/${SCRIPT_NAME}.sc
) |
sed -e '/^ *$/d' > \
115 ldscripts
/${EMULATION_NAME}.x
118 DATA_ALIGNMENT
=${DATA_ALIGNMENT_n}
119 TEXT_START_ADDR
=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}}
120 (.
${srcdir}/scripttempl
/${SCRIPT_NAME}.sc
) |
sed -e '/^ *$/d' > \
121 ldscripts
/${EMULATION_NAME}.xn
124 DATA_ALIGNMENT
=${DATA_ALIGNMENT_N}
125 (.
${srcdir}/scripttempl
/${SCRIPT_NAME}.sc
) |
sed -e '/^ *$/d' > \
126 ldscripts
/${EMULATION_NAME}.xbn
128 if test -n "$GENERATE_SHLIB_SCRIPT"; then
130 DATA_ALIGNMENT
=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}}
132 # Note that TEXT_START_ADDR is set to NONPAGED_TEXT_START_ADDR.
133 (.
${srcdir}/scripttempl
/${SCRIPT_NAME}.sc
) |
sed -e '/^ *$/d' > \
134 ldscripts
/${EMULATION_NAME}.xs
137 for i
in $EMULATION_LIBPATH ; do
138 test "$i" = "$EMULATION_NAME" && COMPILE_IN
=true
141 # Generate e${EMULATION_NAME}.c.
142 .
${srcdir}/emultempl
/${TEMPLATE_NAME-generic}.em
This page took 0.040753 seconds and 4 git commands to generate.