buildsys: add support for building a profiled executable

pull/48/head
William Pitcock 2013-03-01 12:17:16 -06:00
parent d6fb7881d4
commit 1a49758792
2 changed files with 15 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.h.in~
*.o
*.og
*.op
*.gcno
*.gcda
*.gcov
@ -27,5 +28,6 @@ core
/configure
/pkgconf
/pkgconf-gcov
/pkgconf-profile
Makefile

View File

@ -14,6 +14,7 @@ PROG = pkgconf@EXEEXT@
SRCS = main.c cache.c pkg.c bsdstubs.c getopt_long.c fragment.c argvsplit.c fileio.c tuple.c dependency.c queue.c
OBJS = ${SRCS:.c=.o}
GCOV_OBJS = ${SRCS:.c=.og}
PROF_OBJS = ${SRCS:.c=.op}
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
CFLAGS += -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\" -DPKG_DEFAULT_PATH=\"${pkgconfigdir}\" -DSYSTEM_INCLUDEDIR=\"${system_includedir}\" -DSYSTEM_LIBDIR=\"${system_libdir}\" -Wall -Wextra -Wformat=2 -std=gnu99 -D_FORTIFY_SOURCE=2
@ -47,8 +48,20 @@ gcov-check: $(PROG)-gcov
$(SHELL) tests/run.sh ./$(PROG)-gcov
@echo "gcov(1) reporting data should now be generated..."
$(PROG)-profile: $(PROF_OBJS)
${CC} ${LDFLAGS} -pg -o $@ $(PROF_OBJS)
profile-check: $(PROG)-profile
$(SHELL) tests/run.sh ./$(PROG)-profile
@echo "gprof(1) reporting data should now be generated..."
.c.o:
${CC} ${CFLAGS} -c $< -o $@
.c.og:
${CC} ${CFLAGS} -fprofile-arcs -ftest-coverage -c $< -o $@
.c.op:
${CC} ${CFLAGS} -pg -c $< -o $@
.SUFFIXES: .og .op