]> granicus.if.org Git - apache/blob - build/rules.mk.in
Follow up to r1789213: more accurate CHANGES entry.
[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 $< && touch $@
48 LT_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) $(LTCFLAGS) -c $< && touch $@
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 | sed 's/\.o:/.lo:/' >> .deps; \
152                 done; \
153                 sed 's/\.lo:/.slo:/' < .deps > .deps.$$; \
154                 cat .deps.$$ >> .deps; \
155                 rm -f .deps.$$; \
156         fi
157
158 local-clean: x-local-clean
159         rm -f *.o *.lo *.slo *.obj *.a *.la $(CLEAN_TARGETS) $(TARGETS)
160         rm -rf .libs
161
162 local-distclean: local-clean x-local-distclean
163         rm -f .deps Makefile $(DISTCLEAN_TARGETS)
164
165 local-extraclean: local-distclean x-local-extraclean
166         @if test -n "$(EXTRACLEAN_TARGETS)"; then \
167             echo "rm -f $(EXTRACLEAN_TARGETS)"; \
168             rm -f $(EXTRACLEAN_TARGETS) ; \
169         fi
170
171 program-install: $(TARGETS) $(SHARED_TARGETS)
172         @if test -n '$(bin_PROGRAMS)'; then \
173             test -d $(DESTDIR)$(bindir) || $(MKINSTALLDIRS) $(DESTDIR)$(bindir); \
174             list='$(bin_PROGRAMS)'; for i in $$list; do \
175                 $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir); \
176             done; \
177         fi
178         @if test -n '$(sbin_PROGRAMS)'; then \
179             test -d $(DESTDIR)$(sbindir) || $(MKINSTALLDIRS) $(DESTDIR)$(sbindir); \
180             list='$(sbin_PROGRAMS)'; for i in $$list; do \
181                 $(INSTALL_PROGRAM) $$i $(DESTDIR)$(sbindir); \
182             done; \
183         fi
184
185 local-install: program-install $(INSTALL_TARGETS)
186
187 # to be filled in by the actual Makefile if extra commands are needed
188 x-local-depend x-local-clean x-local-distclean x-local-extraclean:
189
190 #
191 # Implicit rules for creating outputs from input files
192 #
193 CXX_SUFFIX = cpp
194 SHLIB_SUFFIX = so
195
196 .SUFFIXES:
197 .SUFFIXES: .S .c .$(CXX_SUFFIX) .lo .o .s .y .l .slo .def .la
198
199 .c.o:
200         $(COMPILE) -c $<
201
202 .s.o:
203         $(COMPILE) -c $<
204
205 .c.lo:
206         $(LT_COMPILE)
207
208 .s.lo:
209         $(LT_COMPILE)
210
211 .c.slo:
212         $(SH_COMPILE)
213
214 .$(CXX_SUFFIX).lo:
215         $(LT_CXX_COMPILE)
216
217 .$(CXX_SUFFIX).slo:
218         $(SH_CXX_COMPILE)
219
220 .y.c:
221         $(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
222         if test -f y.tab.h; then \
223         if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
224         else :; fi
225
226 .l.c:
227         $(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
228
229 # Makes an import library from a def file
230 .def.la:
231         $(LIBTOOL) --mode=compile $(MK_IMPLIB) -o $@ $<
232
233 #
234 # Dependencies
235 #
236 @ap_make_include@ @ap_make_delimiter@$(builddir)/.deps@ap_make_delimiter@
237
238 .PHONY: all all-recursive install-recursive local-all $(PHONY_TARGETS) \
239         shared-build shared-build-recursive local-shared-build \
240         depend depend-recursive local-depend x-local-depend \
241         clean clean-recursive local-clean x-local-clean \
242         distclean distclean-recursive local-distclean x-local-distclean \
243         extraclean extraclean-recursive local-extraclean x-local-extraclean \
244         install local-install docs $(INSTALL_TARGETS)
245