Browse Source

buildsys: add support for building a profiled executable

William Pitcock 7 years ago
parent
commit
1a49758792
2 changed files with 15 additions and 0 deletions
  1. 2
    0
      .gitignore
  2. 13
    0
      Makefile.in

+ 2
- 0
.gitignore View File

@@ -1,6 +1,7 @@
1 1
 *.h.in~
2 2
 *.o
3 3
 *.og
4
+*.op
4 5
 *.gcno
5 6
 *.gcda
6 7
 *.gcov
@@ -27,5 +28,6 @@ core
27 28
 /configure
28 29
 /pkgconf
29 30
 /pkgconf-gcov
31
+/pkgconf-profile
30 32
 
31 33
 Makefile

+ 13
- 0
Makefile.in View File

@@ -14,6 +14,7 @@ PROG			= pkgconf@EXEEXT@
14 14
 SRCS			= main.c cache.c pkg.c bsdstubs.c getopt_long.c fragment.c argvsplit.c fileio.c tuple.c dependency.c queue.c
15 15
 OBJS			= ${SRCS:.c=.o}
16 16
 GCOV_OBJS		= ${SRCS:.c=.og}
17
+PROF_OBJS		= ${SRCS:.c=.op}
17 18
 CFLAGS			= @CFLAGS@
18 19
 LDFLAGS			= @LDFLAGS@
19 20
 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
47 48
 	$(SHELL) tests/run.sh ./$(PROG)-gcov
48 49
 	@echo "gcov(1) reporting data should now be generated..."
49 50
 
51
+$(PROG)-profile: $(PROF_OBJS)
52
+	${CC} ${LDFLAGS} -pg -o $@ $(PROF_OBJS)
53
+
54
+profile-check: $(PROG)-profile
55
+	$(SHELL) tests/run.sh ./$(PROG)-profile
56
+	@echo "gprof(1) reporting data should now be generated..."
57
+
50 58
 .c.o:
51 59
 	${CC} ${CFLAGS} -c $< -o $@
52 60
 
53 61
 .c.og:
54 62
 	${CC} ${CFLAGS} -fprofile-arcs -ftest-coverage -c $< -o $@
63
+
64
+.c.op:
65
+	${CC} ${CFLAGS} -pg -c $< -o $@
66
+
67
+.SUFFIXES: .og .op