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