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