aboutsummaryrefslogtreecommitdiffstats
path: root/lang/gnat/Makefile
blob: a42075dfd9d45311f61ba1e74c5f9d9c567e9a76 (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
# New ports collection makefile for:    GNU Ada gnat
# Date created:         Sat Mar 18 02:16:45 1995
# Whom:         hsu
# Porter (original):    nils@guru.ims.uni-stuttgart.de
# Porter (version 3):   maurice@serc.rmit.edu.au
#
# $FreeBSD$
#
# Note:
# - FreeBSD tasking libraries created by Dan Eischen have been incorporated
#   into this edition
# - The default names of a number of binaries have been altered to avoid
#   conflict with other gcc based products. Standard names can be provided
#   using symbolic links.

PORTNAME=   gnat
PORTVERSION=    3.14p
CATEGORIES= lang
MASTER_SITES=   ftp://cs.nyu.edu/pub/gnat/${PORTVERSION}/ \
        ${MASTER_SITE_LOCAL} ${MASTER_SITE_GNU}
MASTER_SITE_SUBDIR= gcc deischen/gcc .
DISTFILES=  ${GNATNAME}.tgz gcc-2.8.1.tar.gz

MAINTAINER= eischen@vigrid.com

.include <bsd.port.pre.mk>

WRKSRC=     ${WRKDIR}/gcc-2.8.1
GNATNAME=   gnat-${PORTVERSION}-src
GNUHOST=    ${ARCH}-unknown-freebsd${OSREL}
GCC_VERSION=    2.8.1

PLIST_SUB=  GNUHOST=${GNUHOST} GCC_VERSION=${GCC_VERSION} \
        LIBRARY_VERSION=${LIBRARY_VERSION} \
        SHARED_MAJOR=${SHARED_MAJOR}

# Make no mistake about what host/target we are building on/for.
# This package does not support cross-compiling, and this fixes
# problems with bsd.port.mk files from earlier FreeBSD 3.x releases.
CONFIGURE_TARGET=   --host=${GNUHOST} --target=${GNUHOST}
CONFIGURE_ARGS=     --program-prefix=ada
GNU_CONFIGURE=  yes
USE_GMAKE=  yes
MAN1=       adagcc.1 cccp.1

# You need a compiler who calls an existing GNAT compiler (3.12 or greater).
# If you have one, point CC at it.  By default, we'll look for one in the
# obvious places.  If we can't find one, we'll fetch a distfile containing
# a minimum (still pretty large) compiler toolset and use that to build.

# For the GNAT compiler, we look in ${PREFIX} and in ${LOCALBASE}.
.ifdef PREFIX
have_boot!= if [ -x ${PREFIX}/bin/adagcc -a -x ${PREFIX}/bin/gnatbind ]; then \
            ${ECHO_CMD} "${PREFIX}/bin"; \
        else \
            ${ECHO_CMD} ""; \
        fi
.else
have_boot=
.endif
.if empty(have_boot)
have_boot!= if [ -x ${LOCALBASE}/bin/adagcc -a -x ${LOCALBASE}/bin/gnatbind ]; then \
            ${ECHO_CMD} "${LOCALBASE}/bin"; \
        else \
            ${ECHO_CMD} ""; \
        fi
.endif

#
# Check for attempts to cross-compile or build an aout GNAT compiler.
.if empty(have_boot)
have_boot!= if [ ${PORTOBJFORMAT} = "aout" ]; then \
            ${ECHO_CMD} "borken for aout"; \
        else \
            ${ECHO_CMD} ""; \
        fi
.else
have_boot!= if [ `file ${have_boot}/adagcc | awk ' { print $$2 }'` = "ELF" ]; then \
            if [ ${PORTOBJFORMAT} = "elf" ]; then \
                ${ECHO_CMD} ${have_boot}; \
            else \
                ${ECHO_CMD} "borken for aout"; \
            fi \
        else \
            ${ECHO_CMD} "borken for aout"; \
        fi
.endif

.if ${have_boot} == "borken for aout"
BROKEN= "Cannot build with or for an aout compiler."
.endif

.if empty(have_boot)
DISTFILES+= gnat-3.13p-boot.tar.gz
# Warning!  You need the trailing slash on GCC_EXEC_PREFIX.
COMPILEDATA=    GCC_EXEC_PREFIX=${WRKDIR}/adaboot/lib/gcc-lib/ \
        ADA_INCLUDE_PATH=${WRKDIR}/adaboot/lib/gcc-lib/adainclude \
        ADA_OBJECTS_PATH=${WRKDIR}/adaboot/lib/gcc-lib/adalib
have_boot=  ${WRKDIR}/adaboot
.endif

# Make sure we use the Ada-aware gcc compiler.
CC =    adagcc
CONFIGURE_ENV=  ${COMPILE_DATA} PATH=${have_boot}/bin:$$PATH

.if OVERRIDE_CFLAGS
GNATCFLAGS= ${CFLAGS}
GNATLIBCFLAGS=  ${CFLAGS}
.else
GNATCFLAGS= -O2
GNATLIBCFLAGS=  -O2
.endif

# Shared library handling
LIBRARY_VERSION=    3.14
SHARED_MAJOR=   1

# Account for signal set changes
.if ${OSVERSION} > 400010
SIGSET_WORDS=   4
SIGACTION=  new_struct_sigaction
.else
SIGSET_WORDS=   1
SIGACTION=  old_struct_sigaction
.endif

pre-patch:
    @if [ ! -f ${WRKSRC}/config/i386/freebsd-aout.h ]; then \
        ${MV} ${WRKSRC}/config/i386/freebsd.h ${WRKSRC}/config/i386/freebsd-aout.h; \
        ${MV} ${WRKSRC}/config/i386/freebsd-elf.h ${WRKSRC}/config/i386/freebsd.h; \
    fi
    @${ECHO} "===>  Applying FreeBSD patches to gcc for ${DISTNAME}"
    -( ${PATCH} ${PATCH_ARGS} < ${FILESDIR}/freebsdgcc28-patches )
    @${ECHO} "===>  Patching gcc for ${GNATNAME}"
    -( ${PATCH} ${PATCH_ARGS} < ${WRKDIR}/${GNATNAME}/src/gcc-281.dif )
    @${ECHO} "===>  Copying GNAT compiler sources into GCC tree."
    -( ${MV} ${WRKDIR}/${GNATNAME}/src/ada ${WRKDIR}/gcc-2.8.1 )
    @${ECHO} "===>  Making way for FreeBSD GNAT support files"
    -( ${RM} -f ${WRKSRC}/ada/[45]f* )

# Copy any additional files required into the correct locations, and also
# remove .orig files leftover from patching so they won't get installed.
post-patch:
    (cd ${FILESDIR}; \
        for i in *.adb *.ads ; do \
        ${CP} $$i ${WRKSRC}/ada; \
        done )
    ${RM} ${WRKDIR}/gnat-3.14p-src/examples/*.orig

pre-configure:
    @(cd ${WRKSRC}/config/${ARCH}/ ; \
    MAJ=`sysctl -n kern.osreldate | ${SED} -e '/.....$$/s///'` ; \
    ${MV} freebsd.h freebsd.h.in ; \
    ${SED} -e "s:__FreeBSD__=[0-9]*:__FreeBSD__=$${MAJ}:" freebsd.h.in \
        >freebsd.h)
    @(cd ${WRKSRC}/ada/ ; \
    ${MV} 5fosinte.ads 5fosinte.ads.in ; \
    ${SED} -e "s:__FreeBSD__sigset_words:${SIGSET_WORDS}:" \
        -e "s:__FreeBSD__sigaction:${SIGACTION}:" 5fosinte.ads.in \
        > 5fosinte.ads)
    @${TOUCH} ${TOUCH_FLAGS} ${WRKSRC}/cstamp-h.in
    @(cd ${WRKSRC}/ada; \
       ${TOUCH} treeprs.ads a-[es]info.h nmake.ad[bs])

#
# Can't get this to work with default bsd.port.mk do-configure target.
#
do-configure:
    @(cd ${WRKSRC} && ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})

#
# We intentionally override CFLAGS because the build procedure is explicitly
# spelled out in gnat-3.13p-src/src/README.BUILD.  Remove CFLAGS from the
# do-build target at your own risk.
#
do-build:
    (cd ${WRKSRC}; \
        PATH=${have_boot}/bin:$$PATH \
        ${COMPILEDATA} ${GMAKE} CC="${CC}" OLDCC="adagcc" CFLAGS="${GNATCFLAGS}" LANGUAGES="c ada gcov" )
    (cd ${WRKSRC}; \
        ${GMAKE} CFLAGS="${GNATCFLAGS}" LANGUAGES="c ada gcov" bootstrap )
    (cd ${WRKSRC}; \
        ${GMAKE} CFLAGS="${GNATCFLAGS}" gnattools )
    (cd ${WRKSRC}; \
        ${GMAKE} CFLAGS="${GNATCFLAGS}" GNATLIBCFLAGS="-fPIC ${GNATLIBCFLAGS}" \
        soext=.so.${SHARED_MAJOR} LIBRARY_VERSION=${LIBRARY_VERSION} \
        gnatlib-shared )
    ${MV} ${WRKSRC}/ada/rts/lib*-${LIBRARY_VERSION}.so.${SHARED_MAJOR} \
        ${WRKSRC}/ada
    ${RM} ${WRKSRC}/stamp-gnatlib2
    (cd ${WRKSRC}; \
        ${GMAKE} CFLAGS="${GNATCFLAGS}" GNATLIBCFLAGS="${GNATLIBCFLAGS}" gnatlib )

do-install:
    (cd ${WRKSRC}; \
        ${GMAKE} CC="${CC}" LANGUAGES="c ada gcov" ${INSTALL_TARGET} )
    ${INSTALL_DATA} \
        ${WRKSRC}/ada/libgnat-${LIBRARY_VERSION}.so.${SHARED_MAJOR} \
        ${PREFIX}/lib
    ${INSTALL_DATA} \
        ${WRKSRC}/ada/libgnarl-${LIBRARY_VERSION}.so.${SHARED_MAJOR} \
        ${PREFIX}/lib
    ${LN} -s ${PREFIX}/lib/libgnat-${LIBRARY_VERSION}.so.${SHARED_MAJOR} \
        ${PREFIX}/lib/gcc-lib/${GNUHOST}/${GCC_VERSION}/adalib/libgnat.so
    ${LN} -s ${PREFIX}/lib/libgnarl-${LIBRARY_VERSION}.so.${SHARED_MAJOR} \
        ${PREFIX}/lib/gcc-lib/${GNUHOST}/${GCC_VERSION}/adalib/libgnarl.so
    ${INSTALL_SCRIPT} ${WRKSRC}/ada/gnathtml.pl ${PREFIX}/bin
.ifndef(NOPORTDOCS)
    ${MKDIR} ${EXAMPLESDIR}
    ${INSTALL_DATA} \
        ${WRKDIR}/gnat-3.14p-src/examples/* ${EXAMPLESDIR}
.endif

post-install:
    @(for prog in ${PREFIX}/bin/adagcc \
        ${PREFIX}/bin/adagcov \
        ${PREFIX}/bin/gnat \
        ${PREFIX}/bin/gnatbind \
        ${PREFIX}/bin/gnatbl \
        ${PREFIX}/bin/gnatchop \
        ${PREFIX}/bin/gnatfind \
        ${PREFIX}/bin/gnatkr \
        ${PREFIX}/bin/gnatlink \
        ${PREFIX}/bin/gnatls \
        ${PREFIX}/bin/gnatmake \
        ${PREFIX}/bin/gnatmem \
        ${PREFIX}/bin/gnatprep \
        ${PREFIX}/bin/gnatpsta \
        ${PREFIX}/bin/gnatpsys \
        ${PREFIX}/bin/gnatxref \
        ${PREFIX}/bin/${GNUHOST}-gcc \
        ${PREFIX}/lib/gcc-lib/${GNUHOST}/${GCC_VERSION}/cc1 \
        ${PREFIX}/lib/gcc-lib/${GNUHOST}/${GCC_VERSION}/gnat1 \
        ${PREFIX}/lib/gcc-lib/${GNUHOST}/${GCC_VERSION}/cpp ; do \
        if [ -x $$prog ]; then \
        strip $$prog ; \
        fi \
    done)
    @(${TOUCH} ${TOUCH_FLAGS} ${PREFIX}/lib/gcc-lib/${GNUHOST}/${GCC_VERSION}/include/float.h)
    @(chown -R bin:bin ${PREFIX}/lib/gcc-lib/${GNUHOST}/${GCC_VERSION})
    ${LDCONFIG} -m ${PREFIX}/lib

.include <bsd.port.post.mk>