aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile13
-rw-r--r--fixtags.pl25
2 files changed, 36 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index b40ed3c..3920b8d 100644
--- a/Makefile
+++ b/Makefile
@@ -103,12 +103,21 @@ BIGNUM_CFLAGS=-DBIGNUM=BIGFLOAT
#BIGNUM_CFLAGS=-DBIGNUM=BIGINT48
# Default rule for plain 'make' command is to build the binary.
-all: $(XEX)
+all: $(XEX) tags
# I have F10 in my editor bound to 'make test', so:
test: all
atari800 -nobasic $(XEX)
+# ctags. I forgot it can handle cc65 asm source. One wrinkle: C
+# identifiers get prepended with an underscore from the POV of assembly
+# code, and asm identifiers need a leading underscore to be used from
+# C. There's probably a clever way to get ctags to handle this, but I
+# don't know it, so I wrote a perl script to do the job.
+tags:
+ ctags $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC)
+ perl fixtags.pl tags
+
# The above is fast & easy, but from time to time it's necessary
# to test slow loading, make sure the title screen stuff works OK.
testatr: taipan.atr
@@ -227,7 +236,7 @@ convfont: convfont.c
# Obligatory clean and distclean rules.
clean:
- rm -f *.o *.lst convfont *.xex AUTORUN.SYS taipan.atr ver.dat help.dat
+ rm -f *.o *.lst convfont *.xex AUTORUN.SYS taipan.atr ver.dat help.dat tags
distclean: clean
rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz comptitle.s comptitle.dat
diff --git a/fixtags.pl b/fixtags.pl
new file mode 100644
index 0000000..ce7567f
--- /dev/null
+++ b/fixtags.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+# read a ctags file. for every tag found, create its
+# corresponding tag with or without leading _.
+# vim wants the tagfile sorted, so do that, too.
+
+$file = $ARGV[0];
+while(<>) {
+ push @tags, $_;
+ next if /^!/; # skip ctags magic tags
+
+ # skip C #defines
+ my @fields = split '\t';
+ next if $fields[1] =~ /\.c$/ && $fields[3] =~ /^d$/;
+
+ if(/^_/) {
+ s/^_//;
+ } else {
+ s/^/_/;
+ }
+ push @tags, $_;
+}
+
+open OUT, ">$file" or die $!;
+print OUT for sort @tags;