]> granicus.if.org Git - apache/blob - build/rules.mk.in
update after backport
[apache] / build / rules.mk.in
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements.  See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License.  You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 #
17 # The build environment was originally provided by Sascha Schumann.
18
19 @ap_make_include@ @ap_make_delimiter@$(top_builddir)/build/config_vars.mk@ap_make_delimiter@
20
21 # Combine all of the flags together in the proper order so that
22 # the user-defined flags can always override the configure ones, if needed.
23 # Note that includes are listed after the flags because -I options have
24 # left-to-right precedence and CPPFLAGS may include user-defined overrides.
25 # The "MOD_" prefixed variable are provided to allow modules to insert their
26 # (per-subdirectory) settings through definitions in modules.mk, with highest
27 # precedence.
28 #
29 ALL_CFLAGS   = $(MOD_CFLAGS) $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS)
30 ALL_CPPFLAGS = $(DEFS) $(INTERNAL_CPPFLAGS) $(MOD_CPPFLAGS) $(EXTRA_CPPFLAGS) $(NOTEST_CPPFLAGS) $(CPPFLAGS)
31 ALL_CXXFLAGS = $(MOD_CXXFLAGS) $(EXTRA_CXXFLAGS) $(NOTEST_CXXFLAGS) $(CXXFLAGS)
32 ALL_LDFLAGS  = $(MOD_LDFLAGS) $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS)
33 ALL_LIBS     = $(MOD_LIBS) $(EXTRA_LIBS) $(NOTEST_LIBS) $(LIBS)
34 ALL_INCLUDES = $(MOD_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
35
36 # Compile commands
37
38 BASE_CC  = $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
39 BASE_CXX = $(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
40
41 COMPILE      = $(BASE_CC) $(PICFLAGS)
42 CXX_COMPILE  = $(BASE_CXX) $(PICFLAGS)
43
44 SH_COMPILE     = $(LIBTOOL) --mode=compile $(BASE_CC) $(SHLTCFLAGS) -c $< && touch $@
45 SH_CXX_COMPILE = $(LIBTOOL) --mode=compile $(BASE_CXX) $(SHLTCFLAGS) -c $< && touch $@
46
47 LT_COMPILE     = $(LIBTOOL) --mode=compile $(COMPILE) $(LTCFLAGS) -c $< -o $@
48 LT_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) $(LTCFLAGS) -c $< -o $@
49
50 # Link-related commands
51
52 LINK     = $(LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) $(PILDFLAGS) $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
53 SH_LINK  = $(SH_LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) $(LT_LDFLAGS) $(ALL_LDFLAGS) $(SH_LDFLAGS) $(CORE_IMPLIB) $(SH_LIBS) -o $@
54 MOD_LINK = $(LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) -static $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
55
56 # Cross compile commands
57
58 # Helper programs
59
60 INSTALL_DATA = $(INSTALL) -m 644
61 INSTALL_PROGRAM = $(INSTALL) -m 755 $(INSTALL_PROG_FLAGS)
62
63 #
64 # Standard build rules
65 #
66 all: all-recursive
67 depend: depend-recursive
68 clean: clean-recursive
69 distclean: distclean-recursive
70 extraclean: extraclean-recursive
71 install: install-recursive
72 shared-build: shared-build-recursive
73
74 all-recursive install-recursive depend-recursive:
75         @otarget=`echo $@|sed s/-recursive//`; \
76         list=' $(BUILD_SUBDIRS) $(SUBDIRS)'; \
77         for i in $$list; do \
78             if test -d "$$i"; then \
79                 target="$$otarget"; \
80                 echo "Making $$target in $$i"; \
81                 if test "$$i" = "."; then \
82                         made_local=yes; \
83                         target="local-$$target"; \
84                 fi; \
85                 (cd $$i && $(MAKE) $$target) || exit 1; \
86             fi; \
87         done; \
88         if test "$$otarget" = "all" && test -z '$(TARGETS)'; then \
89             made_local=yes; \
90         fi; \
91         if test "$$made_local" != "yes"; then \
92             $(MAKE) "local-$$otarget" || exit 1; \
93         fi
94
95 clean-recursive distclean-recursive extraclean-recursive:
96         @otarget=`echo $@|sed s/-recursive//`; \
97         list='$(CLEAN_SUBDIRS) $(SUBDIRS)'; \
98         for i in $$list; do \
99             if test -d "$$i"; then \
100                 target="$$otarget"; \
101                 echo "Making $$target in $$i"; \
102                 if test "$$i" = "."; then \
103                         made_local=yes; \
104                         target="local-$$target"; \
105                 fi; \
106                 (cd $$i && $(MAKE) $$target); \
107             fi; \
108         done; \
109         if test "$$otarget" = "all" && test -z '$(TARGETS)'; then \
110             made_local=yes; \
111         fi; \
112         if test "$$made_local" != "yes"; then \
113             $(MAKE) "local-$$otarget"; \
114         fi
115
116 shared-build-recursive:
117         @if test `pwd` = "$(top_builddir)"; then \
118             $(PRE_SHARED_CMDS) ; \
119         fi; \
120         list='$(SUBDIRS)'; for i in $$list; do \
121             target="shared-build"; \
122             if test "$$i" = "."; then \
123                 made_local=yes; \
124                 target="local-shared-build"; \
125             fi; \
126             if test "$$i" != "srclib"; then \
127                 (cd $$i && $(MAKE) $$target) || exit 1; \
128             fi; \
129         done; \
130         if test -f 'modules.mk'; then \
131             if test -n '$(SHARED_TARGETS)'; then \
132                 echo "Building shared: $(SHARED_TARGETS)"; \
133                 if test "$$made_local" != "yes"; then \
134                         $(MAKE) "local-shared-build" || exit 1; \
135                 fi; \
136             fi; \
137         fi; \
138         if test `pwd` = "$(top_builddir)"; then \
139                 $(POST_SHARED_CMDS) ; \
140         fi
141
142 local-all: $(TARGETS)
143
144 local-shared-build: $(SHARED_TARGETS)
145
146 local-depend: x-local-depend
147         @if test -n "`ls $(srcdir)/*.c 2> /dev/null`"; then \
148                 rm -f .deps; \
149                 list='$(srcdir)/*.c'; \
150                 for i in $$list; do \
151                         $(MKDEP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) $$i | \
152                                 sed 's/\.o:/.lo:/; s, $(builddir)/, ,' >> .deps; \
153                 done; \
154                 sed 's/\.lo:/.slo:/' < .deps > .deps.$$; \
155                 cat .deps.$$ >> .deps; \
156                 rm -f .deps.$$; \
157         fi
158
159 local-clean: x-local-clean
160         rm -f *.o *.lo *.slo *.obj *.a *.la $(CLEAN_TARGETS) $(TARGETS)
161         rm -rf .libs
162
163 local-distclean: local-clean x-local-distclean
164         rm -f .deps Makefile $(DISTCLEAN_TARGETS)
165
166 local-extraclean: local-distclean x-local-extraclean
167         @if test -n "$(EXTRACLEAN_TARGETS)"; then \
168             echo "rm -f $(EXTRACLEAN_TARGETS)"; \
169             rm -f $(EXTRACLEAN_TARGETS) ; \
170         fi
171
172 program-install: $(TARGETS) $(SHARED_TARGETS)
173         @if test -n '$(bin_PROGRAMS)'; then \
174             test -d $(DESTDIR)$(bindir) || $(MKINSTALLDIRS) $(DESTDIR)$(bindir); \
175             list='$(bin_PROGRAMS)'; for i in $$list; do \
176                 $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir); \
177             done; \
178         fi
179         @if test -n '$(sbin_PROGRAMS)'; then \
180             test -d $(DESTDIR)$(sbindir) || $(MKINSTALLDIRS) $(DESTDIR)$(sbindir); \
181             list='$(sbin_PROGRAMS)'; for i in $$list; do \
182                 $(INSTALL_PROGRAM) $$i $(DESTDIR)$(sbindir); \
183             done; \
184         fi
185
186 local-install: program-install $(INSTALL_TARGETS)
187
188 # to be filled in by the actual Makefile if extra commands are needed
189 x-local-depend x-local-clean x-local-distclean x-local-extraclean:
190
191 #
192 # Implicit rules for creating outputs from input files
193 #
194 CXX_SUFFIX = cpp
195 SHLIB_SUFFIX = so
196
197 .SUFFIXES:
198 .SUFFIXES: .S .c .$(CXX_SUFFIX) .lo .o .s .y .l .slo .def .la
199
200 .c.o:
201         $(COMPILE) -c $<
202
203 .s.o:
204         $(COMPILE) -c $<
205
206 .c.lo:
207         $(LT_COMPILE)
208
209 .s.lo:
210         $(LT_COMPILE)
211
212 .c.slo:
213         $(SH_COMPILE)
214
215 .$(CXX_SUFFIX).lo:
216         $(LT_CXX_COMPILE)
217
218 .$(CXX_SUFFIX).slo:
219         $(SH_CXX_COMPILE)
220
221 .y.c:
222         $(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
223         if test -f y.tab.h; then \
224         if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
225         else :; fi
226
227 .l.c:
228         $(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
229
230 # Makes an import library from a def file
231 .def.la:
232         $(LIBTOOL) --mode=compile $(MK_IMPLIB) -o $@ $<
233
234 #
235 # Dependencies
236 #
237 @ap_make_include@ @ap_make_delimiter@$(builddir)/.deps@ap_make_delimiter@
238
239 .PHONY: all all-recursive install-recursive local-all $(PHONY_TARGETS) \
240         shared-build shared-build-recursive local-shared-build \
241         depend depend-recursive local-depend x-local-depend \
242         clean clean-recursive local-clean x-local-clean \
243         distclean distclean-recursive local-distclean x-local-distclean \
244         extraclean extraclean-recursive local-extraclean x-local-extraclean \
245         install local-install docs $(INSTALL_TARGETS)
246