#!/bin/csh -f
#
#      $Id: rm3_2,v 1.7 2003-05-16 14:53:13 haley Exp $
#
#########################################################################
#									#
#			   Copyright (C)  1992				#
#	     University Corporation for Atmospheric Research		#
#			   All Rights Reserved				#
#									#
#########################################################################
#
#	File:		rm3_2
#
#	Author:		John Clyne
#			National Center for Atmospheric Research
#			PO 3000, Boulder, Colorado
#
#	Date:		Thu Feb 4 10:45:57 MST 1993
#
#	Description:	Remove a post 3.1.3a version of NCAR Graphics. This
#			script removes a particular version of NCAR Graphics
#			but does not remove any sym links pointing to that
#			version
#			
#
#	Usage:		rm3_2 <version> [-bin <bindir>] [-inc <incdir> [-man[1,3,5,8,l] <mandir>] [-lib <libdir>]
#
#	Environment:
#
#	Files:
#
#
#	Options:
#			-bin	: Remove old bin installables from 'bindir'
#			-inc	: Remove old include installables from 'incdir'
#			-lib	: Remove old lib installables from 'libdir'
#			-man1	: Remove old man 1 installables from 'mandir'
#			-man3	: Remove old man 3 installables from 'mandir'
#			-man5	: Remove old man 5 installables from 'mandir'
#			-man8	: Remove old man 8 installables from 'mandir'
#			-manl	: Remove old man l installables from 'mandir'
#

set bins = ()
set incs = ()
set libs = ()
set man1s = ()
set man3s = ()
set man5s = ()
set man8s = ()
set manls = ()

if ($#argv < 3) then 
	echo "Invalid option <$argv[1]>"
	echo "Usage: $0 <version> [-bin <bindir>] [-inc <incdir> [-man[1,3,5,8,l] <mandir>] [-lib <libdir>]"
	exit 1
endif

set version = $argv[1]
shift;

set bins = 	(ConvertMapData WritePlotcharData byacc bnchmk cgm2ncgm \
		cgm_edit cgmtrans cgmtrans.hplj cgmtrans.nolj ctlib ctrans \
		ezmapdemo fcaps findg fontc ftrans gcaps graphc ictrans idt \
		med ncargcc ncargcex ncargex ncargf77 ngi wrapit77 \
		ncargfile ncargmv ncargpath ncargrun ncargtar nnalg \
		ncargversion ncarvversion ncargworld ncgm2cgm ncgmstat \
		ncl ng4ex nhlcc nhlf77 nriftohdf plt pre2ncgm pre2ncgm.prog psblack \
		pswhite pwritxnt ras2ccir601 rascat rasgetpal rasls rassplit \
		rasstat rasview sunplot tgks0a tlocal tplot tdpackdemo \
		tspps xproto xwdtohdf ymake ymkmf ConvertMapData WriteLineFile \
		WriteNameFile WritePlotcharData ncargf90 nhlf90 psplit)

set incs = 	(ncarg)

set libs = 	(libcgm.a libncarg.a libncargC.a libncarg_c.a \
		libncarg_gks.a libncarg_gksC.a libncarg_loc.a libncarg_ras.a \
		libhlu.a libncl.a libnclapi.a libngmath.a ncarg)

set man1s = (cgm2ncgm ctrans fcaps findg fontc gcaps graphc ictrans idt med \
		ncargcc ncargcex ncargex ncargf77 ncargfile ncargpath ncargrun \
		ncargversion ncgm2cgm ng4ex nhlcc nhlf77 pre2ncgm psblack psplit \
		pswhite rascat rasgetpal rasls rassplit rasview nriftohdf xwdtohdf \
		cgm_edit ftrans ncargf90 nhlf90)

set man3s =	(agback agbnch agchax agchcu agchil agchnl agcurv agdshn aggetc \
	aggetf aggeti aggetp aggetr agpwrt agrstr agsave agsetc agsetf agseti \
	agsetp agsetr agstup agutol anotat ardbpa ardrln areas areas_params \
	aredam argeti argetr argtai arinam armvam arpram arscam arseti arsetr \
	autograph autograph_params bivar bivar_params c_csa1s c_csa1xs c_csa2ls \
	c_csa2lxs c_csa2s c_csa2xs c_csa3ls c_csa3lxs c_csa3s c_csa3xs c_dsgetc \
	c_dsgeti c_dsgetr c_dsgetrd c_dsgrid2d c_dsgrid2s c_dsgrid3d c_dsgrid3s \
	c_dspnt2d c_dspnt2s c_dspnt3d c_dspnt3s c_dssetc c_dsseti c_dssetr \
	c_dssetrd c_ftcurv c_ftcurvd c_ftcurvi c_ftcurvp c_ftcurvpi c_ftcurvps \
	c_ftcurvs c_ftgetc c_ftgetfa_data c_ftgetfa_size c_ftgeti c_ftgetr \
	c_ftkurv c_ftkurvd c_ftkurvp c_ftkurvpd c_ftsetc c_ftsetfa c_ftseti \
	c_ftsetr c_ftsurf c_natgridd c_natgrids c_nngetaspectd c_nngetaspects \
	c_nngetc c_nngeti c_nngetr c_nngetrd c_nngetsloped c_nngetslopes \
	c_nnpntd c_nnpntend c_nnpntendd c_nnpntinitd c_nnpntinits c_nnpnts \
	c_nnsetc c_nnseti c_nnsetr c_nnsetrd cfux cfuy cgm clsgks cmfx cmfy \
	cmux cmuy colconv conop1 conop2 conop3 conop4 conpack conpack_params \
	conran conran_family conran_family_params conraq conras conrec \
	conrec_family conrec_family_params conrecqck conrecquick conrecsmooth \
	conrecspr conrecsuper cpback cpchcf cpchcl cpchhl cpchil cpchll cpcica \
	cpclam cpcldm cpcldr cpcltr cpcnrc cpdrpl cpezct cpfx cpfy cpgetc cpgeti \
	cpgetr cplbam cplbdr cpmpxy cppkcl cppklb cprect cprset cpscae cpsetc \
	cpseti cpsetr cpsprs cpsps1 cpsps2 cpux cpuy csa1s csa1xs csa2ls \
	csa2lxs csa2s csa2xs csa3ls csa3lxs csa3s csa3xs csagrid csagrid_errors \
	cufx cufy curv1 curv2 curvd curve curve3 curved curvi curvp1 curvp2 \
	curvpi curvps curvs dandr dashchar dashdb dashdc dashline \
	dashline_params dashpack dashpack_params dashsmth dashsupr displa \
	dpcurv dpdraw dpfrst dpgetc dpgeti dpgetr dplast dpline dpsetc dpseti \
	dpsetr dpsmth dpvect dsgetc dsgeti dsgetr dsgetrd dsgrid dsgrid2d \
	dsgrid2s dsgrid3d dsgrid3s dsgrid_errors dsgrid_params dspnt2d dspnt2s \
	dspnt3d dspnt3s dssetc dsseti dssetr dssetrd entsr eprin errof \
	error_handling ezcntr ezhftn ezisos ezmap ezmap_params ezmapa ezmxy \
	ezmy ezsrfc ezstrm ezvec ezxy ezy fdum fence3 fitgrid fitgrid_params \
	fl2int frame frst3 frstd frstpt ftitle fx fy gaccum_tran_matrix gacolr \
	gactivate_ws gactm gacwk gagetc gageti gagetr gasetc gaseti gasetr gca \
	gcell_array gclear_ws gclks gclose_gks gclose_seg gclose_ws gclrwk gclsg \
	gclwk gcopy_seg_ws gcreate_seg gcrsg gcsgwk gdawk gdeactivate_ws \
	gdel_seg gdsg gesc gescape getset getsi getusv geval_tran_matrix \
	gevtm gfa gfill_area gflas1 gflas2 gflas3 gflas4 gflash ginq_asfs \
	ginq_char_expan ginq_char_ht ginq_char_space ginq_char_up_vec ginq_clip \
	ginq_colr_rep ginq_cur_norm_tran_num ginq_fill_colr_ind \
	ginq_fill_int_style ginq_fill_style_ind ginq_line_colr_ind ginq_linetype \
	ginq_linewidth ginq_marker_colr_ind ginq_marker_size ginq_marker_type \
	ginq_max_norm_tran_num ginq_name_open_seg ginq_norm_tran ginq_op_st \
	ginq_set_seg_names ginq_text_align ginq_text_colr_ind \
	ginq_text_font_prec ginq_text_path gks gopen_gks gopen_ws gopks gopwk \
	gpl gpm gpolyline gpolymarker gqasf gqchh gqchsp gqchup gqchxp gqclip \
	gqcntn gqcr gqfaci gqfais gqfasi gqln gqlwsc gqmk gqmksc gqmntn gqnt \
	gqops gqopsg gqplci gqpmci gqsgus gqtxal gqtxci gqtxfp gqtxp grid gridal \
	gridall gridall_params gridl gsasf gschh gschsp gschup gschxp gsclip \
	gscr gsel_norm_tran gselnt gset_asfs gset_char_expan gset_char_ht \
	gset_char_space gset_char_up_vec gset_clip_ind gset_colr_rep \
	gset_fill_colr_ind gset_fill_int_style gset_fill_style_ind \
	gset_line_colr_ind gset_linetype gset_linewidth gset_marker_colr_ind \
	gset_marker_size gset_marker_type gset_seg_tran gset_text_align \
	gset_text_colr_ind gset_text_font_prec gset_text_path gset_vp gset_win \
	gsfaci gsfais gsfasi gsln gslwsc gsmk gsmksc gsplci gspmci gssgt gstxal \
	gstxci gstxfp gstxp gsvp gswn gtext gtx gupd_ws guwk hafton halfax \
	halftone histgr histogram histogram_params hlsrgb hstopc hstopi hstopl \
	hstopr hsvrgb icfell icloem idbvip idgeti idgetr idpltr idseti idsetr \
	idsfft init3d isgeti isgetr isosrf isosrfhr isosurface isosurface_params \
	isseti issetr kfmx kfmy kfpx kfpy kmpx kmpy kpmx kpmy kumx kumy kupx \
	kupy kurv1 kurv2 kurvd kurvp1 kurvp2 kurvpd labelbar labelbar_params \
	labmod lastd lbfill lbgeti lbgetr lblbar lbseti lbsetr line line3 lined \
	mapaci mapbla mapblm mapdrw mapeod mapfst mapgci mapgrd mapgrm mapgtc \
	mapgti mapgtl mapgtr mapint mapiq mapiqa mapiqd mapiqm mapit mapita \
	mapitd mapitm maplbl maplmb maplot mappos maproj maprs maprst mapsav \
	mapset mapstc mapsti mapstl mapstr maptra maptri maptrn mapusr mapvec \
	mpchln mpfnme mpgetc mpgeti mpgetl mpgetr mpglty mpiaty mpifnb mpilnb \
	mpiola mpiosa mpipai mpipan mpipar mpisci mplnam mplndm mplndr mplnri \
	mpname mprset mpsetc mpseti mpsetl mpsetr mxmy natgrid natgrid_errors \
	natgrid_params natgridd natgrids ncarg_cbind ncarg_gks ncarg_gks_cbind \
	nerro ngckop ngdots nggcog nggetc nggeti nggetr nggsog ngmftc ngmisc \
	ngmisc_params ngpict ngpswk ngreop ngritd ngsetc ngseti ngsetr ngsrat \
	ngwsym nngetaspectd nngetaspects nngetc nngeti nngetr nngetrd \
	nngetsloped nngetslopes nnpntd nnpntend nnpntendd nnpntinitd nnpntinits \
	nnpnts nnsetc nnseti nnsetr nnsetrd opngks pcdlsc pcgetc pcgeti pcgetr \
	pchiqu pcloqu pcmequ pcmpxy pcpnwi pcrset pcsetc pcseti pcsetr perim \
	perim3 periml plchhq plchlq plchmq plotchar plotchar_params plotif \
	plotit point point3 points polypack ppdipo ppditr ppinpo ppintr ppplcl \
	ppppap ppunpo ppuntr psym3 pwrit pwrite_family pwritx pwrity pwrz pwrzi \
	pwrzs pwrzt reset retsr rgbhls rgbhsv rgbyiq scrolled_title \
	scrolled_title_params semess set set3 seter seti setr setusv sfgetc \
	sfgeti sfgetp sfgetr sflush sfnorm sfsetc sfseti sfsetp sfsetr sfsgfa \
	sfwrld slgeti slgetr slogap slrset slseti slsetr softfill \
	softfill_params spps spps_converters spps_params srface stgeti stgetr \
	stinit stitle stream streamlines streamlines_params strmln strset stseti \
	stsetr stuixy stumsl stumta stumxy supcon supmap surf1 surf2 surface \
	surface_params tdclrs tddtri tdez2d tdez3d tdgeti tdgetr tdgrds tdgrid \
	tdgtrs tdinit tditri tdlbla tdlbls tdline tdlnpa tdmtri tdotri tdpack \
	tdpack_params tdpara tdplch tdprpa tdprpi tdprpt tdseti tdsetr tdsort \
	tdstri tdstrs threed tick3 tick4 tick43 ticks vect3 vectd vector vectors \
	vectors_params velvct velvec vvectr vvgetc vvgeti vvgetr vvinit vvrset \
	vvsetc vvseti vvsetr vvudmv vvumxy wmap wmap_params wmbarb wmdflt wmdrft \
	wmdrrg wmgetc wmgeti wmgetr wmlabc wmlabs wmlabt wmlabw wmlgnd wmsetc \
	wmseti wmsetr wmstnm wtstr yiqrgb)

set man5s =	(fontcap graphcap ncarv_spool ras_formats ras_palette ncarg_env \
	ncargintro)

set man8s =	(ncargmv ncargtar)

set manls =	($man1s $man3s $man5s $man8s)


while ($#argv) 
	switch ("$argv[1]")
	case -bin:

		shift
		set bindir = $argv[1];
		breaksw

	case -inc:

		shift
		set incdir = $argv[1];
		breaksw

	case -lib:

		shift
		set libdir = $argv[1];
		breaksw

	case -man1:

		shift
		set man1dir = $argv[1];
		breaksw

	case -man3:

		shift
		set man3dir = $argv[1];
		breaksw

	case -man5:

		shift
		set man5dir = $argv[1];
		breaksw

	case -man8:

		shift
		set man8dir = $argv[1];
		breaksw

	case -manl:

		shift
		set manldir = $argv[1];
		breaksw

	default:
		echo "Invalid option <$argv[1]>"
		echo "Usage: $0 <version> [-bin <bindir>] [-inc <incdir> [-man[1,3,5,8,l] <mandir>] [-lib <libdir>]"
		exit 1

	endsw

	shift
end


if ($?bindir) then
	foreach file ($bins)
		if (-e "$bindir/$file.$version") then
			/bin/rm -r $bindir/$file.$version
			/bin/rm -r $bindir/$file
		endif
	end
endif

if ($?incdir) then
	foreach file ($incs)
		if (-e "$incdir/$file.$version") then
			/bin/rm -r $incdir/$file.$version
			/bin/rm -r $incdir/$file
		endif
	end
endif

if ($?libdir) then
	foreach file ($libs)
		if (-e "$libdir/$file.$version") then
			/bin/rm -r $libdir/$file.$version
			/bin/rm -r $libdir/$file
		endif
	end
endif

if ($?man1dir) then
	foreach file ($man1s)
		if (-e "$man1dir/$file.1.$version") then
			/bin/rm -r $man1dir/$file.1.$version
			/bin/rm -r $man1dir/$file.1
		endif
	end
endif

if ($?man3dir) then
	foreach file ($man3s)
		if (-e "$man3dir/$file.3.$version") then
			/bin/rm -r $man3dir/$file.3.$version
			/bin/rm -r $man3dir/$file.3
		endif
	end
endif

if ($?man5dir) then
	foreach file ($man5s)
		if (-e "$man5dir/$file.5.$version") then
			/bin/rm -r $man5dir/$file.5.$version
			/bin/rm -r $man5dir/$file.5
		endif
	end
endif

if ($?man8dir) then
	foreach file ($man8s)
		if (-e "$man8dir/$file.8.$version") then
			/bin/rm -r $man8dir/$file.8.$version
			/bin/rm -r $man8dir/$file.8
		endif
	end
endif

if ($?manldir) then
	foreach file ($manls)
		if (-e "$manldir/$file.l.$version") then
			/bin/rm -r $manldir/$file.l.$version
			/bin/rm -r $manldir/$file.l
		endif
	end
endif


exit 0
