Makefile
e60a9728
 # $Id$
 #
 # sip_router makefile
 #
1b1b19d8
 # WARNING: requires gmake (GNU Make)
aee4712e
 #  Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 8), OpenBSD (3.2),
 #  limited WinNT (cygwin) support
e60a9728
 
96001c50
 auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
247c2b65
 
 #include  source related defs
 include Makefile.sources
 
c6930bb8
 override exclude_modules:=CVS cpl cpl-c ext radius_acc radius_auth snmp \
054cb6cf
 	$(exclude_modules)
c64e586d
 static_modules=
404073d3
 static_modules_path=$(addprefix modules/, $(static_modules))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
 extra_objs=$(extra_sources:.c=.o)
 
 static_defs= $(foreach  mod, $(static_modules), \
af9d50fc
 		-DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
2510051e
 DEFS=$(static_defs)
404073d3
 modules=$(filter-out $(addprefix modules/, \
 			$(exclude_modules) $(static_modules)), \
 			$(wildcard modules/*))
6ac71d10
 modules_names=$(shell echo $(modules)| \
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
addb384d
 modules_basenames=$(shell echo $(modules)| \
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
6ac71d10
 #modules_names=$(patsubst modules/%, %.so, $(modules))
 modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
e60a9728
 
f20a56a2
 NAME=ser
e60a9728
 
247c2b65
 ALLDEP=Makefile Makefile.sources Makefile.defs Makefile.rules
f8734075
 
247c2b65
 #include general defs (like CC, CFLAGS  a.s.o)
 include Makefile.defs
0ae4dfdc
 
247c2b65
 #export relevant variables to the sub-makes
 export DEFS PROFILE CC  LD MKDEP MKTAGS CFLAGS LDFLAGS MOD_CFLAGS MOD_LDFLAGS
 export LEX YACC YACC_FLAGS
0ae4dfdc
 
04bb7a49
 
247c2b65
 # include the common rules
 include Makefile.rules
e60a9728
 
247c2b65
 #extra targets 
3e429f5c
 
04bb7a49
 $(NAME): static_modules
 
a15c363f
 lex.yy.c: cfg.lex $(ALLDEP)
 	$(LEX) $<
 
054cb6cf
 cfg.tab.c: cfg.y  $(ALLDEP)
a15c363f
 	$(YACC) $(YACC_FLAGS) $<
 
e60a9728
 .PHONY: all
96001c50
 all: $(NAME) modules
e60a9728
 
404073d3
 
96001c50
 
 .PHONY: modules
 modules:
e7a9bd30
 	-@for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "" ; \
 			$(MAKE) -C $$r ; \
 		fi ; \
 	done 
404073d3
 
 .PHONY: static_modules
 static_modules:
e7a9bd30
 	-@echo "Extra objs: $(extra_objs)" 
 	-@for r in $(static_modules_path) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "Making static module $r" ; \
 			$(MAKE) -C $$r static ; \
 		fi ; \
 	done 
404073d3
 
 
247c2b65
 	
f571aa35
 dbg: ser
 	gdb -command debug.gdb
247c2b65
 
0bafb279
 .PHONY: tar
247c2b65
 tar: mantainer-clean 
054cb6cf
 	$(TAR) -C .. \
 		--exclude=$(notdir $(CURDIR))/test \
 		--exclude=$(notdir $(CURDIR))/tmp \
 		--exclude=$(notdir $(CURDIR))/debian/ser \
 		--exclude=$(notdir $(CURDIR))/debian/ser-mysql-module \
 		 -zcf ../$(NAME)-$(RELEASE)_src.tar.gz  $(notdir $(CURDIR)) 
0bafb279
 
 # binary dist. tar.gz
 .PHONY: bin
 bin:
 	mkdir -p tmp/ser/usr/local
054cb6cf
 	$(MAKE) install basedir=tmp/ser prefix=/usr/local 
0bafb279
 	$(TAR) -C tmp/ser/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
 	rm -rf tmp/ser
04bb7a49
 
5c6101da
 .PHONY: deb
 deb:
054cb6cf
 	dpkg-buildpackage -rfakeroot -tc
5c6101da
 
bc5cc4ec
 .PHONY: sunpkg
 sunpkg:
 	mkdir -p tmp/ser
 	mkdir -p tmp/ser_sun_pkg
054cb6cf
 	$(MAKE) install basedir=tmp/ser prefix=/usr/local
bc5cc4ec
 	(cd solaris; \
054cb6cf
 	pkgmk -r ../tmp/ser/usr/local -o -d ../tmp/ser_sun_pkg/ -v "$(RELEASE)" ;\
bc5cc4ec
 	cd ..)
 	cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
 	pkgtrans -s tmp/ser_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
 		IPTELser
 	gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
 	rm -rf tmp/ser
 	rm -rf tmp/ser_sun_pkg
 
04bb7a49
 
db1b5017
 install: all mk-install-dirs install-cfg install-bin install-modules \
6ac71d10
 	install-doc install-man
db1b5017
 
e81ea6ce
 .PHONY: dbinstall
 dbinstall:
 	-@echo "Initializing ser database"
 	scripts/ser_mysql.sh create
 	-@echo "Done"
db1b5017
 
 mk-install-dirs: $(cfg-prefix)/$(cfg-dir) $(bin-prefix)/$(bin-dir) \
6ac71d10
 			$(modules-prefix)/$(modules-dir) $(doc-prefix)/$(doc-dir) \
 			$(man-prefix)/$(man-dir)/man8 $(man-prefix)/$(man-dir)/man5
db1b5017
 
 $(cfg-prefix)/$(cfg-dir): 
 		mkdir -p $(cfg-prefix)/$(cfg-dir)
 
 $(bin-prefix)/$(bin-dir):
 		mkdir -p $(bin-prefix)/$(bin-dir)
 
 $(modules-prefix)/$(modules-dir):
 		mkdir -p $(modules-prefix)/$(modules-dir)
 
 
 $(doc-prefix)/$(doc-dir):
 		mkdir -p $(doc-prefix)/$(doc-dir)
 
6ac71d10
 $(man-prefix)/$(man-dir)/man8:
 		mkdir -p $(man-prefix)/$(man-dir)/man8
 
 $(man-prefix)/$(man-dir)/man5:
 		mkdir -p $(man-prefix)/$(man-dir)/man5
db1b5017
 
054cb6cf
 install-cfg: $(cfg-prefix)/$(cfg-dir)
 		sed -e "s#/usr/lib/ser/modules/#$(modules-target)#g" \
 			< etc/ser.cfg > $(cfg-prefix)/$(cfg-dir)ser.cfg
 		chmod 644 $(cfg-prefix)/$(cfg-dir)ser.cfg
 #		$(INSTALL-CFG) etc/ser.cfg $(cfg-prefix)/$(cfg-dir)
db1b5017
 
054cb6cf
 install-bin: $(bin-prefix)/$(bin-dir) utils/gen_ha1/gen_ha1
db1b5017
 		$(INSTALL-BIN) ser $(bin-prefix)/$(bin-dir)
054cb6cf
 		$(INSTALL-BIN) scripts/sc $(bin-prefix)/$(bin-dir)/serctl
 		$(INSTALL-BIN) scripts/ser_mysql.sh  $(bin-prefix)/$(bin-dir)
 		$(INSTALL-BIN) utils/gen_ha1/gen_ha1 $(bin-prefix)/$(bin-dir)
db1b5017
 
054cb6cf
 utils/gen_ha1/gen_ha1:
 		cd utils/gen_ha1; $(MAKE) all
db1b5017
 
054cb6cf
 install-modules: modules $(modules-prefix)/$(modules-dir)
db1b5017
 	-@for r in $(modules_full_path) "" ; do \
 		if [ -n "$$r" ]; then \
 			$(INSTALL-MODULES)  $$r  $(modules-prefix)/$(modules-dir) ; \
 		fi ; \
 	done 
 
 
054cb6cf
 install-doc: $(doc-prefix)/$(doc-dir)
db1b5017
 	$(INSTALL-DOC) README $(doc-prefix)/$(doc-dir)
5b0cb4c6
 	$(INSTALL-DOC) README.cfg $(doc-prefix)/$(doc-dir)
 	$(INSTALL-DOC) INSTALL $(doc-prefix)/$(doc-dir)
4490b8e2
 	$(INSTALL-DOC) README-MODULES $(doc-prefix)/$(doc-dir)
d615a5cd
 	$(INSTALL-DOC) AUTHORS $(doc-prefix)/$(doc-dir)
addb384d
 	-@for r in $(modules_basenames) "" ; do \
 		if [ -n "$$r" ]; then \
 			if [ -f modules/"$$r"/README ]; then \
 				$(INSTALL-DOC)  modules/"$$r"/README  \
 									$(doc-prefix)/$(doc-dir)/README."$$r" ; \
 			fi ; \
 		fi ; \
 	done 
db1b5017
 
054cb6cf
 install-man: $(man-prefix)/$(man-dir)/man8 $(man-prefix)/$(man-dir)/man5
6ac71d10
 	$(INSTALL-MAN)  ser.8 $(man-prefix)/$(man-dir)/man8
 	$(INSTALL-MAN)  ser.cfg.5 $(man-prefix)/$(man-dir)/man5
db1b5017