Commit | Line | Data |
09c3bca2 |
1 | # $Id: Makefile.PL,v 1.7 2000/12/11 22:00:36 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 | |
15 | $devkit = cwd() . "/.."; |
16 | |
8a851875 |
17 | if (-d "$devkit/libfcgi/" |
1b64d24d |
18 | && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h)) |
19 | { |
8a851875 |
20 | unless (-f "$devkit/libfcgi/libfcgi.a") { |
21 | warn "Please compile the library before attempting " . |
22 | "to compile the perl module.\n"; |
23 | exit -1; |
24 | } |
1b64d24d |
25 | # devkit |
26 | $prefix = $devkit; |
27 | push @libs, "-L$devkit/libfcgi -lfcgi"; |
28 | } |
29 | else { |
30 | # CPAN |
31 | for $dir ("/usr", "/usr/local") { |
32 | if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a" |
33 | && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h)) |
34 | { |
35 | print "Found fcgi library and include files in $dir\n"; |
36 | print "Will be using that instead of included files\n"; |
37 | print "Edit Makefile.PL if you don't like it\n"; |
38 | |
39 | $prefix = $dir; |
40 | push @libs, "-L$dir/lib -lfcgi"; |
41 | last; |
42 | } |
43 | } |
44 | } |
45 | |
46 | $sys = $^O eq 'MSWin32' ? 'win32' : 'unix'; |
47 | push @o, "fcgiapp.o", "os_$sys.o" unless $prefix; |
48 | $inc = $prefix ? "-I$prefix/include" : '-I.'; |
49 | |
0074e702 |
50 | push(@extras, CAPI => 'TRUE') |
51 | if ($] >= 5.005 and $^O eq 'MSWin32' |
52 | and $Config{archname} =~ /-object\b/i); |
53 | |
54 | push(@extras, |
55 | ABSTRACT => 'Fast CGI module', |
56 | AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)') |
57 | if ($ExtUtils::MakeMaker::VERSION >= 5.4301); |
58 | |
1b64d24d |
59 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence |
60 | # the contents of the Makefile that is written. |
61 | WriteMakefile( |
62 | 'NAME' => 'FCGI', |
63 | 'VERSION_FROM' => 'FCGI.pm', |
64 | 'LIBS' => [ @libs ], |
65 | 'OBJECT' => "@o", |
66 | 'INC' => $inc, |
67 | 'dist' => { 'COMPRESS' => 'gzip -9f', |
68 | 'SUFFIX' => 'gz', |
69 | 'PREOP' => '$(CP) '.join(' ', |
70 | map {"../$_"} @dist1, |
71 | (map {"libfcgi/$_"} @dist2), |
72 | map {"include/$_"} @dist3).' $(DISTVNAME);'. |
73 | '$(CP) MANIFEST MANIFEST.old;'. |
74 | 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) . |
75 | '>> $(DISTVNAME)/MANIFEST', |
76 | 'POSTOP' => |
77 | '$(MV) MANIFEST.old MANIFEST', |
78 | }, |
79 | 'clean' => { FILES => 'config.cache fcgi_config.h' }, |
34bfd355 |
80 | 'PL_FILES' => { 'echo.PL' => 'echo.fpl', |
9915cd6d |
81 | 'remote.PL' => 'remote.fpl', |
34bfd355 |
82 | 'threaded.PL' => 'threaded.fpl', |
83 | 'FCGI.PL' => 'FCGI.xs', |
84 | }, |
0074e702 |
85 | @extras, |
1b64d24d |
86 | ); |
87 | |
88 | exit if -f 'fcgi_config.h' or $prefix; |
89 | |
90 | # CPAN and no installed lib found |
91 | if ($sys eq "win32") { |
92 | # configure will almost certainly not run on a normal NT install, |
93 | # use the pregenerated configuration file |
94 | |
09c3bca2 |
95 | use File::Copy qw(copy); |
1b64d24d |
96 | print "Using prebuilt fcgi_config.h file for Windows\n"; |
97 | unlink("fcgi_config.h"); |
09c3bca2 |
98 | die $! unless copy("fcgi_config_x86.h","fcgi_config.h"); |
1b64d24d |
99 | |
100 | # Win build system also can't deal with existence of FCGI.xs or absence of |
101 | # FCGI.c |
102 | unlink("FCGI.xs"); |
103 | open(F, ">FCGI.c"); close(F); |
104 | $now = time; $before = $now - 600; |
105 | utime $before, $before, "FCGI.c"; |
106 | utime $now, $now, "FCGI.PL"; |
107 | |
108 | } else { |
109 | print "Running ./configure for you\n"; |
6ef7789b |
110 | print "Please read configure.readme for information on how to run it yourself\n"; |
1b64d24d |
111 | |
112 | $ENV{'CC'} = $Config{'cc'}; |
113 | system("./configure"); |
114 | } |