Tweak textproc/libtre version 0.8.0_1
[dports.git] / textproc / libtre / Makefile
1 # Created by: ijliao
2 # $FreeBSD: textproc/libtre/Makefile 314782 2013-03-21 00:11:34Z jgh $
3
4 PORTNAME=       libtre
5 PORTVERSION=    0.8.0
6 PORTREVISION=   1
7 CATEGORIES=     textproc
8 MASTER_SITES=   http://laurikari.net/tre/ \
9                 LOCAL/bf
10 DISTNAME=       tre-${PORTVERSION}
11
12 MAINTAINER=     bf@FreeBSD.org
13 COMMENT=        Lightweight fully POSIX compliant regexp matching library
14
15 LICENSE=        BSD
16 LICENSE_FILE=   ${WRKSRC}/LICENSE
17
18 USE_BZIP2=      yes
19 USES=   pathfix
20 USE_PKGCONFIG=  build
21 USE_AUTOTOOLS=  libtool
22 CONFIGURE_ARGS+=        --enable-static
23 USE_LDCONFIG=   yes
24
25 CPPFLAGS+=      -I${LOCALBASE}/include
26 LDFLAGS+=       -L${LOCALBASE}/lib
27
28 OPTIONS_DEFINE= NLS OPTIMIZED_CFLAGS PGO DOCS
29 PGO_DESC=       Enable Profile-Guided Optimization
30
31 MAN1=   tre_agrep.1
32
33 .include <bsd.port.pre.mk>
34 .include <bsd.port.options.mk>
35
36 .if ${PORT_OPTIONS:MNLS}
37 USE_GETTEXT=    yes
38 PLIST_SUB+=     NLS=""
39 .else
40 CONFIGURE_ARGS+=        --disable-nls
41 PLIST_SUB+=     NLS="@comment "
42 .endif
43
44 .if ${PORT_OPTIONS:MOPTIMIZED_CFLAGS}
45 CFLAGS+=        -Wuninitialized -ffast-math -finline-functions \
46                 -fomit-frame-pointer -fexpensive-optimizations \
47                 -fforce-mem -fforce-addr -O3
48 .endif
49
50 .if ${PORT_OPTIONS:MPGO}
51 LDFLAGS+=       -fprofile-generate
52 CFLAGS+=        -fprofile-generate
53 .endif
54
55 post-patch:
56         ${MV} ${WRKSRC}/doc/agrep.1.in ${WRKSRC}/doc/tre_agrep.1.in
57         ${REINPLACE_CMD} -e 's;agrep\.1;tre_agrep\.1;g' ${WRKSRC}/configure \
58         ${WRKSRC}/tre.spec.in ${WRKSRC}/doc/Makefile.in
59         ${REINPLACE_CMD} -e 's;agrep;tre_agrep;g' ${WRKSRC}/tests/agrep/*.ok
60
61 .if ${PORT_OPTIONS:MPGO}
62 .if target(pre-build)
63 .error Makefile error since pre-build target has already been defined
64 .endif
65 pre-build: pgo
66 .endif
67
68 post-install:
69 .if ${PORT_OPTIONS:MDOCS}
70         ${MKDIR} ${DOCSDIR}
71 .for i in tre-api.html tre-syntax.html
72         ${INSTALL_DATA} ${WRKSRC}/doc/${i} ${DOCSDIR}
73 .endfor
74 .endif
75
76 regression-test: build
77         @(cd ${BUILD_WRKSRC} ; ${SETENV} ${MAKE_ENV} ${MAKE} check )
78
79 .if ${PORT_OPTIONS:MPGO}
80 pgo: pgo-pre-build pgo-build pgo-run pgo-post-run pgo-clean
81
82 pgo-pre-build:
83         @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \
84                 ${REINPLACE_CMD} -E \
85                         -e 's,^((C|LD)FLAGS[[:space:]]*=.*)-fprofile-generate,\1,' \
86                         -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \
87                         -e 's,^((C|LD)FLAGS[[:space:]]*=.*)$$,\1 -fprofile-generate,' \
88                         {} \;
89
90 pgo-build:
91         @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${_MAKE_JOBS} ${MAKE_ARGS} ${ALL_TARGET})
92
93 pgo-run:
94 # Check everything to generate profiling information.
95         @-(cd ${BUILD_WRKSRC} ; ${SETENV} ${MAKE_ENV} ${MAKE} check)
96
97 pgo-post-run:
98         @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \
99                 ${REINPLACE_CMD} -E \
100                         -e 's,^((C|LD)FLAGS[[:space:]]*=.*)-fprofile-generate,\1,' \
101                         -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \
102                         -e 's,^(CFLAGS[[:space:]]*=.*)$$,\1 -fprofile-use,' \
103                         {} \;
104         @${REINPLACE_CMD} -E \
105                 -e 's,-fprofile-generate,-fprofile-use,g' \
106                 ${CONFIGURE_WRKSRC}/config.status \
107                 ${CONFIGURE_WRKSRC}/libtool
108         @${REINPLACE_CMD} -E \
109                 -e 's,-fprofile-generate,,g' \
110                 ${BUILD_WRKSRC}/tre.pc
111
112 pgo-clean:
113 # Selectively clean some directories.
114 . for dir in src tests
115         @(cd ${BUILD_WRKSRC}/${dir}; ${SETENV} ${MAKE_ENV} ${MAKE} clean)
116 . endfor
117 # Only remove some files from lib to preserve profiling information.
118         @${FIND} -E ${BUILD_WRKSRC}/lib -iregex ".*\.(a|la|lai|lo|o|so|so\..*)$$" \
119                 -exec ${RM} -f {} \;
120 .endif # if ${PORT_OPTIONS:MPGO}
121
122 .include <bsd.port.post.mk>