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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # The build environment was originally provided by Sascha Schumann.
19 include $(top_builddir)/build/config_vars.mk
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.
26 ALL_CFLAGS = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS)
27 ALL_CPPFLAGS = $(DEFS) $(EXTRA_CPPFLAGS) $(NOTEST_CPPFLAGS) $(CPPFLAGS)
28 ALL_CXXFLAGS = $(EXTRA_CXXFLAGS) $(NOTEST_CXXFLAGS) $(CXXFLAGS)
29 ALL_LDFLAGS = $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS)
30 ALL_LIBS = $(EXTRA_LIBS) $(NOTEST_LIBS) $(LIBS)
31 ALL_INCLUDES = $(INCLUDES) $(EXTRA_INCLUDES)
35 COMPILE = $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
36 CXX_COMPILE = $(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
38 SH_COMPILE = $(LIBTOOL) --mode=compile $(COMPILE) -prefer-pic -c $< && touch $@
39 SH_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) -prefer-pic -c $< && touch $@
41 LT_COMPILE = $(LIBTOOL) --mode=compile $(COMPILE) -prefer-non-pic -static -c $< && touch $@
42 LT_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) -prefer-non-pic -static -c $< && touch $@
44 # Link-related commands
46 LINK = $(LIBTOOL) --mode=link $(COMPILE) $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
47 SH_LINK = $(SH_LIBTOOL) --mode=link $(COMPILE) $(LT_LDFLAGS) $(ALL_LDFLAGS) $(SH_LDFLAGS) $(CORE_IMPLIB) $(SH_LIBS) -o $@
48 MOD_LINK = $(LIBTOOL) --mode=link $(COMPILE) -module $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
50 # Cross compile commands
54 MKINSTALLDIRS = $(abs_srcdir)/build/mkdir.sh
55 INSTALL = $(LIBTOOL) --mode=install $(abs_srcdir)/build/install.sh -c
56 INSTALL_DATA = $(INSTALL) -m 644
57 INSTALL_PROGRAM = $(INSTALL) -m 755 $(INSTALL_PROG_FLAGS)
60 # Standard build rules
63 depend: depend-recursive
64 clean: clean-recursive
65 distclean: distclean-recursive
66 extraclean: extraclean-recursive
67 install: install-recursive
68 shared-build: shared-build-recursive
70 all-recursive install-recursive depend-recursive:
71 @otarget=`echo $@|sed s/-recursive//`; \
72 list=' $(BUILD_SUBDIRS) $(SUBDIRS)'; \
74 if test -d "$$i"; then \
76 echo "Making $$target in $$i"; \
77 if test "$$i" = "."; then \
79 target="local-$$target"; \
81 (cd $$i && $(MAKE) $$target) || exit 1; \
84 if test "$$otarget" = "all" && test -z '$(TARGETS)'; then \
87 if test "$$made_local" != "yes"; then \
88 $(MAKE) "local-$$otarget" || exit 1; \
91 clean-recursive distclean-recursive extraclean-recursive:
92 @otarget=`echo $@|sed s/-recursive//`; \
93 list='$(CLEAN_SUBDIRS) $(SUBDIRS)'; \
95 if test -d "$$i"; then \
97 echo "Making $$target in $$i"; \
98 if test "$$i" = "."; then \
100 target="local-$$target"; \
102 (cd $$i && $(MAKE) $$target); \
105 if test "$$otarget" = "all" && test -z '$(TARGETS)'; then \
108 if test "$$made_local" != "yes"; then \
109 $(MAKE) "local-$$otarget"; \
112 shared-build-recursive:
113 @if test `pwd` = "$(top_builddir)"; then \
114 $(PRE_SHARED_CMDS) ; \
116 list='$(SUBDIRS)'; for i in $$list; do \
117 target="shared-build"; \
118 if test "$$i" = "."; then \
120 target="local-shared-build"; \
122 if test "$$i" != "srclib"; then \
123 (cd $$i && $(MAKE) $$target) || exit 1; \
126 if test -f 'modules.mk'; then \
127 if test -n '$(SHARED_TARGETS)'; then \
128 echo "Building shared: $(SHARED_TARGETS)"; \
129 if test "$$made_local" != "yes"; then \
130 $(MAKE) "local-shared-build" || exit 1; \
134 if test `pwd` = "$(top_builddir)"; then \
135 $(POST_SHARED_CMDS) ; \
138 local-all: $(TARGETS)
140 local-shared-build: $(SHARED_TARGETS)
142 local-depend: x-local-depend
143 if test -n "`ls $(srcdir)/*.c 2> /dev/null`"; then \
144 $(CC) -MM $(ALL_CPPFLAGS) $(ALL_INCLUDES) $(srcdir)/*.c | sed 's/\.o:/.lo:/' > $(builddir)/.deps || true; \
147 local-clean: x-local-clean
148 rm -f *.o *.lo *.slo *.obj *.a *.la $(CLEAN_TARGETS) $(TARGETS)
151 local-distclean: local-clean x-local-distclean
152 rm -f .deps Makefile $(DISTCLEAN_TARGETS)
154 local-extraclean: local-distclean x-local-extraclean
155 @if test -n "$(EXTRACLEAN_TARGETS)"; then \
156 echo "rm -f $(EXTRACLEAN_TARGETS)"; \
157 rm -f $(EXTRACLEAN_TARGETS) ; \
160 local-install: $(TARGETS) $(SHARED_TARGETS) $(INSTALL_TARGETS)
161 @if test -n '$(PROGRAMS)'; then \
162 test -d $(DESTDIR)$(sbindir) || $(MKINSTALLDIRS) $(DESTDIR)$(sbindir); \
163 list='$(PROGRAMS)'; for i in $$list; do \
164 $(INSTALL_PROGRAM) $$i $(DESTDIR)$(sbindir); \
168 # to be filled in by the actual Makefile if extra commands are needed
169 x-local-depend x-local-clean x-local-distclean x-local-extraclean:
172 # Implicit rules for creating outputs from input files
178 .SUFFIXES: .S .c .$(CXX_SUFFIX) .lo .o .s .y .l .slo .def .la
202 $(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
203 if test -f y.tab.h; then \
204 if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
208 $(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
210 # Makes an import library from a def file
212 $(LIBTOOL) --mode=compile $(MK_IMPLIB) -o $@ $<
217 include $(builddir)/.deps
219 .PHONY: all all-recursive install-recursive local-all $(PHONY_TARGETS) \
220 shared-build shared-build-recursive local-shared-build \
221 depend depend-recursive local-depend x-local-depend \
222 clean clean-recursive local-clean x-local-clean \
223 distclean distclean-recursive local-distclean x-local-distclean \
224 extraclean extraclean-recursive local-extraclean x-local-extraclean \
225 install local-install $(INSTALL_TARGETS)