summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/gen-cflg.pl
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/util/gen-cflg.pl')
-rwxr-xr-xcrawl-ref/source/util/gen-cflg.pl38
1 files changed, 38 insertions, 0 deletions
diff --git a/crawl-ref/source/util/gen-cflg.pl b/crawl-ref/source/util/gen-cflg.pl
new file mode 100755
index 0000000000..2f5e8983e2
--- /dev/null
+++ b/crawl-ref/source/util/gen-cflg.pl
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $outfile = $ARGV[0];
+my $cflags = $ARGV[1];
+my $cflags_l = $ARGV[2];
+my $ldflags = $ARGV[3];
+
+$cflags =~ s/\"/\\"/g;
+$cflags_l =~ s/\"/\\"/g;
+$ldflags =~ s/\"/\\"/g;
+
+while ($cflags =~ s/[ \t]{2,}/ /g) {}
+while ($cflags_l =~ s/[ \t]{2,}/ /g) {}
+while ($ldflags =~ s/[ \t]{2,}/ /g) {}
+
+$cflags =~ s/^[ \t]+|[ \t]$//;
+$cflags_l =~ s/^[ \t]+|[ \t]$//;
+$ldflags =~ s/^[ \t]+|[ \t]$//;
+
+my $prefix = "CRAWL";
+my $smprefix = "crawl";
+
+open OUT, ">", "$outfile" or die $!;
+print OUT <<__eof__;
+#ifndef __included_${smprefix}_compile_flags_h
+#define __included_${smprefix}_compile_flags_h
+
+#define ${prefix}_CFLAGS "${cflags}"
+#define ${prefix}_CFLAGS_L "${cflags_l}"
+#define ${prefix}_LDFLAGS "${ldflags}"
+
+#endif
+
+__eof__
+close OUT or die $!;