1use ExtUtils::MakeMaker;
2require ExtUtils::Install;
3
4BEGIN {
5	eval {
6		require FindBin;
7		chdir $FindBin::RealBin;
8	};
9}
10
11use Config;
12
13use File::Copy;
14use File::Path;
15use File::Basename;
16use File::Find;
17use Data::Dumper;
18use Cwd;
19require 5.6.0;
20
21use strict;
22
23use vars (qw($VERSION $DOWARN));
24
25my $TermRead;
26my $Prompt_sub;
27my @mods_to_get;
28my @remove_old;
29my $Lock_troubles;
30
31$VERSION = '5.6.3';
32
33my @os_hints;
34eval {
35	# gets package 'mvhints'
36	require 'hints.pl';
37	@os_hints = mvhints::get_hints();
38};
39
40my @chown_files = qw/
41						error.log
42						etc
43					/;
44
45# Now we can use the libraries
46use lib './lib';
47
48
49my $origdir = cwd();
50
51# See if we have Term::ReadLine::Perl
52eval {
53		require Term::ReadLine;
54		require Term::ReadLine::Perl;
55		require Term::ReadKey;
56		$TermRead = 1;
57};
58unless($@) {
59	$ENV{PERL_RL} = 'Perl';
60}
61
62my $term;
63if($TermRead) {
64	eval {
65		$term = new Term::ReadLine 'MakeFile';
66	};
67
68	! $@ and $Prompt_sub = sub {
69		my($prompt, $default) = @_;
70		$prompt .= "[$default] "
71			if defined $default && !$ENV{PERL_RL};
72		return $term->readline($prompt, $default);
73	};
74}
75
76sub compare_file {
77	my($first,$second) = @_;
78	return 0 unless -s $first == -s $second;
79	local $/;
80	open(FIRST, $first) or return undef;
81	open(SECOND, $second) or (close FIRST and return undef);
82	binmode(FIRST);
83	binmode(SECOND);
84	$first = '';
85	$second = '';
86	while($first eq $second) {
87		read(FIRST, $first, 1024);
88		read(SECOND, $second, 1024);
89		last if length($first) < 1024;
90	}
91	close FIRST;
92	close SECOND;
93	$first eq $second;
94}
95
96sub get_rename {
97	my ($bn, $extra) = @_;
98	$bn =~ s:(.*/)::;
99	my $dn = $1;
100	$extra = '~' if ! $extra;
101	return $dn . "/.$extra." . $bn;
102}
103
104sub install_file {
105	my ($srcdir, $targdir, $filename) = @_;
106	my $srcfile  = $srcdir . '/' . $filename;
107	my $targfile = $targdir . '/' . $filename;
108	my $mkdir = File::Basename::dirname($targfile);
109	my $extra;
110	my $perms;
111
112	if(! -d $mkdir) {
113		File::Path::mkpath($mkdir)
114			or die "Couldn't make directory $mkdir: $!\n";
115	}
116
117	if (! -f $srcfile) {
118		die "Source file $srcfile missing.\n";
119	}
120	else {
121		$perms = (stat(_))[2] & 0777;
122	}
123
124	if( -f $targfile and ! compare_file($srcfile, $targfile) ) {
125		open (GETVER, $targfile)
126			or die "Couldn't read $targfile for version update: $!\n";
127		while(<GETVER>) {
128			/VERSION\s+=.*?\s+([\d.]+)/ or next;
129			$extra = $1;
130			$extra =~ tr/0-9//cd;
131			last;
132		}
133		$extra = '~' unless $extra;
134		my $rename = get_rename($targfile, $extra);
135		while (-f $rename ) {
136			push @remove_old, $rename;
137			$extra .= '~';
138			$rename = get_rename($targfile, $extra);
139		}
140		push @remove_old, $rename;
141		rename $targfile, $rename
142			or die "Couldn't rename $targfile to $rename: $!\n";
143	}
144
145	File::Copy::copy($srcfile, $targfile)
146		or die "Copy of $srcfile to $targfile failed: $!\n";
147	chmod $perms, $targfile;
148
149}
150
151sub copyright_prompt {
152
153	print <<EOF;
154
155 Interchange V$VERSION
156 
157 Copyright (C) 2002-2010 Interchange Development Group.
158 Copyright (C) 1996-2002 Red Hat, Inc.
159 Interchange is free under the terms of the GNU General Public License.
160
161 http://www.icdevgroup.org/
162
163EOF
164}
165
166sub my_prompt {
167    return $_[1] if $MV::Default{force};
168    return &$Prompt_sub(@_)
169        if defined $Prompt_sub;
170    my($pr) = shift || '? ';
171    my($def) = shift;
172    my($ans);
173
174    print $pr;
175    print "[$def] " if $def;
176    chomp($ans = <STDIN>);
177    $ans ? $ans : $def;
178}
179
180
181sub extra_libs {
182	my ($realdir) = @_;
183
184	eval {
185		require Storable;
186	};
187	unless ($@) {
188		my $def = 's';
189        print <<EOF if $MV::Default{storable};
190
191You appear to have Raphael Manfredi's Storable module installed.
192This module will significantly improve your DBM storage and fetch times.
193
194You can reply one of:
195
196	n -- Don't use Storable
197	s -- Use for sessions only, won't break existing databases
198	y -- Use for both sessions and databases
199
200It is recommended that all installations reply S unless there is a need for
201improved performance in Interchange DBM databases.
202
203If you reply YES and you use any GDBM or DB_File databases they will
204NEED TO BE REMADE for ALL CATALOGS using this Interchange server instance.
205EOF
206
207		if($ENV{MINIVEND_STORABLE_DB} || -f "$realdir/_db_storable" || -f "_db_storable") {
208			$def = 'y';
209		}
210		elsif($ENV{MINIVEND_STORABLE} || -f "$realdir/_session_storable" || -f "_session_storable") {
211			$def = 's';
212		}
213		my $ask;
214		$ask = $def;
215		$ask = my_prompt("Use Storable module? (y/n/s) ", $def)
216			if $MV::Default{storable};
217		if ($ask =~ /^\s*(y|d)/i) {
218			open(TSTORABLE, ">_db_storable")
219				or die "creat _db_storable: $!\n";
220			print TSTORABLE "REMOVE THIS FILE TO STOP USING Storable\n";
221			close TSTORABLE;
222		}
223		if ($ask =~ /^\s*(y|s)/i) {
224			open(TSTORABLE, ">_session_storable")
225				or die "creat _session_storable: $!\n";
226			print TSTORABLE "REMOVE THIS FILE TO STOP USING Storable\n";
227			close TSTORABLE;
228		}
229	}
230	return;
231}
232
233sub mk_initp {
234	my ($ref) = @_;
235	local($Data::Dumper::Terse);
236	$Data::Dumper::Terse = 1;
237	open (INITP, ">scripts/initp.pl")
238		or die "Can't write initp.pl: $!\n";
239	print INITP '$MV::Self = ';
240	print INITP Dumper($ref);
241	print INITP ";\n1;";
242	close INITP;
243}
244
245sub initialize {
246#warn "Got to initialize\n";
247	my @scripts = map { "scripts/$_" } qw(
248		compile_link
249		config_prog
250		configdump
251		crontab
252		expire
253		expireall
254		findtags
255		ic_mod_perl
256		interchange
257		localize
258		makecat
259		offline
260		restart
261		update
262	);
263	my %X;
264	$X{INSTALLDIRS}	= "perl";
265	$X{EXE_FILES}	= [ @scripts ];
266	$X{PL_FILES}	= { 'relocate.pl' => [ @scripts ] };
267
268	$MV::Default{LSB} ||= $MV::Default{RPM};
269
270	if(! $MV::Default{force} and ! $MV::Default{PREFIX}) {
271		if($> == 0) {
272			$MV::Default{PREFIX} = '/usr/local/interchange';
273		}
274		else {
275			$MV::Default{PREFIX} = "$ENV{HOME}/interchange";
276		}
277	}
278	if($MV::Default{LSB}) {
279		if($> != 0) {
280			die "Cannot install LSB (RPM-style) unless root.\n";
281		}
282		unlink '_uid';
283		$MV::Default{PREFIX} = '/usr/lib/interchange';
284		$MV::Default{INTERCHANGE_USER} = 'interch';
285	}
286
287	if($MV::Default{rpmbuilddir} or $MV::Default{RPMBUILDDIR}) {
288		$X{RPMBUILDDIR} = $MV::Default{rpmbuilddir} || $MV::Default{RPMBUILDDIR};
289		$MV::Default{RPMBUILDDIR} = $X{RPMBUILDDIR};
290	}
291
292	return \%X if $MV::Default{nocopy};
293
294    my $uid = $MV::Default{INTERCHANGE_USER};
295    if(-f "_uid") {
296        open UID, '_uid'
297            or die "Cannot read _uid file: $!\n";
298        chomp($uid = <UID>);
299        close UID;
300    }
301
302	$Global::TryingThreads	=  $Config{usethreads}
303							|| $Config{useithreads}
304							|| $Config{use5005threads};
305
306	if($Global::TryingThreads and $] < 5.008_008 and ! -f '_allow_threads') {
307		print <<EOF;
308It is not recommended that you run Interchange with a thread-enabled perl,
309which you have called this installer with. Either rerun with 
310
311	/path/to/non-threaded/perl Makefile.PL
312
313or accept the possible problems that come with running on an experimental
314software system.
315EOF
316
317		my $ans = my_prompt("Do you want to try running with threads? ", 'n');
318		exit if $ans !~ /^\s*y/i;
319        open(THR, ">_allow_threads")
320            or die "Can't write allow threads file: $!\n";
321        print THR "I agree not to hold anyone but myself responsible for the results of running an experimental system.\n";
322        close THR;
323	}
324
325#warn "Got past open UID file , uid=$uid user=$>\n";
326
327	GETUID: {
328		if($> == 0 and ! $MV::Default{INTERCHANGE_USER}) {
329			$uid = my_prompt(
330				qq{Interchange cannot be run as root. Which user should run Interchange? },
331				($uid || 'interch'),
332			);
333			my $name = getpwnam($uid);
334			if(! $name) {
335				my $ans = my_prompt("User name $uid doesn't exist. Use anyway? ", 'n');
336				last GETUID if $ans =~ /^\s*y/i;
337				redo GETUID;
338			}
339		}
340		elsif ($uid = $MV::Default{INTERCHANGE_USER}) {
341			# do nothing
342		}
343		else {
344			eval {
345				$uid = scalar getpwuid($>);
346			};
347		}
348	}
349#warn "Got past GETUID\n" ; #if $X{RPMBUILDDIR};
350    if($uid) {
351        open(UID, ">_uid")
352            or die "Can't write uid file: $!\n";
353        print UID "$uid";
354        close UID;
355    }
356
357	for(@Config{
358				  qw/
359					  archlib
360					  archlibexp
361					  privlib
362					  privlibexp
363					  sitearch
364					  sitearchexp
365					  sitelib
366					  sitelibexp
367				  /
368		})
369	{
370		die "Can't install in Perl library!\n" if $MV::Default{PREFIX} eq $_;
371	}
372
373	my $realdir;
374
375	$origdir =~ s:[\\/]\s*$::;
376	$origdir =~ s:^\s*::;
377
378	if(! $MV::Default{final}) {
379		&copyright_prompt();
380
381		# don't suggest install target same as software source directory
382		$MV::Default{PREFIX} = '' if
383			$MV::Default{PREFIX} eq $origdir;
384
385		PROMPTDIR: {
386			if($MV::Default{LSB}) {
387				$realdir = $MV::Default{PREFIX};
388			}
389			else {
390				$realdir = my_prompt(
391									"Where is your Interchange to be installed? ",
392									$MV::Default{PREFIX},
393									);
394				$realdir =~ s:[\\/]\s*$::;
395				$realdir =~ s:^\s*::;
396				if ($realdir eq $origdir) {
397					warn "Can't install in software source directory!\n";
398					redo;
399				}
400			}
401			print "\n";
402		}
403	}
404	else {
405		$MV::Default{final} =~ s:[\\/]\s*$::;
406		$MV::Default{final} =~ s:^\s*::;
407		$realdir = $MV::Default{final};
408	}
409
410	die "Can't install in software source directory!\n" if
411		! $MV::Default{force} && $realdir eq $origdir;
412
413#warn "Got past realdir prompt\n" ; #if $X{RPMBUILDDIR};
414
415	$X{INSTALLSCRIPT}	= "$realdir/bin";
416	$X{INSTALLBIN}		= "$realdir/bin";
417	$X{INSTALLARCHLIB}	= "$realdir";
418	$X{INSTALLPRIVLIB}	= "$realdir/lib";
419	if(! $MV::Default{final}) {
420		$X{INSTALLMAN1DIR}	= "$realdir/man"
421			if ! $MV::Default{INSTALLMAN1DIR};
422		$X{INSTALLMAN3DIR}	= "$realdir/man"
423			if ! $MV::Default{INSTALLMAN3DIR};
424	}
425
426	my @re_link = qw();
427	my @re_dir  = qw();
428	my @re_copy = qw();
429
430	my $upgrade;
431	if($MV::Default{final}) {
432		$^W = 0;
433		for(glob "_*") {
434			File::Copy::copy($_, $realdir);
435		}
436		open(MANI, "MANIFEST")
437			or die "No MANIFEST?\n";
438		my (@files) = <MANI>;
439		close MANI;
440
441#warn "Got past open MANIFEST\n" ; #if $X{RPMBUILDDIR};
442
443		# install share/ files from MANIFEST
444		chomp(my @sharefiles = grep m:^share/:, @files);
445		install_file('.', $realdir, $_) for @sharefiles;
446		# install code/ files from MANIFEST
447		chomp(my @codefiles = grep m:^code/:, @files);
448		install_file('.', $realdir, $_) for @codefiles;
449		# create symbolic links for images used for
450		# other languages either not yet translated
451		# or without embedded text
452		my @imgfiles = grep m:^share/interchange-5/en_US/:, @sharefiles;
453		my @loc;
454		@loc = map { s:.*/::; s/\.cfg$//; $_ } glob('dist/lib/UI/locales/*_*.cfg');
455		my $cwd = cwd();
456		my ($locale, $imgfile, $fname);
457		chdir("$realdir/share/interchange-5")
458			|| die "Couldn't enter directory $realdir/share/interchange-5: $!\n";
459
460		for $locale (@loc) {
461			unless (-d $locale) {
462				mkdir ($locale, 0777)
463					|| die "Couldn't create directory $realdir/share/interchange-5/$locale: $!\n";
464			}
465			for $imgfile (@imgfiles) {
466				$fname = basename($imgfile);
467				next if -f "$locale/$fname";
468				symlink ("../en_US/$fname", "$locale/$fname")
469					|| die "Couldn't create symlink $realdir/share/interchange-5/$locale/$fname: $!\n";
470			}
471		}
472		chdir($cwd)
473			|| die "Couldn't enter directory $cwd: $!\n";
474
475#warn "Got past install SHAREFILES\n" ; #if $X{RPMBUILDDIR};
476
477		# install dist/ files from MANIFEST
478		print "Installing dist/ files\n";
479		@files = grep m:^dist/:, @files;
480		chomp(@files);
481		@files = map { s:^dist/::; $_} @files;
482
483		# New install_file routine
484		chdir 'dist';
485		for (@re_dir) {
486			mkdir $_, 0777
487				or @re_copy = ();
488		}
489		while ($_ = shift @re_copy ) {
490			my $from = $_;
491			my $to = shift @re_copy;
492			push @files, $to;
493			File::Copy::copy($from, $to);
494		}
495		for (@files) {
496			$upgrade ||= -f "$realdir/$_";
497			install_file('.', $realdir, $_);
498		}
499		chdir '..';
500
501#warn "Got past install all files\n" ; #if $X{RPMBUILDDIR};
502
503		for(@os_hints) {
504			my ($condition, $routine) = @$_;
505			unless (ref($condition) =~ /CODE/ and ref($routine) =~ /CODE/) {
506				warn <<EOF;
507OS hint condititon and routine must be code reference, is
508
509	condition: $condition
510	routine:   $routine
511
512Skipping.
513EOF
514				next;
515			}
516			next unless $condition->();
517			my $odir = cwd();
518			chdir $realdir
519				or die "Cannot chdir to $realdir: $!\n";
520			$routine->();
521
522		}
523		while ($_ = shift @re_link ) {
524			my $from = $_;
525			my $to = shift @re_link;
526			push @files, $to;
527			my $odir = cwd();
528			chdir $realdir
529				or die "Cannot chdir to $realdir: $!\n";
530			eval {
531				symlink($from, $to);
532			};
533			chdir $odir;
534		}
535		if(-f "$realdir/_uid" and $> == 0) {
536			open(UID, "$realdir/_uid")
537				or die "Can't open uid file: $!\n";
538			my $uid = <UID>;
539			close UID;
540			$MV::Default{INTERCHANGE_UID} = getpwnam($uid);
541			$MV::Default{INTERCHANGE_GID} = getgrnam($uid);
542			for(@chown_files) {
543				chown	$MV::Default{INTERCHANGE_UID},
544						$MV::Default{INTERCHANGE_GID},
545						"$realdir/$_";
546			}
547		}
548
549		ALLOWTHREADS: {
550			unlink "$realdir/_allow_threads";
551			last ALLOWTHREADS unless $Global::TryingThreads;
552			open(THR, ">$realdir/_allow_threads")
553				or die "Can't write allow threads file: $!\n";
554			print THR "I agree not to hold anyone but myself responsible for the results of running an experimental system.\n";
555			close THR;
556		}
557
558		if($MV::Default{LSB}) {
559			my $d = cwd();
560			print "Doing LSB install...\n";
561			do './install_lsb.pl';
562			print "Done with LSB install.\n";
563		}
564
565		if(@remove_old) {
566			if($MV::Default{UNLINK}) {
567				print "Removing old files....";
568				my $odir = cwd();
569				chdir $realdir
570					or die "Cannot chdir to $realdir: $!\n";
571print "Changed dir to realdir=$realdir.\n";
572				unlink @remove_old;
573				print "done.\n";
574				chdir $odir
575					or die "Cannot chdir to $odir: $!\n";
576print "Changed dir to odir=$odir.\n";
577			}
578			else {
579				my $msg = <<EOF;
580The following old files were found, different from the installed versions.
581You should check and remove them at the earliest opportunity.
582
583EOF
584				$msg .= join "\n\t", '', @remove_old;
585				$msg .= <<EOF;
586
587
588If you have not modified any Interchange usertags, software programs, or
589libraries, it is usually safe to remove them, but you might copy them somewhere
590just in case you forgot something you changed.
591EOF
592				print $msg;
593			}
594		}
595
596		chdir '..';
597
598		print <<EOF;
599
600Your Interchange main software installation appears to have been successful.
601EOF
602		FINCHECK: {
603			@mods_to_get = ();
604			eval {
605					require Digest::MD5;
606				};
607			push(@mods_to_get, 'Digest::MD5') if $@;
608			eval {
609					require Safe::Hole;
610				};
611			push(@mods_to_get, 'Safe::Hole') if $@;
612			eval {
613					require MIME::Base64;
614				};
615			push(@mods_to_get, 'MIME::Base64') if $@;
616			eval {
617					require Storable;
618				};
619			push(@mods_to_get, 'Storable') if $@;
620			eval {
621					require URI::URL;
622				};
623			push(@mods_to_get, 'URI::URL') if $@;
624			eval {
625					require Set::Crontab;
626				};
627			push(@mods_to_get, 'Set::Crontab') if $@;
628		}
629		if(@mods_to_get) {
630			my $mods = join "\n\t", @mods_to_get;
631
632			if ($MV::Default{nocpaninstall}) {
633				print <<EOF;
634You do not appear to have all the required modules installed. You are missing:
635
636	$mods
637
638Please run src/cpan_local_install to install them.
639EOF
640  				exit ($MV::Default{force} ? 0 : 1);
641			} else {
642				print <<EOF;
643You do not appear to have all the required modules installed. You are missing:
644
645	$mods
646
647Trying to install now.
648EOF
649			}
650
651			chdir $realdir
652				or die "Couldn't change directory to $realdir: $!\n";
653			system $^X, 'src/cpan_local_install';
654			eval {
655				require Storable;
656				open JUNK, ">_session_storable"
657					and close JUNK;
658			};
659			eval {
660				require Business::UPS;
661			};
662			if($@) {
663				print "Retrying a couple of modules, just a sec...\n\n";
664				require HTML::Tagset
665					or
666					system $^X, 'src/cpan_local_install', '-c', 'HTML::Tagset';
667				require HTML::Parser
668					or
669					system $^X, 'src/cpan_local_install', '-c', 'HTML::Parser';
670				system $^X, 'src/cpan_local_install', '-c', 'LWP::Simple';
671				system $^X, 'src/cpan_local_install', '-c', 'Business::UPS';
672			}
673			system $^X, 'src/cpan_local_install', '-c';
674		}
675		if($upgrade) {
676		print <<EOF;
677
678Since this was an update, you are now ready to restart and ensure
679your catalogs run as expected. You do NOT need to re-run makecat,
680though you can always do that to make a new catalog. Never run
681makecat on an existing catalog.
682
683EOF
684		}
685		else {
686		print <<EOF;
687
688You are now ready to cd to $realdir and run 'bin/makecat'
689to set up your first catalog.
690
691EOF
692		}
693		exit;
694
695	}
696
697	# Check for extra needed libraries
698	extra_libs($realdir);
699
700	mk_initp(\%X);
701	delete $X{RPMBUILDDIR};
702    return \%X;
703}
704
705sub regularize {
706	for (@_) {
707		s/[\\]\n//g;
708		s/\n\s+/ /g;
709		s/\s+$//g;
710	}
711	wantarray ? @_ : $_[0];
712}
713
714sub MY::install {
715
716	my $self = shift;
717	local *install;
718	sub dont_warn {
719		\*install;
720	}
721
722	my $uidparm;
723
724	if (-f "_uid") {
725		if (open UID, '_uid') {
726			chomp (my $uid = <UID>);
727			close UID;
728			$uidparm = "INTERCHANGE_USER=$uid";
729		}
730	}
731
732	my @args = (
733			'force',
734			'nocpaninstall=$(NOCPANINSTALL)',
735		);
736	my @extra_args = ( qw/INTERCHANGE_USER LSB RPM UNLINK/ );
737	for(@extra_args) {
738		next unless $MV::Default{$_};
739		push @args, "$_=$MV::Default{$_}";
740	}
741	push @args, 'final=$(DESTDIR)$(INSTALLARCHLIB)';
742
743	my $argstring = join " ", @args;
744
745	my $new = <<EOF;
746VERBINST=0
747
748mv_install ::
749			\$(PERL) Makefile.PL $argstring
750
751install :: all pure_install mv_install
752
753EOF
754	$new .= <<EOF;
755rpm_move ::
756		\$(PERL) Makefile.PL force=1 rpmbuilddir=$MV::Default{RPMBUILDDIR} final=\$(INSTALLARCHLIB)
757
758rpm_build :: all pure_install rpm_move
759
760EOF
761	$_ = $self->MM::install;
762	s/\ninstall :.*/$new/;
763	$_;
764}
765
766sub MY::postamble {
767	return <<'EOF';
768UIDIR=dist/lib/UI
769UILCDIR=$(UIDIR)/locales
770UIMENUDIR=$(UIDIR)/pages/include/menus
771
772localefiles:
773	@for langfile in $(UILCDIR)/*_*.cfg; do \
774		lang=`basename $$langfile .cfg`; \
775		mv $$langfile $$langfile.old; \
776		cat $(UILCDIR)/default.cfg >> $$langfile.old; \
777		if ! $(INSTALLBIN)/localize -n -s -m $$langfile.old -u $(UIMENUDIR) -l $$lang `find $(UIDIR) -type f -not -empty -not -name '.#*'` > $$langfile; then \
778		echo "Failed to generate locale file $$langfile"; \
779		mv $$langfile.old $$langfile; \
780		fi; \
781	done
782EOF
783}
784
785my %mv_specific = qw/
786	FINAL            1
787	FORCE            1
788	INTERCHANGE_USER 1
789	LSB              1
790	PREFIX           1
791	RPM              1
792	RPMBUILDDIR      1
793	STORABLE         1
794	UNLINK           1
795/;
796my %delete;
797use Getopt::Long;
798my @saveargs = @ARGV;
799my %optctl = (
800	'junk'			=> sub { 1 },
801	'<>'			=> sub {
802							my ($arg) = @_;
803	#warn "checking option $arg\n";
804							my ($opt, $val);
805							if($arg !~ /=/) {
806								$opt = $arg;
807								$val = 1;
808							}
809							else {
810								($opt, $val) = split /=/, $arg, 2;
811							}
812
813							$delete{$arg} = 1 if $mv_specific{uc $opt};
814
815							$MV::Default{$opt} = $val;
816							return;
817						},
818);
819
820my @options = ( qw/
821	junk
822	<>
823/ );
824
825Getopt::Long::config(qw/permute/);
826GetOptions(\%optctl, @options)
827	or die "Bad option get\n";
828
829#use Data::Dumper;
830#$Data::Dumper::Terse = $Data::Dumper::Indent = 2;
831#print "ARGV: " . Dumper(\@ARGV);
832#print "OPT: " . Dumper(\%MV::Default);
833
834@ARGV = grep ! $delete{$_}, @saveargs;
835
836WriteMakefile(
837	NAME     => "Interchange",
838	DISTNAME => "interchange",
839	clean    => {
840				FILES => "lib/IniConf.pm _uid _db_storable _allow_threads _session_storable lib/File/CounterFile.pm scripts/initp.pl scripts/compile_link scripts/config_prog scripts/configdump scripts/expire scripts/localize scripts/expireall scripts/makecat scripts/ic_mod_perl scripts/interchange scripts/offline scripts/restart scripts/update",
841			   },
842
843	dist     => {
844					CI => "ci -l -t-Initial",
845					SUFFIX   => ".gz",
846					DIST_DEFAULT => 'all tardist',
847					COMPRESS => "gzip -9f",
848					ZIP_FLAGS => '-pr9',
849				},
850	VERSION_FROM => "scripts/interchange.PL",
851	EXE_FILES  => [],
852	CONFIGURE  => \&initialize,
853);
854