1APP_NAME ?= sems
2NAME=$(APP_NAME)
3LIBNAME=$(APP_NAME).so
4
5COREPATH=.
6
7PLUGIN_DIR=plug-in
8SIP_STACK_DIR=sip
9RESAMPLE_DIR=resample
10
11SRCS=$(wildcard *.cpp)
12HDRS=$(SRCS:.cpp=.h)
13OBJS=$(SRCS:.cpp=.o)
14DEPS=$(SRCS:.cpp=.d) $(NAME).d
15AUDIO_FILES=$(notdir $(wildcard wav/*.wav))
16TEST_DIR=tests
17
18.PHONY: all
19all: ../Makefile.defs $(NAME) modules
20
21.PHONY: clean
22clean:
23	@rm -f $(OBJS) $(DEPS) $(NAME)
24	@rm -f lib/*.so compat/getos compat/getarch
25	@$(MAKE) -C $(SIP_STACK_DIR) clean
26	@$(MAKE) -C $(RESAMPLE_DIR) clean
27	@$(MAKE) -C $(PLUGIN_DIR) clean
28
29.PHONY: sip_stack
30sip_stack:
31	@echo ""
32	@echo "making SIP stack"
33	@cd $(SIP_STACK_DIR); $(MAKE) all
34
35.PHONY: modules
36modules:
37	@echo ""
38	@echo "making core modules"
39	@cd $(PLUGIN_DIR); $(MAKE) modules
40
41.PHONY: test
42test:
43	@echo ""
44	@echo "making tests"
45	@cd $(TEST_DIR); $(MAKE)
46
47.PHONY: core
48core: $(OBJS) ../Makefile.defs
49
50include ../Makefile.defs
51
52CPPFLAGS += -I$(COREPATH) -fno-strict-aliasing
53LDFLAGS += -levent -levent_pthreads
54
55ifdef USE_LIBSAMPLERATE
56CPPFLAGS += -DUSE_LIBSAMPLERATE
57LDFLAGS +=-lsamplerate
58endif
59
60# This allows symbols defined in the SIP stack but not used
61# by the core itself to be included in the executable and
62# thus be available for modules
63ifneq ($(LD), clang)
64EXTRA_LDFLAGS += -Wl,--whole-archive $(SIP_STACK_DIR)/sip_stack.a -Wl,--no-whole-archive
65else
66EXTRA_LDFLAGS += -force_load $(SIP_STACK_DIR)/sip_stack.a
67endif
68
69ifneq ($(OS), freebsd)
70	EXTRA_LDFLAGS += -lresolv
71endif
72
73
74ifdef USE_INTERNAL_RESAMPLER
75
76CPPFLAGS += -DUSE_INTERNAL_RESAMPLER
77OBJS += $(RESAMPLE_DIR)/libresample.a
78
79.PHONY: resample_lib
80resample_lib:
81	@echo ""
82	@echo "making internal resampler"
83	@cd $(RESAMPLE_DIR); $(MAKE) all
84
85else
86
87.PHONY: resample_lib
88resample_lib:
89
90endif
91
92ifeq ($(USE_GPERFTOOLS),yes)
93LDFLAGS += -ltcmalloc -lprofiler
94endif
95
96ifdef USE_SPANDSP
97CPPFLAGS += -DUSE_SPANDSP -D__STDC_LIMIT_MACROS
98
99ifdef LIBSPANDSP_STATIC
100LDFLAGS += $(LIBSPANDSP_LDIR)libspandsp.a
101else
102LDFLAGS += -lspandsp
103endif
104endif
105
106-include $(DEPS)
107
108# implicit rules
109%.o : %.cpp ../Makefile.defs
110	$(CXX) -MMD -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
111
112$(NAME): sip_stack resample_lib core ../Makefile.defs
113	@echo ""
114	@echo "making $(NAME) executable"
115	$(LD) -o $(NAME) $(OBJS) $(LDFLAGS) $(EXTRA_LDFLAGS)
116
117
118install: all mk-install-dirs \
119	install-audio \
120	install-modules-cfg \
121	install-cfg \
122	install-bin \
123	install-modules
124
125
126# note: on solaris 8 sed: ? or \(...\)* (a.s.o) do not work
127install-cfg: $(DESTDIR)$(cfg_target) $(DESTDIR)$(app_cfg_target)
128		sed -e "s#/usr/.*lib/sems/audio/#$(audio_target)#g" \
129			-e "s#/usr/.*lib/sems/plug-in/#$(modules_target)#g" \
130			-e "s#/usr/.*etc/sems/#$(cfg_target)#g" \
131			< etc/sems.conf.sample > $(DESTDIR)$(cfg_target)sems.conf.default
132		chmod 644 $(DESTDIR)$(cfg_target)sems.conf.default
133		if [ ! -f $(DESTDIR)$(cfg_target)sems.conf ]; then \
134			cp -f $(DESTDIR)$(cfg_target)sems.conf.default \
135				$(DESTDIR)$(cfg_target)sems.conf; \
136		fi
137
138		$(INSTALL_CFG) etc/app_mapping.conf.sample $(DESTDIR)$(app_cfg_target)app_mapping.conf
139
140install-bin: $(DESTDIR)$(bin_prefix)/$(bin_dir)
141		$(INSTALL_TOUCH) $(DESTDIR)$(bin_prefix)/$(bin_dir)$(NAME)
142		$(INSTALL_BIN) $(NAME) $(DESTDIR)$(bin_prefix)/$(bin_dir)
143
144install-modules: $(PLUGIN_DIR) $(DESTDIR)$(modules_prefix)/$(modules_dir)
145	$(MAKE) -C $(PLUGIN_DIR) install
146
147install-modules-cfg: $(PLUGIN_DIR)
148	$(MAKE) -C $(PLUGIN_DIR) install-cfg
149
150install-audio: $(DESTDIR)$(audio_prefix)/$(audio_dir)
151	for f in $(AUDIO_FILES) ; do \
152		if [ -n "wav/$$f" ]; then \
153			$(INSTALL_TOUCH) $(DESTDIR)$(audio_prefix)/$(audio_dir)$$f; \
154			$(INSTALL_AUDIO) wav/$$f $(DESTDIR)$(audio_prefix)/$(audio_dir)$$f; \
155		fi ; \
156	done
157
158dist: tar
159
160tar:
161	$(TAR) -C .. \
162		--exclude=$(notdir $(CURDIR))/ivr \
163		--exclude=$(notdir $(CURDIR))/tmp \
164		--exclude=.svn* \
165		--exclude=.\#* \
166		--exclude=*.[do] \
167		--exclude=*.la \
168		--exclude=*.lo \
169		--exclude=*.so \
170		--exclude=*.il \
171		--exclude=$(notdir $(CURDIR))/sems \
172		--exclude=$(notdir $(CURDIR))/build-stamp \
173		--exclude=$(notdir $(CURDIR))/configure-stamp \
174		--exclude=$(notdir $(CURDIR))/debian/sems-core \
175		--exclude=*.gz \
176		--exclude=*.bz2 \
177		--exclude=*.tar \
178		--exclude=*~ \
179		-cf - $(notdir $(CURDIR)) | \
180			(mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
181			    cd tmp/_tar1; $(TAR) -xf - ) && \
182			    mv tmp/_tar1/$(notdir $(CURDIR)) \
183			       tmp/_tar2/"$(NAME)-$(RELEASE)" && \
184			    (cd tmp/_tar2 && $(TAR) \
185			                    -zcf ../../"$(NAME)-$(notdir $(CURDIR))-$(RELEASE)".tar.gz \
186			                               "$(NAME)-$(RELEASE)" ) ; \
187			    rm -rf tmp/_tar1; rm -rf tmp/_tar2
188
189
190