1OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]')
2
3#ifeq ($(OSTYPE),hpux)
4#	EXTRATOOLS=hpux-meminfo
5#endif
6#ifeq ($(OSTYPE),hp-ux)
7#	EXTRATOOLS=hpux-meminfo
8#endif
9ifeq ($(OSTYPE),freebsd)
10	EXTRATOOLS=freebsd-meminfo
11endif
12ifeq ($(OSTYPE),dragonfly)
13	EXTRATOOLS=freebsd-meminfo
14endif
15ifeq ($(OSTYPE),netbsd)
16	EXTRATOOLS=netbsd-meminfo
17endif
18ifeq ($(OSTYPE),openbsd)
19	EXTRATOOLS=openbsd-meminfo
20endif
21
22XYMONCLIENTLIB = ../lib/libxymonclient.a
23XYMONCLIENTLIBS = $(XYMONCLIENTLIB)
24XYMONCLIENTCOMMLIB = ../lib/libxymonclientcomm.a
25XYMONCLIENTCOMMLIBS = $(XYMONCLIENTCOMMLIB) $(SSLLIBS) $(ZLIBLIBS) $(NETLIBS) $(LIBRTDEF)
26
27PROGRAMS=xymonlaunch logfetch clientupdate orcaxymon msgcache
28COMMONTOOLS=xymon xymoncmd xymongrep xymoncfg xymondigest
29
30all: $(PROGRAMS) $(COMMONTOOLS) xymonclient.cfg clientlaunch.cfg $(EXTRATOOLS)
31
32xymonclient.cfg: xymonclient.cfg.DIST
33	cat xymonclient.cfg.DIST | sed -e 's!@XYMONHOSTIP@!$(XYMONHOSTIP)!g' >xymonclient.cfg
34	../build/bb-commands.sh >>xymonclient.cfg
35
36clientlaunch.cfg: clientlaunch.cfg.DIST
37ifeq ($(LOCALCLIENT),yes)
38	cat clientlaunch.cfg.DIST | sed -e 's!@CLIENTFLAGS@!--local!g' >clientlaunch.cfg
39else
40	cat clientlaunch.cfg.DIST | sed -e 's!@CLIENTFLAGS@!!g' >clientlaunch.cfg
41endif
42
43logfetch: logfetch.c $(XYMONCLIENTLIB)
44	$(CC) $(CFLAGS) -o $@ logfetch.c $(XYMONCLIENTLIBS)
45
46clientupdate: clientupdate.c $(XYMONCLIENTCOMMLIB) $(XYMONCLIENTLIB)
47	$(CC) $(CFLAGS) -o $@ clientupdate.c $(XYMONCLIENTCOMMLIBS) $(XYMONCLIENTLIBS)
48
49orcaxymon: orcaxymon.c $(XYMONCLIENTCOMMLIB) $(XYMONCLIENTLIB)
50	$(CC) $(CFLAGS) -o $@ orcaxymon.c $(XYMONCLIENTCOMMLIBS) $(XYMONCLIENTLIBS)
51
52msgcache: msgcache.c $(XYMONCLIENTLIB)
53	$(CC) $(CFLAGS) -o $@ msgcache.c $(XYMONCLIENTCOMMLIBS) $(XYMONCLIENTLIBS)
54
55hpux-meminfo: hpux-meminfo.c
56	$(CC) -o $@ hpux-meminfo.c
57
58freebsd-meminfo: freebsd-meminfo.c
59	$(CC) -o $@ freebsd-meminfo.c
60
61openbsd-meminfo: openbsd-meminfo.c
62	$(CC) -o $@ openbsd-meminfo.c
63
64netbsd-meminfo: netbsd-meminfo.c
65	$(CC) -o $@ netbsd-meminfo.c
66
67install:
68	if test ! -d $(INSTALLROOT)$(XYMONHOME)       ; then mkdir -p $(INSTALLROOT)$(XYMONHOME)       ; chmod 755 $(INSTALLROOT)$(XYMONHOME)      ; fi
69	if test ! -d $(INSTALLROOT)$(XYMONHOME)/bin   ; then mkdir -p $(INSTALLROOT)$(XYMONHOME)/bin   ; chmod 755 $(INSTALLROOT)$(XYMONHOME)/bin  ; fi
70	if test ! -d $(INSTALLROOT)$(XYMONHOME)/etc   ; then mkdir -p $(INSTALLROOT)$(XYMONHOME)/etc   ; chmod 755 $(INSTALLROOT)$(XYMONHOME)/etc  ; fi
71	if test ! -d $(INSTALLROOT)$(XYMONHOME)/tmp   ; then mkdir -p $(INSTALLROOT)$(XYMONHOME)/tmp   ; chmod 755 $(INSTALLROOT)$(XYMONHOME)/tmp  ; fi
72	if test ! -d $(INSTALLROOT)$(XYMONHOME)/logs  ; then mkdir -p $(INSTALLROOT)$(XYMONHOME)/logs  ; chmod 755 $(INSTALLROOT)$(XYMONHOME)/logs ; fi
73	if test ! -d $(INSTALLROOT)$(XYMONHOME)/ext   ; then mkdir -p $(INSTALLROOT)$(XYMONHOME)/ext   ; chmod 755 $(INSTALLROOT)$(XYMONHOME)/ext  ; fi
74	if test ! -d $(INSTALLROOT)$(XYMONHOME)/local ; then mkdir -p $(INSTALLROOT)$(XYMONHOME)/local ; chmod 755 $(INSTALLROOT)$(XYMONHOME)/local; fi
75	if test ! -f $(INSTALLROOT)$(XYMONHOME)/etc/localclient.cfg.sample ; then cp localclient.cfg $(INSTALLROOT)$(XYMONHOME)/etc/localclient.cfg.sample ; chmod 644 $(INSTALLROOT)$(XYMONHOME)/etc/localclient.cfg.sample; fi
76	if test ! -f $(INSTALLROOT)$(XYMONHOME)/local/README; then cp README-local $(INSTALLROOT)$(XYMONHOME)/local/README ; chmod 644 $(INSTALLROOT)$(XYMONHOME)/local/README; fi
77	chmod 755 runclient.sh $(PROGRAMS) xymonclient*.sh $(COMMONTOOLS) $(EXTRATOOLS)
78	cp -fp runclient.sh $(INSTALLROOT)$(XYMONHOME)
79	cp -fp $(PROGRAMS) xymonclient*.sh $(COMMONTOOLS) $(EXTRATOOLS) $(INSTALLROOT)$(XYMONHOME)/bin/
80
81	../build/merge-sects clientlaunch.cfg $(INSTALLROOT)$(XYMONHOME)/etc/clientlaunch.cfg.sample
82	../build/merge-lines xymonclient.cfg $(INSTALLROOT)$(XYMONHOME)/etc/xymonclient.cfg.sample
83	chmod 644 $(INSTALLROOT)$(XYMONHOME)/etc/clientlaunch.cfg.sample $(INSTALLROOT)$(XYMONHOME)/etc/xymonclient.cfg.sample
84
85ifndef PKGBUILD
86	chown -R $(XYMONUSER) $(INSTALLROOT)$(XYMONHOME)
87	chgrp -R `$(IDTOOL) -g $(XYMONUSER)` $(INSTALLROOT)$(XYMONHOME)
88	chmod 755 $(INSTALLROOT)$(XYMONHOME)
89endif
90
91install-localclient:
92	chmod 755 xymond_client
93	cp -fp xymond_client $(INSTALLROOT)$(XYMONHOME)/bin/
94ifndef PKGBUILD
95	chown $(XYMONUSER) $(INSTALLROOT)$(XYMONHOME)/bin/xymond_client
96	chgrp `$(IDTOOL) -g $(XYMONUSER)` $(INSTALLROOT)$(XYMONHOME)/bin/xymond_client
97endif
98
99clean:
100	rm -f $(PROGRAMS) $(COMMONTOOLS) xymond_client xymonclient.cfg clientlaunch.cfg $(EXTRATOOLS) *~
101
102