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