aboutsummaryrefslogtreecommitdiff
path: root/textproc/libtre
diff options
context:
space:
mode:
authorMario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>2009-04-22 01:23:43 +0000
committerMario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>2009-04-22 01:23:43 +0000
commit42bd109dcc6a026b9865eaf09ffaf35b376cc7ef (patch)
tree6e261c0a8c0a1c9c15b989fc3d1837551de448af /textproc/libtre
parent5f93c479a11229003604afc7fe442e89f73892b8 (diff)
downloadports-42bd109dcc6a026b9865eaf09ffaf35b376cc7ef.tar.gz
ports-42bd109dcc6a026b9865eaf09ffaf35b376cc7ef.zip
Add WITH_PGO to build with Profile-Guided Optimization
PR: 133302 Approved by: maintainer
Notes
Notes: svn path=/head/; revision=232480
Diffstat (limited to 'textproc/libtre')
-rw-r--r--textproc/libtre/Makefile63
1 files changed, 61 insertions, 2 deletions
diff --git a/textproc/libtre/Makefile b/textproc/libtre/Makefile
index 6bef84f73d5b..779d1232d97e 100644
--- a/textproc/libtre/Makefile
+++ b/textproc/libtre/Makefile
@@ -21,14 +21,15 @@ USE_BZIP2= yes
USE_GNOME= gnomehack gnometarget pkgconfig
USE_AUTOTOOLS= libtool:15
CONFIGURE_ARGS+= --enable-static
-CONFIGURE_ENV+= CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}"
+CONFIGURE_ENV+= CPPFLAGS="${CPPFLAGS}"
USE_LDCONFIG= yes
CPPFLAGS+= -I${LOCALBASE}/include
LDFLAGS+= -L${LOCALBASE}/lib
OPTIONS= NLS "native language support" off \
- OPTIMIZED_CFLAGS "append optimization flags to CFLAGS" off
+ OPTIMIZED_CFLAGS "append optimization flags to CFLAGS" off \
+ PGO "Enable Profile-Guided Optimization" off
MAN1= tre_agrep.1
@@ -48,12 +49,27 @@ CFLAGS+= -Wuninitialized -ffast-math -finline-functions \
-fforce-mem -fforce-addr -O3
.endif
+.if defined(WITH_PGO)
+CONFIGURE_ENV+= CFLAGS="${CFLAGS} -fprofile-generate" \
+ LDFLAGS="${LDFLAGS} -fprofile-generate"
+.else
+CONFIGURE_ENV+= CFLAGS="${CFLAGS}" \
+ LDFLAGS="${LDFLAGS}"
+.endif
+
post-patch:
${MV} ${WRKSRC}/doc/agrep.1.in ${WRKSRC}/doc/tre_agrep.1.in
${REINPLACE_CMD} -e 's;agrep\.1;tre_agrep\.1;g' ${WRKSRC}/configure \
${WRKSRC}/tre.spec.in ${WRKSRC}/doc/Makefile.in
${REINPLACE_CMD} -e 's;agrep;tre_agrep;g' ${WRKSRC}/tests/agrep/*.ok
+.if defined(WITH_PGO)
+.if target(pre-build)
+.error Makefile error since pre-build target has already been defined
+.endif
+pre-build: pgo
+.endif
+
post-install:
.if !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
@@ -65,4 +81,47 @@ post-install:
regression-test: build
@(cd ${BUILD_WRKSRC} ; ${SETENV} ${MAKE_ENV} ${MAKE} check )
+.if defined(WITH_PGO)
+pgo: pgo-pre-build pgo-build pgo-run pgo-post-run pgo-clean
+
+pgo-pre-build:
+ @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \
+ ${REINPLACE_CMD} -E \
+ -e 's,^((C|LD)FLAGS[[:space:]]*=.*)-fprofile-generate,\1,' \
+ -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \
+ -e 's,^((C|LD)FLAGS[[:space:]]*=.*)$$,\1 -fprofile-generate,' \
+ {} \;
+
+pgo-build:
+ @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${_MAKE_JOBS} ${MAKE_ARGS} ${ALL_TARGET})
+
+pgo-run:
+# Check everything to generate profiling information.
+ @-(cd ${BUILD_WRKSRC} ; ${SETENV} ${MAKE_ENV} ${MAKE} check)
+
+pgo-post-run:
+ @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \
+ ${REINPLACE_CMD} -E \
+ -e 's,^((C|LD)FLAGS[[:space:]]*=.*)-fprofile-generate,\1,' \
+ -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \
+ -e 's,^(CFLAGS[[:space:]]*=.*)$$,\1 -fprofile-use,' \
+ {} \;
+ @${REINPLACE_CMD} -E \
+ -e 's,-fprofile-generate,-fprofile-use,g' \
+ ${CONFIGURE_WRKSRC}/config.status \
+ ${CONFIGURE_WRKSRC}/libtool
+ @${REINPLACE_CMD} -E \
+ -e 's,-fprofile-generate,,g' \
+ ${BUILD_WRKSRC}/tre.pc
+
+pgo-clean:
+# Selectively clean some directories.
+. for dir in gnulib src tests
+ @(cd ${BUILD_WRKSRC}/${dir}; ${SETENV} ${MAKE_ENV} ${MAKE} clean)
+. endfor
+# Only remove some files from lib to preserve profiling information.
+ @${FIND} -E ${BUILD_WRKSRC}/lib -iregex ".*\.(a|la|lai|lo|o|so|so\..*)$$" \
+ -exec ${RM} -f {} \;
+.endif # if defined(WITH_PGO)
+
.include <bsd.port.post.mk>