#
# Makefile for TkNetmon application
#
APP	=	TkNetmon
VERSION	=	2.0.7a
PREFIX	=	/usr/local
APPNAME	=	$(APP)-$(VERSION)
APPPATH	=	lib/${APPNAME}
DEVS	=	${APPPATH}/devices
ICONS	=	${APPPATH}/icons
LIBS	=	${APPPATH}/lib
LIBEXECS =	${APPPATH}/libexec
LOCALES	=	${APPPATH}/locale
SOUNDS	=	${APPPATH}/sounds
EXAMPLES=	share/examples/${APP}
DOCS	=	share/doc/${APP}
BIN	=	bin
#
TCLSH	=	/usr/local/bin/tclsh8.4
#
DIRS	=	 $(ICONS) $(LIBS) $(LOCALES) $(SOUNDS) $(EXAMPLES) $(DOCS) $(APPPATH)	
#
LBIN	=	bin/TkNetmon
LROOT	=	TkNetmon.tcl .tknetmonrc README.ru README.en \
		KNOWNBUGS.ru CHANGES.ru LICENSE
LDEVS	=	devices/devtable		
LLIBS	=	lib/Node.tcl lib/Monitor.tcl lib/Dialogs.tcl lib/Preferences.tcl \
		lib/Link.tcl lib/Line.tcl lib/Text.tcl lib/SaveFile.tcl \
		lib/LoadFile.tcl lib/Discovery.tcl lib/snmpNames.tcl    \
		lib/selectTargets.tcl lib/IpAddrLib.tcl lib/LoadHostsFile.tcl \
		lib/msgcat.tcl lib/menuConfig.tcl  lib/EventsLog.tcl \
		lib/Bgp.tcl lib/Interface.tcl lib/ifGroups.tcl  lib/Service.tcl \
		lib/Misc.tcl lib/Methods.tcl  lib/Variables.tcl lib/SNMP.tcl\
		lib/stateSignal.tcl lib/Logo.tcl lib/fontDialog.tcl lib/Sql.tcl \
		lib/Traps.tcl lib/LoadNetStateObjs.tcl
LICONS	=	icons/unknown32.gif icons/unknown48.gif icons/pc32.gif icons/pc48.gif \
		icons/cisco32.gif icons/cisco48.gif icons/win32.gif icons/win48.gif   \
		icons/printer32.gif icons/printer48.gif icons/linux32.gif icons/linux48.gif \
		icons/freebsd32.gif icons/freebsd48.gif icons/hub32.gif icons/hub48.gif \
		icons/router32.gif icons/router48.gif icons/HPUX.gif icons/APCsymmetra.gif \
		icons/pix32.gif
LLOCALES=	locale/ru.msg
LEXAMPLES=	examples/netmon.conf examples/snmp.list examples/targets.list examples/netmon.db.sql
LDOCS	=	doc/UserGuide.html doc/UserGuide.ru.html doc/ProgrammerGuide.html \
		doc/ProgrammerGuide.ru.html doc/Libexec.ru.html doc/FAQ.ru.html \
		doc/Example1.ru.html doc/EventsLog.ru.html
LSOUNDS=	sounds/Up.wav sounds/Down.wav
LLIBEXECS=	libexec/TkPortHistory.tcl libexec/TkDeviceView.tcl libexec/TkIfUtil.tcl \
		libexec/TkSnmpTable.tcl libexec/EventsLog.tcl libexec/object-sql-log.tcl \
		libexec/subobject-sql-log.tcl libexec/SndCtrl.tcl libexec/NodeReport.tcl \
		libexec/SystemLog.tcl

LPARTS	=	$(LBIN) $(LLIBS) $(LLIBEXECS) $(LDOCS) $(LICONS) $(LLOCALES) \
		$(LEXAMPLES) $(LSOUNDS) $(LROOT)

#
all: mklocale
#
install:
#
mklocale: 
	(cd ./locale ; ${TCLSH} ./conv.tcl ) 
#
install: mklocale
	@if pw group show "netmon" 2>/dev/null ; then \
	    echo "Netmon group exist"; \
	else \
	    pw groupadd netmon -M root ; \
	fi
	[ -d $(PREFIX)/$(APPPATH) ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(APPPATH)
	[ -d $(PREFIX)/$(DEVS)    ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(DEVS)
	[ -d $(PREFIX)/$(LIBS)    ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(LIBS)
	[ -d $(PREFIX)/$(LIBEXECS) ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(LIBEXECS)
	[ -d $(PREFIX)/$(ICONS)   ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(ICONS)
	[ -d $(PREFIX)/$(LOCALES) ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(LOCALES)
	[ -d $(PREFIX)/$(SOUNDS)  ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(SOUNDS)
	[ -d $(PREFIX)/$(BIN)     ] || install -d -m 550 -o root -g wheel $(PREFIX)/$(BIN)
	install -c -m 440 -o root -g netmon $(LLIBS)   $(PREFIX)/$(LIBS)
	install -c -m 750 -o root -g netmon $(LLIBEXECS)   $(PREFIX)/$(LIBEXECS)
	install -c -m 440 -o root -g netmon $(LDEVS)  $(PREFIX)/$(DEVS)
	install -c -m 440 -o root -g netmon $(LICONS)  $(PREFIX)/$(ICONS)
	install -c -m 440 -o root -g netmon $(LLOCALES) $(PREFIX)/$(LOCALES)
	install -c -m 440 -o root -g netmon $(LSOUNDS) $(PREFIX)/$(SOUNDS)
	install -c -m 550 -o root -g netmon $(LBIN)    $(PREFIX)/$(BIN)
	install -c -m 440 -o root -g netmon $(LROOT)   $(PREFIX)/$(APPPATH)
#	[ -d $(PREFIX)/$(EXAMPLES) ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(EXAMPLES)
#	install -c -m 440 -o root -g netmon $(LEXAMPLES) $(PREFIX)/$(EXAMPLES)
#	[ -d $(PREFIX)/$(DOCS)    ] || install -d -m 550 -o root -g netmon $(PREFIX)/$(DOCS)
#	install -c -m 440 -o root -g netmon $(LDOCS)   $(PREFIX)/$(DOCS)
