Fixup fromcvs/togit conversion
[pkgsrcv2.git] / lang / gcc-aux / Makefile
1 # $NetBSD: Makefile,v 1.3 2012/08/03 08:53:57 marino Exp $
2 #
3
4 PKGNAME=        gcc-aux-${SNAPSHOT}
5 DISTNAME=       gcc-${GCC_VERSION}
6 CATEGORIES=     lang
7 MASTER_SITES=   ${MASTER_SITE_GNU:=gcc/gcc-${GCC_VERSION}/}
8 DISTFILES=      ${DISTNAME}.tar.bz2
9
10 MAINTAINER=     draco@marino.st
11 HOMEPAGE=       http://www.dragonlace.net/
12 COMMENT=        GNAT Ada compiler based on GCC ${GCC_BRANCH}
13 LICENSE=        gnu-gpl-v3 AND gnu-lgpl-v3
14
15 SNAPSHOT=       20120920
16 GCC_BRANCH=     4.7
17 GCC_POINT=      2
18 GCC_VERSION=    ${GCC_BRANCH}.${GCC_POINT}
19 LANGS=          c
20
21 PKG_DESTDIR_SUPPORT=    user-destdir
22
23 USE_TOOLS+=             gmake sed:run perl makeinfo bzip2 patch pod2man
24 USE_BUILTIN.iconv=      no
25 APPLY_DIFFS=            core
26
27 .include "../../mk/bsd.prefs.mk"
28 .include "options.mk"
29
30 # Requires bootstrap compiler, which is only available for NetBSD i386/AMD64
31 # DragonFly i386/AMD64 and SunOS i386  Bootstrap compilers for OpenBSD and
32 # FreeBSD also exist, but are currently reserved for the native package systems
33 # of those platforms.
34
35 ONLY_FOR_PLATFORM=      DragonFly-*-*        \
36                         NetBSD-[5-9]*-i386   \
37                         NetBSD-[5-9]*-x86_64 \
38                         SunOS-5.1[1-9]*-i386
39
40 BLD_TARGET=             ${MACHINE_ARCH}-aux-${LOWER_OPSYS}${OS_VERSION}
41 THREAD_MODEL=           posix
42 OS_LABEL4VERS=          [pkgsrc]
43 BOOTSTRAP_COMPILER=     NOT_REQUIRED
44 INTENDED_COMPILER=      NATIVE
45 BOOTSTRAP_TRIPLET=      NOT SET
46 FULL_GNATGCC=           NOT SET
47 FULL_PATH=              /sbin:/bin:/usr/sbin:/usr/bin:${PREFIX}/gcc-aux/bin:${PREFIX}/sbin:${PREFIX}/bin
48 OLD_EH=                 register_frame
49 REBUILD_LIB=            Rebuild the following library first:
50 STICONV=                ${PREFIX}/lib/libiconv.a
51 STINTL=                 \$${top_builddir}/../intl/libintl.a
52
53
54 .if ${OPSYS} == "DragonFly"
55 .if ${MACHINE_ARCH} == "i386"
56    OS_LABEL4VERS=       [DragonFly]
57    BOOTSTRAP_TRIPLET=   i386-bootstrap-dragonfly2.8/4.6.0
58 .endif
59 .if ${MACHINE_ARCH} == "x86_64"
60    OS_LABEL4VERS=       [DragonFly64]
61    BOOTSTRAP_TRIPLET=   x86_64-bootstrap-dragonfly2.8/4.6.0
62 .endif
63 BOOTSTRAP_COMPILER=     gnat-bootstrap.${MACHINE_ARCH}.dragonfly.tar.bz2
64 LINK_HEADER=            /usr/include/sys/link_elf.h
65 .endif
66
67
68 .if ${OPSYS} == "NetBSD"
69 .if !empty(OS_VERSION:M5.99.*)
70    NSUFF=       6.0_DEV
71 .elif !empty(OS_VERSION:M6.99.*)
72    NSUFF=       7.0_DEV
73 .else
74    NSUFF=       ${OS_VERSION}
75 .endif
76 .if ${MACHINE_ARCH} == "i386"
77    OS_LABEL4VERS=       [NetBSD]
78    BOOTSTRAP_TRIPLET=   i386-bootstrap-netbsdelf5.1/4.6.0
79    BLD_TARGET=          ${MACHINE_ARCH}-aux-netbsdelf${NSUFF}
80 .endif
81 .if ${MACHINE_ARCH} == "x86_64"
82    OS_LABEL4VERS=       [NetBSD64]
83    BOOTSTRAP_TRIPLET=   x86_64-bootstrap-netbsd5.1/4.6.0
84    BLD_TARGET=          ${MACHINE_ARCH}-aux-netbsd${NSUFF}
85 .endif
86 BOOTSTRAP_COMPILER=     gnat-bootstrap.${MACHINE_ARCH}.netbsd.tar.bz2
87 LINK_HEADER=            /usr/include/link_elf.h
88 .endif
89
90
91 .if ${OPSYS} == "SunOS"
92 .if ${MACHINE_ARCH} == "i386"
93    OS_LABEL4VERS=       [Solaris]
94    BOOTSTRAP_TRIPLET=   i386-bootstrap-solaris5.11/4.6.1
95 .endif
96 SOL_OSV=                `expr substr ${OS_VERSION} 3 2`
97 BLD_TARGET=             ${MACHINE_ARCH}-aux-${LOWER_OPSYS}2.${SOL_OSV}
98 BOOTSTRAP_COMPILER=     gnat-bootstrap.${MACHINE_ARCH}.solaris.tar.bz2
99 MY_CONFIGURE_ENV+=      OBJDUMP=/usr/sfw/bin/gobjdump
100 . if exists(/usr/sfw/bin/gld)
101 EXTRA_CONFARGS+=        --with-gnu-ld --with-ld=/usr/sfw/bin/gld
102 . else
103 EXTRA_CONFARGS+=        --without-gnu-ld --with-ld=/usr/ccs/bin/ld
104 . endif
105 . if exists(/usr/sfw/bin/gas)
106 EXTRA_CONFARGS+=        --with-gnu-as --with-as=/usr/sfw/bin/gas
107 . else
108 EXTRA_CONFARGS+=        --without-gnu-as --with-as=/usr/ccs/bin/as
109 . endif
110 .endif
111
112
113 # define some important directories and files
114 BUILDDIR=               ${WRKDIR}/build
115 WRKSRC=                 ${WRKDIR}/gcc-${GCC_VERSION}
116 PKG_PREFIX=             ${PREFIX}/gcc-aux
117 CFG_SCRIPT=             ${WRKSRC}/configure
118 BOOTSTRAP_PREFIX=       ${WRKDIR}/bootstrap
119 REVFILE=                ${WRKSRC}/gcc/REVISION
120 BASELIB=                ${PREFIX}/lib
121
122
123
124 # testing if gcc-aux is already installed - if so, use this compiler along with
125 # its gnatlink, gnatbind, and gnatmake rather than the older bootstrap versions
126 .if exists(${LOCALBASE}/gcc-aux/bin/ada)
127 FULL_GNATGCC=${LOCALBASE}/gcc-aux/bin/ada
128 .endif
129
130
131 .if ${FULL_GNATGCC} == "NOT SET"
132 # here we know we need to install the bootstrap compiler
133 INTENDED_COMPILER=BOOTSTRAP
134 FULL_GNATGCC=${BOOTSTRAP_PREFIX}/bin/gnatgcc
135 DISTFILES+= ${BOOTSTRAP_COMPILER}
136 SITES.${BOOTSTRAP_COMPILER}=    http://downloads.dragonlace.net/src/ \
137                                 http://dragonlace.mirrors.ada.cx/src/
138 FULL_PATH=${BOOTSTRAP_PREFIX}/bin:/sbin:/bin:/usr/sbin:/usr/bin:${PREFIX}/sbin:${PREFIX}/bin
139 .endif
140
141
142 # For pkg maintenance, uncomment to invoke "bmake mdi"
143 #DISTFILES+= \
144 #  gnat-bootstrap.i386.dragonfly.tar.bz2 \
145 #  gnat-bootstrap.x86_64.dragonfly.tar.bz2 \
146 #  gnat-bootstrap.i386.netbsd.tar.bz2 \
147 #  gnat-bootstrap.x86_64.netbsd.tar.bz2 \
148 #  gnat-bootstrap.i386.solaris.tar.bz2
149
150
151 # establish ada-aware compiler for use
152 MY_CONFIGURE_ENV+=      CC=${FULL_GNATGCC}
153 MY_CONFIGURE_ENV+=      PATH=${FULL_PATH}
154 MY_MAKE_ENV=            PATH=${FULL_PATH}
155 MY_MAKE_ENV+=           ICONVPREFIX=${PREFIX}
156 MY_MAKE_ENV+=           LD_LIBRARY_PATH=${BUILDDIR}/gcc
157 # ${WRKSRC}/fixincludes/ looks for sed and compiles the path to sed into
158 # a binary so we need to make sure we give it the installed sed and not
159 # the tool wrapped one.
160 MY_MAKE_ENV+=           ac_cv_path_SED=${TOOLS_SED}
161 MY_MAKE_ENV+=           lt_cv_path_SED=${TOOLS_SED}
162
163
164 # The standard configuration options
165 CONFIGURE_ARGS=         --enable-languages=${LANGS:Q}
166 CONFIGURE_ARGS+=        --build=${BLD_TARGET}
167 CONFIGURE_ARGS+=        --prefix=${PKG_PREFIX:Q}
168 CONFIGURE_ARGS+=        --with-system-zlib
169 CONFIGURE_ARGS+=        --with-gmp=${BUILDLINK_PREFIX.gmp}
170 CONFIGURE_ARGS+=        --with-mpfr=${BUILDLINK_PREFIX.mpfr}
171 CONFIGURE_ARGS+=        --with-mpc=${BUILDLINK_PREFIX.mpcomplex}
172 CONFIGURE_ARGS+=        --with-libiconv-prefix=${PREFIX}
173 CONFIGURE_ARGS+=        --enable-shared
174 CONFIGURE_ARGS+=        --enable-threads=${THREAD_MODEL}
175 CONFIGURE_ARGS+=        --disable-bootstrap
176 CONFIGURE_ARGS+=        --disable-libmudflap
177 CONFIGURE_ARGS+=        --disable-libgomp
178 CONFIGURE_ARGS+=        --disable-libssp
179 CONFIGURE_ARGS+=        ${EXTRA_CONFARGS}
180
181 # Automatic package list generation
182 GENERATE_PLIST=  cd ${DESTDIR}${PREFIX};
183 GENERATE_PLIST+= ${FIND} * \( -type f -or -type l \) | ${SORT} -dr;
184
185
186 post-extract:
187         # Personalize GNAT for each different machine
188         @${ECHO} "-=> GCC AUX ${OS_LABEL4VERS}" > ${REVFILE}
189
190         # Create new directories in preparation of applying diff files
191 .if !empty(PKG_OPTIONS:Mcxx)
192         ${MKDIR} ${WRKSRC}/libstdc++-v3/config/locale/dragonfly
193         ${MKDIR} ${WRKSRC}/libstdc++-v3/config/os/bsd/dragonfly
194 .endif
195
196         # Apply required composite diff files
197 .for suffix in ${APPLY_DIFFS}
198         @${ECHO} "Applying composite patch diff-${suffix}"
199         @${PATCH} -d ${WRKSRC} -s -E < ${FILESDIR}/diff-${suffix}
200 .endfor
201
202         # Update LINK_SPEC to add gcc-aux lib runpath in every binary
203         @${ECHO} "Configuring LINK_SPEC runpath"
204         @perl -pi -e 's;\@PREFIX\@;${PREFIX};' \
205           ${WRKSRC}/gcc/config/dragonfly.h \
206           ${WRKSRC}/gcc/config/i386/freebsd.h \
207           ${WRKSRC}/gcc/config/i386/netbsd-elf.h
208
209         # Handle static option
210 .if !empty(PKG_OPTIONS:Mstatic) || ${OPSYS} == "NetBSD"
211         @${ECHO} "Reconfiguring GCC Makefile to build compiler statically"
212         @${PATCH} -d ${WRKSRC} -s -E < ${FILESDIR}/diff-static-version
213 .if empty(PKG_OPTIONS:Mnls)
214         @perl -pi -e 's;\@LIBICONV\@;${STICONV};' \
215           ${WRKSRC}/gcc/Makefile.in \
216           ${WRKSRC}/libcpp/Makefile.in \
217           ${WRKSRC}/gcc/ada/gcc-interface/Makefile.in
218 .else
219         @perl -pi -e 's;\@LIBINTL\@;${STINTL} ${STICONV};' ${WRKSRC}/intl/config.intl.in
220         @perl -pi -e 's;\@LIBICONV\@;;' \
221           ${WRKSRC}/gcc/Makefile.in \
222           ${WRKSRC}/libcpp/Makefile.in \
223           ${WRKSRC}/gcc/ada/gcc-interface/Makefile.in
224 .endif
225 .endif
226
227 .if ${INTENDED_COMPILER} == "BOOTSTRAP"
228         # Bootstrap compiler has statically linked z, gmp, mpc, mpfr and iconv
229         # The only shared lib is libc.so.7, so it should work for a long time.
230         # It is at least 28MB and doesn't come with shared libraries.
231
232         ${MKDIR} ${BOOTSTRAP_PREFIX}
233         mv ${BOOTSTRAP_PREFIX}/../bin ${BOOTSTRAP_PREFIX}
234         mv ${BOOTSTRAP_PREFIX}/../lib ${BOOTSTRAP_PREFIX}
235         mv ${BOOTSTRAP_PREFIX}/../libexec ${BOOTSTRAP_PREFIX}
236
237         # Bootstrap compiler malfunctions in NetBSD 6 unless include-fixed
238         # directory is removed first.  It will eventually cause problems
239         # for DragonFly and Solaris as well, so just unconditionally kill it.
240         ${RM} -rf ${BOOTSTRAP_PREFIX}/lib/gcc/${BOOTSTRAP_TRIPLET}/include-fixed
241 .endif
242
243
244 pre-configure:
245 # NetBSD's system compiler is not configured to use dl_iterate_phdr which is
246 # required to build shared libraries if gnat-aux handles exceptions via
247 # dl_iterate_phdr.  Therefore the feature requires statically built
248 # gmp, mpc, mpfr, and iconv libraries in order to build on NetBSD.
249 # DragonFly introduced this functionality with 2.11, but it's possible the
250 # shared libraries were built with an earlier compiler in the case of an
251 # upgrade.  We need to detect this situation on shared library builds and
252 # stop the build if the libraries need to be rebuilt.
253 .if ${OPSYS} == "DragonFly" && empty(PKG_OPTIONS:Mstatic)
254         @if ${GREP} dl_iterate_phdr ${LINK_HEADER} > /dev/null; then \
255           if ${GREP} ${OLD_EH} ${BASELIB}/libmpc.so > /dev/null; then \
256             ${ERROR_MSG} "${REBUILD_LIB} math/mpcomplex"; \
257             exit 101; \
258           fi; \
259           if ${GREP} ${OLD_EH} ${BASELIB}/libmpfr.so > /dev/null; then \
260             ${ERROR_MSG} "${REBUILD_LIB} math/mpfr"; \
261             exit 102; \
262           fi; \
263           if ${GREP} ${OLD_EH} ${BASELIB}/libgmp.so > /dev/null; then \
264             ${ERROR_MSG} "${REBUILD_LIB} devel/gmp"; \
265             exit 103; \
266           fi; \
267           if ${GREP} ${OLD_EH} ${BASELIB}/libiconv.so > /dev/null; then \
268             ${ERROR_MSG} "${REBUILD_LIB} converters/libiconv"; \
269             exit 104; \
270           fi; \
271         fi
272 .endif
273
274
275 do-configure:
276         ${MKDIR} ${BUILDDIR}
277         cd ${BUILDDIR} && ${SETENV} ${MY_CONFIGURE_ENV} \
278         ${CFG_SCRIPT} ${CONFIGURE_ARGS}
279
280
281 do-build:
282         # The unlimited stacksize is for NetBSD64
283         cd ${BUILDDIR} && \
284         ${ULIMIT_CMD_stacksize} && \
285         ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -j${MAKE_JOBS:U1:Q} all
286
287
288 do-test: build test-ada test-fortran test-objc test-cxx test-c
289
290 test-ada:
291 .if !empty(PKG_OPTIONS:Mtestsuite) && !empty(PKG_OPTIONS:Mada)
292 .if (${OPSYS} == "NetBSD") && (${MACHINE_ARCH} == "x86_64")
293         # NetBSD has an extremely small default stacksize of 2MB, which is
294         # insufficient for the gnat.dg testsuite.
295         # specifically: entry_queues test on AMD64
296         # Unlimiting stack resources on i386-netbsdelf* will result in
297         # failure of gnat.dg/task_stack_align.adb execution test.
298         cd ${BUILDDIR} && \
299         ${ULIMIT_CMD_stacksize} && \
300         ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-ada
301 .else
302         cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-ada
303 .endif
304 .endif
305
306 test-fortran:
307 .if !empty(PKG_OPTIONS:Mtestsuite) && !empty(PKG_OPTIONS:Mfortran)
308         cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-fortran
309 .endif
310
311 test-objc:
312 .if !empty(PKG_OPTIONS:Mtestsuite) && !empty(PKG_OPTIONS:Mobjc)
313         cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-objc
314 .endif
315
316 test-cxx:
317 .if !empty(PKG_OPTIONS:Mtestsuite) && !empty(PKG_OPTIONS:Mcxx)
318         # libstdc++ always ends with error status, so ignore it
319         cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk \
320         check-c++ || ${TRUE}
321 .endif
322
323 test-c:
324 .if !empty(PKG_OPTIONS:Mtestsuite)
325         cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-c
326 .endif
327
328
329 do-install:
330         # This was install-strip, but a bug in 4.7.x prevents libobjc
331         # from installation.  Just install the unstripped version until
332         # it's fixed (Bug filed with GCC: 54720)
333         cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} install \
334         DESTDIR=${DESTDIR}
335
336
337
338 .include "../../converters/libiconv/buildlink3.mk"
339 .include "../../devel/gmp/buildlink3.mk"
340 .include "../../math/mpfr/buildlink3.mk"
341 .include "../../math/mpcomplex/buildlink3.mk"
342 .include "../../mk/bsd.pkg.mk"