aboutsummaryrefslogtreecommitdiffstats
path: root/cad/ghdl/Makefile
blob: 8c34f389eb17567a3050fe3b611ed2fa61a72ef3 (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
# Created by: John Marino <marino@FreeBSD.org>
# $FreeBSD$

PORTNAME=   ghdl
PORTVERSION=    0.33
DISTVERSIONPREFIX=  v
CATEGORIES= cad
DISTFILES=  ${DISTNAME}${EXTRACT_SUFX}

MAINTAINER= marino@FreeBSD.org
COMMENT=    GNU VHDL simulator

LICENSE=    GPLv2
LICENSE_FILE=   ${WRKSRC}/COPYING

LIB_DEPENDS=    libgmp.so:${PORTSDIR}/math/gmp \
        libmpfr.so:${PORTSDIR}/math/mpfr \
        libmpc.so:${PORTSDIR}/math/mpc

USES=       ada gmake
USE_GITHUB= yes
GH_ACCOUNT= tgingold

GNU_CONFIGURE=  yes
GCCVER=     4.9.2
LLVMVER=    35
BLD_TARGET= ${ARCH:S/amd64/x86_64/}-portbld-${OPSYS:tl}${OSREL:R}
BUILDDIR=   ${WRKDIR}/build
GCCSRCDIR=  ${WRKDIR}/gcc-${GCCVER}
CFG_SCRIPT= ${GCCSRCDIR}/configure
PKG_PREFIX= ${PREFIX}/ghdl
LINKER_COMMAND= ${LOCALBASE}/${ADAXX}-aux/bin/gcc

GHDL_ARGS=  --enable-languages="c,vhdl" \
        --build=${BLD_TARGET} \
        --prefix=${PKG_PREFIX:Q} \
        --disable-bootstrap \
        --disable-nls \
        --disable-libquadmath \
        --disable-libmudflap \
        --disable-libgomp \
        --disable-libssp \
        --with-system-zlib \
        --with-gmp=${PREFIX} \
        --with-mpfr=${PREFIX} \
        --with-mpc=${PREFIX} \
        --enable-shared \
        --enable-threads=posix \
        ${ICONV_CONFIGURE_ARG} ${EXTRA_CONFIG}

OPTIONS_SINGLE=     BACKEND
OPTIONS_SINGLE_BACKEND= GCC LLVM

GCC_DESC=       Code generator is GCC  (mature)
LLVM_DESC=      Code generator is LLVM (experimental)
LLVM_USES=      libedit ncurses

.if exists (/sbin/hammer)
OPTIONS_DEFAULT=    LLVM
PLIST_SUB=      DRAGONFLY="" FREEBSD="@comment "
.else
OPTIONS_DEFAULT=    GCC
PLIST_SUB=      DRAGONFLY="@comment " FREEBSD=""
.endif

.include <bsd.port.options.mk>

.if ${OPSYS} == FreeBSD
MODERN_BINUTILS=    yes
.endif

.if ${ARCH:S/amd64/x86_64/} == x86_64
PLIST_SUB+= X86_64=""
.else
PLIST_SUB+= X86_64="@comment "
.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:${PORTSDIR}/devel/binutils
AS_COMMAND= ${LOCALBASE}/bin/as
EXTRA_CONFIG+=  --with-ld=${LOCALBASE}/bin/ld
.else
AS_COMMAND= /usr/bin/as
EXTRA_CONFIG+=  --with-ld=/usr/bin/ld
.endif
EXTRA_CONFIG+=  --with-as=${AS_COMMAND}

.if ${PORT_OPTIONS:MGCC}
DISTFILES+= gcc-${GCCVER}.tar.bz2
USES+=      iconv libtool makeinfo perl5
USE_PERL5=  build
INFO=       ghdl
PLIST_SUB+= GLEX=ghdl/libexec/gcc/${BLD_TARGET}/${GCCVER} \
        GLIB=ghdl/lib/gcc/${BLD_TARGET}/${GCCVER} \
        TARGET=${BLD_TARGET}
.  if ${OPSYS} == DragonFly
IGNORE=     not supported by GCC backend
.  endif
.endif

.if ${PORT_OPTIONS:MLLVM}
BUILD_DEPENDS+= llvm-config${LLVMVER}:${PORTSDIR}/devel/llvm${LLVMVER} \
        clang++${LLVMVER}:${PORTSDIR}/lang/clang${LLVMVER}
RUN_DEPENDS+=   llc${LLVMVER}:${PORTSDIR}/devel/llvm${LLVMVER}
PLIST=      ${.CURDIR}/llvm-plist
PLIST_SUB+= GLIB=ghdl/lib/ghdl/
.endif

post-patch:
    @${REINPLACE_CMD} \
        -e 's|\@AS_COMMAND\@|${AS_COMMAND}|' \
        -e 's|\@LINKER_COMMAND\@|${LINKER_COMMAND}|' \
        ${WRKSRC}/src/ghdldrv/ghdldrv.adb
    @${REINPLACE_CMD} \
        -e 's|llvm-config|llvm-config${LLVMVER}|' \
        -e 's|(INSTALL_PROGRAM)|(BSD_INSTALL_PROGRAM)|' \
        -e 's|(INSTALL_DATA)|(BSD_INSTALL_DATA)|' \
        ${WRKSRC}/configure ${WRKSRC}/Makefile.in
    @${REINPLACE_CMD} -e 's|clang++|clang++${LLVMVER}|' \
        -e 's|\((LDFLAGS)\)|\1 -L${LOCALBASE}/lib|' \
        ${WRKSRC}/src/ortho/llvm/Makefile

.if ${PORT_OPTIONS:MGCC}
do-configure:
    ${MKDIR} ${BUILDDIR}
    (cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ./configure \
        --with-gcc=${GCCSRCDIR} --prefix=${PKG_PREFIX:Q})
    ${SETENV} ${MAKE_ENV} ${MAKE_CMD} -C ${WRKSRC} copy-sources
    (cd ${BUILDDIR} && ${SETENV} ${CONFIGURE_ENV} \
        ${CFG_SCRIPT} ${GHDL_ARGS})

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

do-install:
    (cd ${BUILDDIR} && ${SETENV} ${MAKE_ENV} \
        ${MAKE_CMD} install-strip ${MAKE_ARGS})
    ${MV} ${STAGEDIR}${PREFIX}/ghdl/share/man/man1/ghdl.1 \
        ${STAGEDIR}${PREFIX}/man/man1
    ${MV} ${STAGEDIR}${PREFIX}/ghdl/share/info/ghdl.info \
        ${STAGEDIR}${PREFIX}/info
    ${RM} -r ${STAGEDIR}${PREFIX}/ghdl/share

.endif  # TAIL: GCC

.if ${PORT_OPTIONS:MLLVM}
do-configure:
    (cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ./configure \
        --with-llvm=${LOCALBASE} --prefix=${PKG_PREFIX:Q})
.endif  # TAIL: LLVM

check:
    (cd ${WRKSRC}/testsuite && ${SETENV} ${MAKE_ENV} \
        GHDL=${STAGEDIR}${PREFIX}/ghdl/bin/ghdl ${SH} testsuite.sh)

.include <bsd.port.mk>