# State what the pathname of the installation directory is to be, e.g. 
InstallDir = /usr/local/tkmkmf


# State where the user visible link tkmkmf to the real tkmkmf script
# in ${InstallDir}/bin is to be located, e.g.
BinDir = /usr/local/bin


# If you have installed Tcl and Tk so that their include files and libraries
# are automtically located using default search rules then skip the remainder
# of this section, otherwise uncomment and edit the final two lines to state
# where the installation directories of Tcl and Tk are, i.e.
# ${TclDir}/include, ${TclDir}/lib, ${TkDir}/include and ${TkDir}/lib exist.
# TclDir = /usr/local/tcl
# TkDir = /usr/local/tk


# If you want [incr tcl] to be supported then uncomment the next line
# IncrTcl = Yes

# If [incr tcl] is being supported and its include file and library
# are automtically located using default search rules then skip the
# remainder of this section, otherwise uncomment and edit the final
# line to state where the installation directory is, i.e.
# ${ItclDir}/include and ${ItclDir}/lib exist
# ItclDir = /usr/local/itcl


# If you want the use of C++ to be supported and the C++ compiler
# for which support is to be provided requires main to be compiled
# by the compiler, as opposed to being able to use the C-compiled
# one from the Tk library, then state the name of the compiler in
# the final line. I believe this is necessary for AT & T's CC, but
# not for g++.
# CCcompiler = CC


# If your system doesn't have ranlib then set Ranlib in the next line
# to something innocuous like touch.
Ranlib = ranlib


####################################################################
#                                                                  #
#  There shouldn't be any need to change anything below this line  #
#                                                                  #
####################################################################


all:
	@cd config; 						\
	touch Imakefile; 					\
	for arg in `xmkmf`; 					\
	do 							\
	    case $$arg in 					\
		-I*) sed -e '1,$$s%!!!!CONFIGDIR!!!!%${InstallDir}/config%' \
	    		 -e '1,$$s%!!!!XCONFIGDIR!!!!%'$$arg'%' \
            		 <../template/tkmkmf.sed >../bin/tkmkmf ;\
		     break; 					\
	    esac; 						\
	done; 							\
	rm Imakefile Makefile; 					\
	cd ..

	@if test ${TclDir}X = X -a ${TkDir}X = X -a ${ItclDir}X = X ; \
	then 							\
		sed -e '1,$$s%!!!!TKMKMF!!!!%${InstallDir}%' 	\
		    -e '1,$$s%!!!!COMM!!!!%XCOMM %'     	\
		    <template/tkmkmf.rules.sed 			\
		    >config/tkmkmf.rules ; 			\
							     	\
		sed -e '1,$$s%!!!!COMM!!!!%# %'  		\
		    <template/Imakefile.sed 			\
		    >template/Imakefile.sed.tmp ;		\
	else 							\
		sed -e '1,$$s%!!!!TKMKMF!!!!%${InstallDir}%' 	\
		    -e '1,$$s%!!!!COMM!!!!%%'     		\
		    -e '1,$$s%!!!!TCLDIR!!!!%${TclDir}%'     	\
		    -e '1,$$s%!!!!TKDIR!!!!%${TkDir}%'       	\
		    -e '1,$$s%!!!!INCRDIR!!!!%${ItclDir}%'     	\
		    <template/tkmkmf.rules.sed 			\
		    >config/tkmkmf.rules ; 			\
							     	\
		sed -e '1,$$s%!!!!COMM!!!!%%'  			\
		    -e '1,$$s%!!!!TCLDIR!!!!%${TclDir}%'  	\
		    -e '1,$$s%!!!!TKDIR!!!!%${TkDir}%'    	\
		    -e '1,$$s%!!!!INCRDIR!!!!%${ItclDir}%'     	\
		    <template/Imakefile.sed 			\
		    >template/Imakefile.sed.tmp ;		\
	fi

	@if test ${CCcompiler}X = X ;				\
	then							\
		sed -e '/CCON/,/CCOFF/d'			\
		    <template/Imakefile.sed.tmp >src/Imakefile ;\
								\
		sed -e '/CCON/,/CCOFF/d'			\
		    <template/Imakefile.tmpl.sed 		\
		    >template/Imakefile.tmpl.tmp1 ;		\
								\
		sed -e '/CCON/,/CCOFF/d'			\
		    <template/README.src.sed >src/README ;	\
	else							\
		sed -e '/CCON/d' -e '/CCOFF/d'			\
		    -e '1,$$s%!!!!CCOMPILER!!!!%${CCcompiler}%' \
		    <template/Imakefile.sed.tmp >src/Imakefile ;\
								\
		sed -e '/CCON/d' -e '/CCOFF/d'			\
		    <template/Imakefile.tmpl.sed 		\
		    >template/Imakefile.tmpl.tmp1 ;		\
								\
		sed -e '/CCON/d' -e '/CCOFF/d'			\
		    <template/README.src.sed >src/README ;	\
	fi

	@if test ${IncrTcl}X = X ;				\
	then							\
		sed -e '/INCRON/,/INCROFF/d'			\
		    <template/Imakefile.tmpl.tmp1 		\
		    >template/Imakefile.tmpl.tmp ;		\
								\
		sed -e '/INCRON/,/INCROFF/d'			\
		    <template/tkmkmf.h.sed >include/tkmkmf.h ;	\
	else							\
		sed -e '/INCRON/d' -e '/INCROFF/d'		\
		    <template/Imakefile.tmpl.tmp1 		\
		    >template/Imakefile.tmpl.tmp ;		\
								\
		sed -e '/INCRON/d' -e '/INCROFF/d'		\
		    <template/tkmkmf.h.sed >include/tkmkmf.h ;	\
	fi

	@sed -e '1,$$s%!!!!CCOMPILER!!!!%${CCcompiler}%'	\
	     <template/Imakefile.tmpl.tmp >config/Imakefile.tmpl

	@echo
	@echo '***********************************************************'
	@echo '* Now cd to src and run "xmkmf" followed by "make" before *'
	@echo '*         returning here to do the "make install"         *'
	@echo '***********************************************************'
	@echo

install:
	mkdirhier ${InstallDir}
	chmod 755 bin/tkmkmf
	cp -rp include bin lib config ${InstallDir}
	${Ranlib} ${InstallDir}/lib/AppInit.a
	rm -rf ${BinDir}/tkmkmf
	ln -s ${InstallDir}/bin/tkmkmf ${BinDir}/tkmkmf

