
#############################################################################
include param.mk

MKDEPS=		Makefile param.mk subdir_lib.mk

T1=		tclnm
O1=		tclnm.o
S1=		tclnm.c
D1=		$(SUBLIBS) $(MKDEPS)
L1=		$(SUBLIBS) $(SYSLIBS)

T2=		wishnm
O2=		wishnm.o
S2=		wishnm.c
D2=		$(SUBLIBS) $(MKDEPS)
L2=		$(SUBLIBS) $(X11LIBS) $(SYSLIBS)

default:	all

test:		all
		./tclnm test_00

all install clean realclean:	$(MKDEPS)
	@for i in $(SUBDIRS) ;  do \
	    ( \
		cd $$i ; \
	        echo "---> `pwd`" ; \
	        $(MAKE) $@ CC="$(CC)" CFLAGS="$(CFLAGS)" CURSESLIB="$(CURSESLIB)" CURSESOPT="$(CURSESOPT)"; \
	    ) ; \
	done
	@echo "---> `pwd`"
	@$(MAKE) here_$@ 

specs:
	tbl tcl_snmp.3 | nroff -man | col -b > tcl_snmp.txt
	tbl tcl_snmp.3 | groff -Tps -man > tcl_snmp.ps

here_all:	$(TARGETS)
	rm -f tcl_mib.tcl
	ln -s tcl_mib/tcl_mib.tcl .

here_install:
	./tclnm install.tcl

here_clean:
	rm -f *.o *.a core $(TARGETS) *.pag *.dir *.str spec.txt* spec.ps* \
		Part?? tmp.* *.tmp tcl_mib.tcl 
	-find . -name core -exec rm {} \;

here_realclean: here_clean
	rm -f param.mk makefile *.rej *.orig
	cp makefile.init makefile

shar:	clean
	find . -print | grep -v 'Part[0-9][0-9]' | makekit -s60k 

patch:	realclean
	-diff -r -C2 ../tcl_nm-dist . | grep -v '^Only' > proto.patch
	
$(T1):	$(O1) $(D1)
	$(CC) $(CFLAGS) -o $(T1) $(O1) $(L1)

$(T2):	$(O2) $(D2)
	$(CC) $(CFLAGS) -o $(T2) $(O2) $(L2)

param.mk:	Config.edit Makefile
	@echo "Configuration possibly changed..."
	tcl Config.tcl
	@echo "Please rerun this make... "
	@sh -c "exit 1"

