5 # WARNING: requires gmake (GNU Make)
6 # Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 8), OpenBSD (3.2),
12 # 2003-02-24 make install no longer overwrites ser.cfg - patch provided
13 # by Maxim Sobolev <sobomax@FreeBSD.org> and
14 # Tomas Björklund <tomas@webservices.se>
15 # 2003-03-11 PREFIX & LOCALBASE must also be exported (andrei)
16 # 2003-04-07 hacked to work with solaris install (andrei)
17 # 2003-04-17 exclude modules overwritable from env. or cmd. line,
18 # added include_modules and skip_modules (andrei)
19 # 2003-05-30 added extra_defs & EXTRA_DEFS
20 # Makefile.defs force-included to allow recursive make
21 # calls -- see comment (andrei)
22 # 2003-06-02 make tar changes -- unpacks in $NAME-$RELEASE (andrei)
23 # 2003-06-03 make install-cfg will properly replace the module path
24 # in the cfg (re: /usr/.*lib/ser/modules)
25 # ser.cfg.default is installed only if there is a previous
26 # cfg. -- fixes packages containing ser.cfg.default (andrei)
27 # 2003-08-29 install-modules-doc split from install-doc, added
28 # install-modules-all, removed README.cfg (andrei)
29 # added skip_cfg_install (andrei)
32 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
34 #include source related defs
35 include Makefile.sources
37 # whether or not to install ser.cfg or just ser.cfg.default
38 # (ser.cfg will never be overwritten by make install, this is usefull
39 # when creating packages)
42 #extra modules to exclude
45 # if not set on the cmd. line or the env, exclude this modules:
46 exclude_modules?= cpl ext extcmd \
51 auth_radius group_radius uri_radius
52 # always exclude the CVS dir
53 override exclude_modules+= CVS $(skip_modules)
55 #always include this modules
58 # first 2 lines are excluded because of the experimental or incomplete
59 # status of the modules
60 # the rest is excluded because it depends on external libraries
63 static_modules_path=$(addprefix modules/, $(static_modules))
64 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
65 extra_objs=$(extra_sources:.c=.o)
67 static_defs= $(foreach mod, $(static_modules), \
68 -DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
70 override extra_defs+=$(static_defs) $(EXTRA_DEFS)
73 modules=$(filter-out $(addprefix modules/, \
74 $(exclude_modules) $(static_modules)), \
75 $(wildcard modules/*))
76 modules:=$(filter-out $(modules), $(addprefix modules/, $(include_modules) )) \
78 modules_names=$(shell echo $(modules)| \
79 sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
80 modules_basenames=$(shell echo $(modules)| \
81 sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
82 #modules_names=$(patsubst modules/%, %.so, $(modules))
83 modules_full_path=$(join $(modules), $(addprefix /, $(modules_names)))
86 ALLDEP=Makefile Makefile.sources Makefile.defs Makefile.rules
88 #include general defs (like CC, CFLAGS a.s.o)
89 # hack to force makefile.defs re-inclusion (needed when make calls itself with
90 # other options -- e.g. make bin)
97 #export relevant variables to the sub-makes
98 export DEFS PROFILE CC LD MKDEP MKTAGS CFLAGS LDFLAGS MOD_CFLAGS MOD_LDFLAGS
99 export LEX YACC YACC_FLAGS
100 export PREFIX LOCALBASE
101 # export relevant variables for recursive calls of this makefile
105 #export NAME RELEASE OS ARCH
106 #export cfg-prefix cfg-dir bin-prefix bin-dir modules-prefix modules-dir
107 #export doc-prefix doc-dir man-prefix man-dir ut-prefix ut-dir
108 #export cfg-target modules-target
109 #export INSTALL INSTALL-CFG INSTALL-BIN INSTALL-MODULES INSTALL-DOC INSTALL-MAN
110 #export INSTALL-TOUCH
115 tar_extra_args+=--exclude=$(notdir $(CURDIR))/tls*
117 # include the common rules
118 include Makefile.rules
122 $(NAME): static_modules
124 lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
127 cfg.tab.c cfg.tab.h: cfg.y $(ALLDEP)
128 $(YACC) $(YACC_FLAGS) $<
137 -@for r in $(modules) "" ; do \
138 if [ -n "$$r" ]; then \
145 .PHONY: static_modules
147 -@echo "Extra objs: $(extra_objs)"
148 -@for r in $(static_modules_path) "" ; do \
149 if [ -n "$$r" ]; then \
151 echo "Making static module $r" ; \
152 $(MAKE) -C $$r static ; \
159 gdb -command debug.gdb
168 --exclude=$(notdir $(CURDIR))/test* \
169 --exclude=$(notdir $(CURDIR))/tmp* \
170 --exclude=$(notdir $(CURDIR))/debian/ser* \
171 --exclude=$(notdir $(CURDIR))/ser_tls* \
173 --exclude=.cvsignore \
177 --exclude=$(notdir $(CURDIR))/ser \
185 -cf - $(notdir $(CURDIR)) | \
186 (mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
187 cd tmp/_tar1; $(TAR) -xf - ) && \
188 mv tmp/_tar1/$(notdir $(CURDIR)) \
189 tmp/_tar2/"$(NAME)-$(RELEASE)" && \
190 (cd tmp/_tar2 && $(TAR) \
191 -zcf ../../"$(NAME)-$(RELEASE)_src".tar.gz \
192 "$(NAME)-$(RELEASE)" ) ; \
193 rm -rf tmp/_tar1; rm -rf tmp/_tar2
195 # binary dist. tar.gz
198 mkdir -p tmp/ser/usr/local
199 $(MAKE) install basedir=tmp/ser prefix=/usr/local
200 $(TAR) -C tmp/ser/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
205 dpkg-buildpackage -rfakeroot -tc
210 mkdir -p tmp/ser_sun_pkg
211 $(MAKE) install basedir=tmp/ser prefix=/usr/local
213 pkgmk -r ../tmp/ser/usr/local -o -d ../tmp/ser_sun_pkg/ -v "$(RELEASE)" ;\
215 cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
216 pkgtrans -s tmp/ser_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
218 gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
220 rm -rf tmp/ser_sun_pkg
223 install: all mk-install-dirs install-cfg install-bin install-modules \
224 install-doc install-man
228 -@echo "Initializing ser database"
229 scripts/ser_mysql.sh create
232 mk-install-dirs: $(cfg-prefix)/$(cfg-dir) $(bin-prefix)/$(bin-dir) \
233 $(modules-prefix)/$(modules-dir) $(doc-prefix)/$(doc-dir) \
234 $(man-prefix)/$(man-dir)/man8 $(man-prefix)/$(man-dir)/man5
236 $(cfg-prefix)/$(cfg-dir):
237 mkdir -p $(cfg-prefix)/$(cfg-dir)
239 $(bin-prefix)/$(bin-dir):
240 mkdir -p $(bin-prefix)/$(bin-dir)
242 $(modules-prefix)/$(modules-dir):
243 mkdir -p $(modules-prefix)/$(modules-dir)
246 $(doc-prefix)/$(doc-dir):
247 mkdir -p $(doc-prefix)/$(doc-dir)
249 $(man-prefix)/$(man-dir)/man8:
250 mkdir -p $(man-prefix)/$(man-dir)/man8
252 $(man-prefix)/$(man-dir)/man5:
253 mkdir -p $(man-prefix)/$(man-dir)/man5
255 # note: on solaris 8 sed: ? or \(...\)* (a.s.o) do not work
256 install-cfg: $(cfg-prefix)/$(cfg-dir)
257 sed -e "s#/usr/.*lib/ser/modules/#$(modules-target)#g" \
258 < etc/ser.cfg > $(cfg-prefix)/$(cfg-dir)ser.cfg.sample
259 chmod 644 $(cfg-prefix)/$(cfg-dir)ser.cfg.sample
260 if [ -z "${skip_cfg_install}" -a \
261 ! -f $(cfg-prefix)/$(cfg-dir)ser.cfg ]; then \
262 mv -f $(cfg-prefix)/$(cfg-dir)ser.cfg.sample \
263 $(cfg-prefix)/$(cfg-dir)ser.cfg; \
265 # $(INSTALL-CFG) etc/ser.cfg $(cfg-prefix)/$(cfg-dir)
267 install-bin: $(bin-prefix)/$(bin-dir) utils/gen_ha1/gen_ha1 utils/serunix/serunix
268 $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/ser
269 $(INSTALL-BIN) ser $(bin-prefix)/$(bin-dir)
270 $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/sc
271 $(INSTALL-BIN) scripts/sc $(bin-prefix)/$(bin-dir)
272 mv -f $(bin-prefix)/$(bin-dir)/sc $(bin-prefix)/$(bin-dir)/serctl
273 $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/ser_mysql.sh
274 $(INSTALL-BIN) scripts/ser_mysql.sh $(bin-prefix)/$(bin-dir)
275 $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/gen_ha1
276 $(INSTALL-BIN) utils/gen_ha1/gen_ha1 $(bin-prefix)/$(bin-dir)
277 $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/serunix
278 $(INSTALL-BIN) utils/serunix/serunix $(bin-prefix)/$(bin-dir)
280 utils/gen_ha1/gen_ha1:
281 cd utils/gen_ha1; $(MAKE) all
283 utils/serunix/serunix:
284 cd utils/serunix; $(MAKE) all
286 install-modules: modules $(modules-prefix)/$(modules-dir)
287 -@for r in $(modules_full_path) "" ; do \
288 if [ -n "$$r" ]; then \
289 if [ -f "$$r" ]; then \
291 $(modules-prefix)/$(modules-dir)/`basename "$$r"` ; \
292 $(INSTALL-MODULES) "$$r" $(modules-prefix)/$(modules-dir) ; \
294 echo "ERROR: module $$r not compiled" ; \
300 install-modules-all: install-modules install-modules-doc
303 install-doc: $(doc-prefix)/$(doc-dir) install-modules-doc
304 $(INSTALL-TOUCH) $(doc-prefix)/$(doc-dir)/INSTALL
305 $(INSTALL-DOC) INSTALL $(doc-prefix)/$(doc-dir)
306 $(INSTALL-TOUCH) $(doc-prefix)/$(doc-dir)/README-MODULES
307 $(INSTALL-DOC) README-MODULES $(doc-prefix)/$(doc-dir)
308 $(INSTALL-TOUCH) $(doc-prefix)/$(doc-dir)/AUTHORS
309 $(INSTALL-DOC) AUTHORS $(doc-prefix)/$(doc-dir)
310 $(INSTALL-TOUCH) $(doc-prefix)/$(doc-dir)/NEWS
311 $(INSTALL-DOC) NEWS $(doc-prefix)/$(doc-dir)
312 $(INSTALL-TOUCH) $(doc-prefix)/$(doc-dir)/README
313 $(INSTALL-DOC) README $(doc-prefix)/$(doc-dir)
316 install-modules-doc: $(doc-prefix)/$(doc-dir)
317 -@for r in $(modules_basenames) "" ; do \
318 if [ -n "$$r" ]; then \
319 if [ -f modules/"$$r"/README ]; then \
320 $(INSTALL-TOUCH) $(doc-prefix)/$(doc-dir)/README ; \
321 $(INSTALL-DOC) modules/"$$r"/README \
322 $(doc-prefix)/$(doc-dir)/README ; \
323 mv -f $(doc-prefix)/$(doc-dir)/README \
324 $(doc-prefix)/$(doc-dir)/README."$$r" ; \
330 install-man: $(man-prefix)/$(man-dir)/man8 $(man-prefix)/$(man-dir)/man5
331 $(INSTALL-TOUCH) $(man-prefix)/$(man-dir)/man8/ser.8
332 $(INSTALL-MAN) ser.8 $(man-prefix)/$(man-dir)/man8/
333 $(INSTALL-TOUCH) $(man-prefix)/$(man-dir)/man5/ser.cfg.5
334 $(INSTALL-MAN) ser.cfg.5 $(man-prefix)/$(man-dir)/man5