From 1a4975879218ebf51c92526c87c4c81aefef970f Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 1 Mar 2013 12:17:16 -0600 Subject: [PATCH] buildsys: add support for building a profiled executable --- .gitignore | 2 ++ Makefile.in | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 6d8f715..544d003 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.h.in~ *.o *.og +*.op *.gcno *.gcda *.gcov @@ -27,5 +28,6 @@ core /configure /pkgconf /pkgconf-gcov +/pkgconf-profile Makefile diff --git a/Makefile.in b/Makefile.in index 81d05f3..a40d844 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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