Correct ordering of args for cmov insn.
[deliverable/binutils-gdb.git] / ld / genscripts.sh
index 7882a418bf3b1ff5a852483a3cc3986f64b5120a..dd1e9dda4bbe8e0accf896ce311979d606fa588c 100755 (executable)
@@ -1,61 +1,95 @@
-# This shell script does the work of generating the ld-emulation-target
-# specific information from a specific file of paramaters.
-# Usage: genscripts.sh srcdir host_alias target_alias emulation_name
+#!/bin/sh
+# genscripts.sh - generate the ld-emulation-target specific files
+#
+# Usage: genscripts.sh srcdir libdir host_alias target_alias \
+# default_emulation this_emulation
+#
+# Sample usage:
+# genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib sparc-sun-sunos4.1.3 \
+# sparc-sun-sunos4.1.3 sun4 sun3
+# produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c
 
 srcdir=$1
-host_alias=$2
-target_alias=$3
+libdir=$2
+host_alias=$3
+target_alias=$4
+DEFAULT_EMULATION=$5
+EMULATION_NAME=$6
 
-# Include the emulation-specic parameters:
-. ${srcdir}/$4
+# Include the emulation-specific parameters:
+. ${srcdir}/emulparams/${EMULATION_NAME}.sh
 
-# Set the library search path (for libraries named by -lfoo).
-# If LIB_PATH is defined (and non-empty), it is used.
-# (The format is the usual list of colon-separated directories.)
-# (To force a logically empty LIB_PATH, do LIBPATH=":".)
-# Otherwise, the default is /lib:/usr/lib:/usr/local/lib,
-# unless cross-compiling, in which case the default remains empty.
+# Set the library search path, for libraries named by -lfoo.
+# If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used.
+# Otherwise, the default is set here.
+#
+# The format is the usual list of colon-separated directories.
+# To force a logically empty LIB_PATH, do LIBPATH=":".
 
-if [ "x${LIB_PATH}" = "x" -a "x${host_alias}" = "x${target_alias}" ] ; then
-   LIB_PATH=/lib:/usr/lib:/usr/local/lib
+if [ "x${LIB_PATH}" = "x" ] ; then
+   if [ "x${host_alias}" = "x${target_alias}" ] ; then
+      # Native.
+      LIB_PATH=/lib:/usr/lib:${libdir}
+      if [ "${libdir}" != /usr/local/lib ] ; then
+        LIB_PATH=${LIB_PATH}:/usr/local/lib
+      fi
+   else
+      # Cross.
+      LIB_PATH=:
+   fi
 fi
 LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'`
 
-# This  script generates 5 script files from the master script template
-# in ${srcdir}/${SCRIPT_NAME}.sh.  Which one of the 5 script files
-# is actually used depends on command line flags given to ld.
-# The actual script is filtered through the mkscript program
-# to convert it to a form suitable for including in a C program
-# as a C string literal.
+# Generate 5 script files from a master script template in
+# ${srcdir}/scripttempl/${SCRIPT_NAME}.sh.  Which one of the 5 script files
+# is actually used depends on command line options given to ld.
+# (SCRIPT_NAME was set in the emulparams_file.)
 #
 # A .x script file is the default script.
 # A .xr script is for linking without relocation (-r flag).
 # A .xu script is like .xr, but *do* create constructors (-Ur flag).
 # A .xn script is for linking with -n flag (mix text and data on same page).
-# A .xN script is for linking with -N flag (mix text and data on same page).
+# A .xbn script is for linking with -N flag (mix text and data on same page).
 
-THIS_TEXT_START_ADDR=${TEXT_START_ADDR}
 SEGMENT_SIZE=${SEGMENT_SIZE-${PAGE_SIZE}}
 
-DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
-FILTER_SCRIPT=""
-(. ${srcdir}/${SCRIPT_NAME}.sc-sh) | sed -e '/^ *$/d' | ./mkscript \
-  >${EMULATION_NAME}.xr
+# Determine DATA_ALIGNMENT for the 5 variants, using
+# values specified in the emulparams/<emulation>.sh file or default.
+
+DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}"
+DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}"
+DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}"
+DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}"
+DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
+
+LD_FLAG=r
+DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
+DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
+(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
+  ldscripts/${EMULATION_NAME}.xr
+
+LD_FLAG=u
+DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
 CONSTRUCTING=
-(. ${srcdir}/${SCRIPT_NAME}.sc-sh) | sed -e '/^ *$/d' | ./mkscript \
-  >${EMULATION_NAME}.xu
+(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
+  ldscripts/${EMULATION_NAME}.xu
+
+LD_FLAG=
+DATA_ALIGNMENT=${DATA_ALIGNMENT_}
 RELOCATING=
-(. ${srcdir}/${SCRIPT_NAME}.sc-sh) | sed -e '/^ *$/d' | ./mkscript \
-  >${EMULATION_NAME}.x
-THIS_TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}}
-(. ${srcdir}/${SCRIPT_NAME}.sc-sh) | sed -e '/^ *$/d' | ./mkscript \
-  >${EMULATION_NAME}.xn
-DATA_ALIGNMENT="."
-(. ${srcdir}/${SCRIPT_NAME}.sc-sh) | sed -e '/^ *$/d' | ./mkscript \
-  >${EMULATION_NAME}.xN
-
-#sed -e s/"<ldtarget>"/${EMULATION_NAME}/g -e s/"<arch>"/${ARCH}/g \
-# -e s/"<target>"/${EMULATION_NAME}/g -e s/"<target_name>"/${OUTPUT_FORMAT}/g \
-# <${srcdir}/${TEMPLATE_NAME-ldtemplate} >ld__${EMULATION_NAME}.c
-
-. ${srcdir}/${TEMPLATE_NAME-generic}.em
+(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
+  ldscripts/${EMULATION_NAME}.x
+
+LD_FLAG=n
+DATA_ALIGNMENT=${DATA_ALIGNMENT_n}
+TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}}
+(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
+  ldscripts/${EMULATION_NAME}.xn
+
+LD_FLAG=N
+DATA_ALIGNMENT=${DATA_ALIGNMENT_N}
+(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \
+  ldscripts/${EMULATION_NAME}.xbn
+
+# Generate em_${EMULATION_NAME}.c.
+. ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
This page took 0.040078 seconds and 4 git commands to generate.