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#
26ALL_CFLAGS   = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS)
27ALL_CPPFLAGS = $(DEFS) $(EXTRA_CPPFLAGS) $(NOTEST_CPPFLAGS) $(CPPFLAGS)
28ALL_CXXFLAGS = $(EXTRA_CXXFLAGS) $(NOTEST_CXXFLAGS) $(CXXFLAGS)
29ALL_LDFLAGS  = $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS)
30ALL_LIBS     = $(EXTRA_LIBS) $(NOTEST_LIBS) $(LIBS)
31ALL_INCLUDES = $(INCLUDES) $(EXTRA_INCLUDES)
32
33# Compile commands
34
35BASE_CC  = $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
36BASE_CXX = $(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
37
38COMPILE      = $(BASE_CC) @PICFLAGS@
39CXX_COMPILE  = $(BASE_CXX) @PICFLAGS@
40
41SH_COMPILE     = $(LIBTOOL) --mode=compile $(BASE_CC) @SHLTCFLAGS@ -c $< && touch $@
42SH_CXX_COMPILE = $(LIBTOOL) --mode=compile $(BASE_CXX) @SHLTCFLAGS@ -c $< && touch $@
43
44LT_COMPILE     = $(LIBTOOL) --mode=compile $(COMPILE) @LTCFLAGS@ -c $< && touch $@
45LT_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) @LTCFLAGS@ -c $< && touch $@
46
47# Link-related commands
48
49LINK     = $(LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) @PILDFLAGS@ $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
50SH_LINK  = $(SH_LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) $(LT_LDFLAGS) $(ALL_LDFLAGS) $(SH_LDFLAGS) $(CORE_IMPLIB) $(SH_LIBS) -o $@
51MOD_LINK = $(LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) -static $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
52
53# Cross compile commands
54
55# Helper programs
56
57INSTALL_DATA = $(INSTALL) -m 644
58INSTALL_PROGRAM = $(INSTALL) -m 755 $(INSTALL_PROG_FLAGS)
59
60#
61# Standard build rules
62#
63all: all-recursive
64depend: depend-recursive
65clean: clean-recursive
66distclean: distclean-recursive
67extraclean: extraclean-recursive
68install: install-recursive
69shared-build: shared-build-recursive
70
71all-recursive install-recursive depend-recursive:
72	@otarget=`echo $@|sed s/-recursive//`; \
73	list=' $(BUILD_SUBDIRS) $(SUBDIRS)'; \
74	for i in $$list; do \
75	    if test -d "$$i"; then \
76		target="$$otarget"; \
77		echo "Making $$target in $$i"; \
78		if test "$$i" = "."; then \
79			made_local=yes; \
80			target="local-$$target"; \
81		fi; \
82		(cd $$i && $(MAKE) $$target) || exit 1; \
83	    fi; \
84	done; \
85	if test "$$otarget" = "all" && test -z '$(TARGETS)'; then \
86	    made_local=yes; \
87	fi; \
88	if test "$$made_local" != "yes"; then \
89	    $(MAKE) "local-$$otarget" || exit 1; \
90	fi
91
92clean-recursive distclean-recursive extraclean-recursive:
93	@otarget=`echo $@|sed s/-recursive//`; \
94	list='$(CLEAN_SUBDIRS) $(SUBDIRS)'; \
95	for i in $$list; do \
96	    if test -d "$$i"; then \
97		target="$$otarget"; \
98		echo "Making $$target in $$i"; \
99		if test "$$i" = "."; then \
100			made_local=yes; \
101			target="local-$$target"; \
102		fi; \
103		(cd $$i && $(MAKE) $$target); \
104	    fi; \
105	done; \
106	if test "$$otarget" = "all" && test -z '$(TARGETS)'; then \
107	    made_local=yes; \
108	fi; \
109	if test "$$made_local" != "yes"; then \
110	    $(MAKE) "local-$$otarget"; \
111	fi
112
113shared-build-recursive:
114	@if test `pwd` = "$(top_builddir)"; then \
115	    $(PRE_SHARED_CMDS) ; \
116	fi; \
117	list='$(SUBDIRS)'; for i in $$list; do \
118	    target="shared-build"; \
119	    if test "$$i" = "."; then \
120		made_local=yes; \
121		target="local-shared-build"; \
122	    fi; \
123	    if test "$$i" != "srclib"; then \
124		(cd $$i && $(MAKE) $$target) || exit 1; \
125	    fi; \
126	done; \
127	if test -f 'modules.mk'; then \
128	    if test -n '$(SHARED_TARGETS)'; then \
129		echo "Building shared: $(SHARED_TARGETS)"; \
130		if test "$$made_local" != "yes"; then \
131			$(MAKE) "local-shared-build" || exit 1; \
132		fi; \
133	    fi; \
134	fi; \
135	if test `pwd` = "$(top_builddir)"; then \
136		$(POST_SHARED_CMDS) ; \
137	fi
138
139local-all: $(TARGETS)
140
141local-shared-build: $(SHARED_TARGETS)
142
143local-depend: x-local-depend
144	@if test -n "`ls $(srcdir)/*.c 2> /dev/null`"; then \
145		rm -f .deps; \
146		list='$(srcdir)/*.c'; \
147		for i in $$list; do \
148			$(MKDEP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) $$i | sed 's/\.o:/.lo:/' >> .deps; \
149		done; \
150	fi
151
152local-clean: x-local-clean
153	rm -f *.o *.lo *.slo *.obj *.a *.la $(CLEAN_TARGETS) $(TARGETS)
154	rm -rf .libs
155
156local-distclean: local-clean x-local-distclean
157	rm -f .deps Makefile $(DISTCLEAN_TARGETS)
158
159local-extraclean: local-distclean x-local-extraclean
160	@if test -n "$(EXTRACLEAN_TARGETS)"; then \
161	    echo "rm -f $(EXTRACLEAN_TARGETS)"; \
162	    rm -f $(EXTRACLEAN_TARGETS) ; \
163	fi
164
165program-install: $(TARGETS) $(SHARED_TARGETS)
166	@if test -n '$(PROGRAMS)'; then \
167	    test -d $(DESTDIR)$(sbindir) || $(MKINSTALLDIRS) $(DESTDIR)$(sbindir); \
168	    list='$(PROGRAMS)'; for i in $$list; do \
169	        $(INSTALL_PROGRAM) $$i $(DESTDIR)$(sbindir); \
170	    done; \
171	fi
172
173local-install: program-install $(INSTALL_TARGETS)
174
175# to be filled in by the actual Makefile if extra commands are needed
176x-local-depend x-local-clean x-local-distclean x-local-extraclean:
177
178#
179# Implicit rules for creating outputs from input files
180#
181CXX_SUFFIX = cpp
182SHLIB_SUFFIX = so
183
184.SUFFIXES:
185.SUFFIXES: .S .c .$(CXX_SUFFIX) .lo .o .s .y .l .slo .def .la
186
187.c.o:
188	$(COMPILE) -c $<
189
190.s.o:
191	$(COMPILE) -c $<
192
193.c.lo:
194	$(LT_COMPILE)
195
196.s.lo:
197	$(LT_COMPILE)
198
199.c.slo:
200	$(SH_COMPILE)
201
202.$(CXX_SUFFIX).lo:
203	$(LT_CXX_COMPILE)
204
205.$(CXX_SUFFIX).slo:
206	$(SH_CXX_COMPILE)
207
208.y.c:
209	$(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
210	if test -f y.tab.h; then \
211	if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
212	else :; fi
213
214.l.c:
215	$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
216
217# Makes an import library from a def file
218.def.la:
219	$(LIBTOOL) --mode=compile $(MK_IMPLIB) -o $@ $<
220
221#
222# Dependencies
223#
224@ap_make_include@ @ap_make_delimiter@$(builddir)/.deps@ap_make_delimiter@
225
226.PHONY: all all-recursive install-recursive local-all $(PHONY_TARGETS) \
227	shared-build shared-build-recursive local-shared-build \
228	depend depend-recursive local-depend x-local-depend \
229	clean clean-recursive local-clean x-local-clean \
230	distclean distclean-recursive local-distclean x-local-distclean \
231	extraclean extraclean-recursive local-extraclean x-local-extraclean \
232	install local-install docs $(INSTALL_TARGETS)
233
234