summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2021-04-07 21:30:02 -0700
committerH. Peter Anvin <hpa@zytor.com>2021-04-07 21:30:02 -0700
commit067a8ad8523669512ebd81973dbc62f791276ae0 (patch)
tree7d573e5dc9b4c4135853d3b8db988d8ad8ae1a93
parent9e82b7151710478e842283eec2ba25ff4dddb774 (diff)
downloadabc80sim-main.tar.gz
abc80sim-main.tar.xz
abc80sim-main.zip
Makefile: export .c file stem as a define, to simplify txt2c et almain
For autogenerated C files, it can be nice to have the name of the module (not the full filename) to use for generating symbols. Use this in txt2c.sed.
-rw-r--r--Makefile.in6
-rw-r--r--txt2c.sed4
2 files changed, 5 insertions, 5 deletions
diff --git a/Makefile.in b/Makefile.in
index da07cf5..0a33945 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -66,13 +66,13 @@ abc80win$(X): winwrap.c
$(PERL) bin2c.pl $< > $@ || ( rm -f $@ ; false )
%.$(O): %.c $(HDRS)
- $(CC) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CFLAGS) -DMODULE='$(*F)' -c -o $@ $<
%.i: %.c $(HDRS)
- $(CC) $(CFLAGS) -E -o $@ $<
+ $(CC) $(CFLAGS) -DMODULE='$(*F)' -E -o $@ $<
%.s: %.c $(HDRS)
- $(CC) $(CFLAGS) -S -o $@ $<
+ $(CC) $(CFLAGS) -DMODULE='$(*F)' -S -o $@ $<
helptxt.c: HELP.txt txt2c.sed
$(SED) -f txt2c.sed $< > $@
diff --git a/txt2c.sed b/txt2c.sed
index 5420ace..4558141 100644
--- a/txt2c.sed
+++ b/txt2c.sed
@@ -3,7 +3,7 @@ s/\([\\"]\)/\\\1/g
s/^/"/
s/$/\\n"/
1i\
-extern const char helptxt[];\
-const char helptxt[] =
+extern const char MODULE[];\
+const char MODULE[] =
$a\
;