}
print $$0;
}
+<<
+ awk -f <<script2.awk "support\apxs.pl" $(INSTDIR) >"$(INSTDIR)\bin\apxs.pl"
+ BEGIN {
+ target = ARGV[2];
+ gsub( /\\/, "/", target );
+ delete ARGV[2];
+ }
+ { if ( $$0 ~ /@/) {
+ gsub( /@TARGET@/, "httpd" );
+ gsub( /@CC@/, "cl" );
+ gsub( /@CFLAGS@/, "-nologo -MD -W3 -O2 -DNDEBUG -DWIN32 -D_WINDOWS -FD" );
+ gsub( /@CFLAGS_SHLIB@/, "-DSHARED_MODULE" );
+ gsub( /@LD_SHLIB@/, "link" );
+ gsub( /@LDFLAGS_MOD_SHLIB@/, "-nologo -subsystem:windows -dll -libpath:\"" target "/libexec\" -incremental:no -map -machine:I386" );
+ gsub( /@LIBS_SHLIB@/, "ApacheCore.lib kernel32.lib advapi32.lib wsock32.lib ws2_32.lib" );
+ gsub( /@prefix@/, target );
+ gsub( /@sbindir@/, target );
+ gsub( /@includedir@/, target "/include" );
+ gsub( /@libexecdir@/, target "/modules" );
+ gsub( /@sysconfdir@/, target "/conf" );
+ }
+ print $$0;
+ }
<<
##
## Initial DSO support check
##
+if ($^O ne "MSWin32") {
if (not -x "$CFG_SBINDIR/$CFG_TARGET") {
print STDERR "apxs:Error: $CFG_SBINDIR/$CFG_TARGET not found or not executable\n";
exit(1);
print STDERR "apxs:Error: binary `$CFG_SBINDIR/$CFG_TARGET'.\n";
exit(1);
}
+}
##
## Operation
$opt .= "$1 " if ($opt_Wc =~ m|^\s*c,(.*)$|);
}
foreach $opt_I (@opt_I) {
+ $opt_I = '"' . $opt_I . '"' if ($opt_I =~ m|\s|);
$opt .= "-I$opt_I ";
}
foreach $opt_D (@opt_D) {
$opt .= "-D$opt_D ";
}
my $cflags = "$CFG_CFLAGS $CFG_CFLAGS_SHLIB";
+ if ($^O eq "MSWin32") {
+ my $d = $dso_file;
+ $d =~ s|\.so$||;
+ $d = '"' . $d . '"' if ($d =~ m|\s|);
+ $opt .= "-Fd$d ";
+ }
my $s;
foreach $s (@srcs) {
my $o = $s;
- $o =~ s|\.c$|.o|;
- $o =~ s|^.*/||;
- push(@cmds, "$CFG_CC $cflags -I$CFG_INCLUDEDIR $opt -c $s");
+ $s = '"' . $s . '"' if ($s =~ m|\s|);
+ if ($^O ne "MSWin32") {
+ $o =~ s|\.c$|.o|;
+ $o =~ s|^.*/||;
+ $o = '"' . $o . '"' if ($o =~ m|\s|);
+ push(@cmds, "$CFG_CC $cflags -I$CFG_INCLUDEDIR $opt -c $s");
+ } else {
+ $o =~ s|\.c$|.obj|;
+ $o =~ s|^.*/||;
+ $o = '"' . $o . '"' if ($o =~ m|\s|);
+ push(@cmds, "$CFG_CC $cflags -I\"$CFG_INCLUDEDIR\" $opt -c $s -Fo$o");
+ }
unshift(@objs, $o);
}
# create link command
- my $cmd = "$CFG_LD_SHLIB $CFG_LDFLAGS_SHLIB -o $dso_file";
+ my $cmd;
+ if ($^O ne "MSWin32") {
+ $cmd = "$CFG_LD_SHLIB $CFG_LDFLAGS_SHLIB -o $dso_file";
+ } else {
+ $cmd = "$CFG_LD_SHLIB $CFG_LDFLAGS_SHLIB -out:\"$dso_file\"";
+ }
my $o;
foreach $o (@objs) {
$cmd .= " $o";
}
}
foreach $opt_L (@opt_L) {
- $opt .= " -L$opt_L";
+ if ($^O ne "MSWin32") {
+ $opt .= " -L$opt_L";
+ } else {
+ $opt .= " -libpath:\"$opt_L\"";
+ }
}
foreach $opt_l (@opt_l) {
- $opt .= " -l$opt_l";
+ if ($^O ne "MSWin32") {
+ $opt .= " -l$opt_l";
+ } else {
+ $opt .= " $opt_l";
+ }
}
$cmd .= $opt;
$cmd .= " $CFG_LIBS_SHLIB";
exit(1);
}
my $t = $f;
- $t =~ s|^.+/([^/]+)$|$1|;
- if ($opt_i) {
- push(@cmds, "cp $f $CFG_LIBEXECDIR/$t");
- push(@cmds, "chmod 755 $CFG_LIBEXECDIR/$t");
+ if ($^O ne "MSWin32") {
+ $t =~ s|^.+/([^/]+)$|$1|;
+ if ($opt_i) {
+ push(@cmds, "cp $f $CFG_LIBEXECDIR/$t");
+ push(@cmds, "chmod 755 $CFG_LIBEXECDIR/$t");
+ }
}
-
+ else {
+ $t =~ s|^.+[/\\]([^/\\]+)$|$1|;
+ if ($opt_i) {
+ push(@cmds, "copy \"$f\" \"$CFG_LIBEXECDIR/$t\"");
+ }
+ }
+
# determine module symbolname and filename
my $filename = '';
if ($name eq 'unknown') {
if ($content =~ m|.*module\s+(?:MODULE_VAR_EXPORT\s+)?([a-zA-Z0-9_]+)_module\s*=\s*.*|s) {
$name = "$1";
$filename = "$base.c";
- $filename =~ s|^[^/]+/||;
+ $filename =~ s|^.+/||;
+ $filename =~ s|^.+\\|| if ($^O eq "MSWin32");
}
}
if ($name eq '') {
if ($base =~ m|.*mod_([a-zA-Z0-9_]+)\..+|) {
$name = "$1";
$filename = $base;
- $filename =~ s|^[^/]+/||;
+ $filename =~ s|^.+/||;
+ $filename =~ s|^.+\\|| if ($^O eq "MSWin32");
}
}
if ($name eq '') {
push(@amd, sprintf("AddModule %s", $filename));
}
- # execute the commands
- &execute_cmds(@cmds);
-
# activate module via LoadModule/AddModule directive
if ($opt_a or $opt_A) {
- if (not -f "$CFG_SYSCONFDIR/$CFG_TARGET.conf") {
- print STDERR "apxs:Error: Config file $CFG_SYSCONFDIR/$CFG_TARGET.conf not found\n";
+ my $cfgbase = "$CFG_SYSCONFDIR/$CFG_TARGET";
+ if (not -f "$cfgbase.conf") {
+ print STDERR "apxs:Error: Config file $cfgbase.conf not found\n";
exit(1);
}
- open(FP, "<$CFG_SYSCONFDIR/$CFG_TARGET.conf") || die;
+ open(FP, "<$cfgbase.conf") || die;
my $content = join('', <FP>);
close(FP);
if ($content !~ m|\n#?\s*LoadModule\s+|) {
- print STDERR "apxs:Error: Activation failed for custom $CFG_SYSCONFDIR/$CFG_TARGET.conf file.\n";
+ print STDERR "apxs:Error: Activation failed for custom $cfgbase.conf file.\n";
print STDERR "apxs:Error: At least one `LoadModule' directive already has to exist.\n";
exit(1);
}
$content =~ s|^(.*\n)#?\s*$lmd[^\n]*\n|$1$c$lmd\n|sg;
}
$lmd =~ m|LoadModule\s+(.+?)_module.*|;
- print STDERR "[$what module `$1' in $CFG_SYSCONFDIR/$CFG_TARGET.conf]\n";
+ print STDERR "[$what module `$1' in $cfgbase.conf]\n";
}
my $amd;
foreach $amd (@amd) {
}
}
if (@lmd or @amd) {
- if (open(FP, ">$CFG_SYSCONFDIR/$CFG_TARGET.conf.new")) {
+ if (open(FP, ">$cfgbase.conf.new")) {
print FP $content;
close(FP);
- system("cp $CFG_SYSCONFDIR/$CFG_TARGET.conf $CFG_SYSCONFDIR/$CFG_TARGET.conf.bak && " .
- "cp $CFG_SYSCONFDIR/$CFG_TARGET.conf.new $CFG_SYSCONFDIR/$CFG_TARGET.conf && " .
- "rm $CFG_SYSCONFDIR/$CFG_TARGET.conf.new");
+ if ($^O ne "MSWin32") {
+ push(@cmds, "cp $cfgbase.conf $cfgbase.conf.bak");
+ push(@cmds, "cp $cfgbase.conf.new $cfgbase.conf");
+ push(@cmds, "rm $cfgbase.conf.new");
+ } else {
+ $cfgbase =~ s|/|\\|g;
+ push(@cmds, "copy \"$cfgbase.conf\" \"$cfgbase.conf.bak\"");
+ push(@cmds, "copy \"$cfgbase.conf.new\" \"$cfgbase.conf\"");
+ push(@cmds, "del \"$cfgbase.conf.new\"");
+ }
} else {
print STDERR "apxs:Error: unable to open configuration file\n";
}
}
}
+
+ # execute the commands
+ &execute_cmds(@cmds);
}
##EOF##