1 |
commit: b9cfa0a10decdbe659447a221a0634f2b78943b0 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jun 22 21:31:34 2012 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jul 3 04:38:40 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commit;h=b9cfa0a1 |
7 |
|
8 |
precompile headers.h to speed up build slightly |
9 |
|
10 |
Since all system headers are included by way of headers.h, we can |
11 |
pre-compile this to speed up the build up a bit. |
12 |
|
13 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
14 |
|
15 |
--- |
16 |
.gitignore | 2 ++ |
17 |
Makefile.am | 30 +++++++++++++++++++++++++++--- |
18 |
configure.ac | 6 +++++- |
19 |
libsandbox/Makefile.am | 2 +- |
20 |
libsandbox/headers.h | 1 + |
21 |
libsandbox/libsandbox.c | 7 ------- |
22 |
libsbutil/Makefile.am | 1 + |
23 |
libsbutil/headers.h | 1 + |
24 |
tests/Makefile.am | 2 +- |
25 |
9 files changed, 39 insertions(+), 13 deletions(-) |
26 |
|
27 |
diff --git a/.gitignore b/.gitignore |
28 |
index 502b3a1..4d34aee 100644 |
29 |
--- a/.gitignore |
30 |
+++ b/.gitignore |
31 |
@@ -1,5 +1,6 @@ |
32 |
a.out |
33 |
*~ |
34 |
+*.gch |
35 |
*.lo |
36 |
*.la |
37 |
*.o |
38 |
@@ -21,6 +22,7 @@ core |
39 |
.gdbinit |
40 |
|
41 |
/aclocal.m4 |
42 |
+/ar-lib |
43 |
/autom4te.cache/ |
44 |
/build/ |
45 |
/compile |
46 |
|
47 |
diff --git a/Makefile.am b/Makefile.am |
48 |
index e326b23..475c8c0 100644 |
49 |
--- a/Makefile.am |
50 |
+++ b/Makefile.am |
51 |
@@ -1,5 +1,6 @@ |
52 |
ACLOCAL_AMFLAGS = -I m4 |
53 |
MAKEFLAGS = --no-print-directory |
54 |
+AM_CPPFLAGS = $(SANDBOX_DEFINES) |
55 |
|
56 |
SUBDIRS = \ |
57 |
scripts \ |
58 |
@@ -10,12 +11,35 @@ SUBDIRS = \ |
59 |
src \ |
60 |
tests |
61 |
|
62 |
-libsandbox: libsbutil |
63 |
-src: libsbutil |
64 |
-tests: src |
65 |
+SANDBOX_PCH = headers.h.gch libsandbox/headers.h.gch libsbutil/headers.h.gch |
66 |
+BUILT_SOURCES = $(SANDBOX_PCH) |
67 |
+noinst_LTLIBRARIES = libpch.la |
68 |
+nodist_libpch_la_SOURCES = $(SANDBOX_PCH) |
69 |
+GCH_CP = ( \ |
70 |
+ src=`dirname $@`/.libs/`basename $@`.o; \ |
71 |
+ test -e "$$src" || src=$@.o; \ |
72 |
+ cp $$src $@ \ |
73 |
+ ) |
74 |
+# This is built as PIC |
75 |
+$(builddir)/libsbutil/headers.h.gch: headers.h |
76 |
+ $(AM_V_GEN)$(LTCOMPILE) -c -o $@.o $< && $(GCH_CP) |
77 |
+# This is built as PIC + exceptions |
78 |
+$(builddir)/libsandbox/headers.h.gch: headers.h |
79 |
+ $(AM_V_GEN)$(LTCOMPILE) -c -o $@.o $< $(CFLAG_EXCEPTIONS) && $(GCH_CP) |
80 |
+# This is built w/out PIC |
81 |
+$(builddir)/headers.h.gch: headers.h |
82 |
+ $(AM_V_GEN)$(COMPILE) -c -o $@.o $< && $(GCH_CP) |
83 |
+ |
84 |
+libsbutil: libsbutil/headers.h.gch |
85 |
+libsandbox: libsbutil libsandbox/headers.h.gch |
86 |
+src: libsbutil headers.h.gch |
87 |
+tests: src headers.h.gch |
88 |
|
89 |
EXTRA_DIST = headers.h localdecls.h ChangeLog.0 |
90 |
|
91 |
+CLEANFILES = $(SANDBOX_PCH) |
92 |
+DISTCLEANFILES = $(CLEANFILES) |
93 |
+ |
94 |
ChangeLog: |
95 |
touch ChangeLog |
96 |
|
97 |
|
98 |
diff --git a/configure.ac b/configure.ac |
99 |
index 573e412..a6fcd5b 100644 |
100 |
--- a/configure.ac |
101 |
+++ b/configure.ac |
102 |
@@ -19,11 +19,14 @@ AC_MSG_CHECKING([environment state]) |
103 |
env 1>&AS_MESSAGE_LOG_FD |
104 |
AC_MSG_RESULT([ok]) |
105 |
|
106 |
-dnl Checks for programs. |
107 |
+dnl Check for compiler and features first. |
108 |
AC_PROG_CC |
109 |
AM_PROG_CC_C_O |
110 |
AC_ISC_POSIX |
111 |
AC_USE_SYSTEM_EXTENSIONS |
112 |
+ |
113 |
+dnl Checks for programs. |
114 |
+AM_PROG_AR |
115 |
AC_PROG_INSTALL |
116 |
AC_PROG_MAKE_SET |
117 |
AC_PROG_AWK |
118 |
@@ -371,6 +374,7 @@ AC_SUBST([CFLAG_EXCEPTIONS]) |
119 |
CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
120 |
AX_CFLAGS_WARN_ALL |
121 |
AC_DEFUN([SB_CHECK_CFLAG],[AX_CHECK_COMPILE_FLAG([$1],[CFLAGS="$CFLAGS $1"])]) |
122 |
+SB_CHECK_CFLAG([-Winvalid-pch]) |
123 |
SB_CHECK_CFLAG([-fdata-sections]) |
124 |
SB_CHECK_CFLAG([-ffunction-sections]) |
125 |
AC_DEFUN([SB_CHECK_LDFLAG],[AX_CHECK_LINK_FLAG([-Wl,$1],[LDFLAGS="$LDFLAGS -Wl,$1"])]) |
126 |
|
127 |
diff --git a/libsandbox/Makefile.am b/libsandbox/Makefile.am |
128 |
index dc45618..2eb8da1 100644 |
129 |
--- a/libsandbox/Makefile.am |
130 |
+++ b/libsandbox/Makefile.am |
131 |
@@ -83,7 +83,7 @@ else |
132 |
$(AM_V_GEN)t= f= header=$@; $(TRACE_MAKE_HEADER) |
133 |
endif |
134 |
|
135 |
-EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) $(TRACE_FILES) |
136 |
+EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) $(TRACE_FILES) headers.h |
137 |
|
138 |
CLEANFILES = libsandbox.map sb_nr.h symbols.h trace_syscalls*.h |
139 |
DISTCLEANFILES = $(CLEANFILES) |
140 |
|
141 |
diff --git a/libsandbox/headers.h b/libsandbox/headers.h |
142 |
new file mode 100644 |
143 |
index 0000000..7fcc3b2 |
144 |
--- /dev/null |
145 |
+++ b/libsandbox/headers.h |
146 |
@@ -0,0 +1 @@ |
147 |
+#include "../headers.h" |
148 |
|
149 |
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c |
150 |
index 60d4614..2096b06 100644 |
151 |
--- a/libsandbox/libsandbox.c |
152 |
+++ b/libsandbox/libsandbox.c |
153 |
@@ -10,14 +10,7 @@ |
154 |
* as some of the InstallWatch code was used. |
155 |
*/ |
156 |
|
157 |
-#define open xxx_open |
158 |
-#define open64 xxx_open64 |
159 |
- |
160 |
#include "headers.h" |
161 |
- |
162 |
-#undef open |
163 |
-#undef open64 |
164 |
- |
165 |
#include "sbutil.h" |
166 |
#include "libsandbox.h" |
167 |
#include "wrappers.h" |
168 |
|
169 |
diff --git a/libsbutil/Makefile.am b/libsbutil/Makefile.am |
170 |
index 49a7d3b..a93b95c 100644 |
171 |
--- a/libsbutil/Makefile.am |
172 |
+++ b/libsbutil/Makefile.am |
173 |
@@ -44,3 +44,4 @@ libsbutil_la_SOURCES = \ |
174 |
src/dynbuf.c \ |
175 |
$(LOCAL_INCLUDES) |
176 |
|
177 |
+EXTRA_DIST = headers.h |
178 |
|
179 |
diff --git a/libsbutil/headers.h b/libsbutil/headers.h |
180 |
new file mode 100644 |
181 |
index 0000000..7fcc3b2 |
182 |
--- /dev/null |
183 |
+++ b/libsbutil/headers.h |
184 |
@@ -0,0 +1 @@ |
185 |
+#include "../headers.h" |
186 |
|
187 |
diff --git a/tests/Makefile.am b/tests/Makefile.am |
188 |
index a923ddc..cd8f9c2 100644 |
189 |
--- a/tests/Makefile.am |
190 |
+++ b/tests/Makefile.am |
191 |
@@ -5,7 +5,7 @@ EXTRA_DIST = atlocal.in package.m4.in $(AT_FILES) $(TESTSUITE) \ |
192 |
test-skel-0.c \ |
193 |
tests.h |
194 |
|
195 |
-AM_CPPFLAGS = -I$(top_srcdir) |
196 |
+AM_CPPFLAGS = -I$(top_srcdir) $(SANDBOX_DEFINES) |
197 |
|
198 |
check_PROGRAMS = \ |
199 |
get-group \ |