summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Noonan <steven@uplinklabs.net>2009-10-19 15:07:55 -0700
committerSteven Noonan <steven@uplinklabs.net>2009-10-19 15:07:55 -0700
commit725154d095f6ff449d16597201294b7fe99dd215 (patch)
treef88d19aad00fefd105ec120570ec3bd0532912a0
parent0102f92c2f6c0585beb3eb93281fe1f564cdf374 (diff)
downloadcrawl-ref-725154d095f6ff449d16597201294b7fe99dd215.tar.gz
crawl-ref-725154d095f6ff449d16597201294b7fe99dd215.zip
compflag.h: generate via perl script instead of shell
Some platforms broke because they used /bin/sh, which doesn't have the '-n' parameter for 'echo'. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
-rw-r--r--crawl-ref/source/makefile19
-rwxr-xr-xcrawl-ref/source/util/gen-cflg.pl38
2 files changed, 41 insertions, 16 deletions
diff --git a/crawl-ref/source/makefile b/crawl-ref/source/makefile
index 283a6bd2f2..feedfd0f10 100644
--- a/crawl-ref/source/makefile
+++ b/crawl-ref/source/makefile
@@ -419,11 +419,11 @@ endif
endif
ifneq ($(strip $(SAVEDIR)),)
-CFOTHERS_L += '-DSAVE_DIR_PATH="$(strip $(prefix))/$(strip $(SAVEDIR))"'
+CFOTHERS_L += -DSAVE_DIR_PATH=\"$(strip $(prefix))/$(strip $(SAVEDIR))\"
endif
ifneq ($(strip $(DATADIR)),)
-CFOTHERS_L += '-DDATA_DIR_PATH="$(strip $(prefix))/$(strip $(DATADIR))"'
+CFOTHERS_L += -DDATA_DIR_PATH=\"$(strip $(prefix))/$(strip $(DATADIR))\"
endif
ifndef NO_NCURSES
@@ -701,20 +701,7 @@ distclean: clean clean-contrib clean-rltiles
# This information is included in crash reports, and is printed with
# "crawl -version"
compflag.h:
- $(QUIET_GEN)
- @echo "// Automatically generated by makefile" > compflag.h
- @echo "#ifndef __included_crawl_compiler_flags_h" >> compflag.h
- @echo "#define __included_crawl_compiler_flags_h" >> compflag.h
- @echo -n "#define CRAWL_CFLAGS \"" >> compflag.h
- @echo -n $(CFLAGS) | sed 's/\"/\\"/g' >> compflag.h
- @echo "\"" >> compflag.h
- @echo -n "#define CRAWL_CFLAGS_L \"" >> compflag.h
- @echo -n $(CFLAGS_L) | sed 's/\"/\\"/g' >> compflag.h
- @echo "\"" >> compflag.h
- @echo -n "#define CRAWL_LDFLAGS \"" >> compflag.h
- @echo -n $(LDFLAGS) | sed 's/\"/\\"/g' >> compflag.h
- @echo "\"" >> compflag.h
- @echo "#endif" >> compflag.h
+ $(QUIET_GEN)util/gen-cflg.pl compflag.h "$(CFLAGS)" "$(CFLAGS_L)" "$(LDFLAGS)"
$(GAME): $(GAME_DEPENDS)
$(QUIET_LINK)$(CXX) $(LDFLAGS) $(EXTRA_OBJECTS) $(OBJECTS) -o $(GAME) $(LIB)
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 $!;