Commit | Line | Data |
7bb01969 |
1 | # $Id: Makefile.PL,v 1.11 2001/06/08 15:09:47 skimo Exp $ |
1b64d24d |
2 | |
3 | use ExtUtils::MakeMaker; |
4 | use IO::File; |
5 | use Config; |
6 | use Cwd 'cwd'; |
7bb01969 |
7 | use Getopt::Long; |
1b64d24d |
8 | |
9 | @h1 = qw(fastcgi.h fcgiapp.h fcgiappmisc.h fcgimisc.h fcgios.h); |
10 | @h = (@h1, 'fcgi_config.h'); |
11 | @o = qw(FCGI.o); |
12 | @dist1 = qw(LICENSE.TERMS acconfig.h); |
13 | @dist2 = qw(fcgiapp.c os_unix.c os_win32.c); |
14 | @dist3 = (@h1, qw(fcgi_config.h.in fcgi_config_x86.h)); |
15 | |
7bb01969 |
16 | GetOptions ("pure-perl!" => \$pure); |
0833402a |
17 | $pure = |
18 | (prompt("Do you want to use the pure perl implementation", "no") =~ /^y/) |
7bb01969 |
19 | ? "1" : "0" unless defined $pure; |
0833402a |
20 | open(CFG,">FCGI.cfg"); |
21 | print CFG "\$pure = $pure;1;\n"; |
22 | close CFG; |
23 | |
1b64d24d |
24 | $devkit = cwd() . "/.."; |
25 | |
8a851875 |
26 | if (-d "$devkit/libfcgi/" |
1b64d24d |
27 | && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h)) |
28 | { |
8a851875 |
29 | unless (-f "$devkit/libfcgi/libfcgi.a") { |
30 | warn "Please compile the library before attempting " . |
31 | "to compile the perl module.\n"; |
32 | exit -1; |
33 | } |
1b64d24d |
34 | # devkit |
35 | $prefix = $devkit; |
36 | push @libs, "-L$devkit/libfcgi -lfcgi"; |
37 | } |
38 | else { |
39 | # CPAN |
40 | for $dir ("/usr", "/usr/local") { |
41 | if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a" |
42 | && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h)) |
43 | { |
44 | print "Found fcgi library and include files in $dir\n"; |
45 | print "Will be using that instead of included files\n"; |
46 | print "Edit Makefile.PL if you don't like it\n"; |
47 | |
48 | $prefix = $dir; |
49 | push @libs, "-L$dir/lib -lfcgi"; |
50 | last; |
51 | } |
52 | } |
53 | } |
54 | |
55 | $sys = $^O eq 'MSWin32' ? 'win32' : 'unix'; |
56 | push @o, "fcgiapp.o", "os_$sys.o" unless $prefix; |
57 | $inc = $prefix ? "-I$prefix/include" : '-I.'; |
58 | |
0074e702 |
59 | push(@extras, CAPI => 'TRUE') |
60 | if ($] >= 5.005 and $^O eq 'MSWin32' |
61 | and $Config{archname} =~ /-object\b/i); |
62 | |
63 | push(@extras, |
64 | ABSTRACT => 'Fast CGI module', |
65 | AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)') |
66 | if ($ExtUtils::MakeMaker::VERSION >= 5.4301); |
0833402a |
67 | |
68 | $plfiles = { 'echo.PL' => 'echo.fpl', |
69 | 'remote.PL' => 'remote.fpl', |
70 | 'threaded.PL' => 'threaded.fpl', |
71 | 'FCGI.PL' => 'FCGI.pm', |
72 | }; |
73 | $plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure; |
236be38d |
74 | if ($pure) { |
75 | push @extras, |
76 | LINKTYPE => ' '; |
77 | } else { |
0833402a |
78 | push @extras, |
79 | 'LIBS' => [ @libs ], |
80 | 'OBJECT' => "@o", |
81 | 'INC' => $inc; |
82 | } |
0074e702 |
83 | |
1b64d24d |
84 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence |
85 | # the contents of the Makefile that is written. |
00cbdd93 |
86 | |
87 | # Work around bug in previous versions of MakeMaker |
88 | WriteMakefile(NAME => 'FCGI') |
89 | if $ExtUtils::MakeMaker::VERSION <= 5.4302; |
90 | |
0833402a |
91 | $mm = MM->new({ |
1b64d24d |
92 | 'NAME' => 'FCGI', |
0833402a |
93 | 'VERSION_FROM' => 'FCGI.PL', |
1b64d24d |
94 | 'dist' => { 'COMPRESS' => 'gzip -9f', |
95 | 'SUFFIX' => 'gz', |
96 | 'PREOP' => '$(CP) '.join(' ', |
97 | map {"../$_"} @dist1, |
98 | (map {"libfcgi/$_"} @dist2), |
99 | map {"include/$_"} @dist3).' $(DISTVNAME);'. |
100 | '$(CP) MANIFEST MANIFEST.old;'. |
101 | 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) . |
102 | '>> $(DISTVNAME)/MANIFEST', |
103 | 'POSTOP' => |
104 | '$(MV) MANIFEST.old MANIFEST', |
105 | }, |
236be38d |
106 | 'clean' => { FILES => 'config.cache fcgi_config.h' . |
107 | ' FCGI.xs FCGI.c FCGI.cfg ' . |
108 | (join ' ', values %$plfiles)}, |
0833402a |
109 | 'PL_FILES' => $plfiles, |
110 | PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'}, |
0074e702 |
111 | @extras, |
0833402a |
112 | }); |
113 | # don't install oldinterface pod |
114 | delete $mm->{MAN3PODS}{oldinterface.pod}; |
115 | $mm->flush; |
1b64d24d |
116 | |
236be38d |
117 | exit if -f 'fcgi_config.h' or $prefix or $pure; |
1b64d24d |
118 | |
119 | # CPAN and no installed lib found |
120 | if ($sys eq "win32") { |
121 | # configure will almost certainly not run on a normal NT install, |
122 | # use the pregenerated configuration file |
123 | |
09c3bca2 |
124 | use File::Copy qw(copy); |
1b64d24d |
125 | print "Using prebuilt fcgi_config.h file for Windows\n"; |
126 | unlink("fcgi_config.h"); |
09c3bca2 |
127 | die $! unless copy("fcgi_config_x86.h","fcgi_config.h"); |
1b64d24d |
128 | |
129 | # Win build system also can't deal with existence of FCGI.xs or absence of |
130 | # FCGI.c |
131 | unlink("FCGI.xs"); |
132 | open(F, ">FCGI.c"); close(F); |
133 | $now = time; $before = $now - 600; |
134 | utime $before, $before, "FCGI.c"; |
135 | utime $now, $now, "FCGI.PL"; |
136 | |
137 | } else { |
138 | print "Running ./configure for you\n"; |
6ef7789b |
139 | print "Please read configure.readme for information on how to run it yourself\n"; |
1b64d24d |
140 | |
141 | $ENV{'CC'} = $Config{'cc'}; |
142 | system("./configure"); |
143 | } |