Allow returning something of type void in a function that returns void
[delight/core.git] / setup-gcc.sh
blob4969e2e887585abef84f2a7a9c837fe02c649250
1 #!/bin/sh
2 # -1. Make sure we are in the top-level GCC soure directory
3 if test -d gcc && test -d gcc/dlt && test -f gcc/dlt/setup-gcc.sh; then
5 else
6 echo "This script must be run from the top-level GCC source directory."
7 exit 1
8 fi
9 top=`pwd`
11 # D 2.0 will be the default eventually
12 #if test -d gcc/d/dmd2; then
13 # d_lang_version=2
14 #else
15 # d_lang_version=1
16 #fi
18 if test -d gcc/dlt/dmd; then
19 d_lang_version=1
20 elif test -d gcc/dlt/dmd2; then
21 d_lang_version=2
25 # Read command line arguments
26 for arg in "$@"; do
27 case "$arg" in
28 --d-language-version=*) d_lang_version=${arg##--d-language-version=} ;;
30 echo "error: invalid option '$arg'"
31 exit 1
33 esac
34 done
36 if test $d_lang_version -ne 1; then
37 d_subdir_sfx=$d_lang_version
40 if test ! -d gcc/dlt/dmd$d_subdir_sfx; then
41 echo "error: This distribution does not support D version $d_lang_version"
42 exit 1
45 # 0. Find out what GCC version this is
46 if grep version_string gcc/version.c | grep -q '"3.4'; then
47 gcc_ver=3.4
48 elif grep version_string gcc/version.c | grep -q '"4.0'; then
49 gcc_ver=4.0
50 elif grep -q '^4\.1\.' gcc/BASE-VER; then
51 gcc_ver=4.1
54 gcc_patch_key=${gcc_ver}.x
56 # 0.1. Find out if this is Apple's GCC
57 if grep version_string gcc/version.c | grep -qF '(Apple'; then
58 gcc_apple=apple-
59 gcc_apple_build_ver=`grep version_string gcc/version.c | sed -e 's/^.*build \([0-9][0-9]*\).*$/\1/'`
60 if test "$gcc_apple_build_ver" -ge 5465; then
61 gcc_patch_key=5465
65 # 0.2. Determine if this version of GCC is supported
66 gcc_patch_fn=dlt/patches/patch-${gcc_apple}gcc-$gcc_patch_key
67 if test ! -f gcc/"$gcc_patch_fn"; then
68 echo "This version of GCC is not supported."
69 exit 1
72 # 0.5. Find out what GDC and DMD version this is
73 gdc_ver=`cat gcc/d/gdc-version`
74 dmd_ver=`grep 'version = "v' gcc/d/dmd$d_subdir_sfx/mars.c | sed -e 's/^.*"v\(.*\)".*$/\1/'` || exit 1
75 gdc_ver_msg="gdc $gdc_ver, using dmd $dmd_ver"
77 # 0.7 Set the D language version. Note: This creates a file in the D
78 # source directory. If the file is a link, remove it first.
79 rm -f gcc/d/d-make-include
80 echo "D_LANGUAGE_VERSION=$d_lang_version" > gcc/d/d-make-include
82 # 1. Create a directory of links to the Phobos sources in the top-level
83 # directory.
84 mkdir libphobos && \
85 cd libphobos && \
86 ../symlink-tree ../gcc/dlt/phobos$d_subdir_sfx .svn > /dev/null && \
87 cd "$top" || exit 1
89 # 2. Patch the top-level directory
91 # If the patch for the top-level Makefile.in doesn't take, you can regenerate
92 # it with:
93 # autogen -T Makefile.tpl Makefile.def
95 # You will need the autogen package to do this. (http://autogen.sf.net/)
96 patch -p1 < gcc/d/patches/patch-toplev-$gcc_patch_key || exit 1
98 if test -n "$gcc_apple"; then
99 patch -l -p1 < "gcc/d/patches/patch-build_gcc-$gcc_patch_key" || exit 1
102 # 3. Patch the gcc subdirectory
103 cd gcc || exit 1
104 patch -p1 < "$gcc_patch_fn" || exit 1
106 # 3.1 Patch the gcc version string
107 if test "$gcc_ver" = 4.1; then
108 cur_DEV_PHASE=`cat DEV-PHASE`
109 echo "$cur_DEV_PHASE $gdc_ver_msg" > DEV-PHASE
110 else
111 sed -e 's/ *(gdc.*using dmd [0-9\.]*)//' \
112 -e 's/\(, *\)gdc.*using dmd [0-9\.]*/\1/' \
113 -e 's/\(version_string[^"]*"[^"]*\)"/\1 ('"$gdc_ver_msg"')"/' \
114 version.c > version.c.tmp && mv -f version.c.tmp version.c
117 # 4. Maybe apply Darwin patches
118 if test -z "$gcc_apple" && test "`uname`" = Darwin; then
119 if test -f d/patches/patch-gcc-darwin-eh-$gcc_patch_key; then
120 patch -p1 < d/patches/patch-gcc-darwin-eh-$gcc_patch_key || exit 1
124 echo
125 echo "Building D language version $d_lang_version."
126 echo
127 echo "GDC setup complete."
128 exit 0