#
#	dm_gui Makefile for Linux
#
#	$Id: Makefile.installed.linux,v 1.4 2000/05/11 20:51:43 randall Exp $
#
#		CHANGE LOG
#	$Log: Makefile.installed.linux,v $
#	Revision 1.4  2000/05/11 20:51:43  randall
#	- Updates to be able to build true SRPM and RPM with 'make srpm'
#	  Note: 'make rpm' still makes the old-style hybrid RPM.
#	
#	Revision 1.3  2000/04/27 19:58:27  jordanh
#		*	Added O/S dependant files and changed Makefiles to
#			use them.
#	
#		*	Changed dm_status.tcl to use functions defined in
#			dm_osdep.tcl to lookup device names and to check
#			if it should invoke the call monitor.
#	
#		*	Updated .cvsignore to ignore Makefile and dm_osdep.tcl,
#			which is generated from dm_osdep_{arch}.tcl.inc.
#	
#		*	Updated dm_status.tcl to display the Adapter Status
#			by default in the tree-view thing.
#	
#	Revision 1.2  2000/03/09 12:18:31  dickl
#	Removed the "rm -f *.c" from the clobber target.  "rpm -e dgdm" complains
#	if it can't find this file
#	
#	Revision 1.1  2000/01/30 16:22:00  dickl
#	Migrated various dgdm (linux) utilities to this cvs module
#	to make it accessible to all Unix variants
#	
#	
#

include ../../Makefile.inc

INC=../../fep_include
CFLAGS=-I$(INC)

TCLEX= $(shell if [ -f /usr/bin/tcl ]; then echo "tcl"; else echo "tclsh"; fi)

NULL=
TCLMAIN= dm_gui.tcl
TCLLIB=\
	dm_config.tcl \
	dm_status.tcl \
	dm_help.tcl \
	dm_misc.tcl \
	dm_osdep.tcl \
	$(NULL)
ICONS=\
	chart.gif \
	houston-board.gif \
	help.gif \
	help-book.gif \
	tree-adapter.gif \
	tree-port.gif \
	tree-chan.gif \
	$(NULL)

all install clean clobber web::

install:: all
	install -m 0755 $(TCLMAIN) $(DMBIN)/dm_gui
	[ -d $(DMLIB) ] || mkdir -m 755 -p $(DMLIB)
	install -m 0755 $(TCLLIB) $(TCLMAIN) tcldgdm.so $(DMLIB)
	install -m 0644 $(ICONS) pkgIndex.tcl $(DMLIB)
	install -m 0644 dm_gui.8 $(MANDIR)/man8

uninstall: clobber
	rm -f $(DMBIN)/dm_gui
	rm -f $(MANDIR)/man8/dm_gui.8

all::	tcldgdm.so dm_osdep.tcl pkgIndex.tcl

tcldgdm.so: mgmthlc_wrap.o
	$(CC) -shared mgmthlc_wrap.o -o $@

mgmthlc_wrap.o: mgmthlc_wrap.c hlctypes.h
	$(CC) -fpic -c $(CFLAGS) $*.c

mgmthlc_wrap.c: mgmthlc.i $(INC)/mgmthlc.h $(INC)/mgmtdflt.h $(INC)/mgmtcmds.h enums
	if [ -x /usr/bin/swig ]; then \
		swig -tcl8 -make_default -I$(INC) mgmthlc.i; \
	fi

pkgIndex.tcl: $(TCLLIB)
	echo "pkg_mkIndex . tcldgdm.so $(TCLLIB)" \
		| $(TCLEX) > $@ || (rm -f $@; exit 1)

clean::
	-rm -f *.o *.so enums
	-rm -f pkgIndex.tcl

clobber:: clean
	rm -f *_wrap.doc

#
#	This hack forces SWIG to generate some constants that
#	it would otherwise ignore.
#
#	Also, bonus hack: we get rid of some that are just plain
#	broken in the current header file
#
enums: $(INC)/mgmtcmds.h
	echo "enum {" >$@ || rm -f $@
	grep "define[ 	]*[SG]ET_" $(INC)/mgmtcmds.h | \
		sed -e 's/#define[ 	]*//' -e 's/[ 	].*/,/' >> $@
	echo "};" >> $@ || rm -f $@
