pjproject_bundled: Various fixes discovered during testing of OSes
[asterisk/asterisk.git] / third-party / pjproject / Makefile
1 .SUFFIXES:
2 .PHONY: _all all _install install clean distclean echo_cflags configure
3
4 include ../versions.mak
5
6 SPECIAL_TARGETS :=
7
8 ifneq ($(findstring configure,$(MAKECMDGOALS))$(findstring echo_cflags,$(MAKECMDGOALS)),)
9 # Run from $(ASTTOPDIR)/configure
10     SPECIAL_TARGETS += configure
11     include ../Makefile.rules
12     include Makefile.rules
13 endif
14
15 ifeq ($(findstring echo_cflags,$(MAKECMDGOALS)),echo_cflags)
16     -include build.mak
17     ECHO_PREFIX=@\#
18 endif
19
20 ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
21 # clean or distclean
22     SPECIAL_TARGETS += clean
23     include ../Makefile.rules
24     include Makefile.rules
25 endif
26
27 ifeq ($(SPECIAL_TARGETS),)
28 # Run locally or from $(ASTTOPDIR)/Makefile.  All include files should be present
29     ifeq ($(wildcard ../../makeopts),)
30         $(error ASTTOPDIR/configure hasn't been run)
31     endif
32     include ../../makeopts
33
34     ifeq ($(PJPROJECT_BUNDLED),yes)
35         -include ../../menuselect.makeopts
36         include ../Makefile.rules
37
38         all: _all
39         install: _install
40
41         include ../../Makefile.rules
42         include Makefile.rules
43         include build.mak
44         CF := $(filter-out -W%,$(CC_CFLAGS))
45         CF := $(filter-out -I%,$(CF))
46         export CFLAGS += $(CF)
47         export LDFLAGS += $(CC_LDFLAGS)
48     else
49         all install:
50     endif
51 endif
52
53 ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] '
54
55 ifndef $(TMPDIR)
56     ifneq ($(wildcard /tmp),)
57         TMPDIR=/tmp
58     else
59         TMPDIR=.
60     endif
61 endif
62
63 $(TMPDIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 : ../versions.mak
64         $(ECHO_PREFIX) Downloading $@ with $(DOWNLOAD)
65         $(CMD_PREFIX) $(DOWNLOAD) $(PJPROJECT_URL)/$(@F) > $@
66
67 source/.unpacked: $(TMPDIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2
68         $(ECHO_PREFIX) Unpacking $<
69         -@rm -rf source &>/dev/null
70         -@mkdir source &>/dev/null
71         $(CMD_PREFIX) tar --strip-components=1 -C source -xjf $<
72         $(ECHO_PREFIX) Applying patches
73         $(CMD_PREFIX) ./apply_patches $(QUIET_CONFIGURE) ./patches ./source
74         -@touch source/.unpacked
75
76 source/user.mak: source/.unpacked ./patches/user.mak
77         $(ECHO_PREFIX) Applying user.mak
78         $(CMD_PREFIX) cp -f ./patches/user.mak ./source/
79
80 source/pjlib/include/pj/config_site.h: source/.unpacked ./patches/config_site.h
81         $(ECHO_PREFIX) Applying config_site.h
82         $(CMD_PREFIX) cp -f ./patches/config_site.h ./source/pjlib/include/pj/
83
84 build.mak: source/.unpacked source/pjlib/include/pj/config_site.h source/user.mak Makefile.rules
85         $(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS)
86         $(CMD_PREFIX) (cd source ; autoconf aconfigure.ac > aconfigure && ./aconfigure $(QUIET_CONFIGURE) $(PJPROJECT_CONFIG_OPTS))
87         @sed -r -e "/prefix|export PJ_SHARED_LIBRARIES|MACHINE_NAME|OS_NAME|HOST_NAME|CC_NAME|CROSS_COMPILE|LINUX_POLL/d" source/build.mak > build.mak
88
89 configure: build.mak
90
91 echo_cflags: build.mak
92         @echo $(PJ_CFLAGS)
93
94 source/pjlib/build/.pjlib-$(TARGET_NAME).depend: build.mak
95         $(ECHO_PREFIX) "Making dependencies"
96         +$(CMD_PREFIX) $(SUBMAKE) -C source dep
97
98
99 menuselect: ../../menuselect.makeopts ../../makeopts
100         -$(CMD_PREFIX) test -d source && ($(SUBMAKE) -C source clean ; find source -name *.a -delete ; rm -rf source/pjsip-apps/src/python/build) || :
101         -$(CMD_PREFIX) rm -rf pjproject.symbols
102
103
104 source/pjlib/lib/libpj-$(TARGET_NAME).a: menuselect source/pjlib/build/.pjlib-$(TARGET_NAME).depend
105         $(ECHO_PREFIX) Compiling libs
106         +$(CMD_PREFIX) $(SUBMAKE) -C source lib $(REALLY_QUIET)
107
108 pjproject.symbols: source/pjlib/lib/libpj-$(TARGET_NAME).a
109         $(ECHO_PREFIX) Generating symbols
110         $(CMD_PREFIX) nm -Pog $(PJ_LIB_FILES) | sed -n -r -e "s/.+: ([pP][jJ][^ ]+) .+/\1/gp" | sort -u > pjproject.symbols
111
112 source/pjsip-apps/bin/pjsua-$(TARGET_NAME): source/pjlib/lib/libpj-$(TARGET_NAME).a
113         $(ECHO_PREFIX) Compiling apps
114         $(CMD_PREFIX) $(SUBMAKE) -C source/pjsip-apps/build pjsua pjsystest $(REALLY_QUIET)
115
116 source/pjsip-apps/src/python/build/_pjsua.so: source/pjlib/lib/libpj-$(TARGET_NAME).a
117         $(ECHO_PREFIX) Compiling python bindings
118         $(CMD_PREFIX) (cd source/pjsip-apps/src/python ; MAKE=$(MAKE) python setup.py build --build-platlib=./build $(REALLY_QUIET))
119
120 _all: pjproject.symbols source/pjsip-apps/bin/pjsua-$(TARGET_NAME) source/pjsip-apps/src/python/build/_pjsua.so
121
122 _install: _all
123         $(ECHO_PREFIX) Installing apps and python bindings
124         @if [ ! -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject" ]; then \
125                 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject"; \
126         fi;
127         $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/bin/pjsua-$(TARGET_NAME) "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/pjsua"
128         $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/bin/pjsystest-$(TARGET_NAME) "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/pjsystest"
129         $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/src/python/build/_pjsua.so "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/"
130         $(CMD_PREFIX) $(INSTALL) -m 644 source/pjsip-apps/src/python/build/pjsua.py "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/"
131
132 uninstall:
133         $(ECHO_PREFIX) Uninstalling apps and python bindings
134         $(CMD_PREFIX) rm -rf "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject"
135
136 clean:
137         $(ECHO_PREFIX) Cleaning
138         -$(CMD_PREFIX) test -d source && ($(SUBMAKE) -C source clean ; find source -name *.a -delete ; rm -rf source/pjsip-apps/src/python/build) || :
139         -$(CMD_PREFIX) rm -rf pjproject.symbols
140
141 distclean:
142         $(ECHO_PREFIX) Distcleaning
143         -$(CMD_PREFIX) rm -rf source pjproject.symbols pjproject-*.tar.bz2 build.mak
144