File: Makefile.PL

package info (click to toggle)
libhtml-embperl-perl 1.3.6-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,596 kB
  • ctags: 1,190
  • sloc: ansic: 8,985; perl: 4,584; makefile: 83
file content (1272 lines) | stat: -rw-r--r-- 34,479 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
#
# Building Makefile for Embperl
#
# (C) 1997-2001 G.Richter (richter@dev.ecos.de) / ECOS
#
# $Id: Makefile.PL,v 1.56 2002/03/12 05:05:16 richter Exp $
#


use ExtUtils::MakeMaker;
use Cwd qw {abs_path cwd} ;
use Config ;
use File::Basename ;
use Data::Dumper ;

$win32 = ($Config{osname} =~ /win32/i) ;
$aix = ($Config{osname} =~ /aix/i);
$dynlib = {};
print "\nRunning on Win 32\n" if ($win32) ;

$EP2 = -f "epcmd2.c" ; 

## ----------------------------------------------------------------------------



%neededmodules =
    ( 
      'mod_perl.c' => { name	    => 'perl_module', 
			path	    => ['$apache_src/modules/perl/libperl.so', '$EPBINDIR/modules/libperl.so', '$apache_src/mod_perl.so'],
			win32path   => ['$mpdll', '$mpdll/apachemoduleperl.dll', '$mpdll/mod_perl.so', '$EPBINDIR/modules/apachemoduleperl.dll', '$EPBINDIR/modules/mod_perl.so'],
			file	    => ['libperl.so', 'apachemoduleperl.dll', 'mod_perl.so'],
			filetext    => 'libperl.so or mod_perl.so',
			win32filetext   => 'ApacheModulePerl.dll or mod_perl.so',
		      },
      'mod_dir.c'  => { name	    => 'dir_module', 
			path	    => ['$apache_src/modules/standard/mod_dir.so', '$EPBINDIR/modules/mod_dir.so', '$apache_src/mod_dir.so'],
			win32path   => ['$apache_src/modules/standard/apachemoduledir.dll', '$EPBINDIR/modules/apachemoduledir.dll', '$EPBINDIR/modules/mod_dir.so'],
			file	    => ['mod_dir.so', 'apachemoduledir.dll'],
			win32filetext   => 'ApacheModuleDir.dll or mod_dir.so',
		      },

      'mod_env.c'  => { name	    => 'env_module', 
			path	    => ['$apache_src/modules/standard/mod_env.so', '$EPBINDIR/modules/mod_env.so', '$apache_src/mod_env.so'],
			win32path   => ['$apache_src/modules/standard/apachemoduleenv.dll', '$EPBINDIR/modules/apachemoduleenv.dll', '$EPBINDIR/modules/mod_env.so'],
			file	    => ['mod_env.so', 'apachemoduleenv.dll'],
			win32filetext   => 'ApacheModuleEnv.dll or mod_env.so',
		      },

      'mod_mime.c'  => { name	    => 'mime_module', 
			path	    => ['$apache_src/modules/standard/mod_mime.so', '$EPBINDIR/modules/mod_mime.so', '$apache_src/mod_mime.so'],
			win32path   => ['$apache_src/modules/standard/apachemodulemime.dll', '$EPBINDIR/modules/apachemodulemime.dll', '$EPBINDIR/modules/mod_mime.so'],
			file	    => ['mod_mime.so', 'apachemodulemime.dll'],
			win32filetext   => 'ApacheModuleMime.dll or mod_mime.so',
		      },

      'mod_alias.c'  => { name	    => 'alias_module', 
			path	    => ['$apache_src/modules/standard/mod_alias.so', '$EPBINDIR/modules/mod_alias.so', '$apache_src/mod_alias.so'],
			win32path   => ['$apache_src/modules/standard/apachemodulealias.dll', '$EPBINDIR/modules/apachemodulealias.dll', '$EPBINDIR/modules/mod_alias.so'],
			file	    => ['mod_alias.so', 'apachemodulealias.dll'],
			win32filetext   => 'ApacheModuleAlias.dll or mod_alias.so',
		      },

      'mod_cgi.c'  => { name	    => 'cgi_module', 
			path	    => ['$apache_src/modules/standard/mod_cgi.so', '$EPBINDIR/modules/mod_cgi.so', '$apache_src/mod_cgi.so'],
			win32path   => ['$apache_src/modules/standard/apachemodulecgi.dll', '$EPBINDIR/modules/apachemodulecgi.dll', '$EPBINDIR/modules/mod_cgi.so'],
			file	    => ['mod_cgi.so', 'apachemodulecgi.dll'],
			win32filetext   => 'ApacheModuleCgi.dll or mod_cgi.so',
		      },

      'mod_actions.c'  => { name	    => 'action_module', 
			path	    => ['$apache_src/modules/standard/mod_actions.so', '$EPBINDIR/modules/mod_actions.so', '$apache_src/mod_actions.so'],
			win32path   => ['$apache_src/modules/standard/apachemoduleactions.dll', '$EPBINDIR/modules/apachemoduleactions.dll', '$EPBINDIR/modules/mod_actions.so'],
			file	    => ['mod_actions.so','apachemoduleactions.dll'],
			win32filetext   => 'ApacheModuleActions.dll or mod_actions.so',
		      },


    ) ;




## ----------------------------------------------------------------------------


sub MY::test_via_harness 
	{
	my ($txt) = shift -> MM::test_via_harness (@_) ;
	$txt =~ s/PERL_DL_NONLAZY=1/PERL_DL_NONLAZY=0/ ;
	#$txt =~ s/\$\(FULLPERL\)/\$\(FULLPERL\) \-T / ;
	$txt =~ s/\$\(FULLPERL\)/SET PATH=\$\(PATH\)\;$EPENVPATH\n\t\$\(FULLPERL\)/ if ($win32) ;
	return $txt ;
	}

sub MY::test_via_script 
	{
	my ($txt) = shift -> MM::test_via_script (@_) ;
	$txt =~ s/PERL_DL_NONLAZY=1/PERL_DL_NONLAZY=0/ ;
	#$txt =~ s/\$\(FULLPERL\)/\$\(FULLPERL\) \-T / ;
	$txt =~ s/\$\(FULLPERL\)/SET PATH=\$\(PATH\)\;$EPENVPATH\n\t\$\(FULLPERL\)/ if ($win32) ;

	$txt =~ s/\$\(TEST_FILE\)/\$(TEST_FILE) \$(TESTARGS)/g ;

	return $txt ;
	}
	

sub MY::test

	{
	my ($txt) = shift -> MM::test (@_) ;


        $txt .= qq{

testdbinit : pure_all
\t\@echo set args -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) \$(TEST_FILE) \$(TESTARGS) > dbinitembperl

testdbbreak : pure_all
\t\@echo set args -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) \$(TEST_FILE) --dbgbreak \$(TESTARGS) > dbinitembperl
\t\@echo r >> dbinitembperl


testddd : testdbinit
\tPERL_DL_NONLAZY=0 ddd -x dbinitembperl \$(FULLPERL)  

testgdb : testdbinit
\tPERL_DL_NONLAZY=0 gdb -x dbinitembperl \$(FULLPERL)  

testdddb : testdbbreak
\tPERL_DL_NONLAZY=0 ddd -x dbinitembperl \$(FULLPERL)  

testgdbb : testdbbreak
\tPERL_DL_NONLAZY=0 gdb -x dbinitembperl \$(FULLPERL)  

start : pure_all
\tPERL_DL_NONLAZY=0 \$(FULLPERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) \$(TEST_FILE) --start -m \$(TESTARGS)

stop : pure_all
\tPERL_DL_NONLAZY=0 \$(FULLPERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) \$(TEST_FILE) --kill -m \$(TESTARGS)


} ;
	$txt =~ s/\tPERL_DL_NONLAZY=0 /\tSET PATH=\$\(PATH\)\;$EPENVPATH\n\t/g if ($win32) ;
        
        $txt =~ s/\@cd/\n#\t\@cd/ ;  # remove tests for subdirs

	$txt =~ s/\r\n/\n/g ;  # make doesn't like \r\n!

        
        return $txt ;
        }



sub MY::xs_c 
	{
	my ($txt) = shift -> MM::xs_c (@_) ;
	$txt =~ s/\&\&/\n\t/ if ($win32) ;
	return $txt ;
	}

sub MY::dist_test 
	{
	my $self = shift ;
        
        my $txt = $self -> MM::dist_test (@_) ;
	$txt =~ s/-I\$\(PERL_ARCHLIB\) -I\$\(PERL_LIB\)// ;
	$txt =~ s/\$\(PERL\)/\$\(PERLDT\)/ ;
	
        $main::perlbinpath = $self -> {FULLPERL} ;
        
        return $txt ;
	}
	
sub MY::dynamic 
	{
	my $self = shift ;
        
        my $txt = $self -> MM::dynamic (@_) ;

        $txt .= "\tcd crypto && \$(MAKE) SSL_BASE=$sslbase\n" if ($epc_enable) ;
        
        return $txt ;
	}

sub MY::c_o
	{
	my $self = shift ;
        
        my $txt = $self -> MM::c_o (@_) ;
        my $opt = $win32?'Fo':'o ' ;

        $txt =~ s/\$\*/-$opt\$*\$(OBJ_EXT) \$*/g ;
        my @txt = split (/\n/, $txt) ;
        my $cpp = 0 ;
        foreach (@txt)
            {
            if (/\$\*\.cpp/)
                {
                s/\$\(CCCMD\)/\$(CPPCMD) \$(CPPFLAGS)/ ;
                }
            }
        $txt = join ("\n", @txt) ;

        return $txt ;
	}



sub MY::cflags 
	{
	my $self = shift ;
        
        my $txt = $self -> MM::cflags (@_) ;
	$txt =~ s/CCFLAGS\s*=/CCFLAGS = $ccdebug / ;
        
        return $txt ;
	}

$MY::cccmd_seen = 0 ;
sub MY::const_cccmd 
	{
	my $self = shift ;
        
        my $txt = $self -> MM::const_cccmd (@_) ;
        return $txt if ($MY::cccmd_seen++) ;

	my $txt2 = $txt ;
        $txt2 =~ s/\$\(CC\)/\$(CPP)/ ;
        $txt2 =~ s/CCCMD/CPPCMD/ ;

        return "$txt\n\n$txt2"  ;
	}


	
 sub MY::post_initialize
        {
        my $self = shift ;

        # move docs to the right place
         
        my $pm = $self -> {PM} ;
        my $k ;
        my $v ;
        while (($k, $v) = each (%$pm))
            {
            if (($k =~ /\.pod$/) && !($k =~ /^Embperl/) )
                {
                $v =~ s#^(.*/)(.*?)\.pod$#$1Embperl/$2.pod# ;
                $pm -> {$k} = $v ;
                }
            }
                                 
        my $man = $self -> {MAN3PODS} ;
        while (($k, $v) = each (%$man))
            {
            if (!($v =~ /::Embperl/))
                {
                $v =~ s#HTML::#HTML::Embperl::# ;
                $man -> {$k} = $v ;
                }
            }

	# Debian cleanup hacks
	foreach my $hash (qw(MAN3PODS PM)) {
	  foreach (keys %{$self->{$hash}}) {
	    delete $self->{$hash}{$_}
	      if /^(INSTALL|NEWS|Changes)|\.pl$/;
	  }
	}

       $self -> MM::post_initialize (@_) ;
       }


 sub MY::libscan {
   my ($self, $path) = @_;

   # skip tla (arch) meta files
   return undef
     if $path =~ /^(?:\+\+pristine-trees|,,.*|{arch}|\.arch-ids)$/;

   $self->MM::libscan($path);
 }

 sub MY::post_constants
       {
       my $self = shift ;


       my $txt = $self -> MM::post_constants (@_) ;

       $txt .= "\n# Change name of dynamic lib, in case we need two of them (with and w/o Apache support)\nINST_DYNAMIC = \$(INST_ARCHAUTODIR)\\\$(DLBASE).NoApache.\$(DLEXT)\n" if ($EPNOAPACHELIB) ;

       return $txt ;

       }

## ----------------------------------------------------------------------------

sub GetString
	{
	my ($prompt, $default) = @_ ;

	printf ("%s [%s]", $prompt, $default) ;
	chomp ($_ = <STDIN>) ;
	s/\s+$//;
        if (!/^\s*$/)
	    {return $_ ;}
	else
    	{
        if ($_ eq "")
	        {return $default ;}
	    else
            { return "" ; }
    
        }
    }

## ----------------------------------------------------------------------------

sub GetYesNo
	{
	my ($prompt, $default) = @_ ;
	my ($value) ;

	do
	    {
	    $value = lc (GetString ($prompt . "(y/n)", ($default?"y":"n"))) ;
	    }
	until (($value cmp "j") == 0 || ($value cmp "y") == 0 || ($value cmp "n" ) == 0) ;

	return ($value cmp "n") != 0 ;
	}


## ----------------------------------------------------------------------------

sub search_config

    {
    my ($key, $path) = @_ ;


    open CFGFH, $path or return undef ;

    while (<CFGFH>)
        {
        return $1 if (/^$key\s*(?:=|\s)\s*(.*?)$/) ;
        }

    close CFGFH ;
    return undef ;
    }

## ----------------------------------------------------------------------------


sub cnvpath

    {
    my $path = shift ;
    
    $path =~ s/\//\\/g if ($win32) ;

    return $path ;
    }

## ----------------------------------------------------------------------------


sub cnvpath2unix

    {
    my $path = shift ;
    
    $path =~ s#\\#/#g if ($win32) ;

    return $path ;
    }

## ----------------------------------------------------------------------------


sub start

    {
    my ($cmd) = @_ ;


    $cmd =~ s/\//\\/g if ($win32) ;

    
    open STFH, "$cmd|" or die "\nCannot start $cmd\nPlease make sure you have build Apache and mod_perl before makeing Embperl\n" ;

    my @x = <STFH> or die "\nCannot start $cmd\nPlease make sure you have build Apache and mod_perl before makeing Embperl\n" ;

    close STFH ;
    return @x ;
    }


## ----------------------------------------------------------------------------


sub start_errcode

    {
    my ($cmd) = @_ ;


    $cmd =~ s/\//\\/g if ($win32) ;

    
    open STFH, "$cmd|" or return 1 ;

    my @x = <STFH> ;

    #print "@x" ;

    my $code = close STFH ;
    #print "Code = $code ; ? = $?\n" ;

    return $? ;
    }


## ----------------------------------------------------------------------------
#
# Check if required modules present
#


sub CheckModule

    {
    my ($mod, $text) = @_ ;

    eval "require $mod" ;
    if ($@)
        {
        print "$mod not installed on this system\n" ;
        print "$text\n" ;
        return undef ;
        }
    else
        {
        my $ver = ${"$mod\:\:VERSION"} ;
        print "Found $mod  Version $ver\n" ;
        return $ver ;
        }
    }
         


## ----------------------------------------------------------------------------
#
# Check if known config
#


$apache = 0 ;
$b = 0 ;

$optdebug = '' ;
$ccdebug = '' ;
$lddebug = '' ;
$libs    = '' ;
$d       = '' ;

if ($ARGV[0] eq 'debug')
    {
    shift @ARGV;
    $optdebug = '-g -O0' ;
    if ($win32)
        {
        $ccdebug = '-Zi -W3' ;
        $lddebug = '-debug -map -profile' ;
        }
    else
        {
        $ccdebug = '-ggdb -O0' ;
        $lddebug = '-g' ;
        }
    }

if ($ARGV[0] eq 'dmalloc')
    {
    shift @ARGV;
    if ($win32)
        {
        }
    else
        {
        $libs .= '-L/usr/local/lib -ldmalloc' ;
        $d    .= '-DDMALLOC' ;
        }
    }

if (defined ($ARGV[0]) && ($ARGV[0] =~ /^\W/))
    {
    $apache = 2 ;
    $b = 1 ;
    $apache_src = shift @ARGV ;
    }
elsif (defined ($ENV{APACHE_SRC}))
    {
    $apache = 2 ;
    $b = 1 ;
    $apache_src = $ENV{APACHE_SRC} ;
    $apache_src = '' if ($apache_src eq '-') ;
    }

if (!$apache && $apache_src eq '')
    {
    eval 'use Apache::MyConfig' ;

    if ($@ eq '')
        { 
        $apache_src = $Apache::MyConfig::Setup{Apache_Src} ; 
        }
    else
        {
        $apache_src = '' ;
        }
    }

eval 'do "test/conf/config.pl"' ;


if (!$apache && $apache_src eq '')
    {
    $apache_src = $EPAPACHESRC ;
    $loadmodules = $EPMODPERL ;
    }

$base = '..' ;
$base = $ENV{'ProgramFiles'} if ($win32) ;


$apache = GetYesNo ("Build with support for Apache mod_perl?", 'y') if (!$apache) ;

if ($apache && $apache_src ne '')
    {
    if ($apache_src =~ /^(.*?)\/$/)
   	{ $apache_src = $1 ; } 

    if ($apache_src =~ /^(.*?)\/main$/)
   	{ $apache_src = $1 ; } 

    if ($apache_src =~ /^(.*?)\/include$/)
   	{ $apache_src = $1 ; } 

    if (-e "$apache_src/httpd.h" || -e "$apache_src/main/httpd.h" || -e "$apache_src/include/httpd.h")
	    {
	    $b = GetYesNo ("Use $apache_src as Apache source", 'y') if (!$b) ;
	    }
    }

while ($apache && !$b)
    {
    print "Searching for Apache sources...\n" ;
    foreach $src_dir ($base,
		      "$base/src",
		      <$base/apache*/src>,
		      <$base\\apache*\\include>,
		      <$base\\apache*\\apache*\\include>,
		      <./src>)
       {
	print "Look at $src_dir\n" ;
	
	if (-e "$src_dir/httpd.h" || -e "$src_dir/main/httpd.h" || -e "$src_dir/include/httpd.h")
		{
		$b = GetYesNo ("Use $src_dir as Apache source", 'y') ;
		if ($b)
			{
			$apache_src = $src_dir ;
			last ;
			}
		}
	}		

    if ($apache_src =~ /^(.*?)\/$/)
   	{ $apache_src = $1 ; } 

    if ($apache_src =~ /^(.*?)\/main$/)
   	{ $apache_src = $1 ; } 

    if ($apache_src =~ /^(.*?)\/include$/)
   	{ $apache_src = $1 ; } 


    if (!$b)
    	{
    	$base = GetString ("Apache source not found, enter path name or q to quit", 'q') ;
    	if ($base eq 'q')
    		{
    		$apache = 0 ;
    		}
        else
            {
            $base =~ s/\//\\/g if ($win32) ;
            }    	
    	}
    }

if ($b && $apache && $apache_src ne '')
    {
    $apache_src = abs_path ($apache_src) ;

    print "Will use $apache_src for Apache Headers\n" ;

    #### look in which subdir the include files resides ####
    
    if (-e "$apache_src/httpd.h")
         {
         $inc_dir = $apache_src ;
         }
    elsif (-e "$apache_src/main/httpd.h")
         {
         $inc_dir = "$apache_src/main" ;
         }
    elsif (-e "$apache_src/include/httpd.h")
         {
         $inc_dir = "$apache_src/include" ;
         }
    elsif (-e "$ENV{APACHE_HDR}/httpd.h")
         {
         $inc_dir = "$ENV{APACHE_HDR}" ;
         }
        

    if ($win32)
	{ 
        $i = "-I. -I\"$inc_dir\" -I\"$apache_src/regex\" -I\"$apache_src/os/win32\"" ;
        
        foreach (
                    "$apache_src/libexec",
                    "$apache_src/../libexec",
                    "$apache_src/CoreD",
                    "$apache_src/CoreR",
                    "$apache_src/Debug",
                    "$apache_src/Release",
                    $EPHTTPDDLL)
            {
            if (-e "$_/ApacheCore.lib")
                {
                $EPHTTPDDLL = $_ ;
                $o = " \"$_/ApacheCore.lib\"" ;
                last ;
                }
            }

        if (!$o)
            {
            my $oo ;
            while (1)
                {
                $oo = GetString ("ApacheCore.lib not found, please enter path", $o) ;
                $oo .= '/ApacheCore.lib' if ($oo !~ /\.lib$/i) ;
                if (-e $oo)
                    {
                    $oo =~ s#\\#/#g ;
                    $oo =~ s#//#/#g ;
                    $EPHTTPDDLL = $1 if ($o =~ /^(.*)\//) ;
                    $o = " \"$oo\"" ;
                    last ;
                    }
                }
            }

        }
    else
	{
        $i = "-I$inc_dir -I$apache_src/regex -I$apache_src/os/unix" ; 
        $o = '' ;
        }
    $d .= ' -DAPACHE' ;
    $EPNOAPACHELIB = 0 ;
    }
else
    {
    $apache = 0 ;
    if ($win32 && ($EPAPACHESRC || $EPNOAPACHELIB) && -f 'blib/arch/auto/HTML/Embperl/Embperl.dll')
        {
        print "\nYou have already build Embperl with support for Apache mod_perl\n" ;
        $EPNOAPACHELIB = GetYesNo ("Do you want to build a separate dynamic library for use without Apache?", 'y') ;
        }


    print "Will build without mod_perl support\n" ;
    $i = '' ;
    $o = '' ;
    }
		

if ($win32 && $apache)
    {	# borrowed from mod_perl
    local *DEFH;
    open DEFH, ">dirent.h" || die "can't write dirent.h $!";
    print DEFH <<EOF;
/* major kludge to workaround conflict(s) between perl's dirent.h and apache's readdir.h */

#ifdef WIN32

#define _INC_DIRENT
#define DIR void

#endif

EOF
    close DEFH;

    if ($ENV{APACHE_PERL_DLL})
	{
	$mpdll = $ENV{APACHE_PERL_DLL} ;
	}
    elsif ($EPMODPERL =~ /^LoadModule perl_module (.*?)$/)
	{
	$mpdll = $1 ;
	}
    }

#
# Check to see which user to use for httpd tests
#
$loadmodules = $EPMODPERL ;
$EPPATH    = cwd ;
$EPMODPERL = '' ;
$EPSTARTUP ='startup.pl' ;

if ($b && $apache)
    {
    $EPPORT  = 8531 ;
    if (!$win32)
        {
        $EPUSER  = getpwuid($>) ||  $> ;
        $EPGROUP = getgrgid($)) || $) ;
        if ($EPUSER eq 'root')
            {
            my $nobody = (getpwnam('nobody'))[0] ;
            $EPUSER = $nobody if $nobody ;
            }

        if ($EPUSER eq 'root')
            {
            print "Cannot run test httpd as User $EPUSER\n" ;
            $EPUSER = GetString ("User to run httpd", 'nobody') ;
            $EPGROUP = GetString ("Group to run httpd", $EPGROUP) ;
            }
        
        $EPHTTPD = "$apache_src/httpd" ;
        $EPHTTPD = $ENV{EPHTTPD} if (defined ($ENV{EPHTTPD})) ;
        $EPHTTPD = "$apache_src/httpsd" if (!-e $EPHTTPD && -e "$apache_src/httpsd") ;
        
        if (!-e $EPHTTPD)
            {
            $EPHTTPD = GetString ("Enter path and file to start as httpd", "$EPHTTPD") ;
            }
	
	$EPMODPERL="" ;
        }
    else
        {
        if (!$EPHTTPD || !-e $EPHTTPD)
            {
            $EPHTTPD = "$EPHTTPDDLL/Apache.exe" ;
            $EPHTTPD =~ s#core([rd])/Apache.exe#Apache$1/Apache.exe#i ;
            $EPHTTPD =~ s#libexec/Apache.exe#Apache.exe#i ;
            }
        $EPUSER  = 'www' ; # dummy value
        $EPGROUP = 'www' ;
        if (!-e $EPHTTPD)
            {
            $EPHTTPD = GetString ("Enter path and file to start as Apache.exe", "$EPHTTPD") ;
            }
        $EPHTTPDPATH = $EPHTTPD ;
        $EPHTTPDPATH =~ s/Apache.exe//i ;
        }
    

    ### check the apache version ###
                                
    $EPENVPATH = ";$Config{bin};$EPHTTPDDLL;$EPHTTPDPATH;$EPHTTPDDLL/../os/win32/release;$EPHTTPDDLL/../os/win32/debug" ;
    $ENV{PATH} .= $EPENVPATH if ($win32) ;
    
    @EPAPACHEVERSION = start ("\"$EPHTTPD\" -v") ;
    @modules         = start ("\"$EPHTTPD\" -l") ;

    chomp ($EPAPACHEVERSION[0]) ;
    print "Apache Version $EPAPACHEVERSION[0]\n" ;

    $EPSTRONGHOLD = ($EPAPACHEVERSION[0] =~ /stronghold/i) ;
    $EPAPACHE_SSL = grep (/apache_ssl.c/, @modules) ;
    $EPMOD_SSL    = !$EPSTRONGHOLD && grep (/mod_ssl.c/, @modules) ;

    $EPBINDIR	  = dirname ($EPHTTPD) ;    
    $EPMODPERL	  = '' ;
    
    $addmodpath = '' ;
    while (($mod, $opt) = each %neededmodules)
	{
	if (!grep (/$mod/, @modules))
	    { # module not linked staticly
	    $paths = $win32?$opt->{win32path}:$opt->{path} ;
	    $modfile = $win32?$opt->{win32file}:$opt->{file}[0] ;
	    $modfiletext = ($win32?$opt->{win32filetext}:$opt->{filetext}) || $modfile ;
	    $found = 2 ;
	    searchmod:
            while ($found == 2)
		{
		$found = 0 ;
		if ($addmodpath)
		    {
                    foreach $modfile (@{$opt->{file}})
                        {
		        $path = cnvpath ("$addmodpath/$modfile") ;
		        #print "path = $_ -> $path\n" ;
		        if (-f $path)
			    { ## module fould
	    		    $EPMODPERL .= "\r\nLoadModule $opt->{name} \"$path\"" ;
			    print " + Load dynamic module $mod\n   ($path)\n" ;
			    $found = 1 ;
			    last searchmod ;
			    }
		        }
                    }
		foreach (@$paths)
		    {
		    $path = cnvpath (eval "\"$_\"") ;
		    #print "path = $_ -> $path\n" ;
		    if (-f $path)
			{ ## module fould
	    		$EPMODPERL .= "\r\nLoadModule $opt->{name} \"$path\"" ;
			print " + Load dynamic module $mod\n   ($path)\n" ;
			$found = 1 ;
			last ;
			}
		    }
                if (!$found && $loadmodules)
                    {		
                    if ($loadmodules =~ /LoadModule $opt->{name} \"(.*?)\"$/)
                        {
                        $path = $1 ;
		        if (-f $path)
			    { ## module fould
	    		    $EPMODPERL .= "\r\nLoadModule $opt->{name} \"$path\"" ;
			    print " + Load dynamic module $mod\n   ($path)\n" ;
			    $found = 1 ;
			    last ;
			    }
                        }
                    }                            
                
                if (!$found)
		    {
		    my $w32msg = '' ;
		    $w32msg = "\nPlease enter full path including the drive letter!! " if ($win32) ;
		    $addmodpath = GetString ("Library for $mod not found, please enter path to $modfiletext $w32msg", "") ;
		    $found = 2 ;
		    }
		}			    
	    }
	}


		    

    $use_dso = 0 ;
    if (!$win32 && ($EPMODPERL =~ /perl_module/))
	{
        print " + mod_perl was build with USE_DSO\n" ;
	$use_dso = 1 ;
        }

    require Apache::src;
    $dynlib->{'OTHERLDFLAGS'} = Apache::src->new->otherldflags if (defined (&Apache::src::otherldflags)) ;


    if ($EPSTRONGHOLD) 
        {
        $i .= " -I$apache_src/../ssl/include" ;
        $d .= " -DSTRONGHOLD" ;
        print " + found Stronghold\n" ;
        }
    elsif ($EPAPACHE_SSL)
        {
        $d .= " -DEPAPACHE_SSL" ;
        print " + found Apache SSL\n" ;
        }
    elsif ($EPMOD_SSL)
        {
        $sslbase = search_config ('SSL_BASE', "$apache_src/Configuration.apaci") ;
        $sslbase = search_config ('SSL_BASE', "$apache_src/Configuration") if (!$sslbase) ;
        print " + found mod_ssl\n" ;
        $EPSSLDISABLE = !start_errcode ("\"$EPHTTPD\" -t -f $EPPATH/test/conf/ssldisable.conf") ;
        }



    if ($EPSTRONGHOLD)
        {
        my $conf = "$apache_src/../conf/httpd.conf";
        if(-e $conf) 
            {
	    open FH, $conf;
	    while(<FH>)
                {
	        if(/^StrongholdKey/)
                    {
                    chomp ;
		    $EPSTRONGHOLDKEY = $_;
		    last;
	            }
	        }
	    close FH;
            }
        }
    else
        {
        $EPSTRONGHOLDKEY = '' ;
        }

    $epc_enable = search_config ('\s*#define\s+EPC_ENABLE', "crypto/epcrypto_config.h") ;
    if ($epc_enable)
        {
        $sslbase = search_config ('SSL_BASE', "$apache_src/Configuration.apaci") if (!$sslbase) ;
        $sslbase = search_config ('SSL_BASE', "$apache_src/Configuration") if (!$sslbase) ;
        $sslbase = '/usr/local/ssl' if (!$sslbase) ;
        $libs .= " -L$sslbase/lib -lcrypto" ;
        $o    .= ' crypto/epcrypto$(OBJ_EXT) ' ;
        print "Enable crypted sourcefiles\n" ;
        }

    if ($sslbase) 
        {
        $i .= " -I$sslbase/include" 
        }

    print "Test start $EPHTTPD\n" ;
    print "Test httpd will run as user $EPUSER and group $EPGROUP\n" if (!$win32) ;
    print "Test httpd will listen on port $EPPORT\n" ;
    print "Test will use $EPSTRONGHOLDKEY\n" if($EPSTRONGHOLDKEY) ;


    ### check for required modules ###
    
    if (($MPVer = CheckModule ("mod_perl", "-> Cannot build for mod_perl without mod_perl installed!!")))
        {
        if ($win32 && $MPVer lt "1.12")
            {
            print "-> Please upgrade to an higher version of mod_perl on Win32\n" ;
            }
        if ($use_dso && $MPVer lt "1.22")
            {
            print "-> You MUST upgrade to mod_perl 1.22 or higher when mod_perl is build with USE_DSO!!\n" ;
            $EPSTARTUP ='startup_dso.pl' ;
            }
        if ($aix && $MPVer lt "1.22")
            {
            print "-> You MUST upgrade to mod_perl 1.22 or higher to use Embperl on AIX!!\n" ;
            $EPSTARTUP ='startup_dso.pl' ;
            }
        }

    if (CheckModule ("LWP::UserAgent", "-> Cannot test mod_perl and CGI mode"))
        {
        CheckModule ("HTML::HeadParser", "-> Is required by LWP::UserAgent");
        }

    $SessVer = CheckModule ("Apache::Session", "-> Disable tests for persistent data storage") || '' ;

    if ($SessVer && !($SessVer >= 1.00))
        {
        if ($SessVer && !($SessVer =~ /0\.17/))
            {
            print "-> Embperl works only with Apache::Session 1.00 and higher\n" ;
            print "-> Disable tests for persistent data storage\n" ;
            $SessVer = '0' ;
            }
        else
            {
            print "-> Embperl does not support Apache::Session 0.17.x anymore.\n" ;
            print "-> Please upgrade to 1.50 or higher.\n" ;
            print "-> Disable tests for persistent data storage.\n" ;
            $SessVer = '0' ;
            }
        }

    $SessXVer = CheckModule ("Apache::SessionX", "-> Disable tests for persistent data storage") || '' if ($SessVer) ;
    $SessVer ||= 0 ;

    if (($FSVer = CheckModule ("File::Spec", "-> Required for EmbperlObject, make test will fail whithout File::Spec")) < 0.8)
        {
        print "-> EmbperlObject requires File::Spec 0.8 or higher, found $FSVer, please upgrade!\n" ;
        }
        
    CheckModule ("CGI", "-> File Upload will not work without CGI.pm installed") ;

    ### write out test configuration file ###

    open FH, ">$EPPATH/test/conf/config.pl" or die "Cannot open $EPPATH/test/conf/config.pl" ;
    print FH "# This file is automaticly generated by Makefile.PL, do not edit\n" ;
    print FH "\$EPPATH='" . cnvpath($EPPATH) . "' ;\n" ;
    print FH "\$EPUSER='$EPUSER' ;\n" ;
    print FH "\$EPGROUP='$EPGROUP' ;\n" ;
    print FH "\$EPPORT=$EPPORT ;\n" ;
    print FH "\$EPHTTPD='" . cnvpath($EPHTTPD) . "' ;\n" ;
    print FH "\$EPHTTPDDLL='" . cnvpath($EPHTTPDDLL) . "' ;\n" ;
    print FH "\$EPWIN32='$win32' ;\n" ;
    print FH "\$EPAPACHESRC='" . cnvpath($apache_src) . "' ;\n" ;
    print FH "\$EPAPACHE_SSL='" . $EPAPACHE_SSL . "' ;\n" ;
    print FH "\$EPSTRONGHOLD='$EPSTRONGHOLD' ;\n" ;
    print FH "\$EPSSLDISABLE='$EPSSLDISABLE' ;\n" ;
    print FH "\$EPSTRONGHOLDKEY='$EPSTRONGHOLDKEY' ;\n" ;
    print FH "\$EPMODPERL='" . cnvpath2unix($EPMODPERL) . "';\n" ;
    print FH "\$EPSTARTUP='" . cnvpath($EPSTARTUP) . "';\n" ;
    print FH "\$EPAPACHEVERSION='$EPAPACHEVERSION[0]';\n" ;
    print FH "\$EPSESSIONVERSION='$SessVer';\n" ;
    print FH "\$EPSESSIONXVERSION='$SessXVer';\n" ;
    print FH "\$EP2='$EP2';\n" ;
    print FH "\$EPMODPERLVERSION='$MPVer';\n" ;
    print FH "\$EPC_ENABLE='$epc_enable';\n" ;
    print FH "\$EPNOAPACHELIB='$EPNOAPACHELIB';\n" ;
    if ($win32)
        {
        print FH "\$EPNULL='nul';\n" ;
        }
    else
        {
        print FH "\$EPNULL='/dev/null';\n" ;
        }



    }
else
    {
    ### check for required modules ###

    $SessVer = CheckModule ("Apache::Session", "-> Disable tests for persistent data storage") || '' ;

    if ($SessVer && $SessVer lt "0.17")
        {
        print "-> Please upgrade to Apache::Session 0.17 or higher\n" ;
        print "-> Disable tests for persistent data storage\n" ;
        $SessVer = 0 ;
        }

    $SessXVer = CheckModule ("Apache::SessionX", "-> Disable tests for persistent data storage") || '' if ($SessVer) ;
    $SessVer ||= 0 ;

    ### write out test configuration file ###

    open FH, ">$EPPATH/test/conf/config.pl" or die "Cannot open $EPPATH/test/conf/config.pl" ;
    print FH "# This file is automaticly generated by Makefile.PL, do not edit\n" ;
    print FH "\$EPPATH='$EPPATH' ; \n" ;
    print FH "\$EPENVPATH='$EPENVPATH' ; \n" ;
    print FH "\$EPHTTPD='' ;\n" ;
    print FH "\$EPWIN32='$win32' ;\n" ;
    print FH "\$EPSESSIONVERSION='$SessVer';\n" ;
    print FH "\$EPSESSIONXVERSION='$SessXVer';\n" ;
    print FH "\$EPSSLDISABLE='$EPSSLDISABLE' ;\n" ;
    print FH "\$EP2='$EP2';\n" ;
    print FH "\$EPNOAPACHELIB='$EPNOAPACHELIB';\n" ;
    print FH "\$EPC_ENABLE='$epc_enable';\n" ;
    print FH "\$EPHTTPD='" . cnvpath($EPHTTPD) . "' ;\n" ;
    print FH "\$EPHTTPDDLL='" . cnvpath($EPHTTPDDLL) . "' ;\n" ;
    print FH "\$EPWIN32='$win32' ;\n" ;
    print FH "\$EPAPACHESRC='" . cnvpath($EPAPACHESRC) . "' ;\n" ;
    print FH "\$EPMODPERL='" . cnvpath2unix($loadmodules) . "';\n" ;
    }

# $d .= ' -DPERL_IS_5_6 ' if $] >= 5.006;

if ($win32)
    { 
    # check for inclusion of malloc.h and signal.h
    if ($Config{usemultiplicity})
        {
        $d .= ' -D_INC_MALLOC -D_INC_SIGNAL ';
        }

    # Check for winsock2api
    
    my $os_h = "$inc_dir/os.h" ;
    $os_h = "$inc_dir/../os/win32/os.h" if (!-e $os_h) ;
    
    if (open FH2, $os_h )
        {
        my @conf = <FH2> ;
        close FH2 ;

        if (grep (/winsock2\.h/, @conf))
            {
            $d .= ' -D_WINSOCK2API_ -D_MSWSOCK_ ' ;
            }
        elsif (open FH2, "$inc_dir/ap_config.h")
            {
            @conf = <FH2> ;
            close FH2 ;

            if (grep (/winsock2\.h/, @conf))
                {
                $d .= ' -D_WINSOCK2API_ ' ;
                }
            }
        }
    
    $d .= ' -D_WINDOWS ';
    $d .= ' -DMULTIPLICITY' if ($Config{usemultiplicity}) ;

    }

$d .= ' -DEP2' if ($EP2) ;

$dynlib->{'OTHERLDFLAGS'} .= " $lddebug" ;

# 
# See if we need to link to any other libraries
#

my $makemacros = {} ;
if ($EP2)
    {
    opendir DH, "driver" or die "Cannot open directory driver ($!)" ;
    my @files = readdir DH ;
    closedir DH ;
    my @makefiles = grep (/\.MAKEPL$/, @files) ;

    foreach my $makepl (@makefiles)
        {
        #print "Exec driver/$makepl\n" ;
        my $result = do "driver/$makepl" ;
        if ($@)
            {
            print $@ ;
            next ;
            }
        if (ref $result)
            {
            #while (my ($k, $v) = each %$result)
            #    {
            #    print "$k = $v\n" ;
            #    }
            $libs .= ' ' . $result->{libs} ;
            $i    .= ' ' . $result->{cflags} ;
            $d    .= ' ' . $result->{defines} ;
            $o    .= ' ' . $result->{objects} ;
            $makemacros->{CPP} = $result->{cpp} if ($result->{cpp}) ;
            $makemacros->{CPPFLAGS} = $result->{cppflags} if ($result->{cppflags}) ;
            if ($result->{save})
                {
                while (($k, $v) = each (%{$result->{save}}))
                    {
                    print FH "$k='" . $v . "';\n" ;
                    }
                }           
            }
        }

    }


close FH ;

$i .= " -I$EPPATH/xs" ;

%MMARGS = (
    'LIBS'	   => [$libs || ''],   			 
    'DEFINE'	   => "$d \$(DEFS)", 			 
    'INC'	   => "-I$EPPATH $i",     			 
    'VERSION'      => undef,
    'VERSION_FROM' => "$EPPATH/Embperl.pm",
    $optdebug?('OPTIMIZE' => $ccdebug):(),
    ) ;


if ($EP2)
    {
    open FH, ">xs/mmargs.pl" or die "Cannot open xs/mmargs.pl ($!)" ;
    print FH Data::Dumper -> Dump ([\%MMARGS], ['MMARGS']) ;
    close FH ;
    }

my $sublibs .= ' ' . 
join ('$(OBJ_EXT) ', qw{
xs/Embperl/App/App
xs/Embperl/App/Config/Config
xs/Embperl/Component/Component
xs/Embperl/Component/Config/Config
xs/Embperl/Component/Param/Param
xs/Embperl/Component/Output/Output
xs/Embperl/Req/Req
xs/Embperl/Req/Config/Config
xs/Embperl/Req/Param/Param
xs/Embperl/Thread/Thread
xs/Embperl/Syntax/Syntax
}) . '$(OBJ_EXT)';

$sublibs =~ s/\//\\/g if ($win32) ;
$o .= $sublibs if ($EP2) ;

WriteMakefile(
    'NAME'	   => 'HTML::Embperl',
    'VERSION_FROM' => 'Embperl.pm', 		# finds $VERSION
    'OBJECT'       => 'Embperl$(OBJ_EXT) epmain$(OBJ_EXT) epio$(OBJ_EXT) epchar$(OBJ_EXT) eputil$(OBJ_EXT) epeval$(OBJ_EXT) epapinit$(OBJ_EXT) ' . 
                       ($EP2?'epmem$(OBJ_EXT) epinit$(OBJ_EXT) epcgiinit$(OBJ_EXT) epcmd2$(OBJ_EXT) epparse$(OBJ_EXT) epdom$(OBJ_EXT) epcomp$(OBJ_EXT) epcache$(OBJ_EXT) epprovider$(OBJ_EXT)':'epcmd$(OBJ_EXT) ') . $o,
    'LIBS'	   => [$libs || ''],   			 
    'DEFINE'	   => "$d \$(DEFS)", 			 
    'INC'	   => $i,     			 
    'EXE_FILES'    => [ 'embpexec.pl' ],
    'clean'        => { FILES => 'dirent.h test/conf/httpd.conf test/tmp/* Embperl.c' },
    'realclean'    => { FILES => 'embpexec.pl embpexec.bat embpcgi.pl embpcgi.test.pl embpcgi.bat epocgi.pl epocgi.test.pl epocgi.bat embpfastcgi.pl test/conf/config.pl' },
    'dist'         => { COMPRESS => 'gzip', SUFFIX => 'gz'},
    'dynamic_lib'  => $dynlib,
    'PREREQ_PM'    => { 'File::Spec' => 0.8 },
    'ABSTRACT'     => 'Embed Perl code in HTML documents',
    'AUTHOR'       => 'Gerald Richter <richter@dev.ecos.de>',
    'macro'        => $makemacros,
    $EP2?('depend'       => { 'Embperl.c' => 'Embperl.xs DOM.xs Cmd.xs Syntax.xs Old.xs' }):(),
);



#
# Change path to perl binary
#

@bins = ('embpexec.pl','embpexec.bat', 
         'embpcgi.pl', 'embpcgi.test.pl', 'embpcgi.bat',
	 'embpfastcgi.pl', 
         'epocgi.pl', 'epocgi.test.pl', 'epocgi.bat',
         $EP2?('embpmsgid.pl'):(),
         
         ) ;


die "Missing path to perl binary" if (!$perlbinpath) ;


foreach $f (@bins)
	{
	open IN, "<$f.templ" or die "Cannot open $f.templ" ;
	open OUT, ">$f" or die "Cannot open $f" ;
	my $l = 1 ;
        while (<IN>)
		{
		if ($l++ < 10)
                    {
		    #if ($win32)
		    #	{
                    #	s/^\#\!.*?perl.*?\s(.*?)/#!perl $1/ ;
		    #	}
		    #else
		    #	{
                    	s/^\#\!.*?perl.*?\s(.*?)/#!$perlbinpath $1/ ;
		    #	}
		    s/^.*?perl.*?\s-x/$perlbinpath -x/ ;
                    }
		print OUT $_ ;
		}
	close IN ;
	close OUT ;
	chmod 0755, $f or die "Cannot set executable $f" ;
	}

unlink ('Embperl.c') ;