pjproject: fixed a few bugs
[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         TARGETS := pjproject.symbols
49         ifeq ($(findstring TEST_FRAMEWORK,$(MENUSELECT_CFLAGS)),TEST_FRAMEWORK)
50             TARGETS += source/pjsip-apps/bin/pjsua-$(TARGET_NAME)
51             ifneq ($(PYTHONDEV_LIB),)
52                 TARGETS += source/pjsip-apps/src/python/build/_pjsua.so
53             endif
54         endif
55     else
56         all install:
57     endif
58 endif
59
60 ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] '
61
62 ifndef $(TMPDIR)
63     ifneq ($(wildcard /tmp),)
64         TMPDIR=/tmp
65     else
66         TMPDIR=.
67     endif
68 endif
69
70 $(TMPDIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 : ../versions.mak
71         $(ECHO_PREFIX) Downloading $@ with $(DOWNLOAD)
72         $(CMD_PREFIX) $(DOWNLOAD) $(PJPROJECT_URL)/$(@F) > $@
73
74 source/.unpacked: $(TMPDIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2
75         $(ECHO_PREFIX) Unpacking $<
76         -@rm -rf source &>/dev/null
77         -@mkdir source &>/dev/null
78         $(CMD_PREFIX) tar --strip-components=1 -C source -xjf $<
79         $(ECHO_PREFIX) Applying patches
80         $(CMD_PREFIX) ./apply_patches $(QUIET_CONFIGURE) ./patches ./source
81         -@touch source/.unpacked
82
83 source/user.mak: source/.unpacked ./patches/user.mak
84         $(ECHO_PREFIX) Applying user.mak
85         $(CMD_PREFIX) cp -f ./patches/user.mak ./source/
86
87 source/pjlib/include/pj/config_site.h: source/.unpacked ./patches/config_site.h
88         $(ECHO_PREFIX) Applying config_site.h
89         $(CMD_PREFIX) cp -f ./patches/config_site.h ./source/pjlib/include/pj/
90
91 build.mak: source/.unpacked source/pjlib/include/pj/config_site.h source/user.mak Makefile.rules
92         $(ECHO_PREFIX) Configuring with $(PJPROJECT_CONFIG_OPTS)
93         $(CMD_PREFIX) (cd source ; autoconf aconfigure.ac > aconfigure && ./aconfigure $(QUIET_CONFIGURE) $(PJPROJECT_CONFIG_OPTS))
94         @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
95
96 configure: build.mak
97
98 echo_cflags: build.mak
99         @echo $(PJ_CFLAGS)
100
101 source/pjlib/build/.pjlib-$(TARGET_NAME).depend: build.mak
102         $(ECHO_PREFIX) "Making dependencies"
103         +$(CMD_PREFIX) $(SUBMAKE) -C source dep
104
105 menuselect: ../../menuselect.makeopts ../../makeopts
106         -$(CMD_PREFIX) test -d source && ($(SUBMAKE) -C source clean ; find source -name *.a -delete ; rm -rf source/pjsip-apps/src/python/build) || :
107         -$(CMD_PREFIX) rm -rf pjproject.symbols
108
109 source/pjlib/lib/libpj-$(TARGET_NAME).a: menuselect source/pjlib/build/.pjlib-$(TARGET_NAME).depend
110         $(ECHO_PREFIX) Compiling libs
111         +$(CMD_PREFIX) $(SUBMAKE) -C source lib $(REALLY_QUIET)
112
113 pjproject.symbols: source/pjlib/lib/libpj-$(TARGET_NAME).a
114         $(ECHO_PREFIX) Generating symbols
115         $(CMD_PREFIX) nm -Pog $(PJ_LIB_FILES) | sed -n -r -e "s/.+: ([pP][jJ][^ ]+) .+/\1/gp" | sort -u > pjproject.symbols
116
117 source/pjsip-apps/bin/pjsua-$(TARGET_NAME): source/pjlib/lib/libpj-$(TARGET_NAME).a
118         $(ECHO_PREFIX) Compiling apps
119         $(CMD_PREFIX) $(SUBMAKE) -C source/pjsip-apps/build pjsua pjsystest $(REALLY_QUIET)
120
121 source/pjsip-apps/src/python/build/_pjsua.so: source/pjlib/lib/libpj-$(TARGET_NAME).a
122         $(ECHO_PREFIX) Compiling python bindings
123         $(CMD_PREFIX) (cd source/pjsip-apps/src/python ; MAKE=$(MAKE) python setup.py build --build-platlib=./build $(REALLY_QUIET))
124
125 _all: $(TARGETS)
126
127 _install: _all
128         @if [ ! -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject" ]; then \
129                 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject"; \
130         fi;
131 ifneq ($(findstring source/pjsip-apps/bin/pjsua-$(TARGET_NAME),$(TARGETS)),)
132         $(ECHO_PREFIX) Installing apps
133         $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/bin/pjsua-$(TARGET_NAME) "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/pjsua"
134         $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/bin/pjsystest-$(TARGET_NAME) "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/pjsystest"
135 endif
136 ifneq ($(findstring source/pjsip-apps/src/python/build/_pjsua.so,$(TARGETS)),)
137         $(ECHO_PREFIX) Installing python bindings
138         $(CMD_PREFIX) $(INSTALL) -m 755 source/pjsip-apps/src/python/build/_pjsua.so "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/"
139         $(CMD_PREFIX) $(INSTALL) -m 644 source/pjsip-apps/src/python/build/pjsua.py "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject/"
140 endif
141
142 uninstall:
143         $(ECHO_PREFIX) Uninstalling apps and python bindings
144         $(CMD_PREFIX) rm -rf "$(DESTDIR)$(ASTDATADIR)/third-party/pjproject"
145
146 clean:
147         $(ECHO_PREFIX) Cleaning
148         -$(CMD_PREFIX) test -d source && ($(SUBMAKE) -C source clean ; find source -name *.a -delete ; rm -rf source/pjsip-apps/src/python/build ; rm -rf source/pjsip-apps/bin/* ) || :
149         -$(CMD_PREFIX) rm -rf pjproject.symbols
150
151 distclean:
152         $(ECHO_PREFIX) Distcleaning
153         -$(CMD_PREFIX) rm -rf source pjproject.symbols pjproject-*.tar.bz2 build.mak
154