aboutsummaryrefslogtreecommitdiffstats
path: root/lang/gcc6-aux/Makefile
blob: ed100a8a42aadcb7fe9059f6b210f64b7b4a4e1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# Created by: John Marino <marino@FreeBSD.org>
# $FreeBSD$

PORTNAME=   gcc6-aux
PORTVERSION=    ${SNAPSHOT}
PORTREVISION=   ${MAIN_PR}
CATEGORIES= lang
MASTER_SITES=   http://downloads.dragonlace.net/src/:boot \
        LOCAL/marino:boot GCC/${MS_SUBDIR}
DISTFILES=  ${IDENTIFICATION}.tar.bz2

MAINTAINER= marino@FreeBSD.org
COMMENT=    Version of GCC ${GCC_BRANCH} with full Ada support

LICENSE=    GPLv3 GPLv3RLE
LICENSE_COMB=   multi

.include "${.CURDIR}/Makefile.common"

LANGS=          c c++ ada
APPLY_DIFFS=        core cxx ada
INTENDED_COMPILER=  NATIVE
GARCH=          ${ARCH:S/amd64/x86_64/}
BOOTSTRAP_COMPILER= gnat-bootstrap.${GARCH}.${OPSYS:tl}.tar.bz2
BLD_TARGET=     ${GARCH}-aux-${OPSYS:tl}${OSREL}
FULL_GNATGCC=       NOT_SET
OS_LABEL4VERS=      [${OPSYS}${GARCH:M*64:S/amd_//:S/x86_//}]
NO_MTREE=       yes
CPPFLAGS+=      -I${LOCALBASE}/include
LDFLAGS+=       -L${LOCALBASE}/lib

OPTIONS_GROUP=      Standard Bootstrap
OPTIONS_GROUP_Standard= FORT OBJC NLS TESTSUITE ALLSTAGES STATIC
OPTIONS_GROUP_Bootstrap=BOOTSTRAP
OPTIONS_DEFAULT=    FORT OBJC
NO_OPTIONS_SORT=    yes

FORT_DESC=      Fortran language support
OBJC_DESC=      Objective-C language support
TESTSUITE_DESC=     Activate test support
ALLSTAGES_DESC=     Build compiler with itself (twice, brings in libcc1)
STATIC_DESC=        Link compilers and drivers statically
BOOTSTRAP_DESC=     Create bootstrap compiler (overrides other options)

# The BOOTSTRAP option overrides all the others.  "make stage" will build a
# static compiler that supports C, C++, and Ada languages and then create
# a new distfile in $WRKDIR/newbsd with the name following the pattern:
# ada-bootstrap.$ARCH.$OPSYS.XY.tar.bz2.  There is no need to "make install"

.include <bsd.port.options.mk>

.if ${OPSYS} == FreeBSD
ONLY_FOR_ARCHS=     amd64 i386
MODERN_BINUTILS=    yes
BOOTSTRAP_COMPILER= ada-bootstrap.${GARCH}.freebsd.100B.tar.bz2
.endif
.if ${OPSYS} == DragonFly
ONLY_FOR_ARCHS=     x86_64
BOOTSTRAP_COMPILER= ada-bootstrap.${GARCH}.dragonfly.41.tar.bz2
.endif

.if defined(MODERN_BINUTILS)
# Apparently gcc 4.9 needs binutils 2.23 or greater to link Ada correctly
USE_BINUTILS=   yes
RUN_DEPENDS+=   ${LOCALBASE}/bin/as:devel/binutils
EXTRA_CONFIG+=  --with-ld=${LOCALBASE}/bin/ld
EXTRA_CONFIG+=  --with-as=${LOCALBASE}/bin/as
.else
EXTRA_CONFIG+=  --with-ld=/usr/bin/ld
EXTRA_CONFIG+=  --with-as=/usr/bin/as
.endif

WRKSRC=         ${WRKDIR}/${IDENTIFICATION}
BUILDDIR=       ${WRKDIR}/build
NEWBSDIR=       ${WRKDIR}/newbs/bootstrap
CFG_SCRIPT=     ${WRKSRC}/configure
REVFILE=        ${WRKSRC}/gcc/REVISION
PHASEFILE=      ${WRKSRC}/gcc/DEV-PHASE
BOOTSTRAP_PREFIX=   ${WRKDIR}/bootstrap
PKG_PREFIX=     ${PREFIX}/${PORTNAME}
MANPREFIX=      ${PREFIX}/${PORTNAME}/share
BSFILENAME=     ada-bootstrap.${GARCH}.${OPSYS:tl}.${OSREL:S/.//}.tar.bz2

# If we find gnatmake and friends in a standard location, then we'll use this
# compiler instead of downloading the bootstrap.
.if exists (${LOCALBASE}/${PORTNAME}/bin/ada)
.if exists (${LOCALBASE}/${PORTNAME}/bin/gnatbind)
.if exists (${LOCALBASE}/${PORTNAME}/bin/gnatlink)
.if exists (${LOCALBASE}/${PORTNAME}/bin/gnatmake)
FULL_GNATGCC=${LOCALBASE}/${PORTNAME}/bin/ada
FULL_GNATGXX=${LOCALBASE}/${PORTNAME}/bin/g++
FULL_PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PREFIX}/${PORTNAME}/bin:${PREFIX}/bin
.endif
.endif
.endif
.endif

# If FULL_GNATGCC is not set, we'll request the bootstrap compiler
.if ${FULL_GNATGCC} == NOT_SET
INTENDED_COMPILER=BOOTSTRAP
FULL_GNATGCC=${BOOTSTRAP_PREFIX}/bin/gcc
FULL_GNATGXX=${BOOTSTRAP_PREFIX}/bin/g++
FULL_PATH=${BOOTSTRAP_PREFIX}/bin:/sbin:/bin:/usr/sbin:/usr/bin:${PREFIX}/bin
DISTFILES+= ${BOOTSTRAP_COMPILER}:boot
.endif

# for port maintenance, invoke "make makesum PLUS_BOOTSTRAPS=1"
.if defined(PLUS_BOOTSTRAPS)
DISTFILES=  \
   ${IDENTIFICATION}.tar.bz2 \
   ada-bootstrap.i386.freebsd.100B.tar.bz2:boot \
   ada-bootstrap.x86_64.dragonfly.41.tar.bz2:boot \
   ada-bootstrap.x86_64.freebsd.100B.tar.bz2:boot
.endif

.if ${PORT_OPTIONS:MFORT} && !${PORT_OPTIONS:MBOOTSTRAP}
LANGS+=     fortran
EXTRA_CONFIG+=  --enable-libquadmath
.else
EXTRA_CONFIG+=  --disable-libquadmath
.endif

.if ${PORT_OPTIONS:MOBJC} && !${PORT_OPTIONS:MBOOTSTRAP}
LANGS+=     objc
.endif

.if ${PORT_OPTIONS:MTESTSUITE} && !${PORT_OPTIONS:MBOOTSTRAP}
BUILD_DEPENDS+= dejagnu>=1.4:misc/dejagnu
APPLY_DIFFS+=   ada-testsuite
APPLY_DIFFS+=   gcc-testsuite
.endif

.if ${PORT_OPTIONS:MNLS} && !${PORT_OPTIONS:MBOOTSTRAP}
USES+=      gettext
EXTRA_CONFIG+=  --enable-nls
.else
EXTRA_CONFIG+=  --disable-nls
.endif

.if ${PORT_OPTIONS:MSTATIC} && !${PORT_OPTIONS:MBOOTSTRAP}
EXTRA_CONFIG+=      --with-stage1-ldflags=-static
.endif

.if ${PORT_OPTIONS:MBOOTSTRAP}
EXTRA_CONFIG+=      --disable-shared --disable-lto
EXTRA_CONFIG+=      --with-boot-ldflags=-static
.else
.  if !${PORT_OPTIONS:MALLSTAGES}
#  For reasons unknown, build fails at libcc1 when the compiler is not
#  not bootstrapping.  It appears to be an upstream error.  LibCC1 is used
#  for gdb 7.9 exclusively, so it's not really needed.  Let's disable it
#  by default, but let people that want it suffer a 3-stage build.
EXTRA_CONFIG+=      --disable-bootstrap --disable-libcc1
.  endif
USES+=          iconv
.endif

# Establish Ada-aware compiler for use
ADA_CONFIGURE_ENV+= CC=${FULL_GNATGCC}
ADA_CONFIGURE_ENV+= CXX=${FULL_GNATGXX}
ADA_CONFIGURE_ENV+= CFLAGS="${CFLAGS}"
ADA_CONFIGURE_ENV+= CPPFLAGS="${CPPFLAGS}"
ADA_CONFIGURE_ENV+= CXXFLAGS="${CXXFLAGS}"
ADA_CONFIGURE_ENV+= LDFLAGS="${LDFLAGS}"
ADA_CONFIGURE_ENV+= build_configargs="CPPFLAGS=\"${CPPFLAGS}\""
ADA_CONFIGURE_ENV+= host_configargs="CPPFLAGS=\"${CPPFLAGS}\""
ADA_CONFIGURE_ENV+= PATH=${FULL_PATH}
ADA_MAKE_ENV+=      PATH=${FULL_PATH}

# The standard configuration options
ADA_CONFIG_ARGS=    --enable-languages=${LANGS:Q}
ADA_CONFIG_ARGS+=   --build=${BLD_TARGET}
ADA_CONFIG_ARGS+=   --prefix=${PKG_PREFIX:Q}
ADA_CONFIG_ARGS+=   --with-system-zlib
ADA_CONFIG_ARGS+=   --with-gmp=${PREFIX}
ADA_CONFIG_ARGS+=   --with-mpfr=${PREFIX}
ADA_CONFIG_ARGS+=   --with-mpc=${PREFIX}
ADA_CONFIG_ARGS+=   ${ICONV_CONFIGURE_ARG}
ADA_CONFIG_ARGS+=   --enable-shared
ADA_CONFIG_ARGS+=   --enable-threads=posix
ADA_CONFIG_ARGS+=   --enable-checking=release
ADA_CONFIG_ARGS+=   --disable-libmudflap
ADA_CONFIG_ARGS+=   --disable-libgomp
ADA_CONFIG_ARGS+=   --disable-libssp
ADA_CONFIG_ARGS+=   ${EXTRA_CONFIG}

post-extract:
    # Personalize GNAT for each different machine
    @${ECHO} "-=> GNAT AUX ${OS_LABEL4VERS}" > ${REVFILE}
    @${ECHO} ${PHASE} > ${PHASEFILE}

    # Apply required composite diff files
.for suffix in ${APPLY_DIFFS}
    @${ECHO} "Applying composite patch diff-${suffix}"
    @${PATCH} -d ${WRKSRC} -s -E < ${FILESDIR}/diff-${suffix}
.endfor
.if ${PORT_OPTIONS:MSTATIC} || ${PORT_OPTIONS:MBOOTSTRAP}
    # Ensure GNAT tools are built statically
    ${REINPLACE_CMD} -e 's/^GCC_LINK_FLAGS=.*/GCC_LINK_FLAGS=-static/' \
        ${WRKSRC}/gcc/ada/gcc-interface/Makefile.in
.endif
    # Update LINK_SPEC to add gcc-aux lib runpath in every binary
    @${ECHO} "Configuring LINK_SPEC runpath"
    @${REINPLACE_CMD} -e 's;\@PREFIX\@;${PREFIX};' \
        -e 's;\@GCCAUX\@;${PORTNAME};' \
        ${WRKSRC}/gcc/config/dragonfly.h \
        ${WRKSRC}/gcc/config/i386/freebsd64.h \
        ${WRKSRC}/gcc/config/i386/freebsd.h
.if defined(MODERN_BINUTILS)
    # Use dwarf4-compatible addr2line (affects FreeBSD only)
    ${REINPLACE_CMD} -e 's|/usr/bin/addr2line|${PREFIX}/bin/addr2line|g' \
      ${WRKSRC}/gcc/ada/traceback_symbolic.c
.endif

do-configure:
    ${MKDIR} ${BUILDDIR}
    cd ${BUILDDIR} && ${SETENV} ${ADA_CONFIGURE_ENV} \
        ${CFG_SCRIPT} ${ADA_CONFIG_ARGS}

do-build:
    cd ${BUILDDIR} && ${SETENV} ${ADA_MAKE_ENV} \
        ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} ${MAKE_ARGS} all

.if ${PORT_OPTIONS:MTESTSUITE} && !${PORT_OPTIONS:MBOOTSTRAP}
test: build test-ada test-fortran test-objc test-cxx test-c

test-ada:
    cd ${BUILDDIR} && ${SETENV} ${ADA_MAKE_ENV} \
        ${MAKE_CMD} -sk check-ada

test-cxx:
    # libstdc++ testsuite will break every time, for TRUE to continue
    cd ${BUILDDIR} && ${SETENV} ${ADA_MAKE_ENV} \
        ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -sk check-c++ || true

test-c:
    cd ${BUILDDIR} && ${SETENV} ${ADA_MAKE_ENV} \
        ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -sk check-c

test-fortran:
.  if ${PORT_OPTIONS:MFORT}
    cd ${BUILDDIR} && ${SETENV} ${ADA_MAKE_ENV} \
        ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -sk check-fortran
.  endif

test-objc:
.  if ${PORT_OPTIONS:MOBJC}
    cd ${BUILDDIR} && ${SETENV} ${ADA_MAKE_ENV} \
        ${MAKE_CMD} -j${MAKE_JOBS_NUMBER} -sk check-objc
.  endif
.endif

do-install:
    cd ${BUILDDIR} && ${SETENV} ${ADA_MAKE_ENV} \
        ${MAKE_CMD} install-strip ${MAKE_ARGS}
    ${MV} ${STAGEDIR}${PKG_PREFIX}/share ${WRKDIR}/moved_share
    ${MKDIR} ${STAGEDIR}${PREFIX}/share/dejagnu/baseboards \
        ${STAGEDIR}${PREFIX}/share/dejagnu/config
    ${INSTALL_DATA} ${FILESDIR}/android6.exp \
        ${STAGEDIR}${PREFIX}/share/dejagnu/config
    ${INSTALL_DATA} ${FILESDIR}/gnatdroid6.exp \
        ${STAGEDIR}${PREFIX}/share/dejagnu/baseboards

post-stage:
    (cd ${STAGEDIR}${PKG_PREFIX}; ${FIND} * -type d -empty | \
        ${SORT} -dr | ${XARGS} ${RMDIR})
    (cd ${STAGEDIR}${PREFIX}; ${FIND} ${PORTNAME} share \
        \( -type f -or -type l \) | ${SORT} | ${SED} \
        -e 's/\/man\/man[1578]\/.*[1578]$$/&.gz/' >> ${TMPPLIST})
.if ${PORT_OPTIONS:MBOOTSTRAP}
    ${MKDIR} ${NEWBSDIR}
    ${CP} -a ${STAGEDIR}${PKG_PREFIX}/bin ${NEWBSDIR}/
    ${CP} -a ${STAGEDIR}${PKG_PREFIX}/lib ${NEWBSDIR}/
    ${CP} -a ${STAGEDIR}${PKG_PREFIX}/include ${NEWBSDIR}/
    ${CP} -a ${STAGEDIR}${PKG_PREFIX}/libexec ${NEWBSDIR}/
    ${RM} ${NEWBSDIR}/bin/${GARCH}*
    ${RM} -rf ${NEWBSDIR}/lib/gcc/${BLD_TARGET}/${GCC_VERSION}/include-fixed
    (cd ${NEWBSDIR}/.. ; ${TAR} -cyf ${BSFILENAME} bootstrap)
.endif

.include <bsd.port.mk>