Merge bk://openembedded@openembedded.bkbits.net/packages
[vuplus_openembedded] / gcc-csl / gcc-csl_2004-q1a.oe
1 SECTION = "devel"
2 inherit autotools
3
4 DESCRIPTION = "The GNU cc and gcc C compilers."
5 LICENSE = "GPL"
6 MAINTAINER = "Gerald Britton <gbritton@doomcom.org>"
7
8 # libgcc libstdc++ libg2c are listed in our FILES_*, but are actually
9 # packaged in the respective cross packages.
10 PACKAGES = "${PN} ${PN}-symlinks \
11             ${PN}-c++ ${PN}-c++-symlinks \
12             ${PN}-f77 ${PN}-f77-symlinks \
13             libstdc++-dev libg2c-dev \
14             ${PN}-doc"
15
16 FILES_${PN} = "${bindir}/${TARGET_PREFIX}gcc \
17                ${bindir}/${TARGET_PREFIX}cpp \
18                ${bindir}/${TARGET_PREFIX}gcov \
19                ${bindir}/${TARGET_PREFIX}gccbug \
20                ${libexecdir}/gcc/${TARGET_SYS}/${PV}/cc1 \
21                ${libexecdir}/gcc/${TARGET_SYS}/${PV}/collect2 \
22                ${libdir}/gcc/${TARGET_SYS}/${PV}/*.o \
23                ${libdir}/gcc/${TARGET_SYS}/${PV}/specs \
24                ${libdir}/gcc/${TARGET_SYS}/${PV}/lib* \
25                ${libdir}/gcc/${TARGET_SYS}/${PV}/include"
26
27 FILES_${PN}-symlinks = "${bindir}/cc \
28                         ${bindir}/gcc \
29                         ${bindir}/cpp \
30                         ${bindir}/gcov \
31                         ${bindir}/gccbug"
32
33 FILES_${PN}-f77 = "${bindir}/${TARGET_PREFIX}g77 \
34                    ${libexecdir}/gcc/${TARGET_SYS}/${PV}/f771"
35
36 FILES_${PN}-f77-symlinks = "${bindir}/g77 \
37                             ${bindir}/f77"
38
39 # Called from within gcc-cross, so libdir is set wrong
40 #FILES_libg2c = "${libdir}/libg2c.so.*"
41 FILES_libg2c = "/usr/lib/libg2c.so.*"
42
43 FILES_libg2c-dev = "${libdir}/libg2c.so \
44                           ${libdir}/libg2c.a \
45                           ${libdir}/libfrtbegin.a"
46
47 FILES_${PN}-c++ = "${bindir}/${TARGET_PREFIX}g++ \
48                    ${libexecdir}/gcc/${TARGET_SYS}/${PV}/cc1plus"
49
50 FILES_${PN}-c++-symlinks = "${bindir}/c++ \
51                             ${bindir}/g++"
52
53 FILES_libgcc = "/lib/libgcc_s.so.*"
54
55 # Called from within gcc-cross, so libdir is set wrong
56 #FILES_libstdc++ = "${libdir}/libstdc++.so.*"
57 FILES_libstdc++ = "/usr/lib/libstdc++.so.*"
58
59 FILES_libstdc++-dev = "${includedir}/c++/${PV} \
60                        ${libdir}/libstdc++.so \
61                        ${libdir}/libstdc++.la \
62                        ${libdir}/libstdc++.a \
63                        ${libdir}/libsupc++.la \
64                        ${libdir}/libsupc++.a"
65
66 FILES_${PN}-doc = "${infodir} \
67                    ${mandir} \
68                    ${libdir}/gcc/${TARGET_SYS}/${PV}/include/README"
69
70 #          file://gcc34-pre-modify.patch;patch=1
71 SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/arm/2004-Q1A/gcc-${PV}.tar.gz \
72            file://gcc34-reverse-compare.patch;patch=1 \
73            file://gcc34-arm-ldm.patch;patch=1 \
74            file://gcc34-arm-ldm-peephole.patch;patch=1 \
75            file://gcc34-arm-tune.patch;patch=1 \
76            file://gcc34-15089.patch;patch=1 \
77            file://gcc34-15666.patch;patch=1 \
78            file://gcc-uclibc-3.4.0-100-conf.patch;patch=1 \
79            file://gcc-uclibc-3.4.0-200-code.patch;patch=1 \
80            file://gcc-3.4.0-arm-lib1asm.patch;patch=1 \
81            file://gcc-3.4.0-arm-nolibfloat.patch;patch=1"
82
83 python do_unpack () {
84         oe.build.exec_func('base_do_unpack', d)
85         oe.build.exec_func('fix_perms', d)
86 }
87
88 fix_perms () {
89         chmod -R u+w ${S}
90 }
91
92 gccbuild_uclibc_do_patch () {
93         #
94         # Hack things to use the correct shared lib loader
95         #
96         #LIST=`grep -lr -- "-dynamic-linker.*\.so[\.0-9]*" .`
97         #if [ -n "$LIST" ] ; then
98         #       perl -i -p -e "s,-dynamic-linker.*\.so[\.0-9]*},-dynamic-linker /lib/ld-uClibc.so.0},;" $LIST
99         #fi
100
101         #
102         # Prevent system glibc start files from leaking in uninvited...
103         #
104         perl -i -p -e "s,standard_startfile_prefix_1 = \".*,standard_startfile_prefix_1 = \"${CROSS_DIR}/${TARGET_SYS}/lib/\";,;" gcc/gcc.c
105         perl -i -p -e "s,standard_startfile_prefix_2 = \".*,standard_startfile_prefix_2 = \"${CROSS_DIR}/${TARGET_SYS}/usr/lib/\";,;" gcc/gcc.c
106
107         #
108         # Prevent system glibc include files from leaking in uninvited...
109         #
110         perl -i -p -e "s,^NATIVE_SYSTEM_HEADER_DIR.*,NATIVE_SYSTEM_HEADER_DIR=${CROSS_DIR}/${TARGET_SYS}/include,;" gcc/Makefile.in
111         perl -i -p -e "s,^CROSS_SYSTEM_HEADER_DIR.*,CROSS_SYSTEM_HEADER_DIR=${CROSS_DIR}/${TARGET_SYS}/include,;" gcc/Makefile.in
112         perl -i -p -e "s,^#define.*STANDARD_INCLUDE_DIR.*,#define STANDARD_INCLUDE_DIR \"${CROSS_DIR}/${TARGET_SYS}/include\",;" gcc/cppdefault.h
113
114         #
115         # Prevent system glibc libraries from being found by collect2 
116         # when it calls locatelib() and rummages about the system looking 
117         # for libraries with the correct name...
118         #
119         perl -i -p -e "s,\"/lib,\"${CROSS_DIR}/${TARGET_SYS}/lib,g;" \
120                 gcc/collect2.c
121         perl -i -p -e "s,\"/usr/,\"${CROSS_DIR}/${TARGET_SYS}/usr/,g;" \
122                 gcc/collect2.c
123
124         #
125         # Prevent gcc from using the unwind-dw2-fde-glibc code
126         #
127         perl -i -p -e "s,^#ifndef inhibit_libc,#define inhibit_libc
128 #ifndef inhibit_libc,g;" gcc/unwind-dw2-fde-glibc.c
129 }
130
131 python do_patch () {
132     import oe, re
133     oe.build.exec_func('base_do_patch', d)
134     if (re.match('.*uclibc$', oe.data.getVar('TARGET_OS', d, 1)) != None):
135         oe.build.exec_func('gccbuild_uclibc_do_patch', d)
136 }
137
138 S = "${WORKDIR}/gcc-${PV}"
139 B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
140
141 EXTRA_OECONF = "--disable-nls \
142                 --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 }