mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
The docs: target fed doc/Makefile.in directly to nmake, but that file relies on several GNU make-only constructs nmake cannot parse at all: the $^ automatic variable (not valid nmake macro syntax -- fatal parse error), $< used outside of an inference rule (silently unsupported, since nmake only defines $< within .SUFFIXES-style rules), and the GNU-only "-include *.dep" optional wildcard include directive (nmake only understands the unrelated "!include" directive). Add tools/mkmsvcdocmak.pl, which rewrites just those constructs to their explicit nmake-safe equivalents in a generated copy (doc/Makefile.msvc), leaving doc/Makefile.in itself untouched for the Unix/GNU make build. Verified by rewriting doc/Makefile.in this way and building nasmdoc.pdf through it with GNU make standing in for nmake. Also, doc/Makefile.in expects doc/warnings.src, doc/perlbreq.src and doc/pptok.src to have already been generated -- the Unix "doc" target does this via the top-level Makefile.in before recursing into doc/, but msvc.mak's docs: target had no equivalent step. warnings.src and pptok.src already had msvc.mak rules (just not wired up as prerequisites of docs:); perlbreq.src had no rule at all, since the top-level Makefile.in generates it with a POSIX find/sed pipeline that doesn't translate to Windows. Add tools/genperlbreq.pl, a portable pure-Perl equivalent (using File::Find), and a doc\perlbreq.src rule in msvc.mak that uses it; verified it produces output byte-identical to the existing POSIX pipeline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
60 lines
2.3 KiB
Prolog
60 lines
2.3 KiB
Prolog
#!/usr/bin/perl
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
|
# Copyright 1996-2025 The NASM Authors - All Rights Reserved
|
|
|
|
#
|
|
# doc/Makefile.in is written for GNU make (used unmodified, via
|
|
# autoconf substitution, on Unix). It relies on a handful of GNU
|
|
# make-only constructs -- the $^ automatic variable (not valid nmake
|
|
# syntax at all: nmake's parser treats a bare "$^" as an illegal macro
|
|
# reference and aborts), the $< automatic variable used outside of an
|
|
# inference rule (silently unsupported by nmake, since nmake only
|
|
# defines $< within .SUFFIXES-style inference rules), and the
|
|
# GNU-only "-include *.dep" optional-include directive (nmake only
|
|
# understands the "!include" directive and has no equivalent "ignore
|
|
# missing file, glob patterns allowed" form).
|
|
#
|
|
# Mkfiles/msvc.mak needs to feed doc/Makefile.in directly to nmake (it
|
|
# doesn't have its own copy of the doc build rules to maintain in
|
|
# parallel), so this script produces an nmake-safe copy of the file by
|
|
# rewriting just those constructs to their equivalent explicit form.
|
|
# doc/Makefile.in itself is left untouched for the Unix/GNU make
|
|
# build; only the copy this script writes is affected.
|
|
#
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
my ($in, $out) = @ARGV;
|
|
die "Usage: $0 <in> <out>\n" unless defined($in) && defined($out);
|
|
|
|
open(my $ifh, '<', $in) or die "$0: cannot open: $in\n";
|
|
open(my $ofh, '>', $out) or die "$0: cannot open: $out\n";
|
|
|
|
while (my $line = <$ifh>) {
|
|
# insns.src: inslist.pl ../x86/insns.xda
|
|
# $(RUNPERL) $^ $@
|
|
if (index($line, '$(RUNPERL) $^ $@') >= 0) {
|
|
$line =~ s/\$\(RUNPERL\) \$\^ \$\@/\$(RUNPERL) inslist.pl ..\/x86\/insns.xda \$\@/;
|
|
}
|
|
|
|
# $(htmltarget)/nasmdoc.dip/nasmdoc.txt: $< is the first prerequisite
|
|
# of $(ALLSRCS), i.e. $(SRCS) (nasmdoc.src).
|
|
$line =~ s/(\$\(RDSRC\)\s+(?:-ohtml html|dip|txt))\s+\$</$1 \$(SRCS)/;
|
|
|
|
# nasmdoc.pdf/nasmdoc-raw.pdf: $< is the first (only) prerequisite
|
|
# of interest, nasmdoc.ps.
|
|
$line =~ s/(\$\(PDFOPT\)\s+)\$<(\s+\$\@\s+fontpath)/$1nasmdoc.ps$2/;
|
|
|
|
# nasmdoc.pdf.xz: $< is nasmdoc-raw.pdf.
|
|
$line =~ s/(\$\(XZ\)\s+-9e\s+<\s+)\$<(\s+>\s+\$\@)/$1nasmdoc-raw.pdf$2/;
|
|
|
|
# GNU make-only optional wildcard include of auto-dependency files;
|
|
# not parseable by nmake at all, and unneeded for a one-shot build.
|
|
next if $line =~ /^-include\s+\*\.dep\s*$/;
|
|
|
|
print $ofh $line;
|
|
}
|
|
|
|
close($ifh);
|
|
close($ofh);
|