# TREX makefile for Profesional Edition

SRC = src

DOC = $(SRC)/doc

#PATCHES = $(SRC)/patches

DIST_TREX = distrib/trex_pro
DIST_TREX_SOURCE = distrib/trex_source
DIST_APACHE = distrib/trex_pro
DIST_PTN = distrib/ptelnet_client
DIST_PADMIN = distrib/trex_pro
DIST_HOPLITE = distrib/hoplite

SUBS =	libdes \
	libsrc \
	netlib \
	util/gwuser \
	sd \
	dss/agent \
	aproxy/exits \
	aproxy \
	ftproxy \
	fwpulse \
	oobasrv \
	plog \
	fwmon \
	raproxy \
	rpcproxy \
	smwrap \
	smwrapd \
	tnproxy \
	util/adam \
	util/md5 \
	util/portscan \
	util/reports/aproxsum \
	util/reports/ftprpt \
	util/reports/smrpt \
	util/reports/smrptx \
	util/reports/sockdsum \
	util/reports/tnprpt \
	util/reports/webblocksum \
	util/tnkey \
	webgate \
	xforward \
	ptelnet \
	socks \
	apache/src \
	padmin \
	hoplite \
	hoplite/docs \
	monitor \
        analog \
        logrotate \
	fastresolve

EXES =	libdes/speed \
        libdes/destest \
        libdes/des_opts \
        libdes/rpw \
	util/gwuser/gwuser \
	util/gwuser/gwgroup \
	aproxy/aproxy \
	ftproxy/ftproxy \
	fwpulse/fwpulse \
	fwpulse/fwpulsed \
	fwpulse/takeover \
	fwpulse/arp_broadcast \
	oobasrv/oobasrv \
	plog/plog \
	fwmon/fwmon \
	fwmon/procmon \
	fwmon/spoofmon \
	fwmon/synmonld \
	fwmon/synmonkx \
	raproxy/raproxy \
	rpcproxy/rpcproxy \
	smwrap/smwrap \
	smwrapd/smwrapd \
	tnproxy/tnproxy \
	util/adam/adam \
	util/md5/md5 \
	util/portscan/portscan \
	util/reports/aproxsum/aproxsum \
	util/reports/ftprpt/ftprpt \
	util/reports/smrpt/smrpt \
	util/reports/smrptx/smrptx \
	util/reports/sockdsum/sockdsum \
	util/reports/tnprpt/tnprpt \
	util/reports/webblocksum/webblocksum \
	util/tnkey/tnkey \
	webgate/webgate \
	xforward/xforward \
	ptelnet/ptelnet/ptelnet \
	socks/sockd/sockd \
	apache/src/httpd \
	padmin/padminsvr \
	monitor/monitor \
        analog/analog \
        logrotate/logrotate \
	fastresolve/fastresolve/dns-terror/dns-terror

default:
	@for i in $(SUBS); do \
	  (cd $(SRC)/$$i; \
	  PWD=`pwd`; export PWD; \
	  echo "Making $$i ..."; \
	  make 2>&1 |tee make.log); \
	done

all:
	@for i in $(SUBS); do \
	  (cd $(SRC)/$$i; \
	  PWD=`pwd`; export PWD; \
	  echo "Making all in $$i ..."; \
	  make clean; \
	  make 2>&1 |tee make.log); \
	done
	@make distrib

clean:
	@for i in $(SUBS); do \
	  (cd $(SRC)/$$i; \
	  echo "Making clean in $$i ..."; \
	  make clean); \
	done; \
	if [ "`uname`" = "AIX" ]; then \
	  os=aix; \
	  arch=""; \
	elif [ "`uname`" = "HP-UX" ]; then \
	  os=hpux; \
	  arch=""; \
	elif [ "`uname`" = "SunOS" ]; then \
	  os=solaris; \
	  if [ "`uname -p`" = "i386" ]; then \
	    arch=-x86; \
	  else \
	    arch=-sparc; \
	  fi; \
	elif [ "`uname`" = "Linux" ]; then \
	  os=linux; \
	  arch="-`uname -m`"; \
	fi; \
# Remove binary distribution for current platform			\
	echo "Removing $(DIST_TREX)/$$os$$arch/* ..."; \
	rm -rf $(DIST_TREX)/$$os$$arch/*; \
	echo "Removing $(DIST_PTN)/$$os$$arch/* ..."; \
	rm -rf $(DIST_PTN)/$$os$$arch/*; \
	echo "Removing $(DIST_HOPLITE)/$$os$$arch/* ..."; \
	rm -rf $(DIST_HOPLITE)/$$os$$arch/*; \
# Remove TREX source distribution					\
	echo "Removing $(DIST_TREX_SOURCE)/* ..."; \
	rm -rf $(DIST_TREX_SOURCE)/*

depend:
	@ \
# Note that some directories will require a manual update (fwmon,	\
# ftproxy, tnproxy, ... ?)						\
	for i in $(SUBS); do \
	  skip=0; \
# No depend target							\
	  for j in libdes socks util/md5; do \
	    if [ "$$i" = "$$j" ]; then \
	      skip=1; \
	      break; \
	    fi; \
	  done; \
	  if [ $$skip -eq 0 ]; then \
	    (cd $(SRC)/$$i; \
	    echo "Make depending in $$i ..."; \
	    make depend); \
	  fi; \
	done

distrib:  dist

dist:
	@( \
	if [ "`whoami`" != "root" ] && [ "`whoami`" != "rugby" ]; then	\
	  echo "You can only make dist as root or rugby";		\
	  exit 1; 							\
	fi;								\
									\
	PATH=$$PATH:/usr/contrib/bin;					\
	export PATH;							\
	if [ "`uname`" = "AIX" ]; then \
	  os=aix; \
	  arch=""; \
	elif [ "`uname`" = "HP-UX" ]; then \
	  os=hpux; \
	  arch=""; \
	elif [ "`uname`" = "SunOS" ]; then \
	  os=solaris; \
	  if [ "`uname -p`" = "i386" ]; then \
	    arch=-x86; \
	  else \
	    arch=-sparc; \
	  fi; \
	elif [ "`uname`" = "Linux" ]; then \
	  os=linux; \
	  arch="-`uname -m`"; \
	fi; \
	dist=$(DIST_TREX)/$$os$$arch; \
	if [ ! -d $$dist ]; then \
	  mkdir -p $$dist; \
	else \
	  rm -rf $$dist/*; \
	fi; \
									\
	echo "Creating $$dist ..."; \
	cp -f $(SRC)/aproxy/aproxy $$dist; \
	cp -f $(SRC)/ftproxy/ftproxy $$dist; \
	cp -f $(SRC)/fwpulse/fwpulse $$dist; \
	cp -f $(SRC)/fwpulse/fwpulsed $$dist; \
	cp -f $(SRC)/fwpulse/takeover $$dist; \
	cp -f $(SRC)/plog/plog $$dist; \
	cp -f $(SRC)/fwmon/fwmon $$dist; \
	cp -f $(SRC)/fwmon/procmon $$dist; \
	cp -f $(SRC)/raproxy/raproxy $$dist; \
	cp -f $(SRC)/rpcproxy/rpcproxy $$dist; \
	cp -f $(SRC)/smwrap/smwrap $$dist; \
	cp -f $(SRC)/smwrapd/smwrapd $$dist; \
	cp -f $(SRC)/tnproxy/tnproxy $$dist; \
	cp -f $(SRC)/util/adam/adam $$dist; \
 	cp -f $(SRC)/util/gwuser/gwgroup $$dist; \
 	cp -f $(SRC)/util/gwuser/gwuser $$dist; \
 	cp -f $(SRC)/util/tnkey/tnkey $$dist; \
	cp -f $(SRC)/util/md5/md5 $$dist; \
	cp -f $(SRC)/util/portscan/portscan $$dist; \
	cp -f $(SRC)/util/reports/aproxsum/aproxsum $$dist; \
	cp -f $(SRC)/util/reports/ftprpt/ftprpt $$dist; \
	cp -f $(SRC)/util/reports/smrpt/smrpt $$dist; \
	cp -f $(SRC)/util/reports/smrptx/smrptx $$dist; \
	cp -f $(SRC)/util/reports/sockdsum/sockdsum $$dist; \
	cp -f $(SRC)/util/reports/tnprpt/tnprpt $$dist; \
	cp -f $(SRC)/util/reports/webblocksum/webblocksum $$dist; \
	cp -f $(SRC)/logrotate/logrotate $$dist; \
	cp -f $(SRC)/fastresolve/fastresolve/dns-terror/dns-terror $$dist; \
	cp -f $(SRC)/analog/analog $$dist; \
	cp -f $(SRC)/webgate/webgate $$dist; \
	cp -f $(SRC)/xforward/xforward $$dist; \
	cp -f $(SRC)/socks/sockd/sockd $$dist; \
	cp -f $(SRC)/examples/diskmon $$dist; \
	cp -f $(SRC)/examples/message_router $$dist; \
	cp -f $(SRC)/examples/refresh_syslogd $$dist; \
	cp -f $(SRC)/examples/refresh_webgate $$dist; \
									\
	if [ "$$os" = "aix" ]; then \
	  cp $(SRC)/fwpulse/arp_broadcast $$dist; \
	  cp $(SRC)/fwmon/spoofmon $$dist; \
	  cp $(SRC)/fwmon/synmon $$dist; \
	  cp $(SRC)/fwmon/synmonkx $$dist; \
	  cp $(SRC)/fwmon/synmonld $$dist; \
	  cp $(SRC)/fwmon/synmon43 $$dist; \
	  cp $(SRC)/fwmon/synmonkx43 $$dist; \
	  cp $(SRC)/fwmon/synmonld43 $$dist; \
	  cp $(SRC)/monitor/monitor $$dist; \
	elif [ "$$os" = "hpux" ]; then \
	  cp $(SRC)/fwmon/spoofmon $$dist; \
	  cp $(SRC)/fwmon/tcpdump_hpux10 $$dist/tcpdump; \
	elif [ "$$os" = "linux" ]; then \
	  cp -f $(SRC)/fwpulse/arp_broadcast $$dist; \
 	  cp -f $(SRC)/fwmon/spoofmon $$dist; \
	fi; \
									\
        for file in `ls $$dist/* | egrep -v 'diskmon|refresh_|message_router'`; do \
	  if strip $$file; then \
	    echo "stripped $$file"; \
	  else \
            echo "$$file already stripped"; \
	  fi; \
	done; \
									\
	(cd $$dist; ./md5 * | egrep -v 'md5.DB' > md5.DB); \
									\
	cp $(DOC)/README.txt $$dist; \
	cp $(DOC)/RELNOTES.4.$$os.txt $$dist/RELNOTES.txt; \
	cp $(DOC)/getting_started.txt_$$os $$dist/getting_started.txt; \
									\
	if [ ! -d $$dist/examples ]; then \
	  mkdir -p $$dist/examples; \
	fi; \
	if [ ! -d $$dist/examples/exits ]; then \
	  mkdir -p $$dist/examples/exits; \
	fi; \
	mv $$dist/md5.DB $$dist/examples; \
	if [ "$$os" = "aix" ]; then \
	  cp -f $(SRC)/aproxy/exits/libuser_exits.a $$dist/examples/exits; \
	else \
	  cp $(SRC)/aproxy/exits/libuser_exits.so $$dist/examples/exits; \
	fi; \
	cp -f $(SRC)/aproxy/exits/Makefile $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/README $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/user_exits.c $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/user_exits.h $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/user_exits.exp $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/addcrlf.c $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/auth.c $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/rmcrlf.c $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/clientget.c $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/clientput.c $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/serverget.c $$dist/examples/exits; \
	cp -f $(SRC)/aproxy/exits/serverput.c $$dist/examples/exits; \
	cp -f $(SRC)/examples/aliases $$dist/examples; \
	cp -f $(SRC)/examples/aproxy.conf $$dist/examples; \
	cp -f $(SRC)/examples/diskmon.conf $$dist/examples; \
	cp -f $(SRC)/examples/display_alerts $$dist/examples; \
	cp -f $(SRC)/examples/display_syslog $$dist/examples; \
	cp -f $(SRC)/examples/display_webgate $$dist/examples; \
	cp -f $(SRC)/examples/ftproxy.conf $$dist/examples; \
	cp -f $(SRC)/examples/fwpulse.conf $$dist/examples; \
	cp -f $(SRC)/examples/gwuser.conf $$dist/examples; \
	cp -f $(SRC)/examples/iDNS.named.boot $$dist/examples; \
	cp -f $(SRC)/examples/iDNS.named.ca $$dist/examples; \
	cp -f $(SRC)/examples/iDNS.named.hosts $$dist/examples; \
	cp -f $(SRC)/examples/iDNS.named.local $$dist/examples; \
	cp -f $(SRC)/examples/iDNS.named.rev $$dist/examples; \
	cp -f $(SRC)/examples/inetd.conf $$dist/examples; \
	cp -f $(SRC)/examples/named.boot $$dist/examples; \
	cp -f $(SRC)/examples/named.conf $$dist/examples; \
	cp -f $(SRC)/examples/named.ca $$dist/examples; \
	cp -f $(SRC)/examples/named.local $$dist/examples; \
	cp -f $(SRC)/examples/plog.conf $$dist/examples; \
	cp -f $(SRC)/examples/post_reverse_takeover $$dist/examples; \
	cp -f $(SRC)/examples/post_takeover $$dist/examples; \
	cp -f $(SRC)/examples/raproxy.conf $$dist/examples; \
	cp -f $(SRC)/examples/rpcproxy.conf $$dist/examples; \
	cp -f $(SRC)/examples/resolv.conf $$dist/examples; \
	cp -f $(SRC)/examples/resolv.inside.conf $$dist/examples; \
	cp -f $(SRC)/examples/securenets $$dist/examples; \
	cp -f $(SRC)/examples/secureports $$dist/examples; \
	cp -f $(SRC)/examples/services $$dist/examples; \
	cp -f $(SRC)/examples/smwrap.conf $$dist/examples; \
	cp -f $(SRC)/examples/tnproxy.conf $$dist/examples; \
	cp -f $(SRC)/examples/webgate.conf $$dist/examples; \
	cp -f $(SRC)/examples/motd $$dist/examples/motd; \
	if [ "$$os" = "aix" ]; then \
	  cp $(SRC)/examples/cron.root_aix4 $$dist/examples/cron.root; \
	  cp $(SRC)/examples/fwmon.conf.aix $$dist/examples/fwmon.conf; \
	  cp $(SRC)/examples/profile_aix4 $$dist/examples/profile; \
	  cp $(SRC)/examples/rc.nfs_aix4 $$dist/examples/rc.nfs; \
	  cp $(SRC)/examples/rc.tcpip_aix4 $$dist/examples/rc.tcpip; \
	  cp $(SRC)/examples/syslog.conf_aix4 $$dist/examples/syslog.conf; \
	  cp $(SRC)/examples/sockd.conf_aix $$dist/examples/sockd.conf; \
	elif [ "$$os" = "hpux" ]; then \
	  cp $(SRC)/examples/TREX_hpux10 $$dist/examples/TREX; \
	  cp $(SRC)/examples/cron.root_hpux10 $$dist/examples/cron.root; \
	  cp $(SRC)/examples/fwmon.conf.hpux $$dist/examples/fwmon.conf; \
	  cp $(SRC)/examples/profile_hpux10 $$dist/examples/profile; \
	  cp $(SRC)/examples/nsswitch.conf_hpux10 $$dist/examples/nsswitch.conf; \
	  cp $(SRC)/examples/startvue_hpux10 $$dist/examples/startvue; \
	  cp $(SRC)/examples/startvue.rc_hpux10 $$dist/examples/startvue.rc; \
	  cp $(SRC)/examples/sockd.conf_hpux $$dist/examples/sockd.conf; \
	elif [ "$$os" = "solaris" ]; then \
	  cp $(SRC)/examples/TREX_solaris $$dist/examples/TREX; \
	  cp $(SRC)/examples/cron.root_solaris $$dist/examples/cron.root; \
	  cp $(SRC)/examples/openwin-menu_solaris $$dist/examples/openwin-menu; \
	  cp $(SRC)/examples/fwmon.conf.solaris $$dist/examples/fwmon.conf; \
	  cp $(SRC)/examples/profile_solaris $$dist/examples/profile; \
	  cp $(SRC)/examples/nsswitch.conf_solaris $$dist/examples/nsswitch.conf; \
	  cp $(SRC)/examples/startx_solaris $$dist/examples/startx; \
	  cp $(SRC)/examples/startx.rc_solaris $$dist/examples/startx.rc; \
	  cp $(SRC)/examples/sockd.conf_solaris $$dist/examples/sockd.conf; \
        elif [ "$$os" = "linux" ]; then \
          cp -f $(SRC)/examples/TREX_linux $$dist/examples/TREX; \
          cp -f $(SRC)/examples/cron.root_linux $$dist/examples/cron.root; \
	  cp -f $(SRC)/examples/profile_linux $$dist/examples/profile; \
          cp -f $(SRC)/examples/fwmon.conf.linux $$dist/examples/fwmon.conf; \
          cp -f $(SRC)/examples/nsswitch.conf_linux $$dist/examples/nsswitch.conf; \
          cp -f $(SRC)/examples/sendmail.cf_linux $$dist/examples/sendmail.cf; \
          cp -f $(SRC)/examples/syslog.conf_linux $$dist/examples/syslog.conf; \
	  cp $(SRC)/examples/sockd.conf_linux $$dist/examples/sockd.conf; \
	fi; \
									\
	if [ ! -d $(DIST_TREX_SOURCE)/100 ]; then \
	  mkdir -p $(DIST_TREX_SOURCE)/100; \
	else \
	  echo "$(DIST_TREX_SOURCE)/100 already exists.  Proceeding with TREX source."; \
	fi; \
	echo "Adding TREX source to $(DIST_TREX_SOURCE)/100/ ..."; \
	cp -rf $(SRC) $(DIST_TREX_SOURCE)/100/; \
	cp $(DOC)/LPL_License.txt $(DIST_TREX_SOURCE)/100/; \
	cp -f Makefile $(DIST_TREX_SOURCE)/100/; \
	cp -f README.build $(DIST_TREX_SOURCE)/100/; \
	cp -f README.install $(DIST_TREX_SOURCE)/100/; \
	rm -f $(DIST_TREX_SOURCE)/100/src/make.log; \
	rm -f $(DIST_TREX_SOURCE)/100/src/make_cddist; \
	rm -f $(DIST_TREX_SOURCE)/100/src/cp_cddist; \
	rm -f $(DIST_TREX_SOURCE)/100/src/make_disks; \
	rm -rf $(DIST_TREX_SOURCE)/100/src/javatop; \
	find $(DIST_TREX_SOURCE)/100 -name "*.[0-9][0-9][0-9][0-9][0-9][0-9]" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.bak" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.sav" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.old" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.o" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.obj" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.so" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.lo" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.a" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "make.log" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.tar" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.orig" -print|xargs rm -f; \
	find $(DIST_TREX_SOURCE)/100 -name "*.exe" -print|xargs rm -f; \
	for i in $(EXES); do \
	  if [ -f $(DIST_TREX_SOURCE)/100/src/$$i ]; then \
	    rm -f $(DIST_TREX_SOURCE)/100/src/$$i; \
	  fi; \
	done; \
	tar -C $(DIST_TREX_SOURCE) -cf $(DIST_TREX_SOURCE)/trex_100_src.tar 100; \
	gzip $(DIST_TREX_SOURCE)/trex_100_src.tar; \
	rm -rf $(DIST_TREX_SOURCE)/100; \
									\
	if [ ! -d $$dist/WIN32 ]; then \
	  mkdir -p $$dist/WIN32; \
	else \
	  echo "$$dist/WIN32 already exists.  Proceeding with TREX Win32 applications"; \
	fi; \
	echo "Adding TREX WIN32 applications to $$dist/ ..."; \
	cp -f $(SRC)/win32/plogd/plogd.exe $$dist/WIN32; \
	cp -f $(SRC)/win32/plogd/plogd.cfg $$dist/WIN32; \
									\
	if [ ! -d $$dist/doc ]; then \
	  mkdir -p $$dist/doc; \
	else \
	  echo "$$dist/doc already exists.  Proceeding with docs."; \
	fi; \
	cp $(DOC)/TrexAdm.pdf         $$dist/doc; \
	cp $(DOC)/LPL_License.txt $$dist/doc; \
	cp $(SRC)/socks/LICENSE $$dist/doc/LICENSE.dante; \
	cp $(DOC)/Java.license.txt     $$dist/doc)
# Apache
	@(if [ "`uname`" = "AIX" ]; then \
	  os=aix; \
	  arch=""; \
	elif [ "`uname`" = "HP-UX" ]; then \
	  os=hpux; \
	  arch=""; \
	elif [ "`uname`" = "SunOS" ]; then \
	  os=solaris; \
	  if [ "`uname -p`" = "i386" ]; then \
	    arch=-x86; \
	  else \
	    arch=-sparc; \
	  fi; \
	elif [ "`uname`" = "Linux" ]; then \
	  os=linux; \
	  arch="-`uname -m`"; \
	fi; \
	dist=$(DIST_APACHE)/$$os$$arch; \
	if [ ! -d $$dist ]; then \
	  mkdir -p $$dist; \
	else \
	  echo "$$dist already exists.  Proceeding with httpd."; \
	fi; \
									\
	if [ ! -d $$dist/lists ]; then \
	  mkdir -p $$dist/lists; \
	fi; \
	cp $(SRC)/lists/* $$dist/lists; \
									\
	echo "Adding Apache proxy to $$dist ..."; \
	cp $(SRC)/apache/src/httpd $$dist/httpd; \
	if [ "$$os" = "aix" ]; then \
	  cp $(SRC)/examples/httpd.conf $$dist/examples/httpd.conf; \
	elif [ "$$os" = "hpux" ]; then \
	  cp $(SRC)/examples/httpd.conf $$dist/examples/httpd.conf; \
	elif [ "$$os" = "solaris" ]; then \
	  cp $(SRC)/examples/httpd.conf $$dist/examples/httpd.conf; \
	elif [ "$$os" = "linux" ]; then \
	  cp -f $(SRC)/examples/httpd.conf_linux $$dist/examples/httpd.conf; \
	fi; \
	cp -f $(SRC)/apache/LICENSE $$dist/doc/LICENSE.apache; \
	cp -f $(SRC)/examples/mime.types $$dist/examples/mime.types; \
	cp -f $(SRC)/examples/refresh_httpd $$dist; \
	cp -f $(SRC)/examples/link_cache $$dist/examples/link_cache; \
									\
	if strip $$dist/httpd; then \
	  echo "stripped $$dist/httpd"; \
	else \
	  echo "$$dist/httpd already stripped"; \
	fi)
# padmin
	@(if [ "`uname`" = "AIX" ]; then \
	  os=aix; \
	  arch=""; \
	elif [ "`uname`" = "HP-UX" ]; then \
	  os=hpux; \
	  arch=""; \
	elif [ "`uname`" = "SunOS" ]; then \
	  os=solaris; \
	  if [ "`uname -p`" = "i386" ]; then \
	    arch=-x86; \
	  else \
	    arch=-sparc; \
	  fi; \
	elif [ "`uname`" = "Linux" ]; then \
	  os=linux; \
	  arch="-`uname -m`"; \
	fi; \
	dist=$(DIST_PADMIN)/$$os$$arch; \
	if [ ! -d $$dist ]; then \
	  mkdir -p $$dist; \
	else \
	  echo "$$dist already exists.  Proceeding with Padmin."; \
	fi; \
									\
	echo "Adding Padmin to $$dist ..."; \
	cp -f $(SRC)/padmin/padminsvr $$dist/padminsvr; \
	cp -f $(SRC)/examples/padmin.conf $$dist/examples/padmin.conf; \
	cp -f $(SRC)/padmin/apache.bulist $$dist/examples/apache.bulist; \
	cp -f $(SRC)/padmin/custom.bulist $$dist/examples/custom.bulist; \
	cp -f $(SRC)/padmin/trex.bulist $$dist/examples/trex.bulist; \
	cp -f $(SRC)/padmin/system.bulist $$dist/examples/system.bulist; \
									\
	if strip $$dist/padminsvr; then \
          echo "" >/dev/null; \
        else \
	  echo "$$dist/padminsvr already stripped"; \
	fi)
# hoplite
	@(if [ "`uname`" = "AIX" ]; then \
	  os=aix; \
	  arch=""; \
	elif [ "`uname`" = "HP-UX" ]; then \
	  os=hpux; \
	  arch=""; \
	elif [ "`uname`" = "SunOS" ]; then \
	  os=solaris; \
	  if [ "`uname -p`" = "i386" ]; then \
	    arch=-x86; \
	  else \
	    arch=-sparc; \
	  fi; \
	elif [ "`uname`" = "Linux" ]; then \
	  os=linux; \
	  arch="-`uname -m`"; \
	fi; \
	dist=$(DIST_HOPLITE)/$$os$$arch; \
	distwin=$(DIST_HOPLITE)/WIN32; \
	if [ ! -d $$dist ]; then \
	  mkdir -p $$dist; \
	else \
	  rm -rf $$dist/*; \
	fi; \
	if [ ! -d $$distwin ]; then \
	  mkdir -p $$distwin; \
	else \
	  rm -rf $$distwin/*; \
	fi; \
									\
	echo "Creating $$dist ..."; \
	cp -f $(SRC)/hoplite/trex.jar $$dist/trex.jar; \
	grep -v "^JAVATOP="  $(SRC)/hoplite/hoplite  | grep -v "^PROGDIR=" >$$dist/hoplite; \
	cp -f $(SRC)/hoplite/libglue.so $$dist/libglue.so; \
	cp -f $(SRC)/hoplite/docs/trexdocs.jar $$dist/trexdocs.jar; \
	cp -f $(SRC)/hoplite/jhelp/lib/jhelp.jar $$dist/jhelp.jar; \
									\
	echo "Creating $$distwin ..."; \
	cp -f $(SRC)/hoplite/windows/Hoplite32.exe $$distwin; \
	cp -f $(SRC)/hoplite/windows/jre115-win32.exe $$distwin; \
									\
	if strip $$dist/libglue.so; then \
          echo "" >/dev/null; \
        else \
	  echo "$$dist/libglue.so already stripped"; \
	fi)
#ptelnet 
	@(if [ "`uname`" = "AIX" ]; then \
	  os=aix; \
	  arch=""; \
	elif [ "`uname`" = "HP-UX" ]; then \
	  os=hpux; \
	  arch=""; \
	elif [ "`uname`" = "SunOS" ]; then \
	  os=solaris; \
	  if [ "`uname -p`" = "i386" ]; then \
	    arch=-x86; \
	  else \
	    arch=-sparc; \
	  fi; \
	elif [ "`uname`" = "Linux" ]; then \
	  os=linux; \
	  arch="-`uname -m`"; \
	fi; \
	dist=$(DIST_PTN)/$$os$$arch; \
	if [ ! -d $$dist ]; then \
	  mkdir -p $$dist; \
	else \
	  rm -rf $$dist/*; \
	fi; \
	distwin=$(DIST_PTN)/WIN32; \
	if [ ! -d $$distwin ]; then \
	  mkdir -p $$distwin; \
	else \
	  rm -rf $$distwin/*; \
	fi; \
									\
	echo "Creating $$dist ..."; \
	cp -f $(SRC)/ptelnet/ptelnet/ptelnet $$dist; \
									\
	echo "Creating $$distwin ..."; \
	cp -f $(SRC)/win32/ptelnet/ptelnet.exe $$distwin; \
	cp -f $(SRC)/win32/ptelnet/README.install $$distwin; \
									\
        for file in ptelnet; do \
	  if strip $$dist/$$file; then \
	    echo "stripped $$dist/$$file"; \
          else \
            echo "$$dist/$$file already stripped"; \
	  fi; \
	done)
	@(if [ "`uname`" = "AIX" ]; then \
	  os=aix; \
	  arch=""; \
	elif [ "`uname`" = "HP-UX" ]; then \
	  os=hpux; \
	  arch=""; \
	elif [ "`uname`" = "SunOS" ]; then \
	  os=solaris; \
	  if [ "`uname -p`" = "i386" ]; then \
	    arch=-x86; \
	  else \
	    arch=-sparc; \
	  fi; \
	elif [ "`uname`" = "Linux" ]; then \
	  os=linux; \
	  arch="-`uname -m`"; \
	fi; \
	chown -R rugby:staff distrib)
