2 # -1. Make sure we are in the top-level GCC soure directory
3 if test -d gcc
&& test -d gcc
/d
&& test -f gcc
/d
/setup-gcc.sh
; then
6 echo "This script must be run from the top-level GCC source directory."
11 # D 2.0 will be the default eventually
12 #if test -d gcc/d/dmd2; then
18 if test -d gcc
/d
/dmd
; then
20 elif test -d gcc
/d
/dmd2
; then
25 # Read command line arguments
28 --d-language-version=*) d_lang_version
=${arg##--d-language-version=} ;;
30 echo "error: invalid option '$arg'"
36 if test $d_lang_version -ne 1; then
37 d_subdir_sfx
=$d_lang_version
40 if test ! -d gcc
/d
/dmd
$d_subdir_sfx; then
41 echo "error: This distribution does not support D version $d_lang_version"
45 # 0. Find out what GCC version this is
46 if grep version_string gcc
/version.c |
grep -q '"3.4'; then
48 elif grep version_string gcc
/version.c |
grep -q '"4.0'; then
50 elif grep -q '^4\.1\.' gcc
/BASE-VER
; then
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
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
65 # 0.2. Determine if this version of GCC is supported
66 gcc_patch_fn
=d
/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."
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
86 ..
/symlink-tree ..
/gcc
/d
/phobos
$d_subdir_sfx .svn
> /dev
/null
&& \
89 # 2. Patch the top-level directory
91 # If the patch for the top-level Makefile.in doesn't take, you can regenerate
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
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
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
125 echo "Building D language version $d_lang_version."
127 echo "GDC setup complete."