4 use ExtUtils::MakeMaker;
8 my $vergen = '../../../../tools/vergen';
10 ###########################################################################
11 # determine OpenSSL version
12 ## first we have to find a working OpenSSL 0.9.8 at minimum
23 my $openssl_inc_dir = '';
24 my $openssl_lib_dir = '';
25 my $openssl_binary = '';
27 my @paths = qw( /usr/local/ssl
35 if (exists $ENV{OPENSSL_PREFIX}
36 && $ENV{OPENSSL_PREFIX} ne '') {
37 unshift @paths, $ENV{OPENSSL_PREFIX};
44 foreach my $path (@paths)
46 my $tmp_inc = File::Spec->catfile($path, 'include');
47 $tmp_ver = File::Spec->catfile($tmp_inc, 'openssl', 'opensslv.h');
48 my $tmp_lib = File::Spec->catfile($path, 'lib');
49 my $tmp_bin = File::Spec->catfile($path, 'bin', 'openssl');
54 -r $tmp_bin && -x $tmp_bin) {
56 $openssl_inc_dir = $tmp_inc;
57 $openssl_lib_dir = $tmp_lib;
58 $openssl_binary = $tmp_bin;
63 # accept settings from OPENSSL_INC and OPENSSL_LIB if BOTH exist
64 if (exists $ENV{OPENSSL_INC} && $ENV{OPENSSL_INC} != ""
65 && exists $ENV{OPENSSL_LIB} && $ENV{OPENSSL_LIB} != "") {
67 $openssl_inc_dir = $ENV{OPENSSL_INC};
68 $openssl_lib_dir = $ENV{OPENSSL_LIB};
71 die "Could not find usable OpenSSL installation. Stopped"
72 unless defined $openssl_inc_dir;
74 die "Could not find usable OpenSSL binary. Stopped"
75 unless defined $openssl_binary;
77 print STDERR "OpenSSL library: $openssl_lib_dir\n";
78 print STDERR "OpenSSL headers: $openssl_inc_dir\n";
79 print STDERR "OpenSSL binary: $openssl_binary\n";
81 my $openssl_version = `grep '#define OPENSSL_VERSION_TEXT' $tmp_ver`;
83 $openssl_version =~ s/^.*fips.*$//m;
84 $openssl_version =~ s/\n//g;
85 $openssl_version =~ s/^[^"]*"([^"]*)".*$/$1/;
86 print STDERR "OpenSSL version: $openssl_version\n";
87 $openssl_version =~ s/^\s*OpenSSL\s*0\.9\.//i;
88 $openssl_version =~ s/^([0-9]+).*$/$1/;
90 if ($openssl_version < 8)
93 print STDERR "ERROR: OpenSSL 0.9.8 or higher is required.\n";
94 print STDERR "Consider setting OPENSSL_PREFIX correctly.\n\n";
98 # make OpenSSL binary location available to tests
99 open my $fh, ">", File::Spec->catfile("t", "cfg.binary.openssl");
100 print $fh $openssl_binary;
104 ###########################################################################
105 # determine OpenXPKI version
107 my $openxpki_version;
109 $openxpki_version = `$vergen --format version`;
111 if ($CHILD_ERROR != 0) {
112 $openxpki_version = undef;
116 if (! defined $openxpki_version) {
117 # make sure we really require OUR LOCAL version file (not some possibly
118 # already installed but outdated version file)
119 # this is mainly used in archives created from 'make dist' steps
121 local @INC = ( '.' );
122 require OpenXPKI::VERSION;
123 $openxpki_version = $OpenXPKI::VERSION::VERSION;
124 print STDERR "OpenXPKI distribution\n";
125 print STDERR "Version from OpenXPKI::Version: $openxpki_version\n";
129 if (! defined $openxpki_version) {
130 die "Could not determine OpenXPKI version. Stopped";
134 # never commit this file to a version control system
135 package OpenXPKI::VERSION;
136 our \$VERSION = '$openxpki_version';
142 OpenXPKI::VERSION - version number of OpenXPKI core modules.
146 This file is only used to get a clean version number for the
147 installed OpenXPKI core software. This is required by the XS
154 open $fh, ">", File::Spec->catfile('OpenXPKI', 'VERSION.pm')
155 or die "Cannot open version module file OpenXPKI/VERSION.pm!\n";
160 ## restore all formerly ignored modules
161 my $list = `find . -name "*.pm.ignore" -print`;
162 my @list = split /[\n\s+]/, $list;
163 foreach my $module (@list)
165 next if (not defined $module or not length $module);
166 $module =~ s/\.ignore$//;
167 print STDERR "Restoring module $module ... ";
168 if (not rename $module.".ignore", $module)
170 print STDERR "FAILED\n";
171 print STDERR "Cannot restore formerly ignored module!\n";
172 print STDERR "Aborting to ensrue the consistency of the OpenXPKI release.\n";
178 ## should we ignore some modules?
180 if (exists $ENV{IGNORE_MODULES})
182 my $line = $ENV{IGNORE_MODULES};
184 my @modules = split / /, $line;
185 foreach my $module (@modules)
187 print STDERR "Module $module is not going to be installed.\n";
188 $module =~ s/::/\//g;
189 $module .= ".pm" if (substr ($module, length($module)-4,3) ne ".pm");
190 if (not rename $module, $module.".ignore")
192 print STDERR "Cannot deactivate the module $module!\n";
193 print STDERR "Aborting makefile generation to enforce your installation policy.\n";
200 print STDERR "All modules will be installed.\n";
203 ## some information about the used OpenXPKI version
205 print STDERR "This is OpenXPKI version $openxpki_version\n";
207 # removed code statistics code, it introduces an annoying delay during
208 # Makefile creation. it was not working accurateley anyway.
209 # if you wish to generate meaningful statistics use e. g. sloccount instead
210 #print STDERR "Statistics:\n";
211 #my $cmd = 'cat OpenXPKI.pm OpenXPKI.xs `find OpenXPKI -type f | grep -r -v "/\."`| wc -l';
212 #print STDERR " LOC: ".`$cmd`;
213 #$cmd = 'cat `find t -type f | grep -r -v "/\."`| wc -l';
214 #print STDERR " LOT: ".`$cmd`;
215 #$cmd = 'cat `find . -type f | grep -r -v "/\."`| wc -l';
216 #print STDERR " LOA: ".`$cmd`;
218 ## hack to avoid warnings from Log4perl
220 eval 'use Log::Log4perl::Logger';
222 eval '$Log::Log4perl::Logger::NON_INIT_WARNED = 1;';
225 print STDERR "Logger is not installed. Continue anyway.\n";
228 # check if we should add -shared
229 # not all platforms support this feature
232 open $fh, '>test.c' or die "Cannot open test.c. Stopped";
233 print $fh "int main() {}\n";
236 my $cc = $Config{'cc'};
238 my $cc_supports_shared = 1;
239 if (open $fh, "$cc -shared -o test test.c 2>&1 |") {
240 while (my $line = <$fh>) {
241 if ($line =~ m{ unrecognized .* option .* -shared }xms) {
242 $cc_supports_shared = 0;
247 $cc_supports_shared = 0;
250 if (! $cc_supports_shared)
252 print STDERR "C compiler does not support -shared.\n";
255 if ($^O ne 'darwin') {
256 print STDERR "C compiler supports -share. Adding it to LDDLFLAGS.\n";
257 $flags{'LDDLFLAGS'} = '-shared';
260 print STDERR "C compiler claims to support -share. But we are on Mac OS X, experience shows that it still does not work with -share, so we won't add it to LDDLFLAGS ...\n";
265 print STDERR "Could not run C compiler. Continue anyway.\n";
271 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
272 # the contents of the Makefile that is written.
274 'NAME' => 'OpenXPKI',
275 'VERSION' => $openxpki_version,
276 'LIBS' => ["-L$openssl_lib_dir -lcrypto"],
277 'INC' => "-I. -I$openssl_inc_dir",
278 'CCFLAGS' => '-O2 -g',
280 'Class::Accessor::Fast' => '0.31',
281 'Class::Accessor::Chained::Fast' => 1,
282 'Class::Std' => '0.0.8',
283 'CGI::Session' => '3.95',
285 'Data::Password' => '1.07',
286 'Data::Serializer' => '0.44',
287 'DateTime' => "0.22",
288 'DateTime::Format::DateParse' => '0.04',
291 'English' => 1, ## for broken Perl installations like on Ubuntu Drapper
292 'Exception::Class' => "1.22",
293 'Filter::Util::Call' => 1,
294 'IO::Prompt' => '0.099004', # required for deployment tools
295 ## includes the version of libintl-perl which includes Locale::Messages
296 'IPC::ShareLite' => '0.09',
297 'Locale::TextDomain' => 1,
298 'Log::Log4perl' => '0.51',
299 'Mail::RFC822::Address' => '0.3',
302 'Net::LDAP' => "0.32",
303 'Net::Server' => '0.94',
304 'Params::Validate' => '0.77',
305 'Proc::ProcessTable' => '0.43',
306 'Regexp::Common' => 2,
307 'Sys::SigAction' => '0.06',
308 'Template' => '2.15',
310 'Test::Pod' => "1.00",
311 'Test::Pod::Coverage' => "1.00",
312 'Text::CSV_XS' => "0.23",
314 'Workflow' => '0.27',
315 'XML::Filter::XInclude' => 1,
317 'XML::SAX' => '0.12',
318 'XML::SAX::Writer' => '0.44',
320 'XML::Validator::Schema' => '1.08',
321 'XML::SAX::PurePerl' => '0.90',
324 test => {TESTS => 't/*/*.t',
326 macro => { OPENSSL_BINARY => $openssl_binary,
328 clean => {FILES => 't/50_auth/cgisess_*'},
329 'XSPROTOARG' => '-noprototypes',