Skip to content

Commit 2d5cf17

Browse files
author
H. Peter Anvin
committed
misc/emacstbl.pl: add NASM version to output, add to Makefile
Include the version number in the output (misc/nasmtok.el) and add a rule for generating it to the Makefiles. Signed-off-by: H. Peter Anvin <[email protected]>
1 parent b58771d commit 2d5cf17

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

Makefile.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ PERLREQ = config/unconfig.h \
195195
macros/macros.c \
196196
asm/pptok.ph asm/directbl.c asm/directiv.h \
197197
asm/warnings.c include/warnings.h doc/warnings.src \
198+
misc/nasmtok.el \
198199
version.h version.mac version.mak nsis/version.nsh
199200

200201
INSDEP = x86/insns.dat x86/insns.pl x86/insns-iflags.ph x86/iflags.ph
@@ -336,6 +337,11 @@ asm/directbl.c: asm/directiv.dat nasmlib/perfhash.pl perllib/phash.ph
336337
$(RUNPERL) $(srcdir)/nasmlib/perfhash.pl c \
337338
$(srcdir)/asm/directiv.dat asm/directbl.c
338339

340+
# Emacs token files
341+
misc/nasmtok.el: misc/emacstbl.pl asm/tokhash.c asm/pptok.c \
342+
asm/directiv.dat version
343+
$(RUNPERL) $< $@ "$(srcdir)" "$(objdir)"
344+
339345
#-- End Generated File Rules --#
340346

341347
perlreq: $(PERLREQ)

Mkfiles/msvc.mak

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ PERLREQ = config\unconfig.h \
154154
macros\macros.c \
155155
asm\pptok.ph asm\directbl.c asm\directiv.h \
156156
asm\warnings.c include\warnings.h doc\warnings.src \
157+
misc\nasmtok.el \
157158
version.h version.mac version.mak nsis\version.nsh
158159

159160
INSDEP = x86\insns.dat x86\insns.pl x86\insns-iflags.ph x86\iflags.ph
@@ -295,6 +296,11 @@ asm\directbl.c: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
295296
$(RUNPERL) $(srcdir)\nasmlib\perfhash.pl c \
296297
$(srcdir)\asm\directiv.dat asm\directbl.c
297298

299+
# Emacs token files
300+
misc\nasmtok.el: misc\emacstbl.pl asm\tokhash.c asm\pptok.c \
301+
asm\directiv.dat version
302+
$(RUNPERL) $< $@ "$(srcdir)" "$(objdir)"
303+
298304
#-- End Generated File Rules --#
299305

300306
perlreq: $(PERLREQ)

Mkfiles/openwcom.mak

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ PERLREQ = config\unconfig.h &
167167
macros\macros.c &
168168
asm\pptok.ph asm\directbl.c asm\directiv.h &
169169
asm\warnings.c include\warnings.h doc\warnings.src &
170+
misc\nasmtok.el &
170171
version.h version.mac version.mak nsis\version.nsh
171172

172173
INSDEP = x86\insns.dat x86\insns.pl x86\insns-iflags.ph x86\iflags.ph
@@ -308,6 +309,11 @@ asm\directbl.c: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
308309
$(RUNPERL) $(srcdir)\nasmlib\perfhash.pl c &
309310
$(srcdir)\asm\directiv.dat asm\directbl.c
310311

312+
# Emacs token files
313+
misc\nasmtok.el: misc\emacstbl.pl asm\tokhash.c asm\pptok.c &
314+
asm\directiv.dat version
315+
$(RUNPERL) $< $@ "$(srcdir)" "$(objdir)"
316+
311317
#-- End Generated File Rules --#
312318

313319
perlreq: $(PERLREQ) .SYMBOLIC

misc/emacstbl.pl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ ($@)
3131
'floatize' => 'function',
3232
'strfunc' => 'function',
3333
'ifunc' => 'function',
34+
'insn' => 'instruction',
35+
'reg' => 'register',
3436
'seg' => 'special',
3537
'wrt' => 'special' );
3638

@@ -124,6 +126,18 @@ ($)
124126
close($dd);
125127
}
126128

129+
my $version;
130+
sub read_version($) {
131+
my($vfile) = @_;
132+
open(my $v, '<', $vfile)
133+
or die "$0:$vfile: $!\n";
134+
135+
$version = <$v>;
136+
chomp $version;
137+
138+
close($v);
139+
}
140+
127141
sub make_lines($$@) {
128142
my $maxline = shift @_;
129143
my $indent = shift @_;
@@ -171,12 +185,23 @@ ($)
171185
open(my $out, '>', $outfile)
172186
or die "$0:$outfile: $!\n";
173187

188+
my($vol,$dir,$file) = File::Spec->splitpath($outfile);
189+
190+
print $out ";;; ${file} --- lists of NASM assembler tokens\n";
191+
print $out ";;;\n";
192+
print $out ";;; This file contains list of tokens from the NASM x86\n";
193+
print $out ";;; assembler, automatically extracted from NASM ${version}.\n";
194+
print $out ";;;\n";
195+
print $out ";;; This file is intended to be (require)d from a `nasm-mode\'\n";
196+
print $out ";;; major mode definition.\n";
197+
174198
foreach my $type (sort keys(%tokens)) {
175-
print $out "(defconst nasm-${type}\n";
199+
print $out "\n(defconst nasm-${type}\n";
176200
print $out " \'(";
177201

178202
print $out make_lines(78, 4, quote_for_emacs(sort @{$tokens{$type}}));
179-
print $out "))\n";
203+
print $out ")\n";
204+
print $out " \"NASM ${version} ${type} tokens for `nasm-mode\'.\")\n";
180205
}
181206

182207
close($out);
@@ -185,5 +210,6 @@ ($)
185210
read_tokhash_c(File::Spec->catfile($objdir, 'asm', 'tokhash.c'));
186211
read_pptok_c(File::Spec->catfile($objdir, 'asm', 'pptok.c'));
187212
read_directiv_dat(File::Spec->catfile($srcdir, 'asm', 'directiv.dat'));
213+
read_version(File::Spec->catfile($srcdir, 'version'));
188214

189215
write_output($outfile);

0 commit comments

Comments
 (0)