home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / pascal / gpc1.1p2 / gpc1 / usr / src / gpc-1.1p2-2.6.3 / configure < prev    next >
Encoding:
Text File  |  1995-04-20  |  7.4 KB  |  286 lines

  1. #!/bin/sh
  2. # Configuration script for GNU GPC
  3. #   Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc.
  4.  
  5. #This file is part of GNU CC.
  6.  
  7. #GNU CC is free software; you can redistribute it and/or modify
  8. #it under the terms of the GNU General Public License as published by
  9. #the Free Software Foundation; either version 1, or (at your option)
  10. #any later version.
  11.  
  12. #GNU CC is distributed in the hope that it will be useful,
  13. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #GNU General Public License for more details.
  16.  
  17. #You should have received a copy of the GNU General Public License
  18. #along with GNU CC; see the file COPYING.  If not, write to
  19. #the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21. #
  22. # Shell script to create proper links to machine-dependent files in
  23. # preparation for compiling gpc after you have compiled gcc.
  24. #
  25. Usage="configure [--srcdir=DIR] [--pvsdir=DIR] [--gas] [--nfp] [--gccdir=DIR] [--gccsrc=DIR]"
  26. #
  27. # GPC is always built with the same HOST and TARGET for which GCC was built,
  28. #     so it is not necessary to specify those. 
  29. #    --srcdir = GPC specific sources (default . && ..)
  30. #    --gccsrc = Location of GCC Source files (default . && ..)
  31. #    --gccdir = Location of GCC Object files (default $gccsrc)
  32. #    --pvsdir = Location of Pascal Validation Suite (no default)
  33. #    --prefix = Installation prefix
  34. #    --gas     = use gas
  35. #    --nfp     = ????
  36. #
  37. # If configure succeeds, it leaves its status in gpc.status.
  38. # If configure fails after disturbing the status quo, 
  39. #     gpc.status is removed.
  40. #
  41.  
  42. progname=$0
  43.  
  44. srcdir=`echo $progname | sed 's|/[^/]*$||'`
  45. if [ x$srcdir = x$progname ]
  46. then
  47. srcdir=
  48. fi
  49.  
  50. remove=rm
  51. hard_link=ln
  52. symbolic_link='ln -s'
  53.  
  54. # If user does not give --prefix get the prefixes used with
  55. # the gcc we are loaded with.
  56. #
  57. prefix=
  58.  
  59. # Assume gcc objects are in this directory
  60. gccdir=.
  61. # And their sources are here, too
  62. gccsrc=.
  63.  
  64. pvs=0
  65. for arg in $*;
  66. do
  67.   case $arg in
  68.    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  69.     prefix=`echo $arg | sed 's/[+-]*p[a-z]*=//'`
  70.     echo "If you use --prefix, the path may differ from installed gcc path"
  71.     ;;
  72.    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
  73.     srcdir=`echo $arg | sed 's/[+-]*s[a-z]*=//'`
  74.     ;;
  75.    -pvsdir=* | --pvsdir=* | --pvsdi=* | --pvsd=* | --pvs=* | --pv=*)
  76.     pvsdir=`echo $arg | sed 's/[+-]*p[a-z]*=//'`
  77.     pvs=1
  78.     ;;
  79.    -gccdir=* | --gccdir=* | --gccdi=* | --gccd=*)
  80.     gccdir=`echo $arg | sed 's/[+-]*gccd[a-z]*=//'`
  81.     ;;
  82.    -gccsrc=* | --gccsrc=* | --gccsr=* | --gccs=*)
  83.     gccsrc=`echo $arg | sed 's/[+-]*gccs[a-z]*=//'`
  84.     ;;
  85.    -gas | --gas | --ga | --g)
  86.         gas=yes
  87.     ;;
  88.    -nfp | --nfp | --nf | --n)
  89.     nfp=yes
  90.     ;;
  91.    *)
  92.     echo Illegal parameter
  93.     echo "Usage: $progname $Usage"
  94.     ;;    
  95.   esac
  96. done
  97.  
  98. # Complain if objects are not found
  99. if [ ! -f $gccdir/tree.o ]
  100. then
  101.     echo "No GCC objects found"
  102.     echo "Usage: $progname $Usage"
  103.     if [ -r gpc.status ]
  104.     then
  105.         cat gpc.status
  106.     fi
  107.     exit 1
  108. fi
  109.  
  110. # Find the GPC source files, if location was not specified.
  111. if [ x$srcdir = x ]
  112. then
  113.     srcdirdefaulted=1
  114.     srcdir=.
  115.     if [ ! -r gpc-parse.y ]
  116.     then
  117.         srcdir=..
  118.     fi
  119. fi
  120.  
  121. if [ ! -r ${srcdir}/gpc-parse.y ]
  122. then
  123.     if [ x$srcdirdefaulted = x ]
  124.     then
  125.       echo "$progname: Can't find GPC compiler sources in \`${srcdir}'." 1>&2
  126.     else
  127.       echo "$progname: Can't find GPC compiler sources in \`.' or \`..'." 1>&2
  128.     fi
  129.     exit 1
  130. fi
  131.  
  132. # Find the GCC source files, if location was not specified.
  133. if [ x$gccsrc = x ]
  134. then
  135.     gccsrcdirdefaulted=1
  136.     gccsrc=.
  137.     if [ ! -r tree.h ]
  138.     then
  139.         srcdir=..
  140.     fi
  141. fi
  142.  
  143. if [ ! -r ${gccsrc}/tree.h ]
  144. then
  145.     if [ x$gccsrcdirdefaulted = x ]
  146.     then
  147.       echo "$progname: Can't find GCC compiler sources in \`${gccsrc}'." 1>&2
  148.     else
  149.       echo "$progname: Can't find GCC compiler sources in \`.' or \`..'." 1>&2
  150.     fi
  151.     exit 1
  152. fi
  153.  
  154. TARGET_REPLACE=
  155.  
  156. if [ -z "$prefix" ]; then
  157.     if [ ! -f ${gccdir}/xgcc ]; then
  158.         echo "Can't run ${gccdir}/{gccdir}/xgcc to find out prefix"
  159.         exit 1
  160.     fi
  161.     temp=`${gccdir}/xgcc -print-libgcc-file-name`
  162.     if [ x$temp = x ]; then
  163.         echo "Can't find out prefix by running ${gccdir}/xgcc. Install gcc first"
  164.         echo "Or use the --prefix switch"
  165.         exit 1
  166.     fi
  167.     version=`${gccdir}/xgcc -dumpversion`
  168.     prefix=`echo $temp | sed 's+\(.*\)/lib/gcc-lib/.*+\1+'`
  169.     if [ x$prefix = xlibgcc.a ]; then
  170.         echo "You need to install GCC before configuring GPC."
  171.         echo "Otherwise I can not find out the correct prefix."
  172.         echo
  173.         echo "You do not need to put this GCC version in public use,"
  174.         echo "but libgcc.a has to be where you have configured it to be"
  175.         echo "when you compiled GCC, so that gccdir/xgcc says where it is."
  176.         exit 1
  177.     fi
  178.     echo "Using prefix $prefix"
  179.  
  180.     target=`echo $temp | sed 's+'${prefix}'/lib/gcc-lib/\(.*\)/'${version}'/libgcc.a+\1+'`
  181.     echo "Using target $target"
  182.  
  183.     TARGET_REPLACE="s@^target[ ]*=.*@target = ${target}@"
  184. fi
  185.  
  186. # Install a makefile, and make it set VPATH
  187. # if necessary so that the sources are found.
  188. # Also change its value of srcdir.
  189. # Also create a .gdbinit file which runs the one in srcdir
  190. # and tells GDB to look there for source files.
  191. case $srcdir in
  192. .)
  193.     cp Makefile.in Makefile.temp
  194.     ;;
  195. *)
  196.     echo "VPATH = .:${srcdir}:${gccsrc}" > x
  197.     cat x ${srcdir}/Makefile.in | sed "s@^srcdir = \.@srcdir = ${srcdir}@" > Makefile.temp
  198.     rm x
  199.     echo "dir ." > .gdbinit
  200.     echo "dir ${srcdir}" >> .gdbinit
  201.     echo "source ${srcdir}/.gdbinit" >> .gdbinit
  202.     ;;
  203. esac
  204.  
  205. # Conditionalize the makefile for this machine.
  206. if [ -f ${srcdir}/config/${host_make_var_file} ]
  207. then
  208.     sed -e "/####/  r ${srcdir}/config/${host_make_var_file}" Makefile.temp > Makefile.tem
  209. else
  210.     cp Makefile.temp Makefile.tem
  211. fi
  212.  
  213. # Remove all formfeeds. Some makes get confused by them.
  214. # Modify the path where to find GCC binaries
  215. cat Makefile.tem | \
  216.  sed    -e "s@^gccdir = \$(gccsrc)@gccdir = ${gccdir}@" \
  217.     -e "s@ @@"                    \
  218.     -e "s@^prefix[     ]*=.*@prefix = $prefix@"     \
  219.     -e "s@^gccsrc = \.@gccsrc = ${gccsrc}@" > Makefile.tem1
  220.  
  221. if [ -n "$TARGET_REPLACE" ]; then
  222.     cat Makefile.tem1 | sed "$TARGET_REPLACE" > Makefile.tem2
  223.     mv Makefile.tem2 Makefile.tem1
  224. fi
  225.  
  226. # Delete the intermediate files
  227. rm Makefile.temp Makefile.tem
  228.  
  229. # Check if cross-compiling
  230. CROSS=
  231. if [ -f $gccdir/config.status ]; then
  232.     CROSS=`grep "and target" $gccdir/config.status`
  233. fi
  234.  
  235. # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
  236. if [ x$CROSS = x ]
  237. then
  238.     mv Makefile.tem1 Makefile
  239. else
  240.     echo "CROSS=-DCROSS_COMPILE" > Makefile
  241.     cat Makefile.tem1 >> Makefile
  242.     rm Makefile.tem1
  243. fi
  244.  
  245. if [ -f ${srcdir}/config/${host_make_var_file} ]
  246. then
  247.     echo "Created \`Makefile' using \`${host_make_var_file}'."
  248. else
  249.     echo "Created \`Makefile'."
  250. fi
  251.  
  252. # Hmm, find out where the new c-compiler is for the run time system
  253. # (Just to compile it with it, no special reason)
  254. p=`pwd`
  255. cd $gccdir
  256. cdir=`pwd`
  257. cd $p
  258.  
  259. # Copy run time system Makefile.in
  260. if [ ! -d rts ]; then mkdir rts; fi
  261. cat $srcdir/rts/Makefile.in | \
  262.     sed -e "s@^CC =.*@CC = $cdir/xgcc@" > rts/Makefile
  263.  
  264. echo "Created run time system Makefile"
  265.  
  266. # Remove links to the required directories
  267. rm -f srcdir gccdir gccsrc
  268.  
  269. # Link the source gpc directory for run time system makefile
  270. ln -s $srcdir srcdir
  271. ln -s $gccsrc gccsrc
  272. ln -s $gccdir gccdir
  273. echo "Linked srcdir -> $srcdir and gccdir -> $gccsrc"
  274.  
  275. # Document current setup
  276. if [ x$CROSS = x ]; then
  277.  echo "# Compiling $srcdir with $gccdir (objects) and $gccsrc (sources)" | tee gpc.status
  278. else
  279.  echo "# Cross-compiling $srcdir with $gccdir (objects) and $gccsrc (sources)" | tee gpc.status
  280. fi
  281.  
  282. echo "# Configured with the following command:" >> gpc.status
  283. echo "$0 $*" >> gpc.status
  284.  
  285. exit 0
  286.