GCC SPECS file workaround
[harbours.git] / gcc / HARBOUR
blob0f329ae4476abb0391a350c333af6a76c1a5206d
2 # Copyright (c) 2013 Vojtech Horky
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
9 # - Redistributions of source code must retain the above copyright
10 #   notice, this list of conditions and the following disclaimer.
11 # - Redistributions in binary form must reproduce the above copyright
12 #   notice, this list of conditions and the following disclaimer in the
13 #   documentation and/or other materials provided with the distribution.
14 # - The name of the author may not be used to endorse or promote products
15 #   derived from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 shipname=gcc
30 shipversion=4.6.3
31 mirror_="ftp://ftp.fu-berlin.de/unix/languages/gcc"
32 shipsources="$mirror_/releases/$shipname-$shipversion/$shipname-$shipversion.tar.bz2 includes.patch libiberty.patch pex-helenos.c gcc.specs"
33 shiptugs="libgmp libmpfr libmpc libisl zlib"
34 shipfunnels=4
36 build() {
37         run tar xjf ${shipname}-${shipversion}.tar.bz2
38         
39         
40         msg "Patching sources..."
41         # Missing include diretives
42         patch -p0 <includes.patch
43         # Prevent name clashes in getopt.c and fnmatch.c
44         patch -p0 <libiberty.patch
46         cp $HSCT_CONFIG_SUB "${shipname}-${shipversion}/config.sub"
48         run sed 's/\(static search_line_fast_type search_line_fast\);/\1 = search_line_acc_char;/' \
49                 -i "${shipname}-${shipversion}/libcpp/lex.c"
50         run sed '/fopen/s#w+b#wb+#' -i "${shipname}-${shipversion}/gcc/toplev.c"
51         
52         # HelenOS does not have its own unwind.h. Luckily,
53         # we may use the one provided by GCC itself.
54         msg "Fixing unwind.h..."
55         run mkdir -p include
56         run cp ${shipname}-${shipversion}/gcc/unwind-generic.h include/unwind.h
58         # We really do not need to fix any includes
59         run sed 's/STMP_FIXINC=stmp-fixinc/STMP_FIXINC=/' -i "${shipname}-${shipversion}/gcc/configure"
60         
61         # PEX is used to wrap different means to launch an external program
62         # We do not implement the fork() system call, we need to fix it to
63         # use the task_spawn() API.
64         # As the msdos version is not needed at all, we replace it with our
65         # own at various places to ensure the HelenOS version is built
66         # correctly.
67         msg "Providing our pex implementation..."
68         run cp pex-helenos.c "${shipname}-${shipversion}/libiberty/"
69         run sed \
70                 -e 's/@pexecute@/pex-helenos/' \
71                 -e 's/pex-msdos/pex-helenos/g' \
72                 -i "${shipname}-${shipversion}/libiberty/Makefile.in"
73         
74         # Prevent building documentation
75         # (there is a problem with newer version of texinfo?)
76         sed 's/^BUILD_INFO[ \t]*=.*/BUILD_INFO = /g' -i ${shipname}-${shipversion}/gcc/Makefile.in
77         
78         msg "Building..."
79         
80         # Out-of-source build is recommended for GCC
81         run mkdir -p build
82         cd build
83         
84         # This is extremely crippled version but it at least compiles
86         run ../${shipname}-${shipversion}/configure \
87                 $HSCT_CONFIGURE_ARGS \
88                 --target="$HSCT_CCROSS_TARGET" \
89                 --program-prefix="" \
90                 --disable-werror \
91                 --without-ppl \
92                 --without-cloog \
93                 --disable-mudflap \
94                 --disable-libmudflap \
95                 --disable-libgomp \
96                 --disable-gomp \
97                 --with-system-zlib \
98                 --without-headers \
99                 --disable-shared \
100                 --enable-languages=c \
101                 --disable-checking \
102                 --disable-lto \
103                 --disable-threads \
104                 --disable-nls \
105                 --disable-libssp \
106                 --disable-libquadmath \
107                 --enable-decimal-float=dpd \
108                 --disable-multilib \
109                 --disable-multiarch \
110                 --disable-libstdcxx-pch \
111                 --disable-libunwind-exceptions \
112                 --with-gnu-as \
113                 --with-gnu-ld \
114                 CC_FOR_TARGET="$HSCT_TARGET-cc" \
115                 CXX_FOR_TARGET="$HSCT_TARGET-cxx" \
116                 GCC_FOR_TARGET="$HSCT_TARGET-cc" \
117                 AR_FOR_TARGET="$HSCT_TARGET-ar" \
118                 AS_FOR_TARGET="$HSCT_TARGET-as" \
119                 LD_FOR_TARGET="$HSCT_TARGET-ld" \
120                 NM_FOR_TARGET="$HSCT_TARGET-nm" \
121                 OBJDUMP_FOR_TARGET="$HSCT_TARGET-objdump" \
122                 RANLIB_FOR_TARGET="$HSCT_TARGET-ranlib" \
123                 STRIP_FOR_TARGET="$HSCT_TARGET-strip"
125         run make all-gcc -j$shipfunnels STATIC_ONLY=y
128 package() {
129         cd build
130         run make install-gcc "DESTDIR=$PWD/PKG"
131         
132         # Copy the executables
133         run mkdir -p "$HSCT_MY_DIR/app/"
134         for app in gcc cpp gcov; do
135                 run cp PKG/usr/local/bin/$app "$HSCT_MY_DIR/app/"
136         done
137         run cp PKG/usr/local/libexec/gcc/*/$shipversion/cc1 "$HSCT_MY_DIR/app/"
138         
139         # Create default SPECS file to drive the compilation
140         run mkdir -p "$HSCT_MY_DIR/lib/gcc/$HSCT_CCROSS_TARGET/$shipversion/"
141         # FIXME: This is a temporary hack, we should preferably modify the
142         # default SPECS file instead of providing the simplified one.
143         run cp ../gcc.specs "$HSCT_MY_DIR/lib/gcc/$HSCT_CCROSS_TARGET/$shipversion/specs"