Skip to content

Commit

Permalink
Fix building in a separate directory from the source code
Browse files Browse the repository at this point in the history
The code to handle building in a separate directory had seriously
bitrotted.  This contains a number of fixes to make it possible,
including bits like the documentation which never worked in the past.

Signed-off-by: H. Peter Anvin <[email protected]>
  • Loading branch information
H. Peter Anvin committed May 17, 2016
1 parent b06736a commit 4071660
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 117 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ TAGS
/doc/*.txt
/doc/Makefile
/doc/inslist.src
/doc/version.src
/doc/html
/doc/info
/insnsa.c
Expand All @@ -52,7 +53,7 @@ TAGS
/nasm.1
/ndisasm
/ndisasm.man
/nasm.1
/ndisasm.1
/pptok.c
/pptok.h
/pptok.ph
Expand Down
7 changes: 5 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

top_srcdir = @top_srcdir@
srcdir = @srcdir@
objdir = @builddir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
Expand Down Expand Up @@ -205,9 +206,11 @@ perlreq: $(PERLREQ)
nsis/arch.nsh: nsis/getpearch.pl nasm$(X)
$(PERL) $(srcdir)/nsis/getpearch.pl nasm$(X) > nsis/arch.nsh

# Should only be done after "make everything"
# Should only be done after "make everything".
# The use of redirection here keeps makensis from moving the cwd to the
# source directory.
nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
$(MAKENSIS) nsis/nasm.nsi
$(MAKENSIS) -Dsrcdir="$(srcdir)" -Dobjdir="$(objdir)" - < "$<"

# Generated manpages, also pregenerated for distribution
manpages: nasm.1 ndisasm.1
Expand Down
30 changes: 19 additions & 11 deletions doc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# UNIX Makefile for NASM documentation
#

top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
prefix = @prefix@
Expand All @@ -16,7 +17,7 @@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

PERL = perl
PERL = perl -I$(srcdir)
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
TEXI2IPF = texi2ipf
Expand All @@ -26,7 +27,7 @@ ACRODIST = @ACRODIST@ # Acrobat Distiller
PSTOPDF = @PSTOPDF@ # BSD/MacOS X utility
PS2PDF = @PS2PDF@ # Part of GhostScript

SRCS = nasmdoc.src inslist.src changes.src
SRCS = nasmdoc.src inslist.src changes.src version.src
OUT = info html nasmdoc.txt nasmdoc.ps nasmdoc.pdf

# exports
Expand All @@ -38,28 +39,35 @@ all: $(OUT)
os2: nasm.inf

inslist.src: inslist.pl ../insns.dat
$(PERL) $(srcdir)/inslist.pl
$(PERL) $(srcdir)/inslist.pl $(srcdir)/../insns.dat

.PHONY: html
html: html/nasmdoc0.html

RDSRC = $(PERL) $(srcdir)/rdsrc.pl -I$(srcdir)/

html/nasmdoc0.html: $(SRCS) rdsrc.pl
mkdir -p html
$(PERL) $(srcdir)/rdsrc.pl html < $<
$(RDSRC) html "$<"
mv -f *.html html

nasmdoc.dip: $(SRCS) rdsrc.pl
$(PERL) $(srcdir)/rdsrc.pl dip < $<
$(RDSRC) dip "$<"

nasmdoc.texi: $(SRCS) rdsrc.pl
$(PERL) $(srcdir)/rdsrc.pl texi < $<
$(RDSRC) texi "$<"

nasmdoc.txt: $(SRCS) rdsrc.pl
$(PERL) $(srcdir)/rdsrc.pl txt < $<
$(RDSRC) txt "$<"

version.src: $(top_srcdir)/version.pl $(top_srcdir)/version
$(PERL) $(top_srcdir)/version.pl docsrc \
< $(top_srcdir)/version > version.src

nasmdoc.ps: nasmdoc.dip nasmlogo.eps $(srcdir)/../version genpsdriver.pl \
genps.pl psfonts.ph pswidth.ph head.ps
$(PERL) $(srcdir)/genpsdriver.pl > nasmdoc.ps
nasmdoc.ps: nasmdoc.dip nasmlogo.eps \
genps.pl psfonts.ph pswidth.ph head.ps
$(PERL) $(srcdir)/genps.pl -headps $(srcdir)/head.ps nasmdoc.dip \
> nasmdoc.ps

nasmdoc.pdf: nasmdoc.ps
$(ACRODIST) -n -q --nosecurity -o $@ $< || \
Expand Down Expand Up @@ -88,7 +96,7 @@ nasm.inf: nasmdoc.ipf
clean:
-rm -f *.rtf *.hpj *.texi *.gid *.ipf *.dip
-rm -f *.aux *.cp *.fn *.ky *.pg *.log *.toc *.tp *.vr
-rm -f inslist.src
-rm -f inslist.src version.src

spotless: clean
-rm -rf html info
Expand Down
13 changes: 8 additions & 5 deletions doc/genps.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/perl
## --------------------------------------------------------------------------
##
## Copyright 1996-2012 The NASM Authors - All Rights Reserved
## Copyright 1996-2016 The NASM Authors - All Rights Reserved
## See the file AUTHORS included with the NASM distribution for
## the specific copyright holders.
##
Expand Down Expand Up @@ -36,9 +36,6 @@
# Format the documentation as PostScript
#

use Env;
use lib $srcdir;

require 'psfonts.ph'; # The fonts we want to use
require 'pswidth.ph'; # PostScript string width

Expand Down Expand Up @@ -87,6 +84,9 @@
'11x17' => [792,1224], # US double paper size
);

# Canned header file
$headps = 'head.ps';

#
# Parse the command line
#
Expand All @@ -104,6 +104,8 @@
$psconf{$parm} = shift(@ARGV);
} elsif ( $parm =~ /^(title|subtitle|year|author|license)$/ ) {
$metadata{$parm} = shift(@ARGV);
} elsif ( $parm eq 'headps' ) {
$headps = shift(@ARGV);
} else {
die "$0: Unknown option: $arg\n";
}
Expand Down Expand Up @@ -1028,7 +1030,8 @@ ($$)
print "/bullet [",ps_string($charcode{'bullet'}),"] def\n";

# Emit the canned PostScript prologue
open(PSHEAD, "< head.ps");
open(PSHEAD, '<', $headps)
or die "$0: cannot open: $headps: $!\n";
while ( defined($line = <PSHEAD>) ) {
print $line;
}
Expand Down
64 changes: 0 additions & 64 deletions doc/genpsdriver.pl

This file was deleted.

5 changes: 4 additions & 1 deletion doc/nasmdoc.src
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
\#
\# Source code to NASM documentation
\#

\M{category}{Programming}
\M{title}{NASM - The Netwide Assembler}
\M{year}{1996-2016}
Expand All @@ -45,6 +46,9 @@
\M{infotitle}{The Netwide Assembler for x86}
\M{epslogo}{nasmlogo.eps}
\M{logoyadj}{-72}

\& version.src

\IR{-D} \c{-D} option
\IR{-E} \c{-E} option
\IR{-F} \c{-F} option
Expand Down Expand Up @@ -8254,4 +8258,3 @@ column shows the processor type in which the instruction was introduced and,
\A{changelog} \i{NASM Version History}

\& changes.src

50 changes: 36 additions & 14 deletions doc/rdsrc.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/perl
## --------------------------------------------------------------------------
##
##
## Copyright 1996-2016 The NASM Authors - All Rights Reserved
## See the file AUTHORS included with the NASM distribution for
## the specific copyright holders.
Expand All @@ -15,7 +15,7 @@
## copyright notice, this list of conditions and the following
## disclaimer in the documentation and/or other materials provided
## with the distribution.
##
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
Expand Down Expand Up @@ -116,12 +116,20 @@
# \&{filename}
# Includes filename. Recursion is allowed.
#

use IO::File;

use File::Spec;

@include_path = ();

$diag = 1, shift @ARGV if $ARGV[0] eq "-d";
while ($ARGV[0] =~ /^\-[Ii](.*)$/) {
push(@include_path, $1);
shift;
}

($out_format) = @ARGV;
$out_format = shift(@ARGV);
@files = @ARGV;
@files = ('-') unless(scalar(@files));

$| = 1;

Expand All @@ -136,9 +144,8 @@
$pname = "para000000";
@pnames = @pflags = ();
$para = undef;
while (defined($_ = <STDIN>)) {
$_ = &untabify($_);
&check_include($_);
foreach $file (@files) {
&include($file);
}
&got_para($para);
print "done.\n";
Expand Down Expand Up @@ -205,8 +212,9 @@ ($)
}
return $o;
}
sub check_include {
sub read_line {
local $_ = shift;
$_ = &untabify($_);
if (/\\& (\S+)/) {
&include($1);
} else {
Expand All @@ -226,11 +234,25 @@ ($_)
}
sub include {
my $name = shift;
my $F = IO::File->new($name)
or die "Cannot open $name: $!";
while (<$F>) {
&check_include($_);
my $F;

if ($name eq '-') {
open($F, '<-'); # stdin
} else {
my $found = 0;
foreach my $idir ( File::Spec->curdir, @include_path ) {
my $fpath = File::Spec->catfile($idir, $name);
if (open($F, '<', $fpath)) {
$found = 1;
last;
}
}
die "Cannot open $name: $!\n" unless ($found);
}
while (defined($_ = <$F>)) {
&read_line($_);
}
close($F);
}
sub got_para {
local ($_) = @_;
Expand Down Expand Up @@ -1493,7 +1515,7 @@ sub add_item {
#
sub write_dip {
open(PARAS, "> nasmdoc.dip");
foreach $k (keys(%metadata)) {
foreach $k (sort(keys(%metadata))) {
print PARAS 'meta :', $k, "\n";
print PARAS $metadata{$k},"\n";
}
Expand Down
Loading

0 comments on commit 4071660

Please sign in to comment.