Merge oe-devel@oe-devel.bkbits.net:packages
[openembedded.git] / gcc-csl / gcc-csl_2004-q1a.oe
1 SECTION = "devel"
2 inherit autotools gettext
3
4 DESCRIPTION = "The GNU cc and gcc C compilers."
5 LICENSE = "GPL"
6 MAINTAINER = "Gerald Britton <gbritton@doomcom.org>"
7 BROKEN = "1"
8
9 # libgcc libstdc++ libg2c are listed in our FILES_*, but are actually
10 # packaged in the respective cross packages.
11 PACKAGES = "${PN} ${PN}-symlinks \
12             ${PN}-c++ ${PN}-c++-symlinks \
13             ${PN}-f77 ${PN}-f77-symlinks \
14             libstdc++-dev libg2c-dev \
15             ${PN}-doc"
16
17 FILES_${PN} = "${bindir}/${TARGET_PREFIX}gcc \
18                ${bindir}/${TARGET_PREFIX}cpp \
19                ${bindir}/${TARGET_PREFIX}gcov \
20                ${bindir}/${TARGET_PREFIX}gccbug \
21                ${libexecdir}/gcc/${TARGET_SYS}/${PV}/cc1 \
22                ${libexecdir}/gcc/${TARGET_SYS}/${PV}/collect2 \
23                ${libdir}/gcc/${TARGET_SYS}/${PV}/*.o \
24                ${libdir}/gcc/${TARGET_SYS}/${PV}/specs \
25                ${libdir}/gcc/${TARGET_SYS}/${PV}/lib* \
26                ${libdir}/gcc/${TARGET_SYS}/${PV}/include"
27
28 FILES_${PN}-symlinks = "${bindir}/cc \
29                         ${bindir}/gcc \
30                         ${bindir}/cpp \
31                         ${bindir}/gcov \
32                         ${bindir}/gccbug"
33
34 FILES_${PN}-f77 = "${bindir}/${TARGET_PREFIX}g77 \
35                    ${libexecdir}/gcc/${TARGET_SYS}/${PV}/f771"
36
37 FILES_${PN}-f77-symlinks = "${bindir}/g77 \
38                             ${bindir}/f77"
39
40 # Called from within gcc-cross, so libdir is set wrong
41 #FILES_libg2c = "${libdir}/libg2c.so.*"
42 FILES_libg2c = "/usr/lib/libg2c.so.*"
43
44 FILES_libg2c-dev = "${libdir}/libg2c.so \
45                           ${libdir}/libg2c.a \
46                           ${libdir}/libfrtbegin.a"
47
48 FILES_${PN}-c++ = "${bindir}/${TARGET_PREFIX}g++ \
49                    ${libexecdir}/gcc/${TARGET_SYS}/${PV}/cc1plus"
50
51 FILES_${PN}-c++-symlinks = "${bindir}/c++ \
52                             ${bindir}/g++"
53
54 FILES_libgcc = "/lib/libgcc_s.so.*"
55
56 # Called from within gcc-cross, so libdir is set wrong
57 #FILES_libstdc++ = "${libdir}/libstdc++.so.*"
58 FILES_libstdc++ = "/usr/lib/libstdc++.so.*"
59
60 FILES_libstdc++-dev = "${includedir}/c++/${PV} \
61                        ${libdir}/libstdc++.so \
62                        ${libdir}/libstdc++.la \
63                        ${libdir}/libstdc++.a \
64                        ${libdir}/libsupc++.la \
65                        ${libdir}/libsupc++.a"
66
67 FILES_${PN}-doc = "${infodir} \
68                    ${mandir} \
69                    ${libdir}/gcc/${TARGET_SYS}/${PV}/include/README"
70
71 #          file://gcc34-pre-modify.patch;patch=1
72 SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/arm/2004-Q1A/gcc-${PV}.tar.gz \
73            file://gcc34-reverse-compare.patch;patch=1 \
74            file://gcc34-arm-ldm.patch;patch=1 \
75            file://gcc34-arm-ldm-peephole.patch;patch=1 \
76            file://gcc34-arm-tune.patch;patch=1 \
77            file://gcc34-15089.patch;patch=1 \
78            file://gcc34-15666.patch;patch=1 \
79            file://gcc-uclibc-3.4.0-100-conf.patch;patch=1 \
80            file://gcc-uclibc-3.4.0-200-code.patch;patch=1 \
81            file://gcc-3.4.0-arm-lib1asm.patch;patch=1 \
82            file://gcc-3.4.0-arm-nolibfloat.patch;patch=1"
83
84 python do_unpack () {
85         oe.build.exec_func('base_do_unpack', d)
86         oe.build.exec_func('fix_perms', d)
87 }
88
89 fix_perms () {
90         chmod -R u+w ${S}
91 }
92
93 gccbuild_uclibc_do_patch () {
94         #
95         # Hack things to use the correct shared lib loader
96         #
97         #LIST=`grep -lr -- "-dynamic-linker.*\.so[\.0-9]*" .`
98         #if [ -n "$LIST" ] ; then
99         #       perl -i -p -e "s,-dynamic-linker.*\.so[\.0-9]*},-dynamic-linker /lib/ld-uClibc.so.0},;" $LIST
100         #fi
101
102         #
103         # Prevent system glibc start files from leaking in uninvited...
104         #
105         perl -i -p -e "s,standard_startfile_prefix_1 = \".*,standard_startfile_prefix_1 = \"${CROSS_DIR}/${TARGET_SYS}/lib/\";,;" gcc/gcc.c
106         perl -i -p -e "s,standard_startfile_prefix_2 = \".*,standard_startfile_prefix_2 = \"${CROSS_DIR}/${TARGET_SYS}/usr/lib/\";,;" gcc/gcc.c
107
108         #
109         # Prevent system glibc include files from leaking in uninvited...
110         #
111         perl -i -p -e "s,^NATIVE_SYSTEM_HEADER_DIR.*,NATIVE_SYSTEM_HEADER_DIR=${CROSS_DIR}/${TARGET_SYS}/include,;" gcc/Makefile.in
112         perl -i -p -e "s,^CROSS_SYSTEM_HEADER_DIR.*,CROSS_SYSTEM_HEADER_DIR=${CROSS_DIR}/${TARGET_SYS}/include,;" gcc/Makefile.in
113         perl -i -p -e "s,^#define.*STANDARD_INCLUDE_DIR.*,#define STANDARD_INCLUDE_DIR \"${CROSS_DIR}/${TARGET_SYS}/include\",;" gcc/cppdefault.h
114
115         #
116         # Prevent system glibc libraries from being found by collect2 
117         # when it calls locatelib() and rummages about the system looking 
118         # for libraries with the correct name...
119         #
120         perl -i -p -e "s,\"/lib,\"${CROSS_DIR}/${TARGET_SYS}/lib,g;" \
121                 gcc/collect2.c
122         perl -i -p -e "s,\"/usr/,\"${CROSS_DIR}/${TARGET_SYS}/usr/,g;" \
123                 gcc/collect2.c
124
125         #
126         # Prevent gcc from using the unwind-dw2-fde-glibc code
127         #
128         perl -i -p -e "s,^#ifndef inhibit_libc,#define inhibit_libc
129 #ifndef inhibit_libc,g;" gcc/unwind-dw2-fde-glibc.c
130 }
131
132 python do_patch () {
133     import oe, re
134     oe.build.exec_func('base_do_patch', d)
135     if (re.match('.*uclibc$', oe.data.getVar('TARGET_OS', d, 1)) != None):
136         oe.build.exec_func('gccbuild_uclibc_do_patch', d)
137 }
138
139 S = "${WORKDIR}/gcc-${PV}"
140 B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
141
142 EXTRA_OECONF = "--with-gnu-ld \
143                 --enable-shared \
144                 --enable-multilib \
145                 --enable-target-optspace \
146                 --enable-languages=c,c++,f77 \
147                 --enable-threads=posix \
148                 --enable-c99 \
149                 --enable-long-long \
150                 --enable-symvers=gnu \
151                 --program-prefix=${TARGET_PREFIX} \
152                 ${EXTRA_OECONF_PATHS} \
153                 ${EXTRA_OECONF_DEP}"
154
155 EXTRA_OECONF_PATHS = "--with-local-prefix=${prefix}/local \
156                       --with-gxx-include-dir=${includedir}/c++/${PV}"
157
158 EXTRA_OECONF_DEP = ""
159 EXTRA_OECONF_uclibc = "--disable-__cxa_atexit"
160 EXTRA_OECONF_glibc = "--enable-__cxa_atexit"
161 EXTRA_OECONF_append_ramses = " --with-float=soft "
162
163 python __anonymous () {
164     import oe, re
165     if (re.match('linux-uclibc$', oe.data.getVar('TARGET_OS', d, 1)) != None):
166         oe.data.setVar('EXTRA_OECONF_DEP', '${EXTRA_OECONF_uclibc}', d)
167     elif (re.match('linux$', oe.data.getVar('TARGET_OS', d, 1)) != None):
168         oe.data.setVar('EXTRA_OECONF_DEP', '${EXTRA_OECONF_glibc}', d)
169 }
170
171 do_configure () {
172         # Setup these vars for cross building only
173         if [ "${BUILD_SYS}" != "${HOST_SYS}" ]; then
174                 export CC_FOR_TARGET="${CCACHE} ${HOST_PREFIX}gcc"
175                 export GCC_FOR_TARGET="${CCACHE} ${HOST_PREFIX}gcc"
176                 export CXX_FOR_TARGET="${CCACHE} ${HOST_PREFIX}g++"
177                 export AS_FOR_TARGET="${HOST_PREFIX}as"
178                 export LD_FOR_TARGET="${HOST_PREFIX}ld"
179                 export NM_FOR_TARGET="${HOST_PREFIX}nm"
180                 export AR_FOR_TARGET="${HOST_PREFIX}ar"
181                 export RANLIB_FOR_TARGET="${HOST_PREFIX}ranlib"
182         fi
183         (cd ${S} && gnu-configize) || die "failure running gnu-configize"
184         oe_runconf
185 }
186
187 do_install () {
188         autotools_do_install
189
190         # Cleanup some of the /usr/lib{,exec}/gcc stuff ...
191         rm -r ${D}/${libdir}/gcc/${TARGET_SYS}/${PV}/install-tools
192         rm -r ${D}/${libexecdir}/gcc/${TARGET_SYS}/${PV}/install-tools
193
194         # Move libgcc_s into /lib
195         mkdir -p ${D}/lib
196         mv ${D}/${libdir}/libgcc_s.so.* ${D}/lib
197         rm ${D}/${libdir}/libgcc_s.so
198         ln -sf `echo ${libdir}/gcc/${TARGET_SYS}/${PV} \
199                 | tr -s / \
200                 | sed -e 's,^/,,' -e 's,[^/]*,..,g'`/lib/libgcc_s.so.? \
201                       ${D}/${libdir}/gcc/${TARGET_SYS}/${PV}/libgcc_s.so
202
203         # We don't need libtool libraries
204         rm ${D}/${libdir}/libg2c.la
205
206         # Cleanup manpages..
207         rm -r ${D}/${mandir}/man7
208
209         # We use libiberty from binutils
210         rm ${D}/${libdir}/libiberty.a
211
212         cd ${D}/${bindir}
213
214         # We care about g++ not c++
215         rm *c++
216
217         # We don't care about the gcc-<version> ones for this
218         rm *gcc-?.?*
219
220         # These sometimes show up, they are strange, we remove them
221         rm -f ${TARGET_ARCH}-*${TARGET_ARCH}-*
222
223         # Symlinks so we can use these trivially on the target
224         ln -sf ${TARGET_SYS}-g77 g77
225         ln -sf ${TARGET_SYS}-g++ g++
226         ln -sf ${TARGET_SYS}-gcc gcc
227         ln -sf g77 f77
228         ln -sf g++ c++
229         ln -sf gcc cc
230 }