summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-10-25 11:05:07 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2013-10-25 11:06:52 (GMT)
commit0ef16e247a1cb7ec05dc4f78b9499df3713f9ef9 (patch)
treebbb883575c5aa5ca365b28ce957a1fb9cb5e1a52
parentb7423725b9f532c701aebed14ebd84cd3df79e5d (diff)
downloadabc80sim-0ef16e247a1cb7ec05dc4f78b9499df3713f9ef9.zip
abc80sim-0ef16e247a1cb7ec05dc4f78b9499df3713f9ef9.tar.gz
abc80sim-0ef16e247a1cb7ec05dc4f78b9499df3713f9ef9.tar.bz2
abc80sim-0ef16e247a1cb7ec05dc4f78b9499df3713f9ef9.tar.xz
Convert to using autoconf
-rw-r--r--.gitignore5
-rw-r--r--Makefile53
-rw-r--r--Makefile.in69
-rw-r--r--aclocal.m438
-rwxr-xr-xautogen.sh7
-rw-r--r--clock.c1
-rw-r--r--configure.in90
-rwxr-xr-xinstall-sh527
-rw-r--r--inttypes/inttypes.h201
-rw-r--r--mysdl.h11
-rw-r--r--patchlevel.h3
-rw-r--r--screen.h8
-rw-r--r--sdlscrn.c1
-rw-r--r--z80.h2
14 files changed, 980 insertions, 36 deletions
diff --git a/.gitignore b/.gitignore
index 0162c6c..6ef2e45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,8 @@ abcrom80.c
ufddos.c
printer.c
abc80
+config.h
+config.h.in
+config.log
+config.status
+configure
diff --git a/Makefile b/Makefile
index c7256ce..68728d1 100644
--- a/Makefile
+++ b/Makefile
@@ -2,38 +2,27 @@
# Makefile for the ABC80 emulator
#
+top_srcdir = .
+srcdir = .
-# BINDIR should be defined to the directory where
-# the executable program should be installed.
+prefix = /usr/local
+exec_prefix = ${prefix}
+bindir = ${exec_prefix}/bin
+mandir = ${datarootdir}/man
+datarootdir = ${prefix}/share
-BINDIR = /home/hpa/abc80/bin
+CC = gcc
+CFLAGS = -g -O2 -W -Wall
+LDFLAGS =
+LIBS = -lSDL -lpthread
-
-# MANDIR should be defined to the directory where
-# the manual page should be installed.
-# MANEXT is the extension the manuals will receive in MANDIR
-
-MANDIR = /home/hpa/abc80/man/man1
-MANEXT = 1
-
-# DEFINES should contain any other definitions used to
-# configure the program.
-# Currently available configurations are:
-# SMALL_ENDIAN - System is a small endian machine (*86, ALPHA, etc.)
-#
-# Example:
-DEFINES = -DSMALL_ENDIAN -D_REENTRANT
-
-CC = gcc
-CFLAGS = -W -Wall -g -O2 $(DEFINES) -I/usr/X11R6/include -I/usr/include/SDL -DABCDIR=\"$(ABCDIR)\"
-LDFLAGS = -g -L/usr/X11R6/lib
-LIBS = -lSDL -lX11 -lpthread
-
-PERL = perl
+MKDIR = mkdir
+PERL = perl
+RM_F = rm -f
# For Windows/MinGW use obj and .exe
-O = o
-X =
+O = o
+X =
GENO = abcrom40.$(O) abcrom80.$(O) ufddos.$(O) printer.$(O)
GENC = abcrom40.c abcrom80.c ufddos.c printer.c
@@ -53,8 +42,10 @@ HDRS = clock.h screen.h z80.h patchlevel.h
all: abc80
install: abc80$(X)
- -cp abc80$(X) $(BINDIR)
- -cp abc80.man $(MANDIR)/abc80.$(MANEXT)
+ $(MKDIR) -p $(INSTALLROOT)$(bindir)
+ $(INSTALL_PROGRAM) abc80$(X) $(INSTALLROOT)$(bindir)
+ $(MKDIR) -p $(INSTALLROOT)$(mandir)/man1
+ $(INSTALL_DATA) abc80.man $(INSTALLROOT)$(mandir)/man1/abc80.1
abc80$(X): $(OBJS)
$(CC) $(LDFLAGS) -o abc80$(X) $(OBJS) $(LIBS)
@@ -74,5 +65,5 @@ z80.$(O): z80.h
clean:
- $(RM) abc80$(X) *.$(O) *~ core
- $(RM) $(GENC)
+ $(RM_F) abc80$(X) *.$(O) *~ core
+ $(RM_F) $(GENC)
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..191696e
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,69 @@
+#
+# Makefile for the ABC80 emulator
+#
+
+top_srcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+datarootdir = @datarootdir@
+
+CC = @CC@
+CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+
+MKDIR = mkdir
+PERL = perl
+RM_F = rm -f
+
+# For Windows/MinGW use obj and .exe
+O = @OBJEXT@
+X = @EXEEXT@
+
+GENO = abcrom40.$(O) abcrom80.$(O) ufddos.$(O) printer.$(O)
+GENC = abcrom40.c abcrom80.c ufddos.c printer.c
+
+OBJS = abc80.$(O) clock.$(O) sdlscrn.$(O) z80.$(O) abc80_mem.$(O) io.$(O) \
+ abcfont.$(O) disk.$(O) \
+ abcprint.$(O) print.$(O) fileop.$(O) \
+ z80dis.$(O) $(GENO)
+SRCS = abc80.c clock.c sdlscrn.c z80.c abc80_mem.c io.c \
+ abcfont.c disk.c \
+ abcprint.c print.c fileop.c \
+ z80dis.c abcrom40.c abcrom80.c $(GENC)
+HDRS = clock.h screen.h z80.h patchlevel.h
+
+.SUFFIXES: .c .h .$(O) .bin
+
+all: abc80
+
+install: abc80$(X)
+ $(MKDIR) -p $(INSTALLROOT)$(bindir)
+ $(INSTALL_PROGRAM) abc80$(X) $(INSTALLROOT)$(bindir)
+ $(MKDIR) -p $(INSTALLROOT)$(mandir)/man1
+ $(INSTALL_DATA) abc80.man $(INSTALLROOT)$(mandir)/man1/abc80.1
+
+abc80$(X): $(OBJS)
+ $(CC) $(LDFLAGS) -o abc80$(X) $(OBJS) $(LIBS)
+
+.bin.c:
+ $(PERL) bin2c.pl $< > $@ || ( rm -f $@ ; false )
+
+abcrom40.c: abcrom40.bin bin2c.pl
+abcrom80.c: abcrom80.bin bin2c.pl
+printer.c: printer.bin bin2c.pl
+ufddos.c: ufddos.bin bin2c.pl
+
+abc80.$(O): clock.h screen.h z80.h patchlevel.h
+clock.$(O): clock.h z80.h
+sdlscrn.$(O): screen.h z80.h
+z80.$(O): z80.h
+
+
+clean:
+ $(RM_F) abc80$(X) *.$(O) *~ core
+ $(RM_F) $(GENC)
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644
index 0000000..8951278
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,38 @@
+dnl --------------------------------------------------------------------------
+dnl PA_ADD_CFLAGS()
+dnl
+dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation
+dnl --------------------------------------------------------------------------
+AC_DEFUN(PA_ADD_CFLAGS,
+[AC_MSG_CHECKING([if $CC accepts $1])
+ pa_add_cflags__old_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_TRY_LINK([#include <stdio.h>],
+ [printf("Hello, World!\n");],
+ AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([no])
+ CFLAGS="$pa_add_cflags__old_cflags")])
+
+dnl --------------------------------------------------------------------------
+dnl PA_WORKING_STDBOOL
+dnl
+dnl See if we have a working <stdbool.h> and bool support; in particular,
+dnl OpenWatcom 1.8 has a broken _Bool type that we don't want to use.
+dnl --------------------------------------------------------------------------
+AC_DEFUN(PA_WORKING_BOOL,
+[AC_MSG_CHECKING([if $CC has a working bool type])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+int foo(bool x, int y)
+{
+ return x+y;
+}
+ ])],
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_WORKING_BOOL, 1,
+ [Define to 1 if your compiler has a correct implementation of bool])],
+ [AC_MSG_RESULT([no])])
+])
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..5a1395d
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,7 @@
+#!/bin/sh -xe
+#
+# Simple script to run the appropriate autotools from a repository.
+#
+autoheader
+autoconf
+rm -rf autom4te.cache config.log config.status
diff --git a/clock.c b/clock.c
index 6a25fec..f99512c 100644
--- a/clock.c
+++ b/clock.c
@@ -4,7 +4,6 @@
#include "z80.h"
#include "screen.h"
-#include "SDL.h"
/*
* Trig a non maskable interrupt in the Z80 on the clock signal.
diff --git a/configure.in b/configure.in
new file mode 100644
index 0000000..0fb3498
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,90 @@
+dnl Process this file with autoconf 2.61 or later to produce
+dnl a configure script.
+AC_PREREQ(2.61)
+AC_INIT(config.h.in)
+AC_CONFIG_HEADERS(config.h)
+
+AC_PREFIX_PROGRAM(abc80)
+
+dnl Checks for programs.
+dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future
+AC_USE_SYSTEM_EXTENSIONS
+AC_PROG_CC
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_INSTALL
+
+dnl If we have gcc, add appropriate options
+PA_ADD_CFLAGS([-W])
+PA_ADD_CFLAGS([-Wall])
+dnl PA_ADD_CFLAGS([-std=c99])
+dnl PA_ADD_CFLAGS([-pedantic])
+
+dnl Look for programs...
+AC_CHECK_PROGS(NROFF, nroff, false)
+AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
+AC_CHECK_PROGS(XMLTO, xmlto, false)
+AC_CHECK_PROGS(ACRODIST, acrodist, false)
+AC_CHECK_PROGS(PS2PDF, ps2pdf, false)
+AC_CHECK_PROGS(PSTOPDF, pstopdf, false)
+
+dnl Check for progs needed for manpage generation
+if test $ASCIIDOC = false; then
+ AC_MSG_WARN([No acsciidoc package found])
+fi
+if test $XMLTO = false; then
+ AC_MSG_WARN([No xmlto package found])
+fi
+
+dnl Checks for header files.
+AC_HEADER_STDC
+if test $ac_cv_header_stdc = no; then
+ AC_MSG_ERROR([abc80sim requires ANSI C header files to compile])
+fi
+
+AC_CHECK_HEADERS(limits.h)
+if test $ac_cv_header_limits_h = no; then
+ AC_MSG_ERROR([abc80sim requires '<limits.h>' to compile])
+fi
+
+dnl Check for <inttypes.h> or add a substitute version
+AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
+
+dnl The standard header for str*casecmp is <strings.h>
+AC_CHECK_HEADERS(strings.h)
+
+dnl Look for <stdbool.h>
+AC_CHECK_HEADERS(stdbool.h)
+
+AC_CHECK_HEADERS(SDL.h)
+AC_CHECK_HEADERS(SDL/SDL.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_INLINE
+AC_C_RESTRICT
+AC_TYPE_SIZE_T
+PA_WORKING_BOOL
+AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN))
+AH_TEMPLATE(WORDS_BIGENDIAN,
+[Define to 1 if your processor stores words with the most significant
+byte first (like Motorola and SPARC, unlike Intel and VAX).])
+AH_TEMPLATE(WORDS_LITTLEENDIAN,
+[Define to 1 if your processor stores words with the least significant
+byte first (like Intel and VAX, unlike Motorola and SPARC).])
+
+dnl Checks for library functions.
+AC_SEARCH_LIBS([pthread_create], [pthread])
+AC_SEARCH_LIBS([SDL_Init], [SDL])
+AC_SUBST(XOBJS)
+
+dnl
+dnl support cchace
+dnl
+AC_ARG_WITH([ccache],
+ [AC_HELP_STRING([--with-ccache],
+ [Compile with ccache])],
+ [CC="ccache $CC"],
+ [])
+
+AC_OUTPUT(Makefile)
diff --git a/install-sh b/install-sh
new file mode 100755
index 0000000..a9244eb
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,527 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2011-01-19.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ # Protect names problematic for `test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ # Protect names problematic for `test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ do_exit='(exit $ret); exit $ret'
+ trap "ret=129; $do_exit" 1
+ trap "ret=130; $do_exit" 2
+ trap "ret=141; $do_exit" 13
+ trap "ret=143; $do_exit" 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names problematic for `test' and other utilities.
+ case $src in
+ -* | [=\(\)!]) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+ dst=$dst_arg
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writeable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ [-=\(\)!]*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test X"$d" = X && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/inttypes/inttypes.h b/inttypes/inttypes.h
new file mode 100644
index 0000000..e353aa9
--- /dev/null
+++ b/inttypes/inttypes.h
@@ -0,0 +1,201 @@
+/*
+ * inttypes.h
+ *
+ * Small ersatz subset of <inttypes.h>, deriving the types from
+ * <limits.h>.
+ *
+ * Important: the preprocessor may truncate numbers too large for it.
+ * Therefore, test the signed types only ... truncation won't generate
+ * a 01111111... bit pattern.
+ */
+
+#ifndef INTTYPES_H
+#define INTTYPES_H
+
+#include <limits.h>
+
+/*** 64-bit type: long or long long ***/
+
+/* Some old versions of gcc <limits.h> omit LLONG_MAX */
+#ifndef LLONG_MAX
+# ifdef __LONG_LONG_MAX__
+# define LLONG_MAX __LONG_LONG_MAX__
+# else
+# define LLONG_MAX 0 /* Assume long long is unusable */
+# endif
+#endif
+
+#if LONG_MAX == 9223372036854775807L
+
+/* long is 64 bits */
+typedef signed long int64_t;
+typedef unsigned long uint64_t;
+#define _scn64 "l"
+#define _pri64 "l"
+#define INT64_C(x) x ## L
+#define UINT64_C(x) x ## UL
+
+#elif LLONG_MAX == 9223372036854775807LL
+
+/* long long is 64 bits */
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+#define _scn64 "ll"
+#define _pri64 "ll"
+#define INT64_C(x) x ## LL
+#define UINT64_C(x) x ## ULL
+
+#else
+
+#error "Neither long nor long long is 64 bits in size"
+
+#endif
+
+/*** 32-bit type: int or long ***/
+
+#if INT_MAX == 2147483647
+
+/* int is 32 bits */
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+#define _scn32 ""
+#define _pri32 ""
+#define INT32_C(x) x
+#define UINT32_C(x) x ## U
+
+#elif LONG_MAX == 2147483647L
+
+/* long is 32 bits */
+typedef signed long int32_t;
+typedef unsigned long uint32_t;
+#define _scn32 "l"
+#define _pri32 "l"
+#define INT32_C(x) x ## L
+#define UINT32_C(x) x ## UL
+
+#else
+
+#error "Neither int nor long is 32 bits in size"
+
+#endif
+
+/*** 16-bit size: int or short ***/
+
+#if INT_MAX == 32767
+
+/* int is 16 bits */
+typedef signed int int16_t;
+typedef unsigned int uint16_t;
+#define _scn16 ""
+#define _pri16 ""
+#define INT16_C(x) x
+#define UINT16_C(x) x ## U
+
+#elif SHRT_MAX == 32767
+
+/* short is 16 bits */
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+#define _scn16 "h"
+#define _pri16 ""
+#define INT16_C(x) x
+#define UINT16_C(x) x ## U
+
+#else
+
+#error "Neither short nor int is 16 bits in size"
+
+#endif
+
+/*** 8-bit size: char ***/
+
+#if SCHAR_MAX == 127
+
+/* char is 8 bits */
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+#define _scn8 "hh"
+#define _pri8 ""
+#define INT8_C(x) x
+#define UINT8_C(x) x ## U
+
+#else
+
+#error "char is not 8 bits in size"
+
+#endif
+
+/* The rest of this is common to all models */
+
+#define PRId8 _pri8 "d"
+#define PRId16 _pri16 "d"
+#define PRId32 _pri32 "d"
+#define PRId64 _pri64 "d"
+
+#define PRIi8 _pri8 "i"
+#define PRIi16 _pri16 "i"
+#define PRIi32 _pri32 "i"
+#define PRIi64 _pri64 "i"
+
+#define PRIo8 _pri8 "o"
+#define PRIo16 _pri16 "o"
+#define PRIo32 _pri32 "o"
+#define PRIo64 _pri64 "o"
+
+#define PRIu8 _pri8 "u"
+#define PRIu16 _pri16 "u"
+#define PRIu32 _pri32 "u"
+#define PRIu64 _pri64 "u"
+
+#define PRIx8 _pri8 "x"
+#define PRIx16 _pri16 "x"
+#define PRIx32 _pri32 "x"
+#define PRIx64 _pri64 "x"
+
+#define PRIX8 _pri8 "X"
+#define PRIX16 _pri16 "X"
+#define PRIX32 _pri32 "X"
+#define PRIX64 _pri64 "X"
+
+#define SCNd8 _scn8 "d"
+#define SCNd16 _scn16 "d"
+#define SCNd32 _scn32 "d"
+#define SCNd64 _scn64 "d"
+
+#define SCNi8 _scn8 "i"
+#define SCNi16 _scn16 "i"
+#define SCNi32 _scn32 "i"
+#define SCNi64 _scn64 "i"
+
+#define SCNo8 _scn8 "o"
+#define SCNo16 _scn16 "o"
+#define SCNo32 _scn32 "o"
+#define SCNo64 _scn64 "o"
+
+#define SCNu8 _scn8 "u"
+#define SCNu16 _scn16 "u"
+#define SCNu32 _scn32 "u"
+#define SCNu64 _scn64 "u"
+
+#define SCNx8 _scn8 "x"
+#define SCNx16 _scn16 "x"
+#define SCNx32 _scn32 "x"
+#define SCNx64 _scn64 "x"
+
+#define INT8_MIN INT8_C(-128)
+#define INT8_MAX INT8_C(127)
+#define UINT8_MAX UINT8_C(255)
+
+#define INT16_MIN INT16_C(-32768)
+#define INT16_MAX INT16_C(32767)
+#define UINT16_MAX UINT16_C(65535)
+
+#define INT32_MIN INT32_C(-2147483648)
+#define INT32_MAX INT32_C(2147483647)
+#define UINT32_MAX UINT32_C(4294967295)
+
+#define INT64_MIN INT64_C(-9223372036854775808)
+#define INT64_MAX INT64_C(9223372036854775807)
+#define UINT64_MAX UINT64_C(18446744073709551615)
+
+#endif /* INTTYPES_H */
diff --git a/mysdl.h b/mysdl.h
new file mode 100644
index 0000000..2177f15
--- /dev/null
+++ b/mysdl.h
@@ -0,0 +1,11 @@
+#ifndef ABC80_H
+#define ABC80_H 1
+#include "config.h"
+
+#ifdef HAVE_SDL_H
+# include <SDL.h>
+#elif defined(HAVE_SDL_SDL_H)
+# include <SDL/SDL.h>
+#endif
+
+#endif
diff --git a/patchlevel.h b/patchlevel.h
index 8518bd2..a6cb0b4 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -1 +1,2 @@
-#define VERSION "1.2"
+#define VERSION "2.1"
+
diff --git a/screen.h b/screen.h
index 7decb9b..421d3b3 100644
--- a/screen.h
+++ b/screen.h
@@ -1,7 +1,13 @@
#ifndef _SCREEN_H
#define _SCREEN_H
-#include "SDL.h"
+#include "config.h"
+
+#ifdef HAVE_SDL_H
+# include <SDL.h>
+#elif defined(HAVE_SDL_SDL_H)
+# include <SDL/SDL.h>
+#endif
#ifndef MAIN
#define EXTERN extern
diff --git a/sdlscrn.c b/sdlscrn.c
index b33bfa4..d8cb4bd 100644
--- a/sdlscrn.c
+++ b/sdlscrn.c
@@ -8,7 +8,6 @@
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
-#include "SDL.h"
#include "screen.h"
#include "z80.h"
diff --git a/z80.h b/z80.h
index 8fd294b..d4c6673 100644
--- a/z80.h
+++ b/z80.h
@@ -25,7 +25,7 @@ typedef unsigned char uchar;
struct twobyte
{
-#ifdef SMALL_ENDIAN
+#ifdef WORDS_LITTLEENDIAN
uchar low, high;
#else
uchar high, low;