Debian Codegraph @

third-party/pjproject/Makefile

raw symbols SCIP
1 .PHONY: _all all _install install clean distclean echo_cflags configure
2
3 .NOTPARALLEL:
4
5 include ../versions.mak
6
7 export PJDIR := $(shell pwd -P)/source
8
9 SPECIAL_TARGETS :=
10
11 ifneq ($(findstring configure,$(MAKECMDGOALS))$(findstring echo_cflags,$(MAKECMDGOALS)),)
12 # Run from $(ASTTOPDIR)/configure
13 SPECIAL_TARGETS += configure
14 endif
15
16 ifeq ($(findstring echo_cflags,$(MAKECMDGOALS)),echo_cflags)
17 -include build.mak
18 ECHO_PREFIX=@\#
19 endif
20
21 ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
22 # clean or distclean
23 SPECIAL_TARGETS += clean
24 endif
25
26 ifeq ($(findstring uninstall,$(MAKECMDGOALS)),uninstall)
27 SPECIAL_TARGETS += uninstall
28 endif
29
30
31 ifneq ($(wildcard ../../makeopts),)
32 include ../../makeopts
33 endif
34
35 TARGETS = build.mak
36
37 ifeq ($(SPECIAL_TARGETS),)
38 # Run locally or from $(ASTTOPDIR)/Makefile. All include files should be present
39 ifeq ($(wildcard ../../makeopts),)
40 $(error ASTTOPDIR/configure hasn't been run)
41 endif
42
43 ifeq ($(PJPROJECT_BUNDLED),yes)
44 all: _all
45 install: _install
46
47 ifneq ($(wildcard ../../menuselect.makeopts),)
48 include ../../menuselect.makeopts
49 else
50 $(warning ASTTOPDIR/menuselect hasn't been run yet. Can't find debug options.)
51 endif
52 include ../../Makefile.rules
53 include ../Makefile.rules
54 include Makefile.rules
55
56 -include source/user.mak
57 -include source/version.mak
58 -include source/build.mak
59 CF := $(filter-out -W%,$(CC_CFLAGS))
60 CF := $(filter-out -I%,$(CF))
61 ifeq ($(PJPROJECT_BUNDLED_OOT),)
62 ifeq ($(AST_DEVMODE),yes)
63 CF += -DPJPROJECT_BUNDLED_ASSERTIONS=yes
64 endif
65 endif
66 ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),)
67 CF += -O3
68 endif
69 export CFLAGS += $(CF) -g3
70 export LDFLAGS += $(CC_LDFLAGS)
71 TARGETS += pjproject.symbols
72 else
73 all install:
74 endif
75 else
76 include ../../Makefile.rules
77 include ../Makefile.rules
78 include Makefile.rules
79 endif
80
81 export PJ_CFLAGS := $(filter-out -O% -g%,$(PJ_CFLAGS))
82 export CFLAGS += $(CF) $(OPENSSL_INCLUDE)
83 export LDFLAGS += $(CC_LDFLAGS) $(OPENSSL_LIB)
84
85 ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] '
86 ECHO_PREFIX_NONL := $(ECHO_PREFIX) echo -n '[pjproject] '
87 SHELL_ECHO_PREFIX := echo '[pjproject] '
88
89 _all: $(TARGETS)
90
91 $(DOWNLOAD_DIR)/$(TARBALL_FILE): ../versions.mak
92 $(CMD_PREFIX) ($(TARBALL_EXISTS) && $(TARBALL_VERIFY) && touch $@) || (rm -rf $@ ;\
93 $(TARBALL_DOWNLOAD)) || (rm -rf $@ ;\
94 $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD))
95
96 source/.unpacked: $(DOWNLOAD_DIR)/$(TARBALL_FILE)
97 $(CMD_PREFIX) \
98 $(TARBALL_VERIFY) || (rm -rf $@ ; $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD)) ;\
99 $(SHELL_ECHO_PREFIX) Unpacking $< ;\
100 rm -rf source pjproject-*/ $(REALLY_QUIET) || : ;\
101 $(TAR) -xjf $< ;\
102 mv pjproject-$(PJPROJECT_VERSION) source
103 $(ECHO_PREFIX) Applying patches "$(realpath patches)" "$(realpath .)/source"
104 $(CMD_PREFIX) ../apply_patches $(QUIET_CONFIGURE) "$(realpath patches)" "$(realpath .)/source"
105 -@touch source/.unpacked
106
107 source/user.mak: $(if $(PJPROJECT_BUNDLED_OOT),,source/.unpacked) patches/user.mak
108 $(ECHO_PREFIX) Applying user.mak
109 $(CMD_PREFIX) cp -f patches/user.mak source/
110
111 source/pjlib/include/pj/%.h: patches/%.h
112 $(ECHO_PREFIX) Applying custom include file $<
113 $(CMD_PREFIX) cp -f $< source/pjlib/include/pj/
114
115 .rebuild_needed: $(wildcard ../../.lastclean)
116 $(ECHO_PREFIX) Rebuilding
117 $(CMD_PREFIX) $(MAKE) clean $(REALLY_QUIET)
118
119 source/build.mak: Makefile.rules source/user.mak $(if $(PJPROJECT_BUNDLED_OOT),,.rebuild_needed) $(subst patches,source/pjlib/include/pj,$(wildcard patches/*.h))
120 $(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS)
121 $(CMD_PREFIX) (cd source ; ./aconfigure $(QUIET_CONFIGURE) $(PJPROJECT_CONFIG_OPTS))
122
123 build.mak: source/build.mak
124 $(CMD_PREFIX) $(GREP) -v -e prefix -e "export PJ_SHARED_LIBRARIES" -e MACHINE_NAME \
125 -e OS_NAME -e HOST_NAME -e CC_NAME -e CROSS_COMPILE -e LINUX_POLL $< > $@
126
127 configure: source/build.mak
128
129 # We need to filter-out any -O and -g options in PJ_CFLAGS before echoing out
130 # the result so Asterisk modules don't have the optimization and symbolic debug
131 # options overridden by the PJPROJECT configure script selected settings.
132 echo_cflags: source/build.mak
133 @echo $(filter-out -O% -g%,$(PJ_CFLAGS))
134
135 # The dependency_utils script needs TARGET_NAME in the environment
136 export TARGET_NAME
137
138 # PJ_LIB_FILES is set by the pjproject build.mak and contains the libs we
139 # need, but not in the order they need to be built. We need to compile
140 # pjlib, then pjlib-util, then the rest so we separate them out and create
141 # the dependencies. First though, we shorten all file paths by making them
142 # relative to the current directory.
143 SHORTENED_PJ_LIB_FILES = $(subst $(CURDIR)/,,$(PJ_LIB_FILES))
144 # Now separate them
145 PJLIB_LIB_FILES = $(filter %/libpj-$(TARGET_NAME).a,$(SHORTENED_PJ_LIB_FILES))
146 PJLIB_UTIL_LIB_FILES = $(filter %/libpjlib-util-$(TARGET_NAME).a,$(SHORTENED_PJ_LIB_FILES))
147 RESAMPLE_LIB_FILE = $(filter %/libresample-$(TARGET_NAME).a,$(SHORTENED_PJ_LIB_FILES))
148 # The rest.
149 PJSIP_LIB_FILES = $(filter-out $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(RESAMPLE_LIB_FILE),$(SHORTENED_PJ_LIB_FILES))
150
151 # Create the dependency order we need
152 $(PJLIB_UTIL_LIB_FILES): $(PJLIB_LIB_FILES)
153 $(PJSIP_LIB_FILES): $(PJLIB_UTIL_LIB_FILES)
154
155 # and here's the full list
156 ALL_LIB_FILES = $(PJLIB_LIB_FILES) $(PJLIB_UTIL_LIB_FILES) $(PJSIP_LIB_FILES) $(RESAMPLE_LIB_FILE)
157
158 # Assuming that since you're doing an out-of-tree build you're modifying
159 # the pjproject source files, we need to create dependencies between
160 # the libraries and their respective source files. Pjproject does
161 # create dependency files if you run 'make dep' but those files include
162 # the system include files and the paths are relative to the lib's
163 # "build" directory. Neither really works for us.
164 # So...
165 # We create our own "astdep" files with dependency paths relative
166 # to "this" directory and strip out all the system includes.
167 # The dependency_utils script does all the heavy lifting.
168 #
169 # REMINDER: None of this gets invoked unless you're doing an out-of-tree
170 # pjproject build.
171
172 ifdef PJPROJECT_BUNDLED_OOT
173 ALL_PJDEP_FILES = $(shell TARGET_NAME=$(TARGET_NAME) ./dependency_utils getpjdepname $(ALL_LIB_FILES))
174 ALL_ASTDEP_FILES = $(ALL_PJDEP_FILES:.depend=.astdep)
175
176 $(ALL_PJDEP_FILES): build.mak
177 $(ECHO_PREFIX) Generating pjproject dependency file $(@F)
178 $(CMD_PREFIX) $(MAKE) -C $(@D) dep $(REALLY_QUIET)
179
180 $(ALL_ASTDEP_FILES): %.astdep: %.depend
181 $(ECHO_PREFIX) Generating asterisk dependency file $(@F)
182 $(CMD_PREFIX) ./dependency_utils gendepfile $<
183 ifeq ($(SPECIAL_TARGETS),)
184 ifneq ($(ALL_ASTDEP_FILES),)
185 include $(ALL_ASTDEP_FILES)
186 depends: $(ALL_ASTDEP_FILES)
187 endif
188 endif
189 endif
190
191 # resample's a little odd in that it's build directory is one directory
192 # level down from the other libraries. We set the RESAMPLE_OPTS
193 # variable for it then let the ALL_LIB_FILE build rules take over.
194 $(RESAMPLE_LIB_FILE): RESAMPLE_OPTS=/resample all
195
196 .PRECIOUS: $(ALL_LIB_FILES)
197
198 $(ALL_LIB_FILES): BUILD_DIR=$(dir $(@D))
199 $(ALL_LIB_FILES): source/build.mak source/pjlib/include/pj/config_site.h
200 $(ECHO_PREFIX) Compiling $(@F)
201 $(CMD_PREFIX) ( $(MAKE) -C $(BUILD_DIR)build$(if $(RESAMPLE_OPTS),$(RESAMPLE_OPTS), $(@F)) >/dev/null ) $(if $(PJPROJECT_BUNDLED_OOT),2>&1 | ($(GREP) -E -v "^(r - output|ar:)" || : ),$(REALLY_QUIET))
202
203 pjproject.symbols: $(ALL_LIB_FILES)
204 $(ECHO_PREFIX) Generating symbols
205 $(CMD_PREFIX) $(NM) -Pog $(ALL_LIB_FILES) | $(SED) -n -E -e "s/.+: ([_]?[pP][jJ][^ ]+) .+/\1/gp" | sort -u > pjproject.symbols
206
207 _install: _all
208 @if [ ! -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject" ]; then \
209 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject"; \
210 fi;
211
212 all: _all
213
214 uninstall:
215 $(ECHO_PREFIX) Uninstalling
216 $(CMD_PREFIX) rm -rf "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject"
217
218 clean:
219 $(ECHO_PREFIX) Cleaning
220 +-$(CMD_PREFIX) {\
221 if [ -d source ] ; then \
222 $(SUBMAKE) -C source clean ;\
223 $(FIND) source/ '(' -name *.a -or -name *.o -or -name *.so ')' -delete ;\
224 fi ;\
225 rm -rf pjproject.symbols ;\
226 } $(REALLY_QUIET) || :
227
228 distclean: clean
229 $(ECHO_PREFIX) Distcleaning
230 +-$(CMD_PREFIX) {\
231 rm -rf build.mak .rebuild_needed ;\
232 if [ "x$(PJPROJECT_BUNDLED_OOT)" = "x" -a ! -d source/.git ] ; then \
233 rm -rf source pjproject-*.tar.bz2 ;\
234 else \
235 $(SUBMAKE) -C source distclean ;\
236 rm -rf source/build.mak source/user.mak ;\
237 $(FIND) source/ '(' -name '.*.depend' -or -name '.*.astdep' ')' -delete ;\
238 fi \
239 } $(REALLY_QUIET) || :