summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2016-05-16 20:30:09 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2016-05-16 20:30:09 -0700
commit407166001c2df8ef32aae708ff797b069a0d398b (patch)
treebb576fc34a9bb01296a5c88311661a9c27645817
parentb06736ae7ee2af15c2d7176ca9cf241661b7cb49 (diff)
downloadnasm-407166001c2df8ef32aae708ff797b069a0d398b.tar.gz
Fix building in a separate directory from the source code
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 <hpa@linux.intel.com>
-rw-r--r--.gitignore3
-rw-r--r--Makefile.in7
-rw-r--r--doc/Makefile.in30
-rwxr-xr-xdoc/genps.pl13
-rw-r--r--doc/genpsdriver.pl64
-rw-r--r--doc/nasmdoc.src5
-rw-r--r--doc/rdsrc.pl50
-rw-r--r--nsis/nasm.nsi38
-rwxr-xr-xversion.pl5
9 files changed, 98 insertions, 117 deletions
diff --git a/.gitignore b/.gitignore
index 83236c59..dc2879f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,6 +39,7 @@ TAGS
/doc/*.txt
/doc/Makefile
/doc/inslist.src
+/doc/version.src
/doc/html
/doc/info
/insnsa.c
@@ -52,7 +53,7 @@ TAGS
/nasm.1
/ndisasm
/ndisasm.man
-/nasm.1
+/ndisasm.1
/pptok.c
/pptok.h
/pptok.ph
diff --git a/Makefile.in b/Makefile.in
index 13b10ce8..05f36ccc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -8,6 +8,7 @@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
+objdir = @builddir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
@@ -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
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 4932869f..dc81fb1e 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -2,6 +2,7 @@
# UNIX Makefile for NASM documentation
#
+top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
prefix = @prefix@
@@ -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
@@ -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
@@ -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 $@ $< || \
@@ -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
diff --git a/doc/genps.pl b/doc/genps.pl
index 67e0f366..86d10007 100755
--- a/doc/genps.pl
+++ b/doc/genps.pl
@@ -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.
##
@@ -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
@@ -87,6 +84,9 @@ use Fcntl;
'11x17' => [792,1224], # US double paper size
);
+# Canned header file
+$headps = 'head.ps';
+
#
# Parse the command line
#
@@ -104,6 +104,8 @@ while ( $arg = shift(@ARGV) ) {
$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";
}
@@ -1028,7 +1030,8 @@ foreach $fset ( @AllFonts ) {
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;
}
diff --git a/doc/genpsdriver.pl b/doc/genpsdriver.pl
deleted file mode 100644
index 58e1f9a9..00000000
--- a/doc/genpsdriver.pl
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/perl
-## --------------------------------------------------------------------------
-##
-## Copyright 1996-2009 The NASM Authors - All Rights Reserved
-## See the file AUTHORS included with the NASM distribution for
-## the specific copyright holders.
-##
-## Redistribution and use in source and binary forms, with or without
-## modification, are permitted provided that the following
-## conditions are met:
-##
-## * Redistributions of source code must retain the above copyright
-## notice, this list of conditions and the following disclaimer.
-## * Redistributions in binary form must reproduce the above
-## 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
-## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-##
-## --------------------------------------------------------------------------
-
-#
-# Runs the equivalent of the following command line:
-#
-# $(PERL) $(srcdir)/genps.pl -subtitle "version `cat ../version`" \
-# nasmdoc.dip
-#
-# This is implemented as a Perl script since `cat ...` doesn't
-# necessarily work on non-Unix systems.
-#
-
-use File::Spec;
-use Fcntl;
-use Env;
-
-$perl = $ENV{PERL} || 'perl';
-$srcdir = $ENV{srcdir} || File::Spec->curdir();
-
-$versionfile = File::Spec->catfile($srcdir, File::Spec->updir(), 'version');
-$genps = File::Spec->catfile($srcdir, 'genps.pl');
-
-sysopen(VERSION, $versionfile, O_RDONLY)
- or die "$0: cannot open $versionfile\n";
-$version = <VERSION>;
-chomp $version;
-close(VERSION);
-
-# \240 = no-break space, see @NASMEncoding in genps.pl.
-# If we use a normal space, it breaks on 'doze platforms...
-system($perl, $genps, '-subtitle', "version\240".$version,
- @ARGV, 'nasmdoc.dip');
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src
index f38a9ce3..e41c0864 100644
--- a/doc/nasmdoc.src
+++ b/doc/nasmdoc.src
@@ -33,6 +33,7 @@
\#
\# Source code to NASM documentation
\#
+
\M{category}{Programming}
\M{title}{NASM - The Netwide Assembler}
\M{year}{1996-2016}
@@ -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
@@ -8254,4 +8258,3 @@ column shows the processor type in which the instruction was introduced and,
\A{changelog} \i{NASM Version History}
\& changes.src
-
diff --git a/doc/rdsrc.pl b/doc/rdsrc.pl
index 21ec6e75..da9cf252 100644
--- a/doc/rdsrc.pl
+++ b/doc/rdsrc.pl
@@ -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.
@@ -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
@@ -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;
@@ -136,9 +144,8 @@ print "Reading input...";
$pname = "para000000";
@pnames = @pflags = ();
$para = undef;
-while (defined($_ = <STDIN>)) {
- $_ = &untabify($_);
- &check_include($_);
+foreach $file (@files) {
+ &include($file);
}
&got_para($para);
print "done.\n";
@@ -205,8 +212,9 @@ sub untabify($) {
}
return $o;
}
-sub check_include {
+sub read_line {
local $_ = shift;
+ $_ = &untabify($_);
if (/\\& (\S+)/) {
&include($1);
} else {
@@ -226,11 +234,25 @@ sub get_para($_) {
}
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 ($_) = @_;
@@ -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";
}
diff --git a/nsis/nasm.nsi b/nsis/nasm.nsi
index 42411032..ebb8ef9a 100644
--- a/nsis/nasm.nsi
+++ b/nsis/nasm.nsi
@@ -26,6 +26,8 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+!addincludedir "${objdir}/nsis"
+!addincludedir "${srcdir}/nsis"
!include "version.nsh"
!include /nonfatal "arch.nsh"
@@ -50,7 +52,7 @@ SetCompressor lzma
;Name and file
Name "${PACKAGE_NAME}"
-OutFile "../${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe"
+OutFile "${objdir}/${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" ""
@@ -67,8 +69,8 @@ Var CmdFailed
;--------------------------------
;Interface Settings
Caption "${PACKAGE_SHORT_NAME} installation"
-Icon "nasm.ico"
-UninstallIcon "nasm-un.ico"
+Icon "${srcdir}/nsis/nasm.ico"
+UninstallIcon "${srcdir}/nsis/nasm-un.ico"
!define MUI_ABORTWARNING
@@ -98,10 +100,10 @@ UninstallIcon "nasm-un.ico"
Section "NASM" SecNasm
Sectionin RO
SetOutPath "$INSTDIR"
- File "../LICENSE"
- File "../nasm.exe"
- File "../ndisasm.exe"
- File "nasm.ico"
+ File "${srcdir}/LICENSE"
+ File "${objdir}/nasm.exe"
+ File "${objdir}/ndisasm.exe"
+ File "${srcdir}/nsis/nasm.ico"
;Store installation folder
WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR
@@ -137,27 +139,27 @@ skip:
SectionEnd
Section "RDOFF" SecRdoff
- File "../rdoff/ldrdf.exe"
- File "../rdoff/rdf2bin.exe"
- File "../rdoff/rdf2com.exe"
- File "../rdoff/rdf2ith.exe"
- File "../rdoff/rdf2ihx.exe"
- File "../rdoff/rdf2srec.exe"
- File "../rdoff/rdfdump.exe"
- File "../rdoff/rdflib.exe"
+ File "${objdir}/rdoff/ldrdf.exe"
+ File "${objdir}/rdoff/rdf2bin.exe"
+ File "${objdir}/rdoff/rdf2com.exe"
+ File "${objdir}/rdoff/rdf2ith.exe"
+ File "${objdir}/rdoff/rdf2ihx.exe"
+ File "${objdir}/rdoff/rdf2srec.exe"
+ File "${objdir}/rdoff/rdfdump.exe"
+ File "${objdir}/rdoff/rdflib.exe"
SectionEnd
Section "Manual" SecManual
SetOutPath "$INSTDIR"
- File "../doc/nasmdoc.pdf"
+ File "${objdir}/doc/nasmdoc.pdf"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf"
SectionEnd
Section "VS8 integration" SecVS8
CreateDirectory "$INSTDIR\VSrules"
SetOutPath "$INSTDIR\VSrules"
- File "../contrib/VSrules/nasm.README"
- File "../contrib/VSrules/nasm.rules"
+ File "${srcdir}/contrib/VSrules/nasm.README"
+ File "${srcdir}/contrib/VSrules/nasm.rules"
SectionEnd
;--------------------------------
diff --git a/version.pl b/version.pl
index e4157a2d..a5577a02 100755
--- a/version.pl
+++ b/version.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
## --------------------------------------------------------------------------
##
-## Copyright 1996-2009 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.
##
@@ -178,6 +178,9 @@ if ( $what eq 'h' ) {
print $nasm_id, "\n"; # Print ID in decimal
} elsif ( $what eq 'xid' ) {
printf "0x%08x\n", $nasm_id; # Print ID in hexadecimal
+} elsif ( $what eq 'docsrc' ) {
+ printf "\\M{version}{%s}\n", $line;
+ printf "\\M{subtitle}{version %s}\n", $line;
} else {
die "$0: Unknown output: $what\n";
}