1 # $NetBSD: Makefile,v 1.3 2012/08/03 08:53:57 marino Exp $
4 PKGNAME= gcc-aux-${SNAPSHOT}
5 DISTNAME= gcc-${GCC_VERSION}
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
18 GCC_VERSION= ${GCC_BRANCH}.${GCC_POINT}
21 PKG_DESTDIR_SUPPORT= user-destdir
23 USE_TOOLS+= gmake sed:run perl makeinfo bzip2 patch pod2man
27 .include "../../mk/bsd.prefs.mk"
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
35 ONLY_FOR_PLATFORM= DragonFly-*-* \
37 NetBSD-[5-9]*-x86_64 \
40 BLD_TARGET= ${MACHINE_ARCH}-aux-${LOWER_OPSYS}${OS_VERSION}
42 OS_LABEL4VERS= [pkgsrc]
43 BOOTSTRAP_COMPILER= NOT_REQUIRED
44 INTENDED_COMPILER= NATIVE
45 BOOTSTRAP_TRIPLET= 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
54 .if ${OPSYS} == "DragonFly"
55 .if ${MACHINE_ARCH} == "i386"
56 OS_LABEL4VERS= [DragonFly]
57 BOOTSTRAP_TRIPLET= i386-bootstrap-dragonfly2.8/4.6.0
59 .if ${MACHINE_ARCH} == "x86_64"
60 OS_LABEL4VERS= [DragonFly64]
61 BOOTSTRAP_TRIPLET= x86_64-bootstrap-dragonfly2.8/4.6.0
63 BOOTSTRAP_COMPILER= gnat-bootstrap.${MACHINE_ARCH}.dragonfly.tar.bz2
64 LINK_HEADER= /usr/include/sys/link_elf.h
68 .if ${OPSYS} == "NetBSD"
69 .if !empty(OS_VERSION:M5.99.*)
71 .elif !empty(OS_VERSION:M6.99.*)
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}
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}
86 BOOTSTRAP_COMPILER= gnat-bootstrap.${MACHINE_ARCH}.netbsd.tar.bz2
87 LINK_HEADER= /usr/include/link_elf.h
91 .if ${OPSYS} == "SunOS"
92 .if ${MACHINE_ARCH} == "i386"
93 OS_LABEL4VERS= [Solaris]
94 BOOTSTRAP_TRIPLET= i386-bootstrap-solaris5.11/4.6.1
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
103 EXTRA_CONFARGS+= --without-gnu-ld --with-ld=/usr/ccs/bin/ld
105 . if exists(/usr/sfw/bin/gas)
106 EXTRA_CONFARGS+= --with-gnu-as --with-as=/usr/sfw/bin/gas
108 EXTRA_CONFARGS+= --without-gnu-as --with-as=/usr/ccs/bin/as
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
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
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
142 # For pkg maintenance, uncomment to invoke "bmake mdi"
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
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}
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}
181 # Automatic package list generation
182 GENERATE_PLIST= cd ${DESTDIR}${PREFIX};
183 GENERATE_PLIST+= ${FIND} * \( -type f -or -type l \) | ${SORT} -dr;
187 # Personalize GNAT for each different machine
188 @${ECHO} "-=> GCC AUX ${OS_LABEL4VERS}" > ${REVFILE}
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
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}
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
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
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
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.
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}
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
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"; \
259 if ${GREP} ${OLD_EH} ${BASELIB}/libmpfr.so > /dev/null; then \
260 ${ERROR_MSG} "${REBUILD_LIB} math/mpfr"; \
263 if ${GREP} ${OLD_EH} ${BASELIB}/libgmp.so > /dev/null; then \
264 ${ERROR_MSG} "${REBUILD_LIB} devel/gmp"; \
267 if ${GREP} ${OLD_EH} ${BASELIB}/libiconv.so > /dev/null; then \
268 ${ERROR_MSG} "${REBUILD_LIB} converters/libiconv"; \
277 cd ${BUILDDIR} && ${SETENV} ${MY_CONFIGURE_ENV} \
278 ${CFG_SCRIPT} ${CONFIGURE_ARGS}
282 # The unlimited stacksize is for NetBSD64
284 ${ULIMIT_CMD_stacksize} && \
285 ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -j${MAKE_JOBS:U1:Q} all
288 do-test: build test-ada test-fortran test-objc test-cxx test-c
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.
299 ${ULIMIT_CMD_stacksize} && \
300 ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-ada
302 cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-ada
307 .if !empty(PKG_OPTIONS:Mtestsuite) && !empty(PKG_OPTIONS:Mfortran)
308 cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-fortran
312 .if !empty(PKG_OPTIONS:Mtestsuite) && !empty(PKG_OPTIONS:Mobjc)
313 cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-objc
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 \
324 .if !empty(PKG_OPTIONS:Mtestsuite)
325 cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-c
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 \
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"