summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2004-01-24 16:27:32 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:49 +0200
commitbeba34dc223aa0dcf3e5f696966c5e8408b022c3 (patch)
treeea0523ac242bd3e877338e9a771b975d4cd3839a
parentb5dac1e3bdd01a2ce105df747a9073ff0d6a94e2 (diff)
downloaddev86-beba34dc223aa0dcf3e5f696966c5e8408b022c3.tar.gz
Import Dev86src-0.16.15.tar.gzv0.16.15
-rw-r--r--Changes27
-rw-r--r--Makefile64
-rw-r--r--Mk_dist6
-rw-r--r--README37
-rw-r--r--ar/ar.c23
-rw-r--r--as/Makefile2
-rw-r--r--as/as.c6
-rwxr-xr-xas/chk4
-rw-r--r--as/errors.c163
-rw-r--r--as/errors.h162
-rw-r--r--bcc/Makefile7
-rw-r--r--bcc/bcc-cc1.c2
-rw-r--r--bcc/bcc.c244
-rw-r--r--bcc/bcc.doc4
-rw-r--r--bcc/const.h1
-rw-r--r--bcc/declare.c2
-rw-r--r--bcc/input.c76
-rw-r--r--bcc/input.h5
-rw-r--r--bcc/output.c4
-rw-r--r--bcc/preproc.c20
-rw-r--r--bcc/scan.c31
-rw-r--r--bin86/Makefile2
-rw-r--r--bootblocks/Makefile3
-rw-r--r--bootblocks/boot_win.c20
-rw-r--r--cpp/cpp.c6
-rw-r--r--elksemu/Makefile7
-rw-r--r--elksemu/README8
-rw-r--r--elksemu/Security2
-rw-r--r--elksemu/elks.c5
-rw-r--r--elksemu/elks.h22
-rw-r--r--elksemu/elks_sys.c37
-rw-r--r--elksemu/mkefile11
-rw-r--r--ld/ld.c6
-rw-r--r--ld/objdump86.c15
-rw-r--r--libc/Makefile12
-rw-r--r--libc/error/Makefile13
-rw-r--r--libc/error/README9
-rw-r--r--libc/error/error.c2
-rw-r--r--libc/error/error2.c21
-rw-r--r--libc/error/mktab.sh25
-rw-r--r--libc/error/sys_errlist.c2
-rw-r--r--libc/include/linux/stat.h1
-rw-r--r--libc/include/linux/types.h2
-rw-r--r--libc/malloc/malloc.c3
-rw-r--r--makefile.in107
-rw-r--r--man/as86.12
-rw-r--r--man/elksemu.121
-rw-r--r--tests/Makefile9
-rw-r--r--tests/ft.c34
49 files changed, 827 insertions, 470 deletions
diff --git a/Changes b/Changes
index 680d76d..5c5210a 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,32 @@
For version 0.16.*.
+> WARNING to distributions: I've altered the install scripts and paths
+ you will want to check them. Altered paths for bcc.c and normal
+ installs, defaults should now be good for distributions where bcc is a
+ cross compiler. If you set the PREFIX to / it'll install to suggested
+ Native paths. As86_encap moved to LIBDIR.
+
+> I've altered 'perror' and 'strerror' to be normal when compiled for
+ everything except libc_f.a. Only that library it look for the
+ liberror.txt file and it now looks in "/lib/liberror.txt".
+ This means there's no need to install it anywhere except ELKS itself.
+
+> Change -Mg option to use uclibc as glibc2 seems to have stopped working.
+
+> ar.c switch to usnig strerror.
+
+> Move elksemu, it's used like a shared library but is best treated like
+ an emulator so it's now installed in DISTBIN. Also on Linux-386 it's
+ compiled using the system compiler.
+
+> Use the POSIX -R argument to cp rather than the normal standard -r because
+ some new systems have decided to stop supporting their '-r' option.
+
+> Oops, the constant error strings in the assembler were char pointers not
+ char arrays, small waste of space.
+
+> Allow for Linux-2.6 32bit dev_t.
+
> More changes so it compiles better on 'other' machines.
Removed some GNU-Make'isms in the top header file.
diff --git a/Makefile b/Makefile
index 704c9d2..259385b 100644
--- a/Makefile
+++ b/Makefile
@@ -2,20 +2,22 @@
# This file is part of the Linux-8086 Development environment and is
# distributed under the GNU General Public License.
-VERSION=0.16.14
+VERSION=0.16.15
-TARGETS= \
- clean bcc unproto copt as86 ld86 elksemu \
- install install-all install-bcc install-emu install-lib \
+TARGETS=install clean other \
+ bcc unproto copt as86 ld86 elksemu \
+ install-all install-bcc install-emu install-lib \
install-lib2 install-ln install-man install-other \
all-libs alt-libs library lib-386 lib-bsd lib-dos lib-fast lib-stand \
- config other tests dis88 doselks bootblocks ld86r
+ config tests dis88 doselks bootblocks ld86r
ELKSSRC= /usr/src/elks
PREFIX= /usr
-LIBPRE= $(PREFIX)/bcc
BINDIR= $(PREFIX)/bin
-LIBDIR= $(LIBPRE)/lib/bcc
+LIBDIR= $(PREFIX)/lib/bcc
+INCLDIR= $(PREFIX)/lib/bcc
+ASLDDIR= $(BINDIR)
+MANDIR= $(PREFIX)/man
CFLAGS= -O
# Some makes take the last of a list as the default ...
@@ -36,18 +38,25 @@ realclean:
make.fil: ifdef makefile.in
./ifdef -MU makefile.in >tmp.mak
- sed \
- -e "s:%PREFIX%:$(PREFIX):" \
- -e "s:%LIBPRE%:$(LIBPRE):" \
- -e "s:%BINDIR%:$(BINDIR):" \
- -e "s:%LIBDIR%:$(LIBDIR):" \
- -e "s:%ELKSSRC%:$(ELKSSRC):" \
- -e "s:%CC%:$(CC):" \
- -e "s:%CFLAGS%:$(CFLAGS):" \
- -e "s:%LDFLAGS%:$(LDFLAGS):" \
- < tmp.mak > make.tmp
+ echo > tmp.sed
+ [ "$(BINDIR)" != "//bin" ] || echo >> tmp.sed "s:%BINDIR%:/bin:"
+ [ "$(LIBDIR)" != "//lib/bcc" ] || echo >> tmp.sed "s:%LIBDIR%:/lib:"
+ [ "$(INCLDIR)" != "//lib/bcc" ] || echo >> tmp.sed "s:%INCLDIR%:/usr:"
+ [ "$(ASLDDIR)" != "//bin" ] || echo >> tmp.sed "s:%ASLDDIR%:/bin:"
+ [ "$(MANDIR)" != "//man" ] || echo >> tmp.sed "s:%MANDIR%:/usr/man:"
+ echo >> tmp.sed "s:%PREFIX%:$(PREFIX):"
+ echo >> tmp.sed "s:%BINDIR%:$(BINDIR):"
+ echo >> tmp.sed "s:%INCLDIR%:$(INCLDIR):"
+ echo >> tmp.sed "s:%LIBDIR%:$(LIBDIR):"
+ echo >> tmp.sed "s:%ASLDDIR%:$(ASLDDIR):"
+ echo >> tmp.sed "s:%MANDIR%:$(MANDIR):"
+ echo >> tmp.sed "s:%ELKSSRC%:$(ELKSSRC):"
+ echo >> tmp.sed "s:%CC%:$(CC):"
+ echo >> tmp.sed "s:%CFLAGS%:$(CFLAGS):"
+ echo >> tmp.sed "s:%LDFLAGS%:$(LDFLAGS):"
+ sed -f tmp.sed < tmp.mak > make.tmp
mv -f make.tmp make.fil
- @rm -f tmp.mak
+ @rm -f tmp.mak tmp.sed
ifdef: ifdef.o
$(CC) $(LDFLAGS) -o ifdef ifdef.o
@@ -55,22 +64,9 @@ ifdef: ifdef.o
ifdef.o: ifdef.c
$(CC) $(CFLAGS) $(IFDEFFLAGS) -c ifdef.c
-Uninstall:
- @# CHECK FROM HERE
- @make -n Uninstall
- @echo 'Are you really sure... have you checked this...'
- @echo "I haven't used this in _years_ ... ^C to interrupt"
- @read line
- rm -rf /usr/bcc
- rm -f $(BINDIR)/bcc $(BINDIR)/as86_encap $(BINDIR)/dis86
- rm -f $(BINDIR)/as86 $(BINDIR)/ld86
- rm -f $(BINDIR)/objdump86 $(BINDIR)/nm86 $(BINDIR)/size86
- rm -f /lib/elksemu
- rm -f /usr/lib/liberror.txt
- rm -f /usr/man/man1/elks.1* /usr/man/man1/elksemu.1*
- rm -f /usr/man/man1/dis86.1* /usr/man/man1/bcc.1*
- rm -f /usr/man/man1/as86.1* /usr/man/man1/ld86.1*
- @# TO HERE
+uninstall:
+ @echo 'Sorry, no go; it was just wrong.'
+ false
distribution:
@[ `id -u` -eq 0 ] || fakeroot -- sh ./Mk_dist $(VERSION)
diff --git a/Mk_dist b/Mk_dist
index 542bcc1..ad61af7 100644
--- a/Mk_dist
+++ b/Mk_dist
@@ -62,7 +62,7 @@ mkdir ${TMPDIST}/doselks
( cd ${TMPDIST}/doselks ; tar xzf /tmp/doselks.tar.gz )
[ "`id -un`" = "root" ] && {
- chown -R root:root ${TMPDIST}
+ chown -R root:0 ${TMPDIST}
chmod -R og=u-w ${TMPDIST}
}
@@ -193,7 +193,9 @@ echo Compile up the binaries.
cd ${TMPDIR} || exit 1
mkdir -p ${TMPDIST}.ins
-make -C ${TMPDIST} install ARFLAGS=q DIST=${TMPDIST}.ins ELKSSRC=/dev/null ||
+make -C ${TMPDIST} install install-other \
+ ARFLAGS=q ELKSSRC=/dev/null \
+ DIST=${TMPDIST}.ins 'ASLDDIR=$(BINDIR)' ||
exit
make -C ${TMPDIST} other || exit
tar cf ${ARCDIR}/Dev86bin-$VERSION.tar -C ${TMPDIST}.ins .
diff --git a/README b/README
index 78643c3..f3d184e 100644
--- a/README
+++ b/README
@@ -18,22 +18,41 @@ The manual pages in the man subdirectory are matched to these programs,
there are also some hints for using as86 well. The tests and bootblocks
directories give some example code.
-The bcc command defaults to using /usr/bcc/include and /usr/bcc/lib/bcc
+The bcc command defaults to using /usr/lib/bcc/include and /usr/lib/bcc
the libraries _and_ include files are copied to these locations by
-install. This can be changed by overriding 'PREFIX=/usr' or
-'LIBDIR=/usr/bcc/lib/bcc' on the initial make. Also available in the
-same way the 'ELKSSRC=/usr/src/elks' variable can be altered if you
-have ELKS on a different path.
+install. This can be changed by overriding 'PREFIX=/usr/...' or
+'LIBDIR=/usr/...' on the initial make. Also available in the
+same way are the BINDIR, INCLDIR, ASLDDIR, MANDIR and ELSESRC.
+The 'ELKSSRC=/usr/src/elks' variable can be altered if you have ELKS on
+path different from the default or ELKSSRC=/dev/null uses the supplied
+ELKS headers. The ASLDDIR variable can be used to move as86 and ld86
+into the LIBDIR with 'ASLDDIR=$(LIBDIR)'. The final '/include' is added
+to the end of INCLDIR.
In the unlikely event you're makeing a non-cross development environment
-you can, on the initial make, do "make LIBPRE=/usr' to have the libraries
-and include files directly under /usr rather than /usr/bcc.
+you can, on the initial make, do "make PREFIX=/' to have the libraries
+and include files in 'Native' locations.
Note: These prefix options only effect the 'bcc.c' driver program and
the install scripts, all the others get their paths from bcc.c.
The ELKSSRC location can, however, greatly effect how the ELKS
libraries are built.
+If you don't want to install in the locations specified above there
+is also a DIST= argument to make install that is used to specify the
+distribution root to install to.
+
+The last option is not to install at all. All the executables in the
+bin directory can be moved to whereever you wish except for bcc and ncc.
+To use bcc at any other location you can create a symlink from your
+new location to the 'ncc' executable and it will be able to find
+the libraries in the build directory:
+
+eg:
+ cp ar86 elksemu objdump86 $HOME/bin/.
+ cp as86 as86_encap ld86 $HOME/bin/. # Optional.
+ ln -s `pwd`/ncc $HOME/bin/bcc
+
All the versions of the library are built by make; 'normal', 'fast',
'MSDOS', 'standalone' and Linux-i386.
@@ -76,10 +95,10 @@ to allow transparent execution of elks executables. If you're using
a post 2.1.43 or 2.0.36 kernel the only module you need is the binfmt_misc
driver configured like this:
-echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/lib/elksemu:' \
+echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/usr/bin/elksemu:' \
> /proc/sys/fs/binfmt_misc/register
-The elksemu executable must be stored in /lib/elksemu or the above
+The elksemu executable must be stored in /usr/bin/elksemu or the above
line adjusted.
Previous versions need a special module or patch described in elksemu/README
diff --git a/ar/ar.c b/ar/ar.c
index b0694ac..8443fd9 100644
--- a/ar/ar.c
+++ b/ar/ar.c
@@ -37,8 +37,6 @@
#define HAVE_RENAME
#undef HAVE_FSYNC
#define SHORT_FILENAME
-extern char **sys_errlist;
-extern int sys_nerr;
#else
#define HAVE_FCHMOD
#define HAVE_RENAME
@@ -46,8 +44,6 @@ extern int sys_nerr;
#endif
#define HAVE_TRAILING_SLASH_IN_NAME
-extern int errno;
-
#ifdef __GNUC__
# ifndef alloca
# define alloca __builtin_alloca
@@ -66,9 +62,6 @@ extern int errno;
/* Locking is normally disabled because fcntl hangs on the Sun
and it isn't supported properly across NFS anyway. */
-#ifdef LOCKS
-#include <errno.h>
-#endif
/* This structure is used internally to represent the info
on a member of an archive. This is to make it easier to change format. */
@@ -2055,26 +2048,14 @@ void
perror_with_name (name)
char *name;
{
- char *s;
-
- if (errno < sys_nerr)
- s = concat ("", sys_errlist[errno], " for %s");
- else
- s = "unknown error for %s";
- error (s, name);
+ error (concat ("", strerror(errno), " for %s"), name);
}
void
pfatal_with_name (name)
char *name;
{
- char *s;
-
- if (errno < sys_nerr)
- s = concat ("", sys_errlist[errno], " for %s");
- else
- s = "cannot open %s";
- fatal (s, name);
+ fatal (concat ("", strerror(errno), " for %s"), name);
}
/* Return a newly-allocated string whose contents
diff --git a/as/Makefile b/as/Makefile
index dec98d1..60aa952 100644
--- a/as/Makefile
+++ b/as/Makefile
@@ -33,6 +33,8 @@ clean realclean clobber:
.c.o:
$(CC) $(CFLAGS) -c $<
+$(OBJS): const.h errors.h
+
as.o: const.h type.h byteord.h macro.h file.h flag.h globvar.h
assemble.o: const.h type.h address.h globvar.h opcode.h scan.h
error.o: const.h type.h
diff --git a/as/as.c b/as/as.c
index d592b0b..c5fee7e 100644
--- a/as/as.c
+++ b/as/as.c
@@ -28,6 +28,7 @@ PRIVATE struct sym_s *hid_spt[SPTSIZ]; /* hash table */
PRIVATE char * binfilename = 0;
PRIVATE char * objfilename = 0;
+PRIVATE int keep_bad_output = 0;
FORWARD void initp1 P((void));
FORWARD int my_creat P((char *name, char *message));
@@ -85,7 +86,7 @@ PUBLIC void finishup()
/* If an output binary is in error remove it */
close(binfil); binfil=0;
close(objfil); objfil=0;
- if (toterr != 0)
+ if (toterr != 0 && !keep_bad_output)
{
if(binfilename) unlink(binfilename);
if(objfilename) unlink(objfilename);
@@ -280,6 +281,9 @@ char **argv;
if( flag_state ) as_warn.semaphore = -1;
else as_warn.semaphore = 0;
break;
+ case 'k':
+ keep_bad_output = 1;
+ break;
default:
usage(); /* bad option */
}
diff --git a/as/chk b/as/chk
index 007c750..44f316a 100755
--- a/as/chk
+++ b/as/chk
@@ -1,8 +1,8 @@
compile()
{
- # /lib/elksemu ./as86 -3 "$@"
- ./as86 -3 "$@"
+ # /lib/elksemu ./as86 -3 -k "$@"
+ ./as86 -3 -k "$@"
}
for i in `ls asm/*.asm`
diff --git a/as/errors.c b/as/errors.c
index 0f2558a..4a78a7f 100644
--- a/as/errors.c
+++ b/as/errors.c
@@ -1,107 +1,108 @@
#include "syshead.h"
#include "const.h"
+#include "errors.h"
/* Error codes. */
/* Syntax errors. */
-PUBLIC char * COMEXP = "comma expected";
-PUBLIC char * DELEXP = "delimiter expected";
-PUBLIC char * FACEXP = "factor expected";
-PUBLIC char * IREGEXP = "index register expected";
-PUBLIC char * LABEXP = "label expected";
-PUBLIC char * LPEXP = "left parentheses expected";
-PUBLIC char * OPEXP = "opcode expected";
-PUBLIC char * RBEXP = "right bracket expected";
-PUBLIC char * REGEXP = "register expected";
-PUBLIC char * RPEXP = "right parentheses expected";
-PUBLIC char * SPEXP = "space expected";
+PUBLIC char COMEXP[] = "comma expected";
+PUBLIC char DELEXP[] = "delimiter expected";
+PUBLIC char FACEXP[] = "factor expected";
+PUBLIC char IREGEXP[] = "index register expected";
+PUBLIC char LABEXP[] = "label expected";
+PUBLIC char LPEXP[] = "left parentheses expected";
+PUBLIC char OPEXP[] = "opcode expected";
+PUBLIC char RBEXP[] = "right bracket expected";
+PUBLIC char REGEXP[] = "register expected";
+PUBLIC char RPEXP[] = "right parentheses expected";
+PUBLIC char SPEXP[] = "space expected";
/* Expression errors. */
-PUBLIC char * ABSREQ = "absolute expression required";
-PUBLIC char * NONIMPREQ = "non-imported expression required";
-PUBLIC char * RELBAD = "relocation impossible";
+PUBLIC char ABSREQ[] = "absolute expression required";
+PUBLIC char NONIMPREQ[] = "non-imported expression required";
+PUBLIC char RELBAD[] = "relocation impossible";
/* Label errors. */
-PUBLIC char * ILLAB = "illegal label";
-PUBLIC char * MACUID = "MACRO used as identifier";
-PUBLIC char * MISLAB = "missing label";
-PUBLIC char * MNUID = "opcode used as identifier";
-PUBLIC char * REGUID = "register used as identifier";
-PUBLIC char * RELAB = "redefined label";
-PUBLIC char * UNBLAB = "unbound label";
-PUBLIC char * UNLAB = "undefined label";
-PUBLIC char * VARLAB = "variable used as label";
+PUBLIC char ILLAB[] = "illegal label";
+PUBLIC char MACUID[] = "MACRO used as identifier";
+PUBLIC char MISLAB[] = "missing label";
+PUBLIC char MNUID[] = "opcode used as identifier";
+PUBLIC char REGUID[] = "register used as identifier";
+PUBLIC char RELAB[] = "redefined label";
+PUBLIC char UNBLAB[] = "unbound label";
+PUBLIC char UNLAB[] = "undefined label";
+PUBLIC char VARLAB[] = "variable used as label";
/* Addressing errors. */
-PUBLIC char * ABOUNDS = "address out of bounds";
-PUBLIC char * DBOUNDS = "data out of bounds";
-PUBLIC char * ILLMOD = "illegal address mode";
-PUBLIC char * ILLREG = "illegal register";
+PUBLIC char ABOUNDS[] = "address out of bounds";
+PUBLIC char DBOUNDS[] = "data out of bounds";
+PUBLIC char ILLMOD[] = "illegal address mode";
+PUBLIC char ILLREG[] = "illegal register";
/* Control structure errors. */
-PUBLIC char * ELSEBAD = "no matching IF";
-PUBLIC char * ENDBBAD = "no matching BLOCK";
-PUBLIC char * EOFBLOCK = "end of file in BLOCK";
-PUBLIC char * EOFIF = "end of file in IF";
-PUBLIC char * EOFLC = "location counter was undefined at end";
-PUBLIC char * EOFMAC = "end of file in MACRO";
-PUBLIC char * FAILERR = "user-generated error";
+PUBLIC char ELSEBAD[] = "no matching IF";
+PUBLIC char ENDBBAD[] = "no matching BLOCK";
+PUBLIC char EOFBLOCK[] = "end of file in BLOCK";
+PUBLIC char EOFIF[] = "end of file in IF";
+PUBLIC char EOFLC[] = "location counter was undefined at end";
+PUBLIC char EOFMAC[] = "end of file in MACRO";
+PUBLIC char FAILERR[] = "user-generated error";
/* Overflow errors. */
-PUBLIC char * BLOCKOV = "BLOCK stack overflow";
-PUBLIC char * BWRAP = "binary file wrap-around";
-PUBLIC char * COUNTOV = "counter overflow";
-PUBLIC char * COUNTUN = "counter underflow";
-PUBLIC char * GETOV = "GET stack overflow";
-PUBLIC char * IFOV = "IF stack overflow";
+PUBLIC char BLOCKOV[] = "BLOCK stack overflow";
+PUBLIC char BWRAP[] = "binary file wrap-around";
+PUBLIC char COUNTOV[] = "counter overflow";
+PUBLIC char COUNTUN[] = "counter underflow";
+PUBLIC char GETOV[] = "GET stack overflow";
+PUBLIC char IFOV[] = "IF stack overflow";
-PUBLIC char * LINLONG = "line too long";
-PUBLIC char * MACOV = "MACRO stack overflow";
-PUBLIC char * OBJSYMOV = "object symbol table overflow";
-PUBLIC char * OWRITE = "program overwrite";
-PUBLIC char * PAROV = "parameter table overflow";
-PUBLIC char * SYMOV = "symbol table overflow";
-PUBLIC char * SYMOUTOV = "output symbol table overflow";
+PUBLIC char LINLONG[] = "line too long";
+PUBLIC char MACOV[] = "MACRO stack overflow";
+PUBLIC char OBJSYMOV[] = "object symbol table overflow";
+PUBLIC char OWRITE[] = "program overwrite";
+PUBLIC char PAROV[] = "parameter table overflow";
+PUBLIC char SYMOV[] = "symbol table overflow";
+PUBLIC char SYMOUTOV[] = "output symbol table overflow";
/* I/O errors. */
-PUBLIC char * OBJOUT = "error writing object file";
+PUBLIC char OBJOUT[] = "error writing object file";
/* Miscellaneous errors. */
-PUBLIC char * AL_AX_EAX_EXP = "al ax or eax expected";
-PUBLIC char * CTLINS = "control character in string";
-PUBLIC char * FURTHER = "futher errors suppressed";
-PUBLIC char * ILL_IMM_MODE = "illegal immediate mode";
-PUBLIC char * ILL_IND_TO_IND = "illegal indirect to indirect";
-PUBLIC char * ILL_IND = "illegal indirection";
-PUBLIC char * ILL_IND_PTR = "illegal indirection from previous 'ptr'";
-PUBLIC char * ILL_SCALE = "illegal scale";
-PUBLIC char * ILL_SECTION = "illegal section";
-PUBLIC char * ILL_SEG_REG = "illegal segment register";
-PUBLIC char * ILL_SOURCE_EA = "illegal source effective address";
-PUBLIC char * ILL_SIZE = "illegal size";
-PUBLIC char * IMM_REQ = "immediate expression expected";
-PUBLIC char * INDEX_REG_EXP = "index register expected";
-PUBLIC char * IND_REQ = "indirect expression required";
-PUBLIC char * MISMATCHED_SIZE = "mismatched size";
-PUBLIC char * NOIMPORT = "no imports with binary file output";
-PUBLIC char * REENTER = "multiple ENTER pseudo-ops";
-PUBLIC char * REL_REQ = "relative expression required";
-PUBLIC char * REPEATED_DISPL = "repeated displacement";
-PUBLIC char * SEGREL = "segment or relocatability redefined";
-PUBLIC char * SEG_REG_REQ = "segment register required";
-PUBLIC char * SIZE_UNK = "size unknown";
-PUBLIC char * UNKNOWN_ESCAPE_SEQUENCE = "unknown escape sequence";
+PUBLIC char AL_AX_EAX_EXP[] = "al ax or eax expected";
+PUBLIC char CTLINS[] = "control character in string";
+PUBLIC char FURTHER[] = "futher errors suppressed";
+PUBLIC char ILL_IMM_MODE[] = "illegal immediate mode";
+PUBLIC char ILL_IND_TO_IND[] = "illegal indirect to indirect";
+PUBLIC char ILL_IND[] = "illegal indirection";
+PUBLIC char ILL_IND_PTR[] = "illegal indirection from previous 'ptr'";
+PUBLIC char ILL_SCALE[] = "illegal scale";
+PUBLIC char ILL_SECTION[] = "illegal section";
+PUBLIC char ILL_SEG_REG[] = "illegal segment register";
+PUBLIC char ILL_SOURCE_EA[] = "illegal source effective address";
+PUBLIC char ILL_SIZE[] = "illegal size";
+PUBLIC char IMM_REQ[] = "immediate expression expected";
+PUBLIC char INDEX_REG_EXP[] = "index register expected";
+PUBLIC char IND_REQ[] = "indirect expression required";
+PUBLIC char MISMATCHED_SIZE[] = "mismatched size";
+PUBLIC char NOIMPORT[] = "no imports with binary file output";
+PUBLIC char REENTER[] = "multiple ENTER pseudo-ops";
+PUBLIC char REL_REQ[] = "relative expression required";
+PUBLIC char REPEATED_DISPL[] = "repeated displacement";
+PUBLIC char SEGREL[] = "segment or relocatability redefined";
+PUBLIC char SEG_REG_REQ[] = "segment register required";
+PUBLIC char SIZE_UNK[] = "size unknown";
+PUBLIC char UNKNOWN_ESCAPE_SEQUENCE[] = "unknown escape sequence";
-PUBLIC char * FP_REG_REQ = "FP register required";
-PUBLIC char * FP_REG_NOT_ALLOWED = "FP register not allowed";
-PUBLIC char * ILL_FP_REG = "illegal FP register";
-PUBLIC char * ILL_FP_REG_PAIR = "illegal FP register pair";
-PUBLIC char * JUNK_AFTER_OPERANDS = "junk after operands";
+PUBLIC char FP_REG_REQ[] = "FP register required";
+PUBLIC char FP_REG_NOT_ALLOWED[] = "FP register not allowed";
+PUBLIC char ILL_FP_REG[] = "illegal FP register";
+PUBLIC char ILL_FP_REG_PAIR[] = "illegal FP register pair";
+PUBLIC char JUNK_AFTER_OPERANDS[] = "junk after operands";
-PUBLIC char * ALREADY = "already defined";
-PUBLIC char * UNSTABLE_LABEL = "label moved in last pass add -O?";
+PUBLIC char ALREADY[] = "already defined";
+PUBLIC char UNSTABLE_LABEL[] = "label moved in last pass add -O?";
/* Warnings. */
-PUBLIC char * CPUCLASH = "instruction illegal for current cpu";
-PUBLIC char * SHORTB = "short branch would do";
+PUBLIC char CPUCLASH[] = "instruction illegal for current cpu";
+PUBLIC char SHORTB[] = "short branch would do";
diff --git a/as/errors.h b/as/errors.h
index 28e1a58..ad1b57f 100644
--- a/as/errors.h
+++ b/as/errors.h
@@ -1,105 +1,105 @@
/* Error codes. */
/* Syntax errors. */
-EXTERN char * COMEXP; /* "comma expected" */
-EXTERN char * DELEXP; /* "delimiter expected" */
-EXTERN char * FACEXP; /* "factor expected" */
-EXTERN char * IREGEXP; /* "index register expected" */
-EXTERN char * LABEXP; /* "label expected" */
-EXTERN char * LPEXP; /* "left parentheses expected" */
-EXTERN char * OPEXP; /* "opcode expected" */
-EXTERN char * RBEXP; /* "right bracket expected" */
-EXTERN char * REGEXP; /* "register expected" */
-EXTERN char * RPEXP; /* "right parentheses expected" */
-EXTERN char * SPEXP; /* "space expected" */
+EXTERN char COMEXP[]; /* "comma expected" */
+EXTERN char DELEXP[]; /* "delimiter expected" */
+EXTERN char FACEXP[]; /* "factor expected" */
+EXTERN char IREGEXP[]; /* "index register expected" */
+EXTERN char LABEXP[]; /* "label expected" */
+EXTERN char LPEXP[]; /* "left parentheses expected" */
+EXTERN char OPEXP[]; /* "opcode expected" */
+EXTERN char RBEXP[]; /* "right bracket expected" */
+EXTERN char REGEXP[]; /* "register expected" */
+EXTERN char RPEXP[]; /* "right parentheses expected" */
+EXTERN char SPEXP[]; /* "space expected" */
/* Expression errors. */
-EXTERN char * ABSREQ; /* "absolute expression required" */
-EXTERN char * NONIMPREQ; /* "non-imported expression required" */
-EXTERN char * RELBAD; /* "relocation impossible" */
+EXTERN char ABSREQ[]; /* "absolute expression required" */
+EXTERN char NONIMPREQ[]; /* "non-imported expression required" */
+EXTERN char RELBAD[]; /* "relocation impossible" */
/* Label errors. */
-EXTERN char * ILLAB; /* "illegal label" */
-EXTERN char * MACUID; /* "MACRO used as identifier" */
-EXTERN char * MISLAB; /* "missing label" */
-EXTERN char * MNUID; /* "opcode used as identifier" */
-EXTERN char * REGUID; /* "register used as identifier" */
-EXTERN char * RELAB; /* "redefined label" */
-EXTERN char * UNBLAB; /* "unbound label" */
-EXTERN char * UNLAB; /* "undefined label" */
-EXTERN char * VARLAB; /* "variable used as label" */
+EXTERN char ILLAB[]; /* "illegal label" */
+EXTERN char MACUID[]; /* "MACRO used as identifier" */
+EXTERN char MISLAB[]; /* "missing label" */
+EXTERN char MNUID[]; /* "opcode used as identifier" */
+EXTERN char REGUID[]; /* "register used as identifier" */
+EXTERN char RELAB[]; /* "redefined label" */
+EXTERN char UNBLAB[]; /* "unbound label" */
+EXTERN char UNLAB[]; /* "undefined label" */
+EXTERN char VARLAB[]; /* "variable used as label" */
/* Addressing errors. */
-EXTERN char * ABOUNDS; /* "address out of bounds" */
-EXTERN char * DBOUNDS; /* "data out of bounds" */
-EXTERN char * ILLMOD; /* "illegal address mode" */
-EXTERN char * ILLREG; /* "illegal register" */
+EXTERN char ABOUNDS[]; /* "address out of bounds" */
+EXTERN char DBOUNDS[]; /* "data out of bounds" */
+EXTERN char ILLMOD[]; /* "illegal address mode" */
+EXTERN char ILLREG[]; /* "illegal register" */
/* Control structure errors. */
-EXTERN char * ELSEBAD; /* "no matching IF" */
+EXTERN char ELSEBAD[]; /* "no matching IF" */
#define ELSEIFBAD ELSEBAD
-EXTERN char * ENDBBAD; /* "no matching BLOCK" */
+EXTERN char ENDBBAD[]; /* "no matching BLOCK" */
#define ENDIFBAD ELSEBAD
-EXTERN char * EOFBLOCK; /* "end of file in BLOCK" */
-EXTERN char * EOFIF; /* "end of file in IF" */
-EXTERN char * EOFLC; /* "location counter was undefined at end" */
-EXTERN char * EOFMAC; /* "end of file in MACRO" */
-EXTERN char * FAILERR; /* "user-generated error" */
+EXTERN char EOFBLOCK[]; /* "end of file in BLOCK" */
+EXTERN char EOFIF[]; /* "end of file in IF" */
+EXTERN char EOFLC[]; /* "location counter was undefined at end" */
+EXTERN char EOFMAC[]; /* "end of file in MACRO" */
+EXTERN char FAILERR[]; /* "user-generated error" */
/* Overflow errors. */
-EXTERN char * BLOCKOV; /* "BLOCK stack overflow" */
-EXTERN char * BWRAP; /* "binary file wrap-around" */
-EXTERN char * COUNTOV; /* "counter overflow" */
-EXTERN char * COUNTUN; /* "counter underflow" */
-EXTERN char * GETOV; /* "GET stack overflow" */
-EXTERN char * IFOV; /* "IF stack overflow" */
+EXTERN char BLOCKOV[]; /* "BLOCK stack overflow" */
+EXTERN char BWRAP[]; /* "binary file wrap-around" */
+EXTERN char COUNTOV[]; /* "counter overflow" */
+EXTERN char COUNTUN[]; /* "counter underflow" */
+EXTERN char GETOV[]; /* "GET stack overflow" */
+EXTERN char IFOV[]; /* "IF stack overflow" */
-EXTERN char * LINLONG; /* "line too long" */
-EXTERN char * MACOV; /* "MACRO stack overflow" */
-EXTERN char * OBJSYMOV; /* "object symbol table overflow" */
-EXTERN char * OWRITE; /* "program overwrite" */
-EXTERN char * PAROV; /* "parameter table overflow" */
-EXTERN char * SYMOV; /* "symbol table overflow" */
-EXTERN char * SYMOUTOV; /* "output symbol table overflow" */
+EXTERN char LINLONG[]; /* "line too long" */
+EXTERN char MACOV[]; /* "MACRO stack overflow" */
+EXTERN char OBJSYMOV[]; /* "object symbol table overflow" */
+EXTERN char OWRITE[]; /* "program overwrite" */
+EXTERN char PAROV[]; /* "parameter table overflow" */
+EXTERN char SYMOV[]; /* "symbol table overflow" */
+EXTERN char SYMOUTOV[]; /* "output symbol table overflow" */
/* I/O errors. */
-EXTERN char * OBJOUT; /* "error writing object file" */
+EXTERN char OBJOUT[]; /* "error writing object file" */
/* Miscellaneous errors. */
-EXTERN char * AL_AX_EAX_EXP; /* "al ax or eax expected" */
-EXTERN char * CTLINS; /* "control character in string" */
-EXTERN char * FURTHER; /* "futher errors suppressed" */
-EXTERN char * ILL_IMM_MODE; /* "illegal immediate mode" */
-EXTERN char * ILL_IND_TO_IND; /* "illegal indirect to indirect" */
-EXTERN char * ILL_IND; /* "illegal indirection" */
-EXTERN char * ILL_IND_PTR; /* "illegal indirection from previous 'ptr'" */
-EXTERN char * ILL_SCALE; /* "illegal scale" */
-EXTERN char * ILL_SECTION; /* "illegal section" */
-EXTERN char * ILL_SEG_REG; /* "illegal segment register" */
-EXTERN char * ILL_SOURCE_EA; /* "illegal source effective address" */
-EXTERN char * ILL_SIZE; /* "illegal size" */
-EXTERN char * IMM_REQ; /* "immediate expression expected" */
-EXTERN char * INDEX_REG_EXP; /* "index register expected" */
-EXTERN char * IND_REQ; /* "indirect expression required" */
-EXTERN char * MISMATCHED_SIZE; /* "mismatched size" */
-EXTERN char * NOIMPORT; /* "no imports with binary file output" */
-EXTERN char * REENTER; /* "multiple ENTER pseudo-ops" */
-EXTERN char * REL_REQ; /* "relative expression required" */
-EXTERN char * REPEATED_DISPL; /* "repeated displacement" */
-EXTERN char * SEGREL; /* "segment or relocatability redefined" */
-EXTERN char * SEG_REG_REQ; /* "segment register required" */
-EXTERN char * SIZE_UNK; /* "size unknown" */
-EXTERN char * UNKNOWN_ESCAPE_SEQUENCE; /* "unknown escape sequence" */
+EXTERN char AL_AX_EAX_EXP[]; /* "al ax or eax expected" */
+EXTERN char CTLINS[]; /* "control character in string" */
+EXTERN char FURTHER[]; /* "futher errors suppressed" */
+EXTERN char ILL_IMM_MODE[]; /* "illegal immediate mode" */
+EXTERN char ILL_IND_TO_IND[]; /* "illegal indirect to indirect" */
+EXTERN char ILL_IND[]; /* "illegal indirection" */
+EXTERN char ILL_IND_PTR[]; /* "illegal indirection from previous 'ptr'" */
+EXTERN char ILL_SCALE[]; /* "illegal scale" */
+EXTERN char ILL_SECTION[]; /* "illegal section" */
+EXTERN char ILL_SEG_REG[]; /* "illegal segment register" */
+EXTERN char ILL_SOURCE_EA[]; /* "illegal source effective address" */
+EXTERN char ILL_SIZE[]; /* "illegal size" */
+EXTERN char IMM_REQ[]; /* "immediate expression expected" */
+EXTERN char INDEX_REG_EXP[]; /* "index register expected" */
+EXTERN char IND_REQ[]; /* "indirect expression required" */
+EXTERN char MISMATCHED_SIZE[]; /* "mismatched size" */
+EXTERN char NOIMPORT[]; /* "no imports with binary file output" */
+EXTERN char REENTER[]; /* "multiple ENTER pseudo-ops" */
+EXTERN char REL_REQ[]; /* "relative expression required" */
+EXTERN char REPEATED_DISPL[]; /* "repeated displacement" */
+EXTERN char SEGREL[]; /* "segment or relocatability redefined" */
+EXTERN char SEG_REG_REQ[]; /* "segment register required" */
+EXTERN char SIZE_UNK[]; /* "size unknown" */
+EXTERN char UNKNOWN_ESCAPE_SEQUENCE[]; /* "unknown escape sequence" */
-EXTERN char * FP_REG_REQ; /* "FP register required" */
-EXTERN char * FP_REG_NOT_ALLOWED; /* "FP register not allowed" */
-EXTERN char * ILL_FP_REG; /* "illegal FP register" */
-EXTERN char * ILL_FP_REG_PAIR; /* "illegal FP register pair" */
-EXTERN char * JUNK_AFTER_OPERANDS; /* "junk after operands" */
+EXTERN char FP_REG_REQ[]; /* "FP register required" */
+EXTERN char FP_REG_NOT_ALLOWED[]; /* "FP register not allowed" */
+EXTERN char ILL_FP_REG[]; /* "illegal FP register" */
+EXTERN char ILL_FP_REG_PAIR[]; /* "illegal FP register pair" */
+EXTERN char JUNK_AFTER_OPERANDS[]; /* "junk after operands" */
-EXTERN char * ALREADY; /* "already defined" */
-EXTERN char * UNSTABLE_LABEL; /* "label moved in last pass add -O?" */
+EXTERN char ALREADY[]; /* "already defined" */
+EXTERN char UNSTABLE_LABEL[]; /* "label moved in last pass add -O?" */
/* Warnings. */
-EXTERN char * CPUCLASH; /* "instruction illegal for current cpu" */
-EXTERN char * SHORTB; /* "short branch would do" */
+EXTERN char CPUCLASH[]; /* "instruction illegal for current cpu" */
+EXTERN char SHORTB[]; /* "short branch would do" */
diff --git a/bcc/Makefile b/bcc/Makefile
index 8c2c19b..8f13f6e 100644
--- a/bcc/Makefile
+++ b/bcc/Makefile
@@ -4,13 +4,12 @@
#
PREFIX=/usr
-LIBPRE=$(PREFIX)
CFLAGS =-O
LDFLAGS =-s
BINDIR =$(PREFIX)/bin
-LIBDIR =$(LIBPRE)/lib/bcc
-BCCDEFS =-DLOCALPREFIX=$(LIBPRE) -DBINDIR=$(BINDIR) -DDEFARCH=0
+LIBDIR =$(PREFIX)/lib/bcc
+BCCDEFS =-DLOCALPREFIX=$(PREFIX) -DBINDIR=$(BINDIR) -DDEFARCH=0
BCFLAGS=$(ANSI) $(CFLAGS) $(LDFLAGS)
@@ -31,7 +30,7 @@ bcc: bcc.c
$(CC) $(BCFLAGS) $(BCCDEFS) bcc.c -o $@
ncc: bcc.c
- $(CC) $(BCFLAGS) -DL_TREE -DDEFARCH=0 bcc.c -o $@
+ $(CC) $(BCFLAGS) -DLOCALPREFIX= -DDEFARCH=0 bcc.c -o $@
bcc09: bcc.c
$(CC) $(BCFLAGS) -DMC6809 $(BCCDEFS) bcc.c -o $@
diff --git a/bcc/bcc-cc1.c b/bcc/bcc-cc1.c
index 6f545be..7ba8be0 100644
--- a/bcc/bcc-cc1.c
+++ b/bcc/bcc-cc1.c
@@ -11,8 +11,10 @@ char **argv;
growheap(0); /* init order is important */
syminit();
etreeinit();
+#ifdef BUILTIN_CPP
ifinit();
predefine();
+#endif
openio(argc, argv);
codeinit();
typeinit();
diff --git a/bcc/bcc.c b/bcc/bcc.c
index 67e5469..5efc4c6 100644
--- a/bcc/bcc.c
+++ b/bcc/bcc.c
@@ -42,7 +42,6 @@
#define W_OK 2 /* Test for write permission. */
#define X_OK 1 /* Test for execute permission. */
#define F_OK 0 /* Test for existence. */
-#define L_TREE 1 /* Use different tree style */
#define DEFARCH 0 /* Default to 8086 code */
#include "version.h"
#else
@@ -132,6 +131,7 @@ char * tmpdir = "/tmp/";
int main P((int argc, char **argv));
void getargs P((int argc, char **argv));
void add_prefix P((char * path));
+void build_prefix P((char * path1, char * path2, char * path3));
void run_aspreproc P((struct file_list * file));
void run_preproc P((struct file_list * file));
void run_unproto P((struct file_list * file));
@@ -149,45 +149,35 @@ void validate_link_opts P((void));
void append_file P((char * filename, int ftype));
void append_option P((char * option, int otype));
void prepend_option P((char * option, int otype));
-char * expand_tilde P((char * str));
+char * build_libpath P((char * opt, char * str, char * suffix));
void * xalloc P((int size));
void Usage P((void));
void fatal P((char * why));
char * copystr P((char * str));
char * catstr P((char * str, char * str2));
-#ifdef L_TREE
-void reset_localprefix P((void));
-#endif
+void reset_prefix_path P((void));
void run_command P((struct file_list * file));
-#ifndef LOCALPREFIX
-#define LOCALPREFIX /usr
+char * prefix_path = "";
+
+#ifdef LOCALPREFIX
+char * localprefix = QUOT(LOCALPREFIX);
+#else
+char * localprefix = "/";
#endif
-char * localprefix = QUOT(LOCALPREFIX);
-#ifndef L_TREE
-char * default_include = "-I~/include";
-char * default_libdir0 = "-L~/lib/bcc/i86/";
-char * default_libdir3 = "-L~/lib/bcc/i386/";
-char * optim_rules = "-d~/lib/bcc/i86";
+
+/* These paths are NATIVE install paths, change others below */
+char * default_include = "/usr/include";
+char * optim_rules = "/lib";
+#ifdef LIBDIR
+char * default_libdir = QUOT(LIBDIR);
#else
-char * default_include = "-I~/include";
-char * default_libdir0 = "-L~/lib/";
-char * default_libdir3 = "-L~/lib/i386/";
-char * optim_rules = "-d~/lib";
+char * default_libdir = "/lib";
#endif
+char * libdir_suffix = "";
char devnull[] = "/dev/null";
-char * exec_prefixs[] = {
-
- /* Place fillers for dynamic fill */
- devnull, devnull, devnull, devnull, devnull,
-
- "~/lib/bcc/",
-#ifdef BINDIR
- QUOT(BINDIR) "/",
-#endif
- "~/lib/",
- "~/bin/",
+char * exec_prefixs[16] = {
0 /* Last chance is contents of $PATH */
};
@@ -199,18 +189,55 @@ int argc;
char ** argv;
{
struct file_list * next_file;
+ char * temp;
progname = argv[0];
-#ifdef L_TREE
- reset_localprefix();
-#endif
+ if ((temp = getenv("BCC_PREFIX")) != 0 )
+ localprefix = copystr(temp);
+
getargs(argc, argv);
validate_link_opts();
- default_include = expand_tilde(default_include);
- default_libdir0 = expand_tilde(default_libdir0);
- default_libdir3 = expand_tilde(default_libdir3);
- optim_rules = expand_tilde(optim_rules);
+ reset_prefix_path();
+
+ if (!*localprefix || !localprefix[1]) {
+
+ if (*localprefix == '/') {
+ /* Paths for full NATIVE install "-M/" */
+ build_prefix(default_libdir, libdir_suffix, "");
+ build_prefix(default_libdir, "", "");
+
+ default_include = build_libpath("-I", "/usr/include", "");
+ default_libdir = build_libpath("-L", default_libdir, libdir_suffix);
+ optim_rules = build_libpath("-d", optim_rules, libdir_suffix);
+#if 0
+ } else if (*localprefix == '+') {
+ /* Paths for a special */
+#endif
+ } else {
+ /* Relative paths to a build dir "-M-" */
+ build_prefix("/lib", libdir_suffix, "");
+ build_prefix("/lib", "", "");
+
+ default_include = build_libpath("-I", "/include", "");
+ default_libdir = build_libpath("-L", "/lib", libdir_suffix);
+ optim_rules = build_libpath("-d", "/lib", libdir_suffix);
+ }
+
+ } else {
+ /* Relative paths to normal PREFIX directory */
+ default_include = build_libpath("-I", "/lib/bcc/include", "");
+ default_libdir = build_libpath("-L", "/lib/bcc", libdir_suffix);
+ optim_rules = build_libpath("-d", "/lib/bcc", libdir_suffix);
+
+ build_prefix("/lib/bcc", libdir_suffix, "");
+ build_prefix("/lib/bcc", "", "");
+ }
+
+ build_prefix("/bin", "", "");
+#ifdef BINDIR
+ add_prefix(QUOT(BINDIR) "/");
+#endif
if (opt_v>1) { command.cmd = ""; command_reset(); }
@@ -260,7 +287,7 @@ void
run_aspreproc(file)
struct file_list * file;
{
- static char * cc1bcc = CC1BCC;
+ static char cc1bcc[] = CC1BCC;
if (opt_arch<5) {
if (opt_e)
@@ -290,7 +317,7 @@ struct file_list * file;
{
int last_stage = 0;
int combined_cpp;
- static char * cc1bcc = CC1BCC;
+ static char cc1bcc[] = CC1BCC;
if (opt_arch<5) {
if (opt_e)
@@ -381,21 +408,32 @@ struct file_list * file;
command_reset();
newfilename(file, !do_as, 's', 1);
command_opt("-c!");
- if (opt_O)
+ if (opt_O && opt_arch == 0)
{
sprintf(buf, "-huse16 %c86", opt_O);
command_opt(buf);
}
command_opt(optim_rules);
- command_opts('o');
command_opt("rules.start");
- if (opt_O)
- {
- sprintf(buf, "rules.%c86", opt_O);
+ command_opts('o');
+
+ if (opt_O) {
+ if (opt_arch == 0)
+ sprintf(buf, "rules.%c86", opt_O);
+ else
+ sprintf(buf, "rules.lv_%c", opt_O);
command_opt(buf);
}
- command_opt("rules.86");
+
+ switch(opt_arch) {
+ case 0: command_opt("rules.86"); break;
+ case 1:
+ case 2: command_opt("rules.i386"); break;
+ case 4: command_opt("rules.6809"); break;
+ default:command_opt("rules.mid"); break;
+ }
+
command_opt("rules.end");
run_command(file);
@@ -436,9 +474,9 @@ struct file_list * file;
{
command.cmd = LD86;
command_reset();
- newfilename(file, !do_link, 'o', 1);
command_opt("-r");
command_opt("-N");
+ newfilename(file, !do_link, 'o', 1);
run_command(file);
}
}
@@ -472,15 +510,14 @@ run_link()
command_opt("-i");
if (!opt_L)
- {
- if (opt_arch==1) command_opt(default_libdir3);
- else command_opt(default_libdir0);
- }
+ command_opt(default_libdir);
command_arch();
if (!opt_x)
command_opt("-C0");
}
+ /* Current Debian compilers only work in with this: */
+ else command_opt("--static");
for(next_file = files; next_file; next_file = next_file->next)
command_opt(next_file->file);
@@ -605,13 +642,13 @@ command_reset()
memcpy(buf, *prefix, p-*prefix);
buf[p-*prefix] = 0;
- strcat(buf, localprefix);
+ strcat(buf, prefix_path);
strcat(buf, p+1);
}
strcat(buf, command.cmd);
if (!*command.cmd)
- fprintf(stderr, "PATH+=%s\n", buf);
+ fprintf(stderr, "PATH%d=%s\n", prefix-exec_prefixs, buf);
else if (access(buf, X_OK) == 0)
{
command.fullpath = copystr(buf);
@@ -832,7 +869,7 @@ char ** argv;
case 'O':
do_optim=1;
- if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '3' ))
+ if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '9' ))
opt_O = opt_arg[0];
else if (opt_arg[0] == '-')
append_option(opt_arg, 'o');
@@ -866,7 +903,15 @@ char ** argv;
break;
case 'M':
+ if (opt_arg[0] == '/') {
+ localprefix = copystr(opt_arg);
+ break;
+ }
if (opt_arg[1]) Usage();
+ if (opt_arg[0] == '-') {
+ localprefix = "";
+ break;
+ }
opt_M = *opt_arg;
break;
@@ -1002,23 +1047,21 @@ char ** argv;
opt_arch = 2;
prepend_option("-D__unix__", 'p');
prepend_option("-D__linux__", 'p');
- /* This one works (in Debian potato), /usr/bin/gcc crashes. */
- add_prefix("/usr/bin/i486-linuxlibc1-");
+
+ /* This is a more traditional libc, it also gives a 20k executable
+ * for hello world vs. 400k with glibc2 and --static.
+ * NB: DLL libc no longer seems to work.
+ */
+ add_prefix("/usr/bin/i386-uclibc-");
break;
case '8': /* Use 'c386' program as compiler */
opt_arch = 3;
+ prepend_option("-D__unix__", 'p');
+ prepend_option("-D__c386__", 'p');
break;
case '9': /* 6809 compiler */
opt_arch = 4;
-#ifndef L_TREE
- default_libdir0 = "-L~/lib/bcc/m09/";
- optim_rules = "-d~/lib/bcc/m09";
- add_prefix("~/lib/bcc/m09/");
-#else
- default_libdir0 = "-L~/lib/m09/";
- optim_rules = "-d~/lib/m09";
- add_prefix("~/lib/m09/");
-#endif
+ prepend_option("-D__6809__", 'p');
break;
case '0': /* Plain old Unix V7 style */
opt_arch = 5;
@@ -1036,6 +1079,29 @@ char ** argv;
append_option("-O", 'C');
append_option("-O", 'a');
}
+
+ if (opt_arch == 1) libdir_suffix = "/i386";
+ if (opt_arch == 4) libdir_suffix = "/m09";
+}
+
+void
+build_prefix(path1, path2, path3)
+char * path1, * path2, * path3;
+{
+ char * newstr;
+ int l;
+ newstr = xalloc(strlen(path1)+strlen(path1)+strlen(path3)
+ + strlen(prefix_path)+2);
+
+ strcpy(newstr, prefix_path);
+ strcat(newstr, path1);
+ strcat(newstr, path2);
+ strcat(newstr, path3);
+ l = strlen(newstr);
+ if (l>1 && newstr[l-1] != '/')
+ strcat(newstr, "/");
+
+ add_prefix(newstr);
}
void
@@ -1045,14 +1111,18 @@ char * path;
char ** p;
if (!path || !*path) return;
- for(p=exec_prefixs; *p; p++) {
- if( *p == devnull )
+ for( p=exec_prefixs;
+ p<exec_prefixs+(sizeof(exec_prefixs)/sizeof(*p))-1;
+ p++) {
+
+ if( !*p )
{
*p = path;
- break;
+ return;
}
+ if (strcmp(*p, path) == 0) return;
}
- if (!*p) fatal("Too many -B options");
+ fatal("Too many -B options");
}
void append_file (filename, ftype)
@@ -1128,17 +1198,15 @@ int otype;
options = newopt;
}
-char * expand_tilde(str)
-char * str;
+char * build_libpath(opt, str, suffix)
+char * opt, * str, * suffix;
{
char * newstr;
- char * ptr = strchr(str, '~');
- if( ptr == 0 ) return copystr(str);
-
- newstr = xalloc(strlen(str)+strlen(localprefix));
- if( ptr!=str ) memcpy(newstr, str, ptr-str);
- strcpy(newstr+(ptr-str), localprefix);
- strcat(newstr, ptr+1);
+ newstr = xalloc(strlen(opt)+strlen(str)+strlen(prefix_path)+strlen(suffix)+1);
+ strcpy(newstr, opt);
+ strcat(newstr, prefix_path);
+ strcat(newstr, str);
+ strcat(newstr, suffix);
return newstr;
}
@@ -1168,28 +1236,42 @@ char * str;
exit(1);
}
-#ifdef L_TREE
#ifdef MSDOS
-void reset_localprefix()
+void reset_prefix_path()
{
char *ptr, *temp;
+ if (*localprefix && localprefix[1]) {
+ prefix_path = localprefix;
+ return;
+ }
+
temp = copystr(progname);
if( (ptr = strrchr(temp, '\\')) != 0
&& temp<ptr-4 && strncmp(ptr-4, "\\BIN", 4) == 0 )
{
ptr[-4] = 0;
- localprefix = temp;
+ prefix_path = temp;
}
else
free(temp);
}
#else
-void reset_localprefix()
+void reset_prefix_path()
{
char *ptr, *temp;
+ if (*localprefix && localprefix[1]) {
+ prefix_path = localprefix;
+ return;
+ }
+
+ if ( *localprefix == '/' && !localprefix[1]) {
+ prefix_path = "";
+ return;
+ }
+
if( *progname == '/' )
temp = copystr(progname);
else
@@ -1237,14 +1319,12 @@ void reset_localprefix()
&& temp<ptr-4 && strncmp(ptr-4, "/bin", 4) == 0 )
{
ptr[-4] = 0;
- localprefix = temp;
+ prefix_path = temp;
}
else
free(temp);
}
#endif
-#endif
-
void
run_command(file)
diff --git a/bcc/bcc.doc b/bcc/bcc.doc
index acf4ab0..31c19f9 100644
--- a/bcc/bcc.doc
+++ b/bcc/bcc.doc
@@ -1,3 +1,5 @@
+WARNING: This document bis out of date; it's kept mainly for the 6809 notes.
+
bcc options
-----------
@@ -15,7 +17,7 @@ outfile stdout for preprocessor output
somewhere/file.[cis] -> file.o for assembler output
a.out for ld output
--ansi Pass the source through '/usr/bin/unprotoize' first
+-ansi Pass the source through 'unproto' first
-0 8086 target (works even on 80386 host)
-3 80386 target (works even on 8086 host)
-A pass remainder of option to assembler (e.g. -A-l -Alistfile for a listing)
diff --git a/bcc/const.h b/bcc/const.h
index a854685..7055354 100644
--- a/bcc/const.h
+++ b/bcc/const.h
@@ -26,6 +26,7 @@
#ifndef VERY_SMALL_MEMORY
#define DEBUG /* generate compiler-debugging code */
#define OPTIMISE /* include optimisation code */
+#define BUILTIN_CPP
#endif
#ifdef I8088
diff --git a/bcc/declare.c b/bcc/declare.c
index 1b9e00a..ad3b31e 100644
--- a/bcc/declare.c
+++ b/bcc/declare.c
@@ -1052,9 +1052,11 @@ PUBLIC void needvarname()
PUBLIC void program()
{
+#ifdef BUILTIN_CPP
if (orig_cppmode)
cppscan(0);
else
+#endif
{
nextsym();
while (sym != EOFSYM)
diff --git a/bcc/input.c b/bcc/input.c
index 4f8ec6a..317c053 100644
--- a/bcc/input.c
+++ b/bcc/input.c
@@ -19,6 +19,10 @@
#define INBUFSIZE 2048
+#ifndef BUILTIN_CPP
+#define NO_EOFHACK
+#endif
+
struct fbufstruct /* file buffer structure */
{
struct fcbstruct fcb; /* status after opening an include sub-file */
@@ -51,8 +55,10 @@ PRIVATE struct inclist inclast =
#endif
NULL,
};
+#ifdef BUILTIN_CPP
PRIVATE fastin_t inclevel; /* nest level of include files */
/* depends on zero init */
+#endif
PRIVATE struct fbufstruct *inputbuf; /* current input file buffer */
/* its fcb only to date in includes */
/* depends on zero (NULL) init */
@@ -63,8 +69,10 @@ FORWARD void backslash P((void));
#endif
FORWARD void definefile P((char *fname));
FORWARD void inputinit P((char *fname, fd_t fd));
-FORWARD void leaveinclude P((void));
FORWARD void usage P((void));
+#ifdef BUILTIN_CPP
+FORWARD void leaveinclude P((void));
+#endif
#ifdef ARBITRARY_BACKSLASH_NEWLINES
PRIVATE void backslash()
@@ -138,10 +146,13 @@ PUBLIC void closein()
#else
close(input.fd);
#endif
+#ifdef BUILTIN_CPP
while (inclevel != 0)
leaveinclude();
+#endif
}
+#ifdef BUILTIN_CPP
PRIVATE void definefile(fname)
char *fname;
{
@@ -155,6 +166,7 @@ char *fname;
definestring(def);
ourfree(def);
}
+#endif
PUBLIC void errorloc()
{
@@ -170,6 +182,7 @@ PUBLIC void errorloc()
{
outudec(input.linenumber);
outbyte('.');
+#ifdef BUILTIN_CPP
if (maclevel == 0)
outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset);
else
@@ -180,6 +193,9 @@ PUBLIC void errorloc()
outudec((unsigned) maclevel);
outbyte(')');
}
+#else
+ outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset);
+#endif
}
infbuf->fcb.includer = input.includer;
while ((infbuf = infbuf->fcb.includer) != NULL)
@@ -202,6 +218,7 @@ PUBLIC void gch1()
specialchar();
}
+#ifdef BUILTIN_CPP
/* process #include */
PUBLIC void include()
@@ -217,10 +234,15 @@ PUBLIC void include()
while (blanksident())
{
+#ifdef BUILTIN_CPP
if ((gsymptr = findlorg(gsname)) == NULL ||
gsymptr->flags != DEFINITION)
break;
entermac();
+#else
+ if ((gsymptr = findlorg(gsname)) == NULL )
+ break;
+#endif
}
if ((terminator = ch) == '<')
terminator = '>';
@@ -345,6 +367,7 @@ ts_s_filename_tot -= charptr - fnameptr;
#endif
charptr = fnameptr;
}
+#endif
/* initialise current input file */
@@ -373,14 +396,18 @@ ts_s_inputbuf_tot += sizeof *inputbuf;
inputbuf = newinputbuf;
newinputbuf->fname = fname;
newinputbuf->fname_malloced = FALSE;
+#ifdef BUILTIN_CPP
undefinestring(filemacro);
definefile(fname);
if (orig_cppmode && !suppress_line_numbers)
outcpplinenumber(1, fname, input.includer == NULL ? "" : " 1");
+#endif
*(input.limit = newinputbuf->fbuf) = EOL;
+#ifdef BUILTIN_CPP
/* dummy line so #include processing can start with skipline() */
ch = *(lineptr = newinputbuf->fbuf - 1) = EOL;
+#endif
}
PUBLIC void linecontol()
@@ -412,11 +439,14 @@ ts_s_pathname_tot -= strlen(inputbuf->fname) + 1;
inputbuf->fname = linename;
ptr=lineptr;
+#ifdef BUILTIN_CPP
undefinestring(filemacro);
definefile(inputbuf->fname);
+#endif
ch = *(lineptr = ptr);
}
+#ifdef BUILTIN_CPP
/* switch from include file to file which included it */
PRIVATE void leaveinclude()
@@ -442,13 +472,16 @@ ts_s_inputbuf_tot -= sizeof *inputbuf;
#endif
inputbuf = input.includer;
input = inputbuf->fcb;
+#ifdef BUILTIN_CPP
undefinestring(filemacro);
definefile(inputbuf->fname);
+#endif
ch = *(lineptr = input.lineptr);
skipline();
if (orig_cppmode && !suppress_line_numbers)
outcpplinenumber(input.linenumber, inputbuf->fname, " 2");
}
+#endif
/* open input and output files and get options */
@@ -499,7 +532,9 @@ char *argv[];
#ifdef DEBUG
case 'd': /* print debugging information in asm output */
#endif
+#ifdef BUILTIN_CPP
case 'E': /* acting as cpp */
+#endif
case 'f': /* pass first argument in register */
#ifdef DYNAMIC_LONG_ORDER
case 'l': /* long big-endian */
@@ -520,6 +555,7 @@ char *argv[];
if (arg[1] == '0') /* flag 0 is negative logic flag 3 */
flag['3'] = TRUE + FALSE - flag['0'];
break;
+#ifdef BUILTIN_CPP
case 'D':
definestring(arg + 2);
break;
@@ -536,6 +572,7 @@ ts_s_includelist += sizeof *incnew;
case 'U':
undefinestring(arg + 2);
break;
+#endif
case 'o':
if (arg[2] != 0 || ++argn >= argc)
usage();
@@ -546,6 +583,7 @@ ts_s_includelist += sizeof *incnew;
break;
}
}
+#ifdef BUILTIN_CPP
#ifdef I8088
#ifdef I80386
if (flag['3'])
@@ -607,6 +645,28 @@ ts_s_includelist += sizeof *incnew;
#ifdef NOFLOAT
definestring("__HAS_NO_FLOATS__");
#endif
+
+#else /* !BUILTIN_CPP */
+
+#ifdef I80386
+ if (flag['3']) i386_32 = TRUE;
+#endif
+ if (flag['c']) callersaves = TRUE;
+#ifdef DEBUG
+ debugon = flag['d'];
+#endif
+ if (flag['f']) arg1inreg = TRUE;
+ arg1op = arg1inreg ? ROOTLISTOP : LISTOP;
+#ifdef DYNAMIC_LONG_ORDER
+ if (flag['l']) long_big_endian = TRUE;
+#endif
+ suppress_line_numbers = flag['P'];
+#ifdef POSINDEPENDENT
+ if (flag['p']) posindependent = TRUE;
+#endif
+ if (flag['O']) optimise = TRUE;
+
+#endif
ctext = flag['t'];
#ifdef DEBUG
if (ctext) debugon = 1;
@@ -642,6 +702,7 @@ PUBLIC void skipeol()
outbyte(' ');
outline(lineptr);
}
+#ifdef BUILTIN_CPP
#ifndef ASM_BARE
if (!virtual_nl && (orig_cppmode || asmmode))
#else
@@ -651,6 +712,13 @@ PUBLIC void skipeol()
if (!skip_printing_nl)
#endif
outbyte('\n');
+#else /* !BUILTIN_CPP */
+ if (asmmode)
+#ifdef INSERT_BACKSLASH_NEWLINES
+ if (!skip_printing_nl)
+#endif
+ outbyte('\n');
+#endif
#ifdef INSERT_BACKSLASH_NEWLINES
if (bs_state == 1 && *(lineptr - 1) == EOL)
@@ -715,6 +783,7 @@ case0:
ch = *lineptr;
if (nread == 0)
{
+#ifdef BUILTIN_CPP
if (inclevel == 0)
{
eofile = TRUE;
@@ -725,6 +794,9 @@ case0:
leaveinclude();
skipeol();
}
+#else
+ eofile = TRUE;
+#endif
return;
}
if (ctext && !asmmode)
@@ -738,6 +810,7 @@ case0:
PUBLIC void specialchar()
{
+#ifdef BUILTIN_CPP
if (maclevel != 0)
{
if (ch == EOL) /* it might also be backslash or COEOL */
@@ -745,6 +818,7 @@ PUBLIC void specialchar()
if (ch != EOL)
return;
}
+#endif
more:
#ifdef ARBITRARY_BACKSLASH_NEWLINES
if (ch == '\\')
diff --git a/bcc/input.h b/bcc/input.h
index 42c31f7..9a1a269 100644
--- a/bcc/input.h
+++ b/bcc/input.h
@@ -26,13 +26,16 @@ struct fcbstruct /* file control block structure */
EXTERN bool_t asmmode; /* nonzero when processing assembler code */
/* depends on zero init */
EXTERN char ch; /* current char */
-EXTERN bool_t cppmode; /* nonzero if acting as cpp not as compiler */
EXTERN bool_t eofile; /* nonzero after end of main file reached */
/* depends on zero init */
EXTERN struct fcbstruct input; /* current input file control block */
/* input.lineptr is not kept up to date */
EXTERN char *lineptr; /* ptr to current char */
+
+#ifdef BUILTIN_CPP
+EXTERN bool_t cppmode; /* nonzero if acting as cpp not as compiler */
EXTERN maclev_t maclevel; /* nest level of #defined identifiers */
/* depends on zero init */
EXTERN bool_t orig_cppmode; /* same as cppmode ex. not varied while in # */
EXTERN bool_t virtual_nl; /* For -C and asm, don't print first nl */
+#endif
diff --git a/bcc/output.c b/bcc/output.c
index b82f968..dd00c71 100644
--- a/bcc/output.c
+++ b/bcc/output.c
@@ -157,7 +157,9 @@ char *message;
PUBLIC void finishup()
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode)
+#endif
{
if (watchlc)
{
@@ -208,7 +210,9 @@ PUBLIC void flushout()
}
if (nbytes != 0)
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode)
+#endif
clearlabels(outbufptr, outbufptr + nbytes);
if (write(output, outbufptr, nbytes) != nbytes)
{
diff --git a/bcc/preproc.c b/bcc/preproc.c
index 1f35013..97e2a96 100644
--- a/bcc/preproc.c
+++ b/bcc/preproc.c
@@ -12,6 +12,16 @@
#include "table.h"
#include "type.h"
+/* blanksident() - return nonzero if at blanks followed by an identifier */
+
+PUBLIC bool_pt blanksident()
+{
+ blanks();
+ return isident();
+}
+
+#ifdef BUILTIN_CPP
+
#define MAX_IF 32
#define MAX__LINE__ 10 /* enough for 32-bit source unsigneds */
#define MAX_MACRO 32
@@ -138,14 +148,6 @@ PRIVATE void asmcontrol()
outnstr("!BCC_ENDASM");
}
-/* blanksident() - return nonzero if at blanks followed by an identifier */
-
-PUBLIC bool_pt blanksident()
-{
- blanks();
- return isident();
-}
-
PUBLIC void checknotinif()
{
while (iflevel != 0)
@@ -1076,3 +1078,5 @@ char *str;
{
defineorundefinestring(str, FALSE);
}
+
+#endif
diff --git a/bcc/scan.c b/bcc/scan.c
index b96093d..36271e4 100644
--- a/bcc/scan.c
+++ b/bcc/scan.c
@@ -119,6 +119,7 @@ PUBLIC void blanks()
continue;
reglineptr = lineptr;
}
+#ifdef BUILTIN_CPP
if (*reglineptr != '/')
return;
if (SYMOFCHAR(*(reglineptr + 1)) == SPECIALCHAR)
@@ -131,6 +132,9 @@ PUBLIC void blanks()
return;
gch1();
skipcomment();
+#else
+ return;
+#endif
}
}
@@ -139,8 +143,10 @@ int asm_only;
{
int start_of_line = 1;
#ifndef ASM_BARE
+#ifdef BUILTIN_CPP
virtual_nl = 1;
#endif
+#endif
while (!asm_only || asmmode)
{
int sym = SYMOFCHAR(ch);
@@ -172,6 +178,7 @@ int asm_only;
outstr(constant.value.s); /* XXX - embedded null would kill it */
charptr = constant.value.s;
break;
+#ifdef BUILTIN_CPP
case CONTROL:
gch1();
if (maclevel != 0)
@@ -196,6 +203,12 @@ int asm_only;
}
outbyte('/');
break;
+#else /* !BUILTIN_CPP */
+ case CONTROL:
+ gch1();
+ docontrol();
+ continue;
+#endif
case FLOATCONST:
gch1();
if (SYMOFCHAR(ch) == INTCONST)
@@ -211,6 +224,7 @@ int asm_only;
break;
case IDENT:
getident();
+#ifdef BUILTIN_CPP
if ((gsymptr = findlorg(gsname)) != NULL)
{
if (gsymptr->flags == DEFINITION)
@@ -219,6 +233,7 @@ int asm_only;
break;
}
}
+#endif
outstr(gsname);
break;
case INTCONST:
@@ -253,7 +268,11 @@ int asm_only;
/* must be '\\' */
default:
/* Allow for multi-instruction lines in asm */
+#ifdef BUILTIN_CPP
if( ch == '^' && !orig_cppmode && asmmode ) ch='\n';
+#else
+ if( ch == '^' && asmmode ) ch='\n';
+#endif
OUTBYTE(ch);
ch = *++lineptr;
@@ -261,8 +280,10 @@ int asm_only;
break;
}
#ifndef ASM_BARE
+#ifdef BUILTIN_CPP
virtual_nl = 0;
#endif
+#endif
}
}
@@ -473,12 +494,14 @@ PUBLIC void nextsym()
constant.type = itype;
return;
case CONTROL:
+#ifdef BUILTIN_CPP
if (maclevel != 0)
{
error("# in a macro: not preprocessed"); /* XXX? */
return;
}
else
+#endif
{
int old_asmmode = asmmode;
docontrol();
@@ -505,11 +528,13 @@ PUBLIC void nextsym()
getident();
if ((gsymptr = findlorg(gsname)) != NULL)
{
+#ifdef BUILTIN_CPP
if (gsymptr->flags == DEFINITION)
{
entermac();
break;
}
+#endif
if (gsymptr->flags == KEYWORD)
sym = gsymptr->offset.offsym;
}
@@ -609,11 +634,13 @@ PUBLIC void nextsym()
}
return;
case SLASH:
+#ifdef BUILTIN_CPP
if (ch == '*')
{
skipcomment();
break;
}
+#endif
if (ch == '=')
{
sym = DIVABOP;
@@ -749,7 +776,9 @@ PUBLIC void stringorcharconst()
gch1();
if (ch == EOL)
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode)
+#endif
eofin("escape sequence");
break;
}
@@ -758,7 +787,9 @@ PUBLIC void stringorcharconst()
GCH1();
if (ch == EOL)
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode && ifcheck() )
+#endif
error(terminator == '"' ? "end of line in string constant"
: "end of line in character constant");
break;
diff --git a/bin86/Makefile b/bin86/Makefile
index 2be62a8..3d8aa6f 100644
--- a/bin86/Makefile
+++ b/bin86/Makefile
@@ -27,13 +27,11 @@ all:
install: all
install $(INSTALL_OPTS) as/as86 $(BINDIR)/as$(SUF)
- install $(INSTALL_OPT) as/as86_encap $(BINDIR)/as$(SUF)_encap
install $(INSTALL_OPTS) ld/ld86 $(BINDIR)/ld$(SUF)
install $(INSTALL_OPTS) ld/objdump86 $(BINDIR)/objdump$(SUF)
install $(MAN_OPTS) man/*.1 $(MANDIR)
ln -sf objdump$(SUF) $(BINDIR)/nm$(SUF)
ln -sf objdump$(SUF) $(BINDIR)/size$(SUF)
- ln -sf as86.1 $(MANDIR)/as86_encap.1
depend clean clobber:
set -e ; for d in $(DIRS); do \
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index 9622817..60d8b8f 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -37,7 +37,8 @@ BOOTBLOCKS=sysboot.v noboot.v skip.v msdos.v msdos16.v \
EXTRAS=minix.h zimage.s minix_elks.c lsys.c boot_win.c
-install:
+install: makeboot
+ install -m 755 -s makeboot $(DIST)$(PREFIX)/bin/makeboot
monitor.com: $(MOBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(MONDEFS) -d $(MOBJ) -o monitor.com -M > monitor.sym
diff --git a/bootblocks/boot_win.c b/bootblocks/boot_win.c
index 5ee7180..e38eebb 100644
--- a/bootblocks/boot_win.c
+++ b/bootblocks/boot_win.c
@@ -35,6 +35,7 @@ main()
{
int i, rv;
int floppy_only = 0;
+ int c,h,s,os;
reset_screen();
cprintf("...\n");
@@ -52,8 +53,15 @@ main()
if (!floppy_only) {
for(rv=-1, i=0x1BE; i<0x1FE; i+= 16) {
- if (bs_buf[i] == (char)0x80)
+ if (bs_buf[i] == (char)0x80) {
rv = 0;
+ s = (bs_buf[i+2] & 63) ;
+ h = (bs_buf[i+1] & 255) ;
+ c = (bs_buf[i+3] & 255) + ((bs_buf[i+2] & 0xC0) << 2);
+
+ os = (bs_buf[i+4] & 255) ;
+ break;
+ }
}
if (rv) {
@@ -62,6 +70,16 @@ main()
}
}
+ if (!floppy_only && (os==4 || os==6 || os==11 || os==12 || os==13)) {
+ for(i=0; i<6; i++)
+ if (!(rv = _bios_disk_read(0x80, c, h, s, 1, bs_buf))) break;
+
+ if (rv != 0 || bs_buf[510] != 0x55 || bs_buf[511] != (char)0xAA) {
+ cprintf("DOS Partition not bootable.\n");
+ floppy_only = 1;
+ }
+ }
+
if (floppy_only)
cprintf("Press return to wipe MBR: ");
else
diff --git a/cpp/cpp.c b/cpp/cpp.c
index 7fcc4b5..7d287f4 100644
--- a/cpp/cpp.c
+++ b/cpp/cpp.c
@@ -134,8 +134,8 @@ gettok()
if( ch == TK_WORD )
{
- struct token_trans *p;
- if( p=is_ckey(curword, strlen(curword)) )
+ struct token_trans *p = is_ckey(curword, strlen(curword)) ;
+ if( p )
return p->token;
}
@@ -551,7 +551,7 @@ unchget(ch)
fprintf(stderr, "\b", ch);
#endif
if(ch == 0) return; /* Hummm */
- if(ch == EOF) ch=EOT; /* EOF is pushed back as ^Z */
+ if(ch == EOF) ch=EOT; /* EOF is pushed back as a normal character. */
ch &= 0xFF;
if(unputc&0xFF000000)
diff --git a/elksemu/Makefile b/elksemu/Makefile
index f613fde..df97c2d 100644
--- a/elksemu/Makefile
+++ b/elksemu/Makefile
@@ -26,13 +26,16 @@ OBJ=elks.o elks_sys.o elks_signal.o minix.o
elksemu: $(OBJ)
$(CC) $(CFLAGS) -o $@ $^
-elks_sys.o: call_tab.v
+elks_sys.o: call_tab.v efile.h
$(OBJ): elks.h
call_tab.v: dummy
-cp -p ../libc/syscall/call_tab.v . 2>/dev/null
-cp -p ../libc/syscall/defn_tab.v . 2>/dev/null
+efile.h: ../libc/error/liberror.txt
+ sh mkefile ../libc/error/liberror.txt
+
dummy:
# The kernel patch or module _requires_ this location but binfmt-misc is easy
@@ -42,7 +45,7 @@ install: elksemu
install -s -o root -g root -m 4555 elksemu $(DIST)/lib/elksemu
clean realclean:
- rm -f $(OBJ) binfmt_elks.o elksemu call_tab.v defn_tab.v
+ rm -f $(OBJ) binfmt_elks.o elksemu call_tab.v defn_tab.v efile.h
module: binfmt_elks.o
diff --git a/elksemu/README b/elksemu/README
index 065d22b..a7092b8 100644
--- a/elksemu/README
+++ b/elksemu/README
@@ -6,18 +6,12 @@ If you're using a 2.0.36, 2.1.43, 2.2.0 or later kernel then the
binfmt_misc driver is in the stock kernel and all you need to do is
add the following line into the relevent /etc/rc* file.
-echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/lib/elksemu:' \
+echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/usr/bin/elksemu:' \
> /proc/sys/fs/binfmt_misc/register
Note, however, if binfmt_misc is compiled as a module it will not auto
load so you will have to do this manually.
-Further by default the elksemu executable is compiled as an OMAGIC
-executable and needs binfmt_aout. If binfmt_aout is a module and your
-/etc/modules.conf is not correctly configured you may have to load this
-module manually too. Alternativily you can compile elksemu using GCC
-to produce an ELF executable.
-
If your kernel version is 1.2.13 then apply the patch in the Kernel_patch
file.
diff --git a/elksemu/Security b/elksemu/Security
index 2fbef8b..16418e7 100644
--- a/elksemu/Security
+++ b/elksemu/Security
@@ -1,4 +1,4 @@
-The install scripts now install /lib/elksemu as a suid-root executable.
+Is is possible to install /usr/bin/elksemu as a suid-root executable.
This gives two additional facilities when running elks executables.
1) It is now possible to run programs that are execute only, without
diff --git a/elksemu/elks.c b/elksemu/elks.c
index ddcf549..3dd3a4d 100644
--- a/elksemu/elks.c
+++ b/elksemu/elks.c
@@ -223,7 +223,8 @@ void build_stack(char ** argv, char ** envp)
*pip++ = 0;
}
-void main(int argc, char *argv[], char *envp[])
+int
+main(int argc, char *argv[], char *envp[])
{
int fd;
struct stat st;
@@ -258,7 +259,7 @@ void main(int argc, char *argv[], char *envp[])
setregid(rgid, egid);
setreuid(ruid, euid);
- dbprintf(("ELKSEMU 0.12.0\n"));
+ dbprintf(("ELKSEMU\n"));
elks_init();
/* The Linux vm will deal with not allocating the unused pages */
diff --git a/elksemu/elks.h b/elksemu/elks.h
index 5da93a1..26fa446 100644
--- a/elksemu/elks.h
+++ b/elksemu/elks.h
@@ -24,17 +24,17 @@
struct elks_stat
{
- unsigned short st_dev;
- unsigned short st_inode;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- int st_size;
- int st_atime;
- int st_mtime;
- int st_ctime;
+ unsigned short est_dev;
+ unsigned short est_inode;
+ unsigned short est_mode;
+ unsigned short est_nlink;
+ unsigned short est_uid;
+ unsigned short est_gid;
+ unsigned short est_rdev;
+ int est_size;
+ int est_atime;
+ int est_mtime;
+ int est_ctime;
};
diff --git a/elksemu/elks_sys.c b/elksemu/elks_sys.c
index a886e99..5699edc 100644
--- a/elksemu/elks_sys.c
+++ b/elksemu/elks_sys.c
@@ -24,6 +24,8 @@
#include <sys/time.h>
#include "elks.h"
+#include "efile.h"
+
#ifdef DEBUG
#define dbprintf(x) db_printf x
#else
@@ -69,17 +71,17 @@ static void squash_stat(struct stat *s, int bx)
ELKS_POKE(long, bx+26, s->st_ctime);
#else
struct elks_stat * ms = ELKS_PTR(struct elks_stat, bx);
- ms->st_dev=s->st_dev;
- ms->st_inode=(unsigned short)s->st_ino; /* Bits lost */
- ms->st_mode=s->st_mode;
- ms->st_nlink=s->st_nlink;
- ms->st_uid=s->st_uid;
- ms->st_gid=s->st_gid;
- ms->st_rdev=s->st_rdev;
- ms->st_size=s->st_size;
- ms->st_atime=s->st_atime;
- ms->st_mtime=s->st_mtime;
- ms->st_ctime=s->st_ctime;
+ ms->est_dev=s->st_dev;
+ ms->est_inode=(unsigned short)s->st_ino; /* Bits lost */
+ ms->est_mode=s->st_mode;
+ ms->est_nlink=s->st_nlink;
+ ms->est_uid=s->st_uid;
+ ms->est_gid=s->st_gid;
+ ms->est_rdev=s->st_rdev;
+ ms->est_size=s->st_size;
+ ms->est_atime=s->st_atime;
+ ms->est_mtime=s->st_mtime;
+ ms->est_ctime=s->st_ctime;
#endif
}
@@ -142,6 +144,17 @@ static int elks_open(int bx,int cx,int dx,int di,int si)
dbprintf(("open(%s, %d, %d)\n",
dp,cx,dx));
+ /* Nasty hack so /lib/liberror.txt doesn't exist on the host.
+ */
+ if (strcmp(dp, "/lib/liberror.txt") == 0 ) {
+ int fd = open("/tmp/liberror.txt", O_CREAT|O_EXCL|O_RDWR, 0666);
+ if (fd < 0) return fd;
+ unlink("/tmp/liberror.txt");
+ write(fd, efile, sizeof(efile));
+ lseek(fd, 0L, 0);
+ return fd;
+ }
+
if( cx == O_RDONLY )
{
if(stat(dp,&s)==-1)
@@ -451,7 +464,7 @@ static int elks_execve(int bx,int cx,int dx,int di,int si)
ct=0;
if( is_elks )
{
- argp[0]="/lib/elksemu";
+ argp[0]="/usr/bin/elksemu";
/* argp[1]=ELKS_PTR(char, bx); */
ct=1;
}
diff --git a/elksemu/mkefile b/elksemu/mkefile
new file mode 100644
index 0000000..b9e24ee
--- /dev/null
+++ b/elksemu/mkefile
@@ -0,0 +1,11 @@
+#!/bin/sh -
+
+awk '
+BEGIN {
+ printf "char efile[] =\n"
+}
+{ printf " \"%s\\n\"\n", $0 }
+END{
+ printf ";\n";
+}
+' < "$1" > efile.h
diff --git a/ld/ld.c b/ld/ld.c
index cc95fb7..2d31f13 100644
--- a/ld/ld.c
+++ b/ld/ld.c
@@ -53,13 +53,15 @@ char *suf;
PRIVATE char *expandlib(fn)
char *fn;
{
- char *path;
+ char *path, *s;
int i;
for (i = lastlib - 1; i >= 0; --i)
{
- path = ourmalloc(strlen(libs[i]) + strlen(fn) + 1);
+ path = ourmalloc(strlen(libs[i]) + strlen(fn) + 2);
strcpy(path, libs[i]);
+ s = path + strlen(path);
+ if (s!=path && s[-1] != '/') strcat(path, "/");
strcat(path, fn);
if (access(path, R_OK) == 0)
return path;
diff --git a/ld/objdump86.c b/ld/objdump86.c
index 2c93aa0..d477f3b 100644
--- a/ld/objdump86.c
+++ b/ld/objdump86.c
@@ -79,6 +79,7 @@ int multiple_files = 0;
int byte_order = 0;
long size_text, size_data, size_bss;
+long tot_size_text=0, tot_size_data=0, tot_size_bss=0;
int
main(argc, argv)
@@ -118,6 +119,12 @@ char ** argv;
for(ar=1; ar<argc; ar++) if(argv[ar][0] != '-')
do_file(argv[ar]);
+ if( display_mode == 1 && multiple_files)
+ printf("%ld\t%ld\t%ld\t%ld\t%lx\tTotal\n",
+ tot_size_text, tot_size_data, tot_size_bss,
+ tot_size_text+ tot_size_data+ tot_size_bss,
+ tot_size_text+ tot_size_data+ tot_size_bss);
+
return 0;
}
@@ -242,6 +249,10 @@ char * archive;
if(archive) printf("%s(%s)\n", archive, fname);
else printf("%s\n", fname);
+
+ tot_size_text += size_text;
+ tot_size_data += size_data;
+ tot_size_bss += size_bss;
}
if( sections == 1 && display_mode != 0 )
@@ -753,6 +764,10 @@ size_aout()
header[2]+ header[3]+ header[4],
header[2]+ header[3]+ header[4],
ifname);
+
+ tot_size_text += header[2];
+ tot_size_data += header[3];
+ tot_size_bss += header[4];
}
void
diff --git a/libc/Makefile b/libc/Makefile
index a9a5460..481c034 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -20,6 +20,8 @@ include VERSION
endif
CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
+USERID=$(shell id -gn)
+GROUPID=$(shell id -un)
############################################################################
@@ -74,11 +76,11 @@ clean:
############################################################################
install_incl: transfer
- install -d $(BCCHOME)/include
- rm -f $(BCCHOME)/include/linuxmt $(BCCHOME)/include/arch ||:
- cp -Lpr include/* $(BCCHOME)/include
- -chown -R root:root $(BCCHOME)/include
- -chmod -R u=rwX,og=rX $(BCCHOME)/include
+ install -d $(DISTINCL)/include
+ rm -f $(DISTINCL)/include/linuxmt $(DISTINCL)/include/arch ||:
+ cp -LpR include/* $(DISTINCL)/include
+ -chown -R $(USERID):$(GROUPID) $(DISTINCL)/include
+ -chmod -R ugo-x,u=rwX,og=rX $(DISTINCL)/include
############################################################################
diff --git a/libc/error/Makefile b/libc/error/Makefile
index f14e956..01a488f 100644
--- a/libc/error/Makefile
+++ b/libc/error/Makefile
@@ -4,14 +4,23 @@
CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
-ifeq ($(LIB_OS),ELKS)
+ifeq ($(PLATFORM),i86-FAST)
OBJ=error.o sys_errlist.o perror.o sys_siglist.o __assert.o
else
+ifeq ($(LIB_OS),ELKS)
+OBJ=error2.o perror.o sys_siglist.o __assert.o
+else
OBJ=__assert.o
endif
+endif
all: $(LIBC)($(OBJ))
@$(RM) $(OBJ)
clean:
- rm -f *.o libc.a
+ rm -f *.o libc.a error_list.h
+
+$(LIBC)(error2.o): error_list.h
+
+error_list.h: liberror.txt
+ sh mktab.sh
diff --git a/libc/error/README b/libc/error/README
index 02c123f..3165722 100644
--- a/libc/error/README
+++ b/libc/error/README
@@ -1,10 +1,11 @@
-Copyright (C) 1996 Robert de Bath <robert@debath.thenet.co.uk>
+Copyright (C) 1996,2004 Robert de Bath <robert@debath.thenet.co.uk>
This file is part of the Linux-8086 C library and is distributed
under the GNU Library General Public License.
-These routines assume the existance of a file /usr/lib/liberror.txt,
-this file contains the actual error messages. One useful feature,
-the language of the error messages can be easily changed.
+The file "liberror.txt" is the master list of errors for ELKS only.
+WARNING:
+ If you use the -Mf compile style this file must be in the filessystem
+ as "/lib/liberror.txt" unless you're using elksemu.
-Robert
diff --git a/libc/error/error.c b/libc/error/error.c
index 3695719..4be2a56 100644
--- a/libc/error/error.c
+++ b/libc/error/error.c
@@ -24,7 +24,7 @@ int err;
}
if( err <= 0 ) goto unknown; /* NB the <= allows comments in the file */
- fd = open("/usr/lib/liberror.txt", 0);
+ fd = open("/lib/liberror.txt", 0);
if( fd < 0 ) goto unknown;
while( (cc=read(fd, inbuf, sizeof(inbuf))) > 0 )
diff --git a/libc/error/error2.c b/libc/error/error2.c
new file mode 100644
index 0000000..4ad2892
--- /dev/null
+++ b/libc/error/error2.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 1996,2004 Robert de Bath <robert@debath.thenet.co.uk>
+ * This file is part of the Linux-8086 C library and is distributed
+ * under the GNU Library General Public License.
+ */
+#include <string.h>
+
+#include "error_list.h"
+
+char *
+strerror(err)
+int err;
+{
+ static char retbuf[20];
+
+ if( err > 0 && err <= sys_nerr )
+ return sys_errlist[err];
+
+ strcpy(retbuf, "Error ");
+ strcpy(retbuf+6, itoa(err));
+ return retbuf;
+}
diff --git a/libc/error/mktab.sh b/libc/error/mktab.sh
new file mode 100644
index 0000000..b5afcc4
--- /dev/null
+++ b/libc/error/mktab.sh
@@ -0,0 +1,25 @@
+#!/bin/sh -
+
+awk '{
+ e=$0;
+ sub("^[^ ]* ", "", e);
+ sub(" [^ ]*$", "", e);
+ n=0+$1;
+ if (!(n in errlist))
+ errlist[n] = e;
+ if(n > maxerr) maxerr=n;
+}
+END{
+ printf ("#define NR_ERRORS\t%d\n", maxerr+1);
+ printf ("int sys_nerr = NR_ERRORS;\n");
+ printf ("char *sys_errlist[NR_ERRORS] = {\n");
+
+ for(i=0; i<=maxerr; i++) {
+ if (errlist[i] == "")
+ printf(" \"Error %d\"", i);
+ else
+ printf(" \"%s\"", errlist[i]);
+ if (i != maxerr) printf(",\n"); else printf("\n");
+ }
+ printf ("};\n");
+}' < liberror.txt > error_list.h
diff --git a/libc/error/sys_errlist.c b/libc/error/sys_errlist.c
index 48aa6a3..8dfa3ec 100644
--- a/libc/error/sys_errlist.c
+++ b/libc/error/sys_errlist.c
@@ -42,7 +42,7 @@ static void init_vars()
int i, cc, fd, err, len, bufoff=0;
char * ptr;
- fd = open("/usr/lib/liberror.txt", 0);
+ fd = open("/lib/liberror.txt", 0);
if( fd < 0 ) return;
for(i=0; i<NR_ERRORS; i++) sys_errlist[i] = "Unknown error";
diff --git a/libc/include/linux/stat.h b/libc/include/linux/stat.h
index eccf1e4..df7ba75 100644
--- a/libc/include/linux/stat.h
+++ b/libc/include/linux/stat.h
@@ -9,7 +9,6 @@
struct stat {
dev_t st_dev;
- unsigned short __pad1;
ino_t st_ino;
umode_t st_mode;
nlink_t st_nlink;
diff --git a/libc/include/linux/types.h b/libc/include/linux/types.h
index c1a6d7e..b5418db 100644
--- a/libc/include/linux/types.h
+++ b/libc/include/linux/types.h
@@ -14,7 +14,7 @@ typedef __u16 mode_t;
typedef __u32 loff_t;
typedef __u32 speed_t;
-typedef __u16 dev_t;
+typedef __u32 dev_t;
typedef __u32 ino_t;
typedef __u32 tcflag_t;
typedef __u8 cc_t;
diff --git a/libc/malloc/malloc.c b/libc/malloc/malloc.c
index 86ffd42..61ff3d4 100644
--- a/libc/malloc/malloc.c
+++ b/libc/malloc/malloc.c
@@ -78,6 +78,9 @@ mem *x;
#endif
#ifdef L_alloca
+/* This alloca is based on the same concept as the EMACS fallback alloca.
+ * It should probably be considered Copyright the FSF under the GPL.
+ */
static mem *alloca_stack = 0;
void *
diff --git a/makefile.in b/makefile.in
index c026376..7960f05 100644
--- a/makefile.in
+++ b/makefile.in
@@ -17,7 +17,7 @@ CC =%CC%
CFLAGS =%CFLAGS%
LDFLAGS =
MAKEARG =CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' \
- PREFIX=$(PREFIX) LIBPRE='$(LIBPRE)' LIBDIR='$(LIBDIR)' \
+ PREFIX=$(PREFIX) LIBDIR='$(LIBDIR)' \
BINDIR='$(BINDIR)' ANSI='$(ANSI)'
MAKEC=$(MAKE) -C
MAKEX=
@@ -75,16 +75,10 @@ BCCARCH =-Mf -O
CFLAGS += -no-cpp-precomp
#endif
-# Yet again other systems have general weirdness here.
-#ifdef __linux__
-INDAT=-o root -g root -m 644
-INEXE=-o root -g root -m 755 -s
-INSCR=-o root -g root -m 755
-#else
+# Install files with the userid of the currently running process.
INDAT=-m 644
-INEXE=-m 755
+INEXE=-m 755 -s
INSCR=-m 755
-#endif
#ifdef __CYGWIN__
EXE=.exe
@@ -95,28 +89,38 @@ EXE=
#ifdef GNUMAKE
all: check_config bcc cpp unproto copt as86 ar86 ld86 objdump86 \
library lib-bsd alt-libs elksemu
+
+install: check_config install-bcc install-man \
+ install-lib install-emu
+
+install-all: install install-other
+
#else
all: check_config bcc cpp unproto copt as86 ar86 ld86 objdump86
@echo
@echo 'NOTE: To build the libraries you need GNU-Make.'
@echo ' They are available precompiled in the Dev86clb-X.X.X.zip file.'
-#endif
-install: check_config install-bcc install-man \
- install-lib install-lib2 install-emu
+install install-all: check_config install-bcc install-man
+ @echo
+ @echo 'NOTE: To build the libraries you need GNU-Make.'
+ @echo ' They are available precompiled in the Dev86clb-X.X.X.zip file.'
-install-all: install install-other
+#endif
##############################################################################
LIBARGS= CC=ncc "CCFLAGS=-O" AR=$(AR) ARFLAGS=$(ARFLAGS)
+LIB3ARGS= CC=ncc AR=$(AR) ARFLAGS=$(ARFLAGS)
# Season in the top makefile
ELKSSRC= %ELKSSRC%
PREFIX= %PREFIX%
-LIBPRE= %LIBPRE%
BINDIR= %BINDIR%
LIBDIR= %LIBDIR%
+INCLDIR= %INCLDIR%
+ASLDDIR= %ASLDDIR%
+MANDIR= %MANDIR%
#ifdef GNUMAKE
export ELKSSRC
@@ -124,7 +128,8 @@ export ELKSSRC
DISTBIN= $(DIST)$(BINDIR)
DISTLIB= $(DIST)$(LIBDIR)
-DISTPRE= $(DIST)$(LIBPRE)
+DISTASLD=$(DIST)$(ASLDDIR)
+DISTINCL=$(DIST)$(INCLDIR)
# Others to install
OTHERS= tests dis88 doselks bootblocks
@@ -186,74 +191,52 @@ objdump86: bindir
$(MAKEC) ld $(MAKEARG) objdump86
cp -p ld/objdump86$(EXE) bin/objdump86$(EXE)
-elksemu: bindir
#ifndef __AS386_16__
#ifdef __linux_i386__
+elksemu: bindir
+ $(MAKEC) elksemu elksemu
+ cp -p elksemu/elksemu bin/elksemu
+#else
+elksemu: bindir
$(MAKEC) elksemu CC='ncc' elksemu
cp -p elksemu/elksemu bin/elksemu
#endif
#endif
-install-ln: bcc cpp unproto copt as86 ar86 ld86 elksemu
- install -d $(DISTBIN)
- ln -fs `pwd`/bin/ncc $(DISTBIN)/bcc
- ln -fs `pwd`/bin/as86_encap $(DISTBIN)/as86_encap
- ln -fs `pwd`/bin/as86 $(DISTBIN)/as86
- ln -fs `pwd`/bin/ar86 $(DISTBIN)/ar86
- ln -fs `pwd`/bin/ld86 $(DISTBIN)/ld86
-#ifndef __AS386_16__
-#ifdef __linux_i386__
- ln -fs `pwd`/bin/elksemu $(DIST)/lib/elksemu
-#endif
-#endif
- -install -d $(DIST)/usr/lib
- -install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt
-
install-bcc: bcc cpp unproto copt as86 ar86 ld86 objdump86
- install -d $(DISTBIN) $(DISTLIB) $(DISTLIB)/i86
+ install -d $(DISTBIN) $(DISTLIB)
install $(INEXE) bin/Bcc$(EXE) $(DISTBIN)/bcc$(EXE)
- install $(INSCR) bin/as86_encap $(DISTBIN)/as86_encap
- install $(INEXE) bin/as86$(EXE) $(DISTBIN)/as86$(EXE)
+ install $(INEXE) bin/as86$(EXE) $(DISTASLD)/as86$(EXE)
+ install $(INEXE) bin/ld86$(EXE) $(DISTASLD)/ld86$(EXE)
install $(INEXE) bin/ar86$(EXE) $(DISTBIN)/ar86$(EXE)
- install $(INEXE) bin/ld86$(EXE) $(DISTBIN)/ld86$(EXE)
install $(INEXE) bin/objdump86$(EXE) $(DISTBIN)/objdump86$(EXE)
install $(INEXE) bin/objdump86$(EXE) $(DISTBIN)/nm86$(EXE)
install $(INEXE) bin/objdump86$(EXE) $(DISTBIN)/size86$(EXE)
+ install $(INSCR) bin/as86_encap $(DISTLIB)/as86_encap
install $(INEXE) lib/bcc-cc1$(EXE) $(DISTLIB)/bcc-cc1$(EXE)
install $(INEXE) lib/bcc-cpp$(EXE) $(DISTLIB)/bcc-cpp$(EXE)
install $(INEXE) lib/unproto$(EXE) $(DISTLIB)/unproto$(EXE)
install $(INEXE) lib/copt$(EXE) $(DISTLIB)/copt$(EXE)
- install $(INDAT) lib/rules.* $(DISTLIB)/i86
- @test ! -f $(DISTLIB)/as86 || rm -f $(DISTLIB)/as86
- @test ! -f $(DISTLIB)/ld86 || rm -f $(DISTLIB)/ld86
+ install $(INDAT) lib/rules.* $(DISTLIB)
# NB: This doesn't install as a suid root, that's ok though.
install-emu: elksemu
-#ifndef __AS386_16__
#ifdef __linux_i386__
- install -d $(DIST)/lib
- install $(INEXE) bin/elksemu $(DIST)/lib/elksemu
-#endif
+ install -d $(DISTBIN)
+ install $(INEXE) bin/elksemu $(DISTBIN)/elksemu
#endif
install-man:
- -$(MAKEC) man MANDIR=$(DIST)$(PREFIX)/man install
-
-install-lib: lib/lib0-done lib/lib2-done
- install -d $(DISTLIB)/i86
- $(MAKEC) libc $(LIBARGS) BCCHOME=$(DISTPRE) install_incl
- install $(INDAT) lib/crt0.o $(DISTLIB)/i86/crt0.o
- install $(INDAT) lib/libc.a $(DISTLIB)/i86/libc.a
- install $(INDAT) lib/libbsd.a $(DISTLIB)/i86/libbsd.a
- -install -d $(DIST)/usr/lib
- -install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt
-
-install-lib2: lib/lib1-done
- install -d $(DISTLIB)/i86
- install $(INDAT) lib/libc_f.a $(DISTLIB)/i86/libc_f.a
- install $(INDAT) lib/libc_s.a $(DISTLIB)/i86/libc_s.a
- install $(INDAT) lib/libdos.a $(DISTLIB)/i86/libdos.a
-
+ -$(MAKEC) man MANDIR=$(DIST)$(MANDIR) install
+
+install-lib: lib/lib0-done lib/lib2-done lib/lib1-done
+ $(MAKEC) libc $(LIBARGS) DISTINCL=$(DISTINCL) install_incl
+ install $(INDAT) lib/crt0.o $(DISTLIB)/crt0.o
+ install $(INDAT) lib/libc.a $(DISTLIB)/libc.a
+ install $(INDAT) lib/libc_f.a $(DISTLIB)/libc_f.a
+ install $(INDAT) lib/libc_s.a $(DISTLIB)/libc_s.a
+ install $(INDAT) lib/libbsd.a $(DISTLIB)/libbsd.a
+ install $(INDAT) lib/libdos.a $(DISTLIB)/libdos.a
#ifndef __AS386_16__
install -d $(DISTLIB)/i386
install $(INDAT) lib/i386/crt0.o $(DISTLIB)/i386/crt0.o
@@ -312,14 +295,12 @@ lib-dos: bindir
cp -p libc/libdos.a lib/libdos.a
sh libcompat lib/libdos.a
-#ifndef __AS386_16__
lib-386: bindir
test -f bin/ncc
- $(MAKEC) libc $(LIBARGS) PLATFORM=i386-BCC
+ $(MAKEC) libc $(LIB3ARGS) PLATFORM=i386-BCC
cp -p libc/crt3.o lib/i386/crt0.o
cp -p libc/libc3.a lib/i386/libc.a
sh libcompat lib/i386/libc.a
-#endif
##############################################################################
@@ -354,6 +335,8 @@ other:
$(MAKEC) $$i BCC=ncc DIST=$(DIST) PREFIX=$(PREFIX) || exit 1; \
done
+##############################################################################
+
clean:
-@for i in $(CLEANLIST) ; do $(MAKEC) $$i $@ ; true ; done
diff --git a/man/as86.1 b/man/as86.1
index 619d604..060984d 100644
--- a/man/as86.1
+++ b/man/as86.1
@@ -16,7 +16,7 @@ as86 \- Assembler for 8086..80386 processors
.B as86_encap\ prog.s\ prog.v
.RB [ prefix_ ]
-.RB [ as86\ options ]
+.RB [ as86_options ]
.SH DESCRIPTION
.B as86
diff --git a/man/elksemu.1 b/man/elksemu.1
index 6686040..5df195f 100644
--- a/man/elksemu.1
+++ b/man/elksemu.1
@@ -16,11 +16,11 @@ the
.B bcc(1)
C compiler.
-It is not usual to invoke
-.I /lib/elksemu
-directly, either the simple patch or kernel module distributed with it
-will cause the kernel to run
-.I /lib/elksemu
+Yom may use the
+.I binfmt-misc
+module under Linux 2.1.43 or greater as described in the elksemu README
+which will cause the kernel to run
+.I elksemu
with the correct arguments whenever the user tries to execute an ELKS
executable directly.
@@ -28,14 +28,17 @@ executable directly.
There are no flag options to elksemu, the first argument is the name of the
program to run the rest are arguments that are passed to the Elks program.
+.SH SECURITY
The
.B elksemu
-program is normally installed suid-root and in this event it is able to
+program may be installed suid-root and in this event it is able to
run execute only (chmod 111) elks executables and act correctly on the
-suid permission bits on those executable. This may be considered a
-security hazard so elksemu does
+suid permission bits on any executable.
+This should be considered a security hazard so elksemu does
.I not
-have to be installed suid-root.
+have to be installed suid-root.
+If you consider using this facility you should also be aware that it will
+override the 'nosuid' mount(8) option.
.SH SEE ALSO
bcc(1), as86(1), ld86(1)
diff --git a/tests/Makefile b/tests/Makefile
index 015f65e..fb77f34 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -15,7 +15,14 @@ LINK_FILES=cat chgrp chmod chown cp install ln mkdir mkfifo mknod mv rm
all: $(EXE)
-install links:
+install:
+ echo Use real-install if you actually want to install these
+
+real-install:
+ install wc hd env ft $(DIST)$(PREFIX)/bin
+ for i in $(LINK_FILES) ; do ln -s ft $(DIST)$(PREFIX)/bin/$$i ; done
+
+install_links:
for i in $(LINK_FILES) ; do ln -s ft $$i ; done
no_links:
diff --git a/tests/ft.c b/tests/ft.c
index c27c5dd..bce51c5 100644
--- a/tests/ft.c
+++ b/tests/ft.c
@@ -588,7 +588,7 @@ char * prefix; char * ustring;
}
}
- if( set_user < 0 && set_group < 0 && set_mode < 0 && *mode_str == 0)
+ if( set_user == -1 && set_group == -1 && set_mode < 0 && *mode_str == 0)
{
error(EINVAL, "", "Permission string has no changes");
exit(1);
@@ -664,6 +664,7 @@ static char oldpath[2048] = "~";
static int last_uid=-1, last_gid=-1, last_mode=-1;
struct passwd * pptr;
struct group * gptr;
+ int major, minor;
if( flg_verbose>1 )
{
@@ -721,6 +722,14 @@ static int last_uid=-1, last_gid=-1, last_mode=-1;
if( (cur_file_stat.st_mode&07777) != (last_mode&07777) )
printf(":%03o", cur_file_stat.st_mode & 07777);
+ major = (cur_file_stat.st_rdev >> 8);
+ minor = (cur_file_stat.st_rdev&0xFF);
+#ifdef __linux__
+ major &= 0xFFF;
+ minor |= ((cur_file_stat.st_rdev&0xFF000000)>>12);
+#else
+ major &= 0xFF;
+#endif
switch(cur_file_stat.st_mode & S_IFMT)
{
case S_IFDIR: printf("\td"); break;
@@ -728,11 +737,9 @@ static int last_uid=-1, last_gid=-1, last_mode=-1;
#ifdef __HAS_SOCKETS
case S_IFSOCK: printf("\ts"); break;
#endif
- case S_IFBLK: printf("\tb,%d,%d", cur_file_stat.st_rdev>>8,
- cur_file_stat.st_rdev&0xFF);
+ case S_IFBLK: printf("\tb,%d,%d", major, minor);
break;
- case S_IFCHR: printf("\tc,%d,%d", cur_file_stat.st_rdev>>8,
- cur_file_stat.st_rdev&0xFF);
+ case S_IFCHR: printf("\tc,%d,%d", major, minor);
break;
}
last_mode = ((cur_file_stat.st_mode&07777)|S_IFREG);
@@ -987,8 +994,8 @@ char * file;
/* Try to preserve ownership. For non-root it might fail, but that's ok.
But root probably wants to know, e.g. if NFS disallows it. */
- user = cur_file_stat.st_uid; if(set_user>=0) user = set_user;
- group = cur_file_stat.st_gid; if(set_group>=0) group = set_group;
+ user = cur_file_stat.st_uid; if(set_user != -1) user = set_user;
+ group = cur_file_stat.st_gid; if(set_group != -1) group = set_group;
if (chown (file, user, group)
&& (errno != EPERM || geteuid() == 0 || (flg_preserve==0 && flg_force==0)))
@@ -1157,7 +1164,7 @@ char * dirname;
}
if( retv>=0 && cmd_tok == CMD_MKDIR )
{
- if( set_user > 0 || set_group > 0 )
+ if( set_user != -1 || set_group != -1 )
{
if( chown(dirname, set_user, set_group) < 0)
warning(errno, "Cannot change directory owner ", dirname);
@@ -1173,12 +1180,19 @@ char * dirname;
int
cmd_mknod()
{
- int device;
+ int device, major, minor;
int rv = -1;
int mode=0666;
if( set_mode >= 0 ) mode=set_mode;
- device = (atoi(flist[2])<<8) + atoi(flist[3]);
+ major = atoi(flist[2]);
+ minor = atoi(flist[3]);
+#ifdef __linux__
+ /* Linux 2.6+ uses an odd arrangment. */
+ device = (major<<8) + (minor & 0xFF) + ((minor & 0xFFF00) << 12);
+#else
+ device = (major<<8) + (minor & 0xFF);
+#endif
if(flist[1][0] == 'b')
rv = mknod(flist[0], S_IFBLK|mode, device);