Skip to content

Commit

Permalink
Merge pull request #26 from stronnag/user_instal_msys_fixes
Browse files Browse the repository at this point in the history
User install, msys fixes for 64bit
  • Loading branch information
stronnag authored Aug 29, 2022
2 parents 8946d30 + dcf0a4c commit 6475d7e
Show file tree
Hide file tree
Showing 31 changed files with 540 additions and 1,206 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# Note you can build 32bit binaries on x86-64 by
# CFLAGS=-m32 make

DIRS = as68 c68 cc cpp ld slb
DIRS = as68 c68 cc cpp ld slb tools
CLEANDIRS = $(DIRS:%=clean-%)
INSTALLDIRS = $(DIRS:%=install-%)

prefix ?= /usr/local/bin
export prefix

prefix ?= /usr/local
CFLAGS += -Wall -Wextra -pedantic

export CFLAGS
export prefix

all: $(DIRS)
$(DIRS):
$(MAKE) -C $@
$(MAKE) -C $@

clean: $(CLEANDIRS)

Expand Down
99 changes: 84 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,116 @@
xtc68
=====

Cross compiler for QDOS c68 on POSIX platforms
Cross compiler for QDOS C68 on POSIX platforms (and Windows).

This is a resurrection of the 1999-ish code base to compile on modern POSIX systems (well Linux at least). No effort has gone into updating the obsolete DOS and NT variants.
This is a resurrection of the 1999-ish code base to compile on modern POSIX-like systems.

As of 2021-08-24, the codebase is 64bit clean. There is no longer any requirement to build 32bit executables.
As of 2021-08-24, the codebase is 64bit clean. There is no longer any requirement to build 32bit executables, even on Windows.

## Installation

You can either install a [binary distribution](https://github.com/stronnag/xtc68/releases) for Linux, MacOS, Windows or [build from source](#building). For platforms where there is no binary distribution, [build from source](#building) in required. Such platforms are:

* Anything other than x86_64 (amd64) with Linux, MacOS and Windows.

The binary installations are tar or Zip files, with the following structure:

```
xtc68/bin
xtc68/share/qdos
xtc68/share/qdos/etc
xtc68/share/qdos/include
xtc68/share/qdos/lib
```

You should then install a [c68 runtime](#runtime) into the `xtc68/share/qdos/include` (header files) and `xtc68/share/qdos/lib` (libraries and startup files).

## Runtime

You need the C68 runtime binary distribution. A good place to start looking is http://www.dilwyn.me.uk/c/index.html. If runtime disk1 is installed under `support`, the `install.sh` script will install a usable environment, such that:
You need the C68 runtime binary distribution. A good place to start looking is http://www.dilwyn.me.uk/c/index.html. If runtime disk1 is installed under `support`, the `sdk-install.sh` script will install a usable environment, such that:

```
qcc -o hw hw.c
```
will generate a QDOS executable, where `hw.c` is a trivial, standard "Hello World" application, assuming `/usr/local/bin` is on `$PATH`.
will generate a QDOS executable, where `hw.c` is a trivial, standard "Hello World" application, assuming the installation directory `$(prefix)/bin` is on `$PATH`.

It is not purpose of this repo to provide a QDOS c68 environemnt, nor does it offer any help for QDOS development; it mere maintains a cross compiler.
Note that it is not purpose of this repository to provide a QDOS C68 development environment, nor does it offer any help for QDOS development; it mere maintains a cross compiler.

## Installation
### Runtime path resolution

On most POSIX (like) systems (Linux, *BSD, MacOS, Msys, Cygwin) to build and install the excutables:
The search path for QDOS header files and libraries is:

* Under the `share/qdos` directory where `share` is at the same level as the binary `bin` directory (i.e. as distributed binaries)
* Under the directory defined at build time `$prefix/share/qdos`; `prefix` defaults to `/usr/local` for the binary distributions.
* In directories defined by the environment variables `QLINC` (header files) and `QLLIB` (libraries).
* In the fallback directories under `/usr/local/share/qdos`

So, if you unzip the supplied Windows Zip file to `C:\` (you now have `C:\xtc68` and sub-directories) and then added the C68 header files to `C:\xtc68\share\qdos\include` and the C68 libraries to `C:\xtc68\share\qdos\lib` (i.e. into the default directories the Zip file has conveniently provided), finally add `C:\xtc68\bin` to the `PATH` environment variable; it all should "just work".

```
# build and install the executables
make && sudo make install
# on *BSD, you need GNU Make
gmake && sudo gmake install
> # Powershell
> # Assume we have a trival "hello world" hw.c
> $env:PATH += "C:\xtc68\bin;"
> qcc -O -o helloworld hw.c
helloworld: dataspace 904 (388)
>
```

## Building

On most POSIX (like) systems (Linux, *BSD, MacOS, Msys) to build and install the executables.

Modern practice on essentially "sole user" systems is to install under `~/.local`, with `~/.local/bin` appended to the `PATH`, so:

```
make install prefix=~/.local
# gmake install prefix=~/.local ## FreeBSD et al
```

To install the QDOS includes and libraries

```
./install.sh -s
./sdk-install.sh [~/.local]
```

If the optional directory is omitted, `/usr/local` is assumed. You can also use the environment variable `PREFIX` (or `prefix`) instead.

If you really want to install in `/usr/local`:

```
# build and install the executables in /usr/local (default)
make && sudo make install
# on *BSD, you need GNU Make
gmake && sudo gmake install
sudo ./sdk-install.sh
```

Note `sudo` is required for a non-root user to install to `/usr/local`.

## Integration with native make (i.e. GNU Make)

* The `install.sh` script provides `ql.mak`, which it will copy to `/usr/local/qdos/etc/ql.mak`
* In your QDOS project `Makefile`, as the first line:
* The `sdk-install.sh` script provides `ql.mak`, which it will copy to `$PREFIX/share/qdos/etc/ql.mak`
* In your QDOS project `Makefile`, as the first line (`.local` prefix install)

```
# local install, alas $$HOME is not expanded here ..
include /home/USERNAME/.local/share/qdos/etc/ql.mak
```

* or

```
# System install
include /usr/local/qdos/etc/ql.mak
```

* or

```
mkdir ~/.config/xtc68
cp $PREFIX/share/qdos/etc/ql.mak ~/.config/xtc68/
# then in a Makefile
include /home/USERNAME/.config/xtc68/ql.mak
```

Now you can easily use GNU Make to build your QDOS project.
6 changes: 3 additions & 3 deletions as68/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VPATH = ../

GCFLAGS = -O2
CFLAGS += $(GCFLAGS) -DXTC68 -DLABELDIFF -DUSELINE -DMINIX -DHOST_LITTLE_ENDIAN
CFLAGS += $(GCFLAGS) -DXTC68 -DLABELDIFF -DUSELINE -DMINIX -DHOST_LITTLE_ENDIAN
LDFLAGS =

OBJS = cbuf.o cpy.o gen.o hdr.o lex.o main.o ops.o \
Expand Down Expand Up @@ -29,5 +29,5 @@ clean:
rm -f *.o as68

install: as68
install -d $(prefix)
install as68 $(prefix)
install -d $(prefix)/bin
install as68 $(prefix)/bin
52 changes: 0 additions & 52 deletions as68/Makefile.NT

This file was deleted.

52 changes: 0 additions & 52 deletions as68/Makefile.qdos

This file was deleted.

9 changes: 4 additions & 5 deletions as68/jas.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>

#include <stdint.h>
#include <inttypes.h>

typedef struct _sym {
struct _sym *next;
union {
char here[8];
long stix[2];
} name;
long value;
intptr_t value;
unsigned short index;
unsigned short flags;
unsigned short access;
} SYM;

typedef struct {
struct _sym *psym;
long value;
intptr_t value;
} EXPR;

/*
Expand Down Expand Up @@ -194,5 +195,3 @@ struct _branch {
#ifndef GENERIC
extern long dottxt;
#endif /* GENERIC */


2 changes: 1 addition & 1 deletion as68/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ VOID Yinstruction(void)
ldp->minus = lp->sym2;
ldp->constant = lp->u.val.value;

generate(size, GENLDIFF, (long) ldp, NULL);
generate(size, GENLDIFF, (intptr_t) ldp, NULL);
}
#endif /* LABELDIFF */
free( (char *) lp );
Expand Down
4 changes: 2 additions & 2 deletions c68/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,5 @@ pkzip:
pkzip $(PROG)src$(S)zip $(HDR68K) $(HDRX86) $(HDR386) $(HDR86) $(HDRARM) $(HDRC30) $(HDRPPC)

install: $(PROG)
install -d $(prefix)
install $(PROG) $(prefix)
install -d $(prefix)/bin
install $(PROG) $(prefix)/bin
Loading

0 comments on commit 6475d7e

Please sign in to comment.