Skip to content

Replace the build system to use ab. #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 79 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
25cd8e8
Rename the cemcom.ansi directory to not have a dot in the name.
davidgiven Mar 27, 2025
cf1f432
First swatch of ab buildfiles. cemcom.ansi builds.
davidgiven Mar 28, 2025
0bbc304
Enough works to build a simple boot.s.
davidgiven Mar 29, 2025
d86dbad
Put the compiler name back to cemcom.ansi now that ab support for dotted
davidgiven Mar 29, 2025
7c541c2
Fix broken move.
davidgiven Mar 29, 2025
964f9cc
The pc86 libc builds (although I'm not sure how. There is no
davidgiven Mar 29, 2025
ed667ef
Realise that I was actually compiling with the system ack and not the
davidgiven Mar 29, 2025
08cd986
The Basic compiler and library builds.
davidgiven Mar 29, 2025
d04fd11
Make the M2 compiler build.
davidgiven Mar 29, 2025
eb6025e
The Pascal compiler builds.
davidgiven Mar 29, 2025
9bb8ae2
The Modula-2 standard library builds.
davidgiven Mar 29, 2025
fec5cb5
The Pascal standard library builds.
davidgiven Mar 29, 2025
495a7f5
The pc86 libsys builds.
davidgiven Mar 29, 2025
8e3fe47
Make the cpm plat and the i80 mach build.
davidgiven Mar 29, 2025
0f335aa
Typo fix.
davidgiven Mar 29, 2025
7a115d8
M2 and C now export their headers.
davidgiven Mar 29, 2025
e2a5a9c
Almost have an example building.
davidgiven Mar 29, 2025
841a63d
The C examples build.
davidgiven Mar 29, 2025
524c6ce
The examples build with optimisation.
davidgiven Mar 29, 2025
c50db71
Update build scripts.
davidgiven Mar 29, 2025
c15abbf
Ubuntu 20 is way too old.
davidgiven Mar 29, 2025
816372b
ego and -O2 works.
davidgiven Mar 30, 2025
e5a0f9c
The linux386 plat builds.
davidgiven Mar 30, 2025
c43ccd1
The linux68k plat builds.
davidgiven Mar 30, 2025
ebf2499
The Windows build needs pkg-config now.
davidgiven Mar 30, 2025
babcc1d
Fix some more dependencies.
davidgiven Mar 30, 2025
eba43f7
Even more dependency fixes.
davidgiven Mar 30, 2025
eca5fd7
Add debugging to Windows build.
davidgiven Mar 30, 2025
f5dab4c
linuxppc now builds.
davidgiven Mar 30, 2025
d3a3d17
linuxmips (and mcg) build.
davidgiven Mar 30, 2025
ff99991
minix68k builds.
davidgiven Mar 30, 2025
7e20350
msdos86 builds.
davidgiven Mar 30, 2025
c5be288
msdos386 builds.
davidgiven Mar 30, 2025
5638bd1
osx386 builds.
davidgiven Mar 30, 2025
22c4c1d
osxppc builds.
davidgiven Mar 30, 2025
2929e21
The rpi plat now builds.
davidgiven Mar 30, 2025
d23069a
The pdpv7 plat builds (and cg).
davidgiven Mar 30, 2025
01eb2e7
The em22 plat builds (and ass).
davidgiven Mar 30, 2025
7f20817
Make the non-C examples build.
davidgiven Mar 31, 2025
a6593af
Remember to turn all the plats on!
davidgiven Mar 31, 2025
40ba6a0
Update ab.
davidgiven Apr 1, 2025
6040ba7
The M2 build uses a build script which doesn't work properly and isn't
davidgiven Apr 1, 2025
302f546
Try using gmake on OSX.
davidgiven Apr 1, 2025
1d29f47
Remember to install gmake.
davidgiven Apr 1, 2025
2784860
Update ab.
davidgiven Apr 2, 2025
74079e8
Remove Windows verbose logging.
davidgiven Apr 2, 2025
c2c5565
Got the first tests building (but not running yet).
davidgiven Apr 2, 2025
bc752c7
Tests now run --- but Pascal is broken, somehow.
davidgiven Apr 3, 2025
3760440
Fix a nasty bug in exportheaders where it just didn't work.
davidgiven Apr 4, 2025
b6456f7
Update ab.
davidgiven Apr 4, 2025
9ecb2d6
Pascal builds again.
davidgiven Apr 4, 2025
14e2ac1
Enable the core tests.
davidgiven Apr 4, 2025
a6abc32
Convert the float tests.
davidgiven Apr 4, 2025
258b4be
Convert the long-long tests.
davidgiven Apr 4, 2025
678eac0
Convert the M2 tests.
davidgiven Apr 4, 2025
1219d8d
The linux68k tests run.
davidgiven Apr 4, 2025
150864a
The linuxppc tests run.
davidgiven Apr 4, 2025
010047c
The pc86 tests run.
davidgiven Apr 4, 2025
414bbe1
Finally delete ackbuilder!
davidgiven Apr 4, 2025
1f012be
Only run the tests if we're not on Windows (because Windows doesn't have
davidgiven Apr 9, 2025
59be147
Import a Dhrystone benchmark.
davidgiven Apr 10, 2025
a95682b
Use the mingw python instead of the msys python.
davidgiven Apr 10, 2025
50fef3a
Eliminate ansi.h and all the _PROTOTYPE nonsense.
davidgiven Apr 10, 2025
7ddbb78
Enable copious build tracing.
davidgiven Apr 11, 2025
4305197
Try and build Windows stuff with the WIN32 flag set.
davidgiven Apr 14, 2025
01a5524
i80 doesn't build on Windows due to there being too many files on a c…
davidgiven Apr 16, 2025
dacf4f8
Try and get things building on Windows.
davidgiven Apr 17, 2025
026c3aa
Format.
davidgiven Apr 17, 2025
10bfea9
Remember to put the extension on the pdpv7 ext.
davidgiven Apr 17, 2025
13bb022
Eliminate most 'compression' as it just slows stuff down.
davidgiven Apr 17, 2025
6fe04bf
Fix some bad extern declarations causing crashes on OSX.
davidgiven Apr 17, 2025
95c83e2
Fix typo preventing the OSX bad make check from working.
davidgiven Apr 17, 2025
aa9f81f
Remember to build the Windows installer.
davidgiven Apr 17, 2025
fdadbf2
Remember that 'all' must come first...
davidgiven Apr 17, 2025
59e7d86
Point the windows installer at a more correct location...
davidgiven Apr 17, 2025
36ee2e3
makensis only understands backslash paths.
davidgiven Apr 17, 2025
c9e05bc
Building all plats takes a while, so make the user select which plats…
davidgiven Apr 17, 2025
9a9f8ee
No, variables set on the command line don't trigger a build.mk regene…
davidgiven Apr 17, 2025
a3589cf
Update README.
davidgiven Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 7 additions & 6 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on: [push, pull_request]

jobs:
build-linux:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: apt
run: sudo apt update && sudo apt install bison flex ninja-build lua5.3
run: sudo apt update && sudo apt install bison flex lua5.3
- name: make
run: make

Expand All @@ -21,10 +21,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: brew
run: brew install ninja lua@5.4
run: brew install python lua@5.4 coreutils make
- name: make
run: |
make
gmake
build-windows:
runs-on: windows-latest
Expand All @@ -41,15 +41,16 @@ jobs:
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-lua
mingw-w64-ucrt-x86_64-nsis
ninja
mingw-w64-ucrt-x86_64-pkg-config
mingw-w64-ucrt-x86_64-python
bison
flex
zip
git
- uses: actions/checkout@v3
- name: build
run: |
make LDFLAGS="-s -static" CFLAGS="-g -Os"
make LDFLAGS="-s -static"
- name: package
run: |
make ack-setup.exe
Expand Down
136 changes: 24 additions & 112 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

DEFAULT_PLATFORM ?= pc86

# Which architectures should get built?

$(if $(PLATS), $(error Don't set PLATS on the command line, because reasons. Edit the Makefile instead.))
PLATS = all
# PLATS = linux386 linuxppc linuxmips

# Where should the ACK put its temporary files?

ifeq ($(TMPDIR),)
Expand All @@ -15,142 +21,48 @@ else
ACK_TEMP_DIR ?= $(TMPDIR)
endif

INSDIR = $(OBJ)/staging

# Where is the ACK going to be installed, eventually? If you don't want to
# install it and just want to run the ACK from the build directory
# ($(TMPDIR)/ack-build/staging, by default), leave this as $(INSDIR).

ifeq ($(OS),Windows_NT)
PREFIX ?= c:/ack
else
PREFIX ?= /usr/local
PREFIX ?= /opt/pkg/ack
#PREFIX = $(INSDIR)
endif

# Where do you want to put the object files used when building?

BUILDDIR ?= $(ACK_TEMP_DIR)/ack-build

# What build flags do you want to use for native code?

CFLAGS ?= -g \
CFLAGS ?= -g -Os \
-Werror=return-type \
-Werror=implicit-function-declaration \
-Werror=strict-prototypes
-Werror=strict-prototypes \
-DUNREACHABLE_CODE='__builtin_unreachable()' \
-DNORETURN=_Noreturn

HOSTCFLAGS = $(CFLAGS)
ACKCFLAGS = -O

LDFLAGS ?= -g

# Various commands.

AR ?= ar
CC ?= gcc
LUA ?= lua

# Which build system to use; use 'ninja' or 'make' (in lower case). Leave
# blank to autodetect.

BUILDSYSTEM ?=
.PHONY: all
all: +all

# Build flags for ninja.
# Custom rule to build the installer.

NINJAFLAGS ?=

# Build flags for make.

MAKEFLAGS ?=

# ======================================================================= #
# END OF CONFIGURATION #
# ======================================================================= #

# You shouldn't need to change anything below this point unless you are
# actually developing ACK.

OBJDIR = $(abspath $(BUILDDIR)/obj)
BINDIR = $(abspath $(BUILDDIR)/bin)
LIBDIR = $(abspath $(BUILDDIR)/lib)
INCDIR = $(abspath $(BUILDDIR)/include)
INSDIR = $(abspath $(BUILDDIR)/staging)
ack-setup.exe: etc/windows-installer.nsi all
makensis -dBUILDDIR="$$(realpath $(INSDIR))" -dOUTFILE="$$(realpath $@)" $<

PLATIND = $(INSDIR)/share/ack
PLATDEP = $(INSDIR)/lib/ack
export PLATS

MANDATORYCFLAGS = \
-DUNREACHABLE_CODE='__builtin_unreachable()' \
-DNORETURN=_Noreturn

MANDATORYLDFLAGS =

.NOTPARALLEL:

ifeq ($(BUILDSYSTEM),)
ifneq ($(shell which ninja),)
BUILDSYSTEM = ninja
else
BUILDSYSTEM = make
endif
endif

build-file = $(BUILDDIR)/build.$(BUILDSYSTEM)
lua-files = $(shell find . -name 'build*.lua')
our-lua = $(BUILDDIR)/lua

# GNU make sets MAKECMDGOALS to the list of targets from the command
# line. We look for targets with '+' and forward them to BUILDSYSTEM.
# This handles commands like
# $ make util/opt+pkg util/ego+pkg

all-goals = +ack +tests
plus-goals := $(patsubst all,$(all-goals),$(or $(MAKECMDGOALS),all))
plus-goals := $(foreach g,$(plus-goals),$(if $(findstring +,$(g)),$(g),))

# @true silences extra message, "make: Nothing to be done..."

all: build-plus-goals
@true

ifneq ($(plus-goals),)
$(plus-goals): build-plus-goals
@true
endif

build-plus-goals: $(build-file)
ifeq ($(BUILDSYSTEM),ninja)
@ninja $(NINJAFLAGS) -f $(build-file) $(plus-goals)
else ifeq ($(BUILDSYSTEM),make)
# GNU make passes MAKEFLAGS in environment.
@$(MAKE) -f $(build-file) $(plus-goals)
else
$(error unknown BUILDSYSTEM = $(BUILDSYSTEM))
endif

$(build-file): first/ackbuilder.lua Makefile $(lua-files)
@mkdir -p $(BUILDDIR)
@$(LUA) first/ackbuilder.lua \
first/build.lua build.lua \
--$(BUILDSYSTEM) \
LUA=$(LUA) \
DEFAULT_PLATFORM=$(DEFAULT_PLATFORM) \
OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \
LIBDIR=$(LIBDIR) \
INCDIR=$(INCDIR) \
INSDIR=$(INSDIR) \
PLATIND=$(PLATIND) \
PLATDEP=$(PLATDEP) \
PREFIX="$(PREFIX)" \
AR=$(AR) \
CC=$(CC) \
CFLAGS="$(MANDATORYCFLAGS) $(CFLAGS)" \
LDFLAGS="$(MANDATORYLDFLAGS) $(LDFLAGS)" \
> $(build-file)

ack-setup.exe: etc/windows-installer.nsi
makensis -dBUILDDIR=$(BUILDDIR)/staging -dOUTFILE="$$(realpath $@)" $<

install:
mkdir -p $(PREFIX)
tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)

clean:
rm -rf $(BUILDDIR)

AB_ENABLE_PROGRESS_INFO = false
include build/ab.mk
55 changes: 23 additions & 32 deletions README
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
THE AMSTERDAM COMPILER KIT V6.1pre1
===================================
THE AMSTERDAM COMPILER KIT V6.2+
================================

© 1987-2005 Vrije Universiteit, Amsterdam
2022-08-19
2025-04-17


INTRODUCTION
Expand All @@ -13,42 +13,40 @@ front end compilers for a number of different languages, code generators,
support libraries, and all the tools necessary to go from source code to
executable on any of the platforms it supports.

This is an early prerelease of the apocryphal version 6.1 release. Not a
lot is supported, the build mechanism needs work, and a lot of things are
probably broken. However, what's there should be sufficient to get things
done and to evaluate how the full 6.1 release should work.



SUPPORT
=======

Languages:

ANSI C, B, Pascal, Modula 2, Basic. K&R is supported via the ANSI C compiler.
ANSI C, Pascal, Modula 2, Basic. K&R is supported via the ANSI C compiler.

Platforms:

pc86 produces bootable floppy disk images for 8086 PCs
cpm produces i80 CP/M .COM files
em22 produces EM22 bytecode files
linux386 produces ELF executables for PC Linux systems
linux68k produces ELF executables for m68020 Linux systems
linuxppc produces ELF executables for PowerPC Linux systems
linuxmips produces ELF executables for little-endian MIPS32r2 Linux systems
linuxppc produces ELF executables for PowerPC Linux systems
minix68k produces Minix executables for m68000 Minix systems
cpm produces i80 CP/M .COM files
rpi produces Raspberry Pi GPU binaries
pdpv7 produces PDP/11 V7 Unix binaries
msdos86 produces i86 MS-DOS .COM files
msdos386 produces i386 MS-DOS 32-bit DPMI .EXE files
msdos86 produces i86 MS-DOS .COM files
osx386 produces i386 OSX MachO executables
osxppc produces PowerPC OSX MachO executables
pc86 produces bootable floppy disk images for 8086 PCs
pdpv7 produces PDP/11 V7 Unix binaries
rpi produces Raspberry Pi GPU binaries



INSTALLATION
============

The version 5.0 build mechanism has been completely rewritten. Installation
ought to be fairly straightforward. It will build on Unixishes including Linux,
OSX, and Windows using MSYS2 and mingw32.
The version 5.0 build mechanism has been completely rewritten (twice).
Installation ought to be fairly straightforward. It will build on Unixishes
including Linux, OSX, and Windows using MSYS2 and mingw32.

Requirements:

Expand All @@ -61,32 +59,25 @@ Requirements:

- Lua (any version) with the lua-posix library installed.

- (optionally) ninja; if you've got this, this will be autodetected and give
you faster builds.

- about 115MB free in /tmp (or some other temporary directory).
- Python 3.4 or above.

- about 15MB in the target directory.
- about 1GB in the target directory.

Instructions:

- edit the Makefile. There's a small section at the top where you can change
the configuration. Probably the only one you may want to edit is PREFIX,
which changes where the ACK installs to.
which changes where the ACK installs to, and PLATS, which changes which
architectures are built. Look in `plat/*` to see what plats there are.

- Run:

make

...from the command line. This will do the build.

The make system is fully parallelisable. If you have a multicore system,
install ninja and it'll use all your cores. If you don't have ninja, you
can still use make for parallel builds with:

make -r -j8 # or however many cores you have

...but frankly, I recommend ninja.
The make system is fully parallelisable by default, but does take a while
to start up.

- Run:

Expand Down Expand Up @@ -192,4 +183,4 @@ Please enjoy.

David Given (davidgiven on Github)
dg@cowlark.com
2018-09-18
2025-04-17
Loading
Loading