summaryrefslogtreecommitdiff
path: root/makedef.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-07-28 14:04:53 +0200
committerNicholas Clark <nick@ccl4.org>2011-08-01 11:53:57 +0200
commitc1b34f5f97867eb890e535d297dd284487aef5b4 (patch)
tree04a666655ddcb203b9a76f79e9c426c05694939f /makedef.pl
parent208d7614b345d1fbee3347436a4ce3868b50efbd (diff)
downloadperl-c1b34f5f97867eb890e535d297dd284487aef5b4.tar.gz
In makedef.pl, consolidate all the C compiler flags parsing code.
This isn't quite a "pure" refactoring, as -Dfoo=bar read from %Config will now be processed as $Config{foo} = 'bar'; instead of $Config{foo} = 1; However, it won't change any behaviour, as the only time makedef.pl uses a value of %define for anything other than a truth test is $define{PERL_DLL}, and that is passed in on the command-line by the Makefile invoking makedef.pl
Diffstat (limited to 'makedef.pl')
-rw-r--r--makedef.pl22
1 files changed, 10 insertions, 12 deletions
diff --git a/makedef.pl b/makedef.pl
index 69e90ca7ea..0874fbac22 100644
--- a/makedef.pl
+++ b/makedef.pl
@@ -42,17 +42,18 @@ $TARG_DIR = '';
my %define;
+sub process_cc_flags {
+ foreach (map {split /\s+/, $_} @_) {
+ $define{$1} = $2 // 1 if /^-D(\w+)(?:=(.+))?/;
+ }
+}
+
while (@ARGV) {
my $flag = shift;
- if ($flag =~ s/^CC_FLAGS=/ /) {
- for my $fflag ($flag =~ /(?:^|\s)-D(\S+)/g) {
- $fflag .= '=1' unless $fflag =~ /^(\w+)=/;
- $define{$1} = $2 if $fflag =~ /^(\w+)=(.+)$/;
- }
+ if ($flag =~ /^(?:CC_FLAGS=)?(-D\w.*)/) {
+ process_cc_flags($1);
next;
}
- $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
- $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
$CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
$PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
$FILETYPE = $1 if ($flag =~ /^FILETYPE=(\w+)$/);
@@ -68,11 +69,8 @@ exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n";
# Is the following guard strictly necessary? Added during refactoring
# to keep the same behaviour when merging other code into here.
-if ($PLATFORM ne 'win32' && $PLATFORM ne 'wince' && $PLATFORM ne 'netware') {
- foreach (@Config{qw(ccflags optimize)}) {
- $define{$1} = 1 while /-D(\w+)/g;
- }
-}
+process_cc_flags(@Config{qw(ccflags optimize)})
+ if $PLATFORM ne 'win32' && $PLATFORM ne 'wince' && $PLATFORM ne 'netware';
# Add the compile-time options that miniperl was built with to %define.
# On Win32 these are not the same options as perl itself will be built