Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffe13a4583 | ||
|
|
c602379db9 | ||
|
|
9da790283e | ||
|
|
0ba3023570 | ||
|
|
06665f4624 | ||
|
|
0f10f91839 | ||
|
|
c59e2f03ab | ||
|
|
5f00cd2e53 | ||
|
|
e92393d6f3 | ||
|
|
b21aede758 | ||
|
|
3f6a9560c5 | ||
|
|
93f542eb7a | ||
|
|
2071a7dbb0 | ||
|
|
4cb35a7d72 | ||
|
|
d853b7f2fb | ||
|
|
ca57bb617b | ||
|
|
ee6e8bdfc3 | ||
|
|
595e5258aa | ||
|
|
d627b11b98 | ||
|
|
da1cb44497 | ||
|
|
a39e88ecca | ||
|
|
b31c94cf32 | ||
|
|
5c73826e4c | ||
|
|
46f101f4dd | ||
|
|
2830ec90b1 | ||
|
|
60b5f91561 | ||
|
|
b2d6e23b5f | ||
|
|
6e6d9c26b5 | ||
|
|
1c4e04de3a | ||
|
|
a05a174f40 | ||
|
|
1b34c8cc9f | ||
|
|
25c717d9b3 | ||
|
|
1ed1edf94d | ||
|
|
08d1784f95 | ||
|
|
e3b4856beb | ||
|
|
0f7eaacc5f | ||
|
|
97bb7d9316 | ||
|
|
20d58dea19 | ||
|
|
2bbd5a38de | ||
|
|
a8d9183e25 | ||
|
|
a262a916dc | ||
|
|
74fb1cff61 | ||
|
|
c0cd8650a6 | ||
|
|
369ec26b03 | ||
|
|
2a5ab5b856 | ||
|
|
350e569c2c | ||
|
|
d87b482eac | ||
|
|
b31ac47714 | ||
|
|
03763cbbf0 | ||
|
|
452127650a | ||
|
|
bd3e7b87e6 | ||
|
|
6093a51511 | ||
|
|
41f96d5169 | ||
|
|
c5bfc89269 | ||
|
|
22c8f3ac10 | ||
|
|
674eb61908 | ||
|
|
653bd13b40 | ||
|
|
7b8e3edd43 | ||
|
|
5362498c1c | ||
|
|
f6d58a0d04 | ||
|
|
36a59de862 | ||
|
|
0946773758 | ||
|
|
3d1d1277b7 | ||
|
|
60330b05cd | ||
|
|
e54911f642 | ||
|
|
71df09d022 | ||
|
|
498d867bc3 | ||
|
|
f1cd17c51e | ||
|
|
d28368333a | ||
|
|
9f7ae734db | ||
|
|
7eff32c40d | ||
|
|
d3715f3ca4 | ||
|
|
659f26136a | ||
|
|
33af50ea26 | ||
|
|
cb89c679ec | ||
|
|
d78a72a6e2 | ||
|
|
a551523b22 | ||
|
|
b907b15d4f | ||
|
|
45e01dcd3e | ||
|
|
cc534493fd |
@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
BasedOnStyle: WebKit
|
|
||||||
AllowShortLoopsOnASingleLine: 'false'
|
|
||||||
AlwaysBreakAfterDefinitionReturnType: false
|
|
||||||
BreakBeforeBraces: Allman
|
|
||||||
IndentCaseLabels: 'true'
|
|
||||||
PointerAlignment: Left
|
|
||||||
TabWidth: '4'
|
|
||||||
UseTab: ForIndentation
|
|
||||||
|
|
||||||
...
|
|
||||||
17
.distr
17
.distr
@ -1,7 +1,9 @@
|
|||||||
README
|
README
|
||||||
CHANGES
|
CHANGES
|
||||||
Copyright
|
Copyright
|
||||||
Makefile
|
pm
|
||||||
|
pmfile
|
||||||
|
config.pm
|
||||||
|
|
||||||
h
|
h
|
||||||
modules/h
|
modules/h
|
||||||
@ -11,7 +13,7 @@ util/data
|
|||||||
util/LLgen
|
util/LLgen
|
||||||
|
|
||||||
modules/src/alloc
|
modules/src/alloc
|
||||||
#modules/src/assert
|
modules/src/assert
|
||||||
modules/src/system
|
modules/src/system
|
||||||
modules/src/string
|
modules/src/string
|
||||||
modules/src/read_em
|
modules/src/read_em
|
||||||
@ -29,7 +31,7 @@ util/ack
|
|||||||
lib/descr/fe
|
lib/descr/fe
|
||||||
util/arch
|
util/arch
|
||||||
#util/cpp
|
#util/cpp
|
||||||
#util/cgg
|
util/cgg
|
||||||
util/ncgg
|
util/ncgg
|
||||||
util/misc
|
util/misc
|
||||||
util/opt
|
util/opt
|
||||||
@ -41,22 +43,15 @@ lang/cem
|
|||||||
lang/pc
|
lang/pc
|
||||||
lang/m2
|
lang/m2
|
||||||
#lang/occam
|
#lang/occam
|
||||||
lang/basic
|
#lang/basic
|
||||||
|
|
||||||
mach/proto
|
mach/proto
|
||||||
mach/i80
|
mach/i80
|
||||||
mach/i86
|
mach/i86
|
||||||
mach/i386
|
mach/i386
|
||||||
mach/m68020
|
|
||||||
mach/vc4
|
|
||||||
|
|
||||||
plat
|
|
||||||
plat/cpm
|
plat/cpm
|
||||||
plat/pc86
|
plat/pc86
|
||||||
plat/linux
|
|
||||||
plat/linux386
|
plat/linux386
|
||||||
plat/linux68k
|
|
||||||
plat/rpi
|
|
||||||
|
|
||||||
examples
|
examples
|
||||||
man
|
|
||||||
|
|||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*~
|
||||||
|
*.o
|
||||||
|
.*
|
||||||
|
-.gitignore
|
||||||
|
/pattern.c
|
||||||
9
.hgtags
Normal file
9
.hgtags
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
5a0daa6017c4aa5ae23b870e97eb7431021762bc distr2
|
||||||
|
15b742c4c278c27029eca0e41f16463bc076de6e distr3
|
||||||
|
a0686e2ca8d6780ce37b8267b865f60e9317a340 llgen-1-0
|
||||||
|
d96cd06672c368e8aaa584fead379ce1d343acad oct-1
|
||||||
|
bf69b3579e8545ecfc03f5e2550586e3c479270d release-6-0-pre-4
|
||||||
|
e880082b57f12a7df1c33a2da2c7424d6368f185 dist2
|
||||||
|
fe535e3e8bc859d4a4e4a186f42670f9e588a5aa release-5-6
|
||||||
|
90102c21c4480102634c6a482d0dd55f2d9ca00f release-6-0-pre-3
|
||||||
|
ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1
|
||||||
@ -1,6 +0,0 @@
|
|||||||
before_install:
|
|
||||||
- sudo apt-get install ed lua5.1 liblua5.1-posix1 ninja-build
|
|
||||||
language: c
|
|
||||||
script:
|
|
||||||
- make PREFIX=/tmp/acki -j4
|
|
||||||
|
|
||||||
7
CHANGES
7
CHANGES
@ -2,11 +2,6 @@
|
|||||||
# $State$
|
# $State$
|
||||||
# $Revision$
|
# $Revision$
|
||||||
|
|
||||||
6.1pre1
|
|
||||||
|
|
||||||
Threw away the make-based build system, because it just didn't work. Wrote
|
|
||||||
ackbuilder. Many, many little bugfixes and cleanups, too many to remember.
|
|
||||||
|
|
||||||
6.0pre4
|
6.0pre4
|
||||||
|
|
||||||
Fixed some minor bit-rotting issues that were preventing compilation on
|
Fixed some minor bit-rotting issues that were preventing compilation on
|
||||||
@ -37,4 +32,4 @@
|
|||||||
compilers, Pascal, Modula-2, Basic and Occam. Working backends: i86. Working
|
compilers, Pascal, Modula-2, Basic and Occam. Working backends: i86. Working
|
||||||
platforms: pc86, the very noddy testbed setup that produces floppy disk
|
platforms: pc86, the very noddy testbed setup that produces floppy disk
|
||||||
images.
|
images.
|
||||||
|
|
||||||
32
Copyright
32
Copyright
@ -1,32 +0,0 @@
|
|||||||
Copyright (c) 1987, 1990, 1993, 2005 Vrije Universiteit, Amsterdam, The Netherlands.
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use of the Amsterdam Compiler Kit in source and
|
|
||||||
binary forms, with or without modification, are permitted provided
|
|
||||||
that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following
|
|
||||||
disclaimer in the documentation and/or other materials provided
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of Vrije Universiteit nor the names of the
|
|
||||||
software authors or contributors may be used to endorse or
|
|
||||||
promote products derived from this software without specific
|
|
||||||
prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
|
|
||||||
CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
IN NO EVENT SHALL VRIJE UNIVERSITEIT OR ANY AUTHORS OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
||||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
32
LICENSE
Normal file
32
LICENSE
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
Copyright (c) 1987, 1990, 1993, 2005 Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of the Amsterdam Compiler Kit in source and
|
||||||
|
binary forms, with or without modification, are permitted provided
|
||||||
|
that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer in the documentation and/or other materials provided
|
||||||
|
with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of Vrije Universiteit nor the names of the
|
||||||
|
software authors or contributors may be used to endorse or
|
||||||
|
promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
|
||||||
|
CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL VRIJE UNIVERSITEIT OR ANY AUTHORS OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
|
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
104
Makefile
104
Makefile
@ -1,104 +0,0 @@
|
|||||||
# ======================================================================= #
|
|
||||||
# ACK CONFIGURATION #
|
|
||||||
# (Edit this before building) #
|
|
||||||
# ======================================================================= #
|
|
||||||
|
|
||||||
# What platform to build for by default?
|
|
||||||
|
|
||||||
DEFAULT_PLATFORM = pc86
|
|
||||||
|
|
||||||
# Where should the ACK put its temporary files?
|
|
||||||
|
|
||||||
ACK_TEMP_DIR = /tmp
|
|
||||||
|
|
||||||
# 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
|
|
||||||
# (/tmp/ack-build/staging, by default), leave this as $(INSDIR).
|
|
||||||
|
|
||||||
#PREFIX = /usr/local
|
|
||||||
PREFIX = $(INSDIR)
|
|
||||||
|
|
||||||
# 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?
|
|
||||||
|
|
||||||
CFLAGS = -g
|
|
||||||
LDFLAGS =
|
|
||||||
|
|
||||||
# Various commands.
|
|
||||||
|
|
||||||
AR = ar
|
|
||||||
CC = gcc
|
|
||||||
|
|
||||||
# Which build system to use; use 'ninja' or 'make' (in lower case). Leave
|
|
||||||
# blank to autodetect.
|
|
||||||
|
|
||||||
BUILDSYSTEM =
|
|
||||||
|
|
||||||
# Build flags for ninja.
|
|
||||||
|
|
||||||
NINJAFLAGS =
|
|
||||||
|
|
||||||
# Build flags for make.
|
|
||||||
|
|
||||||
MAKEFLAGS = -r
|
|
||||||
|
|
||||||
# ======================================================================= #
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
PLATIND = $(INSDIR)/share/ack
|
|
||||||
PLATDEP = $(INSDIR)/lib/ack
|
|
||||||
|
|
||||||
MAKECMDGOALS ?= +ack
|
|
||||||
BUILD_FILES = $(shell find * -name '*.lua')
|
|
||||||
|
|
||||||
ifneq ($(shell which ninja),)
|
|
||||||
BUILDSYSTEM = ninja
|
|
||||||
BUILDFLAGS = $(NINJAFLAGS)
|
|
||||||
else
|
|
||||||
BUILDSYSTEM = make
|
|
||||||
BUILDFLAGS = $(MAKEFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(findstring +, $(MAKECMDGOALS)),)
|
|
||||||
|
|
||||||
$(MAKECMDGOALS): $(BUILDDIR)/build.$(BUILDSYSTEM)
|
|
||||||
@$(BUILDSYSTEM) $(BUILDFLAGS) -f $^ $(MAKECMDGOALS)
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(BUILDDIR)/build.$(BUILDSYSTEM): first/ackbuilder.lua Makefile $(BUILD_FILES)
|
|
||||||
@mkdir -p $(BUILDDIR)
|
|
||||||
@lua5.1 first/ackbuilder.lua \
|
|
||||||
first/build.lua build.lua \
|
|
||||||
--$(BUILDSYSTEM) \
|
|
||||||
OBJDIR=$(OBJDIR) \
|
|
||||||
BINDIR=$(BINDIR) \
|
|
||||||
LIBDIR=$(LIBDIR) \
|
|
||||||
INCDIR=$(INCDIR) \
|
|
||||||
INSDIR=$(INSDIR) \
|
|
||||||
PLATIND=$(PLATIND) \
|
|
||||||
PLATDEP=$(PLATDEP) \
|
|
||||||
AR=$(AR) \
|
|
||||||
CC=$(CC) \
|
|
||||||
> $(BUILDDIR)/build.$(BUILDSYSTEM)
|
|
||||||
|
|
||||||
install:
|
|
||||||
mkdir -p $(PREFIX)
|
|
||||||
tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -rf $(BUILDDIR)
|
|
||||||
|
|
||||||
121
README
121
README
@ -1,9 +1,8 @@
|
|||||||
THE AMSTERDAM COMPILER KIT V6.1pre1
|
THE AMSTERDAM COMPILER KIT V6.0pre4
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
© 1987-2005 Vrije Universiteit, Amsterdam
|
|
||||||
2016-08-02
|
|
||||||
|
|
||||||
|
© 1987-2005 Vrije Universiteit, Amsterdam 2010-08-08
|
||||||
|
© 2013-2014 Manoel Trapier, Paris
|
||||||
|
|
||||||
INTRODUCTION
|
INTRODUCTION
|
||||||
============
|
============
|
||||||
@ -13,79 +12,87 @@ front end compilers for a number of different languages, code generators,
|
|||||||
support libraries, and all the tools necessary to go from source code to
|
support libraries, and all the tools necessary to go from source code to
|
||||||
executable on any of the platforms it supports.
|
executable on any of the platforms it supports.
|
||||||
|
|
||||||
This is an early prerelease of the apocryphal version 6.1 release. Not a
|
This is an early prerelease of the apocryphal version 6.0 release. Not a
|
||||||
lot is supported, the build mechanism needs work, and a lot of things are
|
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
|
probably broken. However, what's there should be sufficient to get things
|
||||||
done and to evaluate how the full 6.1 release should work.
|
done and to evaluate how the full 6.0 release should work.
|
||||||
|
|
||||||
|
This is a fork from the original repository found on sourceforge. This
|
||||||
|
fork exist for three reason, the first is I strongly prefere git than
|
||||||
|
mercurial (this is a personal preference) and second I want to make it
|
||||||
|
work on Mac OS X but the OSX clang/gcc does not really like the K&R
|
||||||
|
syntax, so I take into the process of ANSIfy it. The third reason is why
|
||||||
|
I want to use the ACK, it support old CPU, like the 6502 or i8080, i8086
|
||||||
|
and it is open source unlike a lot of compiler we can found nowadays for
|
||||||
|
such targets, and it support more than C that is a wonderfull bonus!
|
||||||
|
|
||||||
|
I have plan to add targets like the NES, add support for the 65c816 and
|
||||||
|
add the SNES target, add the WonderSwan as a target and so on. I see in
|
||||||
|
this compiler kit a wonderfull project for all sort of old computer that
|
||||||
|
are still used nowadays and used CPU that are no longuer targeted by
|
||||||
|
modern compilers.
|
||||||
|
|
||||||
|
I plan to push my changes on the original version, at least for the new
|
||||||
|
targets and cpu.
|
||||||
|
|
||||||
SUPPORT
|
SUPPORT
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Languages:
|
Languages:
|
||||||
|
|
||||||
ANSI C, Pascal, Modula 2, Basic. K&R is supported via the ANSI C compiler.
|
ANSI C, Pascal, Modula 2. K&R is supported via the ANSI C compiler.
|
||||||
|
|
||||||
Platforms:
|
Platforms:
|
||||||
|
|
||||||
pc86 produces bootable floppy disk images for 8086 PCs
|
pc86 produces bootable floppy disk images for 8086 PCs
|
||||||
linux386 produces ELF executables for PC Linux systems
|
linux386 produces ELF executables for PC Linux systems
|
||||||
linux68k produces ELF executables for m68020 Linux systems
|
|
||||||
cpm produces i80 CP/M .COM files
|
cpm produces i80 CP/M .COM files
|
||||||
rpi produces Raspberry Pi GPU binaries
|
|
||||||
|
|
||||||
|
|
||||||
INSTALLATION
|
INSTALLATION
|
||||||
============
|
============
|
||||||
|
|
||||||
The version 5.0 build mechanism has been completely rewritten. Installation
|
The version 6.0 build mechanism has been completely rewritten and is based
|
||||||
ought to be fairly straightforward.
|
around the Prime Mover build tool (see http://primemover.sf.net for more
|
||||||
|
information). Installation ought to be fairly straightforward.
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
- an ANSI C compiler. This defaults to gcc. You can change this by setting
|
- an ANSI C compiler. Currently, I'm afraid, it's hard-coded to use gcc.
|
||||||
the CC make variable.
|
To change, try changing the variable definitions in first/c.pm. This also
|
||||||
|
needs to be available as 'cc' from the shell.
|
||||||
- flex and yacc.
|
|
||||||
|
- about 20MB free in /tmp (or some other temporary directory).
|
||||||
- GNU make.
|
|
||||||
|
|
||||||
- Lua 5.1 and the luaposix library (used by the build system).
|
|
||||||
|
|
||||||
- (optionally) ninja; if you've got this, this will be autodetected and give
|
|
||||||
you faster builds.
|
|
||||||
|
|
||||||
- about 40MB free in /tmp (or some other temporary directory).
|
|
||||||
|
|
||||||
- about 6MB in the target directory.
|
- about 6MB in the target directory.
|
||||||
|
|
||||||
Instructions:
|
Instructions:
|
||||||
|
|
||||||
- edit the Makefile. There's a small section at the top where you can change
|
- edit config.pm. There's a small section at the top containing some editable
|
||||||
the configuration. Probably the only one you may want to edit is PREFIX,
|
variables. Probably the only one you may want to edit is PREFIX, which
|
||||||
which changes where the ACK installs to.
|
changes where the ACK installs to.
|
||||||
|
|
||||||
- Run:
|
- Run:
|
||||||
|
|
||||||
make
|
./pm configure
|
||||||
|
|
||||||
...from the command line. This will do the build.
|
...from the command line. This will write out a configuration file.
|
||||||
|
|
||||||
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 MAKEFLAGS='-r -j8' # or however many cores you have
|
|
||||||
|
|
||||||
...but frankly, I recommend ninja.
|
|
||||||
|
|
||||||
- Run:
|
- Run:
|
||||||
|
|
||||||
sudo make install
|
./pm
|
||||||
|
|
||||||
...from the command line. This will install the ACK in your PREFIX
|
...from the command line. This will actually do the build. This takes
|
||||||
directory (by default, /usr/local).
|
about two minutes on my 1.6GHz Athlon Linux machine and about 30 on my
|
||||||
|
166MHz Pentium OpenBSD machine.
|
||||||
|
|
||||||
|
- Run:
|
||||||
|
|
||||||
|
./pm install
|
||||||
|
|
||||||
|
...from the command line (possibly with sudo). This will install the built
|
||||||
|
ACK into whatever directory you nominated in PREFIX.
|
||||||
|
|
||||||
The ACK should now be ready to use.
|
The ACK should now be ready to use.
|
||||||
|
|
||||||
|
|
||||||
@ -103,9 +110,8 @@ Some useful options include:
|
|||||||
-o <file> specifies the output file
|
-o <file> specifies the output file
|
||||||
-c produce a .o file
|
-c produce a .o file
|
||||||
-c.s produce a .s assembly file
|
-c.s produce a .s assembly file
|
||||||
-O enable optimisation (optimisation levels go up to 6)
|
-O enable optimisation
|
||||||
-ansi compile ANSI C (when using the C compiler)
|
-ansi compile ANSI C (when using the C compiler)
|
||||||
-v be more verbose (repeatable)
|
|
||||||
<file> build file
|
<file> build file
|
||||||
|
|
||||||
ack figures out which language to use from the file extension:
|
ack figures out which language to use from the file extension:
|
||||||
@ -117,7 +123,6 @@ ack figures out which language to use from the file extension:
|
|||||||
.p Pascal
|
.p Pascal
|
||||||
.o object files
|
.o object files
|
||||||
.s assembly files
|
.s assembly files
|
||||||
.e ACK intermediate code assembly files
|
|
||||||
|
|
||||||
For further information, see the man page (which actually does get
|
For further information, see the man page (which actually does get
|
||||||
installed, but is rather out of date).
|
installed, but is rather out of date).
|
||||||
@ -128,13 +133,12 @@ A sample command line is:
|
|||||||
ack -mlinux386 -O examples/paranoia.c
|
ack -mlinux386 -O examples/paranoia.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GOTCHAS
|
GOTCHAS
|
||||||
=======
|
=======
|
||||||
|
|
||||||
There are some things you should be aware of.
|
There are some things you should be aware of.
|
||||||
|
|
||||||
- Look at plat/<PLATFORMNAME>/README for information about the supported
|
- Look at plat/<PLATFORMNAME>/README for information about the two supported
|
||||||
platforms.
|
platforms.
|
||||||
|
|
||||||
- The library support is fairly limited; for C, it's at roughly the ANSI C
|
- The library support is fairly limited; for C, it's at roughly the ANSI C
|
||||||
@ -150,10 +154,6 @@ There are some things you should be aware of.
|
|||||||
- The ACK uses its own .o format. You won't be able to mix the ACK's object
|
- The ACK uses its own .o format. You won't be able to mix the ACK's object
|
||||||
files and another compiler's.
|
files and another compiler's.
|
||||||
|
|
||||||
- The distribution contains *everything*, including the weird, ancient,
|
|
||||||
archaic stuff that doesn't work any more and never will, such as the int EM
|
|
||||||
interpreter and the assembler-linkers. Only some of it builds. Look for
|
|
||||||
build.lua files.
|
|
||||||
|
|
||||||
DISCLAIMER
|
DISCLAIMER
|
||||||
==========
|
==========
|
||||||
@ -171,12 +171,19 @@ more welcome.
|
|||||||
The ACK is licensed under a BSD-like license. Please see the 'Copyright' file
|
The ACK is licensed under a BSD-like license. Please see the 'Copyright' file
|
||||||
for the full text.
|
for the full text.
|
||||||
|
|
||||||
You can find the mailing list on the project's web site:
|
You will find this "ANSI Fork" on github:
|
||||||
|
|
||||||
|
http://github.com/Godzil/ack
|
||||||
|
|
||||||
|
You can find the ACK mailing list and the original project's web site:
|
||||||
|
|
||||||
http://tack.sourceforge.net/
|
http://tack.sourceforge.net/
|
||||||
|
|
||||||
Please enjoy.
|
Please enjoy.
|
||||||
|
|
||||||
|
Manoel Trapier (aka godzil) for the ANSI-fication port
|
||||||
|
|
||||||
David Given (dtrg on Sourceforge)
|
David Given (dtrg on Sourceforge)
|
||||||
dg@cowlark.com
|
dg@cowlark.com
|
||||||
2016-08-02
|
2010-08-08
|
||||||
|
|
||||||
|
|||||||
9
bin/.distr
Normal file
9
bin/.distr
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cc-and-mkdep.ack
|
||||||
|
cc-and-mkdep.all
|
||||||
|
cc-and-mkdep.sun
|
||||||
|
do_deps
|
||||||
|
do_resolve
|
||||||
|
lint-lib.ack
|
||||||
|
lint-lib.unix
|
||||||
|
mk_manpage
|
||||||
|
rm_deps
|
||||||
38
build.lua
38
build.lua
@ -1,38 +0,0 @@
|
|||||||
vars.cflags = {
|
|
||||||
"-g", "-O"
|
|
||||||
}
|
|
||||||
vars.ackcflags = {
|
|
||||||
"-O6"
|
|
||||||
}
|
|
||||||
vars.plats = {
|
|
||||||
"cpm",
|
|
||||||
"linux386",
|
|
||||||
"linux68k",
|
|
||||||
"pc86",
|
|
||||||
"rpi",
|
|
||||||
}
|
|
||||||
|
|
||||||
local plat_packages = {}
|
|
||||||
for _, p in ipairs(vars.plats) do
|
|
||||||
plat_packages[#plat_packages+1] = "plat/"..p.."+pkg"
|
|
||||||
end
|
|
||||||
|
|
||||||
installable {
|
|
||||||
name = "ack",
|
|
||||||
map = {
|
|
||||||
"lang/basic/src+pkg",
|
|
||||||
"lang/cem/cemcom.ansi+pkg",
|
|
||||||
"lang/m2/comp+pkg",
|
|
||||||
"lang/pc/comp+pkg",
|
|
||||||
"util/ack+pkg",
|
|
||||||
"util/amisc+pkg",
|
|
||||||
"util/arch+pkg",
|
|
||||||
"util/ego+pkg",
|
|
||||||
"util/led+pkg",
|
|
||||||
"util/misc+pkg",
|
|
||||||
"util/opt+pkg",
|
|
||||||
"examples+pkg",
|
|
||||||
plat_packages
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ ACK_TEMP_DIR = "/tmp"
|
|||||||
|
|
||||||
-- Where is the ACK going to be installed, eventually?
|
-- Where is the ACK going to be installed, eventually?
|
||||||
|
|
||||||
PREFIX = "/tmp/ack-temp/staging"
|
PREFIX = "/usr/local"
|
||||||
|
|
||||||
-- ======================================================================= --
|
-- ======================================================================= --
|
||||||
-- BROKEN ACK CONFIGURATION --
|
-- BROKEN ACK CONFIGURATION --
|
||||||
|
|||||||
15
distr/Exceptions
Normal file
15
distr/Exceptions
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
++ ./doc/install.pr made
|
||||||
|
++ ./doc/int/.distr made
|
||||||
|
++ ./etc/new_table_done made
|
||||||
|
++ ./lang/cem/cemcom.ansi/Version.c made
|
||||||
|
++ ./lang/cem/libcc.ansi/stdlib/malloc.c made
|
||||||
|
++ ./lang/cem/cemcom/Version.c made
|
||||||
|
++ ./lang/pc/comp/Version.c made
|
||||||
|
++ ./lang/m2/comp/Version.c made
|
||||||
|
++ ./lang/m2/m2mm/Version.c made
|
||||||
|
++ ./mach/sparc/ce/EM_table made
|
||||||
|
++ ./mach/sparc_solaris/libem/LIST made
|
||||||
|
++ ./util/LLgen/src/LLgen.c.dist made
|
||||||
|
++ ./util/cpp/Version.c made
|
||||||
|
++ ./util/ego/share/pop_push.h made
|
||||||
|
++ ./util/grind/ops.c made
|
||||||
90
distr/How_To
Normal file
90
distr/How_To
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
How to make a distribution
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
I have written a new tool to generate the distributions that does not rely on
|
||||||
|
having a local CVS server --- distr/mkdist.
|
||||||
|
|
||||||
|
To use it, you need to specify your CVS work tree, the destination directory
|
||||||
|
that the distribution will be written to, plus flags. It should be self-
|
||||||
|
documenting; use:
|
||||||
|
|
||||||
|
mkdist --help
|
||||||
|
|
||||||
|
...to get documentation.
|
||||||
|
|
||||||
|
It uses .distr files in exactly the same way as the previous mechanism.
|
||||||
|
|
||||||
|
The documentation for the old distribution tools follows.
|
||||||
|
|
||||||
|
David Given
|
||||||
|
dg@cowlark.com
|
||||||
|
2005-06-25
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
How to make a fresh distribution:
|
||||||
|
For a distribution you need ".distr" files and RCS files.
|
||||||
|
The EM home directory contains a file called ".distr". It contains
|
||||||
|
the names of all the files and directories you want to have in the distribution.
|
||||||
|
The directories should contain .distr files, the other files should
|
||||||
|
be placed under CVS.
|
||||||
|
There are files that derive from other files and yet should be placed
|
||||||
|
in the distribution.
|
||||||
|
These files should not be placed under RCS or CVS.
|
||||||
|
The file "Exceptions" in this directory contains the current list of
|
||||||
|
these files.
|
||||||
|
|
||||||
|
When all this is correct, use the shell script mktree the extract
|
||||||
|
the distribution from the EM tree.
|
||||||
|
sh mktree destination_tree repository_tree <distrname> 2>f.attf
|
||||||
|
Use the "cvs rtag" command to give the distribution a name first!
|
||||||
|
Make sure that the destination tree exists and is empty!
|
||||||
|
Failing to do that will almost certainly result in a welter of
|
||||||
|
error messages.
|
||||||
|
The file f.attf contains mktree error messages and should be compared
|
||||||
|
to Exceptions.
|
||||||
|
The actions of mktree are quite complicated. It starts in the current
|
||||||
|
directory creating a version in the destination directory.
|
||||||
|
Then it reads the .distr file.
|
||||||
|
For each file mentioned there it performes certain actions:
|
||||||
|
1- Directory Change to that directory and call yourself recursively.
|
||||||
|
2- File
|
||||||
|
a- Does a file LIST exist in this directory AND
|
||||||
|
is the first line of LIST equal to the name of the
|
||||||
|
destination file? If so, try to extract all the files
|
||||||
|
named in the rest of the LIST file and call the program
|
||||||
|
arch to create a library "arch cDr `cat LIST`".
|
||||||
|
In this manner libraries can be distributed whose members
|
||||||
|
have their own RCS file.
|
||||||
|
else
|
||||||
|
b- Try to run 'make distr'
|
||||||
|
else
|
||||||
|
c- Try to run 'make <filename>'
|
||||||
|
else
|
||||||
|
d- give message that says "not present" (or some such).
|
||||||
|
|
||||||
|
Now, the tree contains all the files in the distribution, but it also contains
|
||||||
|
files that should not be in the distribution, especially the files created
|
||||||
|
by CVS.
|
||||||
|
That is why we now give the command:
|
||||||
|
dtar cdf distr .
|
||||||
|
The file distr is the one you should put on tape!
|
||||||
|
But,.... before doing that: Try it out!
|
||||||
|
Repeat the process described in the installation manual.
|
||||||
|
Only if that succeeds you are sure that you included the files needed.
|
||||||
|
Good Luck,
|
||||||
|
Ed Keizer, 85/4/15.
|
||||||
|
|
||||||
|
Updated for 3rd distribution by Ceriel Jacobs, 87/3/11.
|
||||||
|
And again,
|
||||||
|
Good Luck!
|
||||||
|
|
||||||
|
Updated for 4th distribution by Ceriel Jacobs, 88/4/08.
|
||||||
|
And again,
|
||||||
|
Good Luck!
|
||||||
|
Updated for 5th distribution by Ceriel Jacobs, 91/19/12.
|
||||||
|
And again,
|
||||||
|
Good Luck!
|
||||||
|
Updated for 1st upgrade to 5th distribution by Ceriel Jacobs, 91/12/11.
|
||||||
|
And again,
|
||||||
|
Good Luck!
|
||||||
26
distr/dwalk
Executable file
26
distr/dwalk
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
: ${CDIR=.}
|
||||||
|
${DF-:} $CDIR .distr
|
||||||
|
if test ! -r $DESTDIR/$CDIR/.distr
|
||||||
|
then
|
||||||
|
echo ++ no .distr in $CDIR 1>&2
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
for i in `cat $DESTDIR/$CDIR/.distr`
|
||||||
|
do
|
||||||
|
if test -d $i
|
||||||
|
then
|
||||||
|
( if cd $i
|
||||||
|
then
|
||||||
|
CDIR=$CDIR/$i
|
||||||
|
export CDIR
|
||||||
|
exec $DDIR/dwalk $*
|
||||||
|
else
|
||||||
|
echo ++ Could not access $CDIR/$i 1>&2
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
else
|
||||||
|
${DF-:} $CDIR $i
|
||||||
|
fi
|
||||||
|
done
|
||||||
1
distr/echod
Executable file
1
distr/echod
Executable file
@ -0,0 +1 @@
|
|||||||
|
echo $1
|
||||||
10
distr/listall
Executable file
10
distr/listall
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
case $# in
|
||||||
|
0) DESTDIR=. ;;
|
||||||
|
1) DESTDIR=$1 ;;
|
||||||
|
*) echo $0 [directory] ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
DD=`pwd`/listall.d
|
||||||
|
DW=`pwd`/dwalk
|
||||||
|
export DD DESTDIR
|
||||||
|
cd $DESTDIR
|
||||||
|
$DW
|
||||||
2
distr/listall.d
Executable file
2
distr/listall.d
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
echo "<$1>"
|
||||||
|
ls -bCdx `cat .distr`
|
||||||
10
distr/listdirs
Executable file
10
distr/listdirs
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
case $# in
|
||||||
|
0) DIR=. ;;
|
||||||
|
1) DIR=$1 ;;
|
||||||
|
*) echo $0 [directory] ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
DD=`pwd`/echod
|
||||||
|
DW=`pwd`/dwalk
|
||||||
|
export DD
|
||||||
|
cd $DIR
|
||||||
|
$DW
|
||||||
40
distr/mk_distr_syms
Executable file
40
distr/mk_distr_syms
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
: Utility to make a tree of symbolic links to source tree.
|
||||||
|
: Mount the source tree read-only, use this script, and then try installation.
|
||||||
|
case $# in
|
||||||
|
2) ;;
|
||||||
|
*) echo "Usage: $0 <source-tree> <symlink-tree>" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ -f $1/.distr ]
|
||||||
|
then
|
||||||
|
for i in `cat $1/.distr`
|
||||||
|
do
|
||||||
|
if [ -d $1/$i ]
|
||||||
|
then
|
||||||
|
if mkdir $2/$i && $0 $1/$i $2/$i
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -f $1/$i ]
|
||||||
|
then
|
||||||
|
if ln -s $1/$i $2/$i
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Missing file $1/$i" 1>&2
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "No .distr file in $1" 1>&2
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
11
distr/mka
Executable file
11
distr/mka
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
for i in `tail +2 $DESTDIR/$1/LIST`
|
||||||
|
do
|
||||||
|
${DF-false} $1 $i
|
||||||
|
done
|
||||||
|
cd $DESTDIR/$1
|
||||||
|
arch cDr `cat LIST`
|
||||||
|
: I do not remove the files constituating the library, because
|
||||||
|
: they might be present in .distr
|
||||||
0
lang/build.lua → distr/mkd
Normal file → Executable file
0
lang/build.lua → distr/mkd
Normal file → Executable file
177
distr/mkdist
Executable file
177
distr/mkdist
Executable file
@ -0,0 +1,177 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# $Source$
|
||||||
|
# $State$
|
||||||
|
|
||||||
|
# Set up default variables.
|
||||||
|
|
||||||
|
destdir=
|
||||||
|
srcdir=`pwd`
|
||||||
|
arch=/usr/local/bin/arch
|
||||||
|
delete=no
|
||||||
|
copy="ln"
|
||||||
|
|
||||||
|
# --- Options parsing -------------------------------------------------------
|
||||||
|
|
||||||
|
while [ "$1" != "" ]; do
|
||||||
|
case "$1" in
|
||||||
|
-s|--srcdir)
|
||||||
|
srcdir="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-d|--destdir)
|
||||||
|
destdir="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-x|--delete)
|
||||||
|
delete=yes
|
||||||
|
;;
|
||||||
|
|
||||||
|
-c|--copy)
|
||||||
|
copy="cp -Rp"
|
||||||
|
;;
|
||||||
|
|
||||||
|
-S|--symlink)
|
||||||
|
copy="ln -s"
|
||||||
|
;;
|
||||||
|
|
||||||
|
-a|--arch)
|
||||||
|
arch="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-h|--help)
|
||||||
|
echo "mkdist [options]"
|
||||||
|
echo "Options are:"
|
||||||
|
echo " -s --srcdir <path> The CVS tree to read from. (default: CWD)"
|
||||||
|
echo " -d --destdir <path> The directory to create the distribution in."
|
||||||
|
echo " -x --delete Erase the destination directory first."
|
||||||
|
echo " -c --copy Make physical copies of the files. (default: hardlink)"
|
||||||
|
echo " -S --symlink Make symbolic links instead of copying or hardlinking."
|
||||||
|
echo " -a --arch <path> Where the ACK 'arch' tool is."
|
||||||
|
echo " -h --help Display this message."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Unrecognised option. Try --help for help."
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$destdir" = "" ]; then
|
||||||
|
echo "You must specify a destination directory. (Try --help for help.)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Main routines ---------------------------------------------------------
|
||||||
|
|
||||||
|
# These two routines do the work of traversing the source tree and building
|
||||||
|
# the distribution tree.
|
||||||
|
|
||||||
|
addfile() {
|
||||||
|
local f
|
||||||
|
f="${1##$srcdir/}"
|
||||||
|
mkdir -p $destdir/`dirname $f`
|
||||||
|
$copy "$1" "$destdir/$f"
|
||||||
|
}
|
||||||
|
|
||||||
|
process_dir() {
|
||||||
|
local path
|
||||||
|
local archivename
|
||||||
|
|
||||||
|
path=$1
|
||||||
|
cd $path
|
||||||
|
echo $PWD
|
||||||
|
|
||||||
|
# Look for a LIST file and cache the first line.
|
||||||
|
|
||||||
|
archivename=
|
||||||
|
if [ -f LIST ]; then
|
||||||
|
archivename=`head -1 LIST`
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in `cat $path/.distr`; do
|
||||||
|
case "$i" in
|
||||||
|
\#*) # Comment. Do nothing.
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
if [ -d $i ]; then
|
||||||
|
# This is a directory. Recurse into it.
|
||||||
|
|
||||||
|
( process_dir $path/$i )
|
||||||
|
elif [ -f $i ]; then
|
||||||
|
# This is a file.
|
||||||
|
|
||||||
|
addfile $path/$i
|
||||||
|
elif [ "$i" = "$archivename" ]; then
|
||||||
|
# Build the named archive.
|
||||||
|
|
||||||
|
$arch cDr `cat LIST`
|
||||||
|
addfile $path/$archivename
|
||||||
|
else
|
||||||
|
echo "Don't know what to do with $i, listed in $PWD/.distr."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Main program ----------------------------------------------------------
|
||||||
|
|
||||||
|
# Test to make sure that $arch points to the right thing.
|
||||||
|
|
||||||
|
if !(strings $arch | grep archiver > /dev/null); then
|
||||||
|
echo "$arch does not seem to point at the ACK archiver tool."
|
||||||
|
echo "(Don't confuse this with the Linux tool for displaying your"
|
||||||
|
echo "architecture.)"
|
||||||
|
echo ""
|
||||||
|
echo "Press RETURN to go ahead anyway, or CTRL+C to abort."
|
||||||
|
read ignored
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Actually do the work.
|
||||||
|
|
||||||
|
echo "Creating distribution from CVS tree: $srcdir"
|
||||||
|
echo " into destination tree: $destdir"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [ -e $destdir ]; then
|
||||||
|
if [ "$delete" = "yes" ]; then
|
||||||
|
echo "Press RETURN to erase $destdir and its contents, or CTRL+C to abort."
|
||||||
|
read
|
||||||
|
echo "Erasing..."
|
||||||
|
rm -rf "$destdir"
|
||||||
|
else
|
||||||
|
echo "$destdir exists. Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Working..."
|
||||||
|
mkdir -p $destdir
|
||||||
|
process_dir $srcdir
|
||||||
|
echo "Done."
|
||||||
|
|
||||||
|
# Revision history
|
||||||
|
# $Log$
|
||||||
|
# Revision 1.5 2007-04-24 19:48:41 dtrg
|
||||||
|
# Removed bashish.
|
||||||
|
#
|
||||||
|
# Revision 1.4 2007/02/25 20:56:41 dtrg
|
||||||
|
# Performed major renovations to make the script work on OpenBSD.
|
||||||
|
#
|
||||||
|
# Revision 1.3 2007/02/24 02:05:56 dtrg
|
||||||
|
# Removed some bashish; added comment support; removed the make
|
||||||
|
# distr functionality, as nothing was using it any more and it was
|
||||||
|
# causing problems.
|
||||||
|
#
|
||||||
|
# Revision 1.2 2005/06/24 23:19:23 dtrg
|
||||||
|
# Added new mkdist tool.
|
||||||
|
#
|
||||||
|
# Revision 1.1 2005/06/24 22:13:57 dtrg
|
||||||
|
# Created new tool to generate distributions.
|
||||||
19
distr/mkf
Executable file
19
distr/mkf
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -f $DESTDIR/$1/$2 ]
|
||||||
|
then
|
||||||
|
:
|
||||||
|
elif grep LIST $DESTDIR/$1/.distr >/dev/null 2>&1 &&
|
||||||
|
(test "$2" = "`head -1 $DESTDIR/$1/LIST`") >/dev/null 2>&1 &&
|
||||||
|
${DA-false} "$1" "$2"
|
||||||
|
then
|
||||||
|
: Fetched library contents one by one and put them together
|
||||||
|
elif ( cd $DESTDIR/$1 ; make distr ) > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
echo ++ $1/$2 made 1>&2
|
||||||
|
elif ( cd $DESTDIR/$1 ; make $2 ) > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
echo ++ $1/$2 made 1>&2
|
||||||
|
else
|
||||||
|
echo ++ $1/$2 not present 1>&2
|
||||||
|
fi
|
||||||
42
distr/mktree
Normal file
42
distr/mktree
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
case $# in
|
||||||
|
2|3) ;;
|
||||||
|
*) echo Usage: $0 directory repdir [ SVrecord ] 1>&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
case $0 in
|
||||||
|
/*) DDIR=`dirname $0`
|
||||||
|
;;
|
||||||
|
*) DDIR=`pwd`/`dirname $0`
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case $1 in
|
||||||
|
/*) DESTDIR=$1 ;;
|
||||||
|
*) DESTDIR=`pwd`/$1 ;;
|
||||||
|
esac
|
||||||
|
case $2 in
|
||||||
|
/*) REPDIR=$2 ;;
|
||||||
|
*) REPDIR=`pwd`/$2 ;;
|
||||||
|
esac
|
||||||
|
# DD=$DDIR/mkd
|
||||||
|
# export DD
|
||||||
|
mkdir -p $DESTDIR
|
||||||
|
CVSROOT=/usr/proj/em/Repositories
|
||||||
|
export CVSROOT
|
||||||
|
cd $DESTDIR
|
||||||
|
case $# in
|
||||||
|
3)
|
||||||
|
cvs checkout world -r $3
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
cvs checkout world
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
cd $REPDIR
|
||||||
|
DF=$DDIR/mkf
|
||||||
|
DA=$DDIR/mka
|
||||||
|
export DDIR DESTDIR DF DA REPDIR
|
||||||
|
|
||||||
|
$DDIR/dwalk
|
||||||
|
|
||||||
|
cd $DESTDIR
|
||||||
|
find . -type d -print | xargs chmod "uog+rx"
|
||||||
|
chmod -R "og-w,u+w,uog+r" .
|
||||||
26
distr/todistr
Normal file
26
distr/todistr
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
REV=
|
||||||
|
FILE=
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
case $# in
|
||||||
|
0) break ;;
|
||||||
|
esac
|
||||||
|
ARG="$1"
|
||||||
|
shift
|
||||||
|
case "$ARG" in
|
||||||
|
-r*) REV=`echo "$ARG"| sed s/-r//` ;;
|
||||||
|
-*) FLAGS="$FLAGS $ARG" ;;
|
||||||
|
*) case x$FILE in
|
||||||
|
x) FILE="$ARG" ;;
|
||||||
|
*) echo todistr can only be done on one file at the time
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
case x$REV in
|
||||||
|
x) REV=`rlog -h "$FILE"|sed -n -e '/head/s/^head:[ ]*//p'` ;;
|
||||||
|
esac
|
||||||
|
case x$REV in
|
||||||
|
x) exit 2 ;;
|
||||||
|
esac
|
||||||
|
rcs -ndistr4:$REV $FLAGS $FILE
|
||||||
32
doc/.distr
Normal file
32
doc/.distr
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
READ_ME
|
||||||
|
Makefile
|
||||||
|
proto.make
|
||||||
|
ack.doc
|
||||||
|
basic.doc
|
||||||
|
cg.doc
|
||||||
|
crefman.doc
|
||||||
|
ansi_C.doc
|
||||||
|
em
|
||||||
|
install.doc
|
||||||
|
install.pr
|
||||||
|
ncg.doc
|
||||||
|
pcref.doc
|
||||||
|
peep.doc
|
||||||
|
regadd.doc
|
||||||
|
toolkit.doc
|
||||||
|
v7bugs.doc
|
||||||
|
val.doc
|
||||||
|
6500.doc
|
||||||
|
i80.doc
|
||||||
|
z80.doc
|
||||||
|
m68020.doc
|
||||||
|
m2ref.doc
|
||||||
|
nopt.doc
|
||||||
|
top
|
||||||
|
ego
|
||||||
|
occam
|
||||||
|
int
|
||||||
|
ceg
|
||||||
|
sparc
|
||||||
|
lint
|
||||||
|
pascal
|
||||||
4
doc/LLgen/.distr
Normal file
4
doc/LLgen/.distr
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
LLgen.n
|
||||||
|
LLgen_NCER.n
|
||||||
|
LLgen.refs
|
||||||
|
proto.make
|
||||||
3
doc/ceg/.distr
Normal file
3
doc/ceg/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
proto.make
|
||||||
|
ceg.ref
|
||||||
|
ceg.tr
|
||||||
18
doc/ego/.distr
Normal file
18
doc/ego/.distr
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
proto.make
|
||||||
|
bo
|
||||||
|
ca
|
||||||
|
cf
|
||||||
|
cj
|
||||||
|
cs
|
||||||
|
ic
|
||||||
|
il
|
||||||
|
intro
|
||||||
|
lv
|
||||||
|
ov
|
||||||
|
ra
|
||||||
|
refs.gen
|
||||||
|
refs.opt
|
||||||
|
refs.stat
|
||||||
|
sp
|
||||||
|
sr
|
||||||
|
ud
|
||||||
1
doc/ego/bo/.distr
Normal file
1
doc/ego/bo/.distr
Normal file
@ -0,0 +1 @@
|
|||||||
|
bo1
|
||||||
1
doc/ego/ca/.distr
Normal file
1
doc/ego/ca/.distr
Normal file
@ -0,0 +1 @@
|
|||||||
|
ca1
|
||||||
6
doc/ego/cf/.distr
Normal file
6
doc/ego/cf/.distr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
cf1
|
||||||
|
cf2
|
||||||
|
cf3
|
||||||
|
cf4
|
||||||
|
cf5
|
||||||
|
cf6
|
||||||
1
doc/ego/cj/.distr
Normal file
1
doc/ego/cj/.distr
Normal file
@ -0,0 +1 @@
|
|||||||
|
cj1
|
||||||
5
doc/ego/cs/.distr
Normal file
5
doc/ego/cs/.distr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
cs1
|
||||||
|
cs2
|
||||||
|
cs3
|
||||||
|
cs4
|
||||||
|
cs5
|
||||||
5
doc/ego/ic/.distr
Normal file
5
doc/ego/ic/.distr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ic1
|
||||||
|
ic2
|
||||||
|
ic3
|
||||||
|
ic4
|
||||||
|
ic5
|
||||||
6
doc/ego/il/.distr
Normal file
6
doc/ego/il/.distr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
il1
|
||||||
|
il2
|
||||||
|
il3
|
||||||
|
il4
|
||||||
|
il5
|
||||||
|
il6
|
||||||
3
doc/ego/intro/.distr
Normal file
3
doc/ego/intro/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
head
|
||||||
|
intro1
|
||||||
|
tail
|
||||||
1
doc/ego/lv/.distr
Normal file
1
doc/ego/lv/.distr
Normal file
@ -0,0 +1 @@
|
|||||||
|
lv1
|
||||||
1
doc/ego/ov/.distr
Normal file
1
doc/ego/ov/.distr
Normal file
@ -0,0 +1 @@
|
|||||||
|
ov1
|
||||||
4
doc/ego/ra/.distr
Normal file
4
doc/ego/ra/.distr
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
ra1
|
||||||
|
ra2
|
||||||
|
ra3
|
||||||
|
ra4
|
||||||
1
doc/ego/sp/.distr
Normal file
1
doc/ego/sp/.distr
Normal file
@ -0,0 +1 @@
|
|||||||
|
sp1
|
||||||
4
doc/ego/sr/.distr
Normal file
4
doc/ego/sr/.distr
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
sr1
|
||||||
|
sr2
|
||||||
|
sr3
|
||||||
|
sr4
|
||||||
5
doc/ego/ud/.distr
Normal file
5
doc/ego/ud/.distr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ud1
|
||||||
|
ud2
|
||||||
|
ud3
|
||||||
|
ud4
|
||||||
|
ud5
|
||||||
28
doc/em/.distr
Normal file
28
doc/em/.distr
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
proto.make
|
||||||
|
READ_ME
|
||||||
|
app.codes.nr
|
||||||
|
app.exam.nr
|
||||||
|
assem.nr
|
||||||
|
cont.nr
|
||||||
|
descr.nr
|
||||||
|
dspace.nr
|
||||||
|
em.i
|
||||||
|
env.nr
|
||||||
|
even.c
|
||||||
|
exam.e
|
||||||
|
exam.p
|
||||||
|
int
|
||||||
|
intro.nr
|
||||||
|
ip.awk
|
||||||
|
ispace.nr
|
||||||
|
mach.nr
|
||||||
|
macr.nr
|
||||||
|
mapping.nr
|
||||||
|
mem.nr
|
||||||
|
title.nr
|
||||||
|
traps.nr
|
||||||
|
types.nr
|
||||||
|
mkdispatch.c
|
||||||
|
dispat1.sed
|
||||||
|
dispat2.sed
|
||||||
|
dispat3.sed
|
||||||
5
doc/em/int/.distr
Normal file
5
doc/em/int/.distr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
proto.make
|
||||||
|
READ_ME
|
||||||
|
em.p
|
||||||
|
emdmp.c
|
||||||
|
mktables.c
|
||||||
15
doc/lint/.distr
Normal file
15
doc/lint/.distr
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
proto.make
|
||||||
|
abstract
|
||||||
|
appendix_A
|
||||||
|
appendix_B
|
||||||
|
chap1
|
||||||
|
chap2
|
||||||
|
chap3
|
||||||
|
chap4
|
||||||
|
chap5
|
||||||
|
chap6
|
||||||
|
chap7
|
||||||
|
chap8
|
||||||
|
chap9
|
||||||
|
contents
|
||||||
|
frontpage
|
||||||
12
doc/occam/.distr
Normal file
12
doc/occam/.distr
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
proto.make
|
||||||
|
ctot
|
||||||
|
p0
|
||||||
|
p1
|
||||||
|
p2
|
||||||
|
p3
|
||||||
|
p4
|
||||||
|
p5
|
||||||
|
p6
|
||||||
|
p7
|
||||||
|
p8
|
||||||
|
p9
|
||||||
20
doc/pascal/.distr
Normal file
20
doc/pascal/.distr
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
ab+intro.doc
|
||||||
|
compar.doc
|
||||||
|
conf.doc
|
||||||
|
contents.doc
|
||||||
|
deviations.doc
|
||||||
|
example.doc
|
||||||
|
extensions.doc
|
||||||
|
hints.doc
|
||||||
|
his.doc
|
||||||
|
improv.doc
|
||||||
|
internal.doc
|
||||||
|
options.doc
|
||||||
|
proto.make
|
||||||
|
reference.doc
|
||||||
|
rtl.doc
|
||||||
|
syntax.doc
|
||||||
|
test.doc
|
||||||
|
titlepg.doc
|
||||||
|
transpem.doc
|
||||||
|
vrk.doc
|
||||||
15
doc/sparc/.distr
Normal file
15
doc/sparc/.distr
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
A
|
||||||
|
B
|
||||||
|
init
|
||||||
|
intro
|
||||||
|
note_on_reg_wins
|
||||||
|
refs
|
||||||
|
timing
|
||||||
|
title
|
||||||
|
proto.make
|
||||||
|
pics
|
||||||
12
doc/sparc/pics/.distr
Normal file
12
doc/sparc/pics/.distr
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
EM_stack.orig
|
||||||
|
EM_stack.ours
|
||||||
|
compile_bars
|
||||||
|
mem_config
|
||||||
|
perf
|
||||||
|
perf.comp
|
||||||
|
perf.d
|
||||||
|
perf.dhry
|
||||||
|
reg_layout
|
||||||
|
run-time_bars
|
||||||
|
run-time_bars.bup
|
||||||
|
signal_stack
|
||||||
3
doc/top/.distr
Normal file
3
doc/top/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
proto.make
|
||||||
|
refs.top
|
||||||
|
top.n
|
||||||
6
emtest/.distr
Normal file
6
emtest/.distr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Makefile
|
||||||
|
READ_ME
|
||||||
|
ok
|
||||||
|
select.c
|
||||||
|
test.h
|
||||||
|
tests
|
||||||
7
etc/.distr
Normal file
7
etc/.distr
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
proto.make
|
||||||
|
em_table
|
||||||
|
new_table
|
||||||
|
new_table_done
|
||||||
|
pop_push
|
||||||
|
traps
|
||||||
|
ip_spec.t
|
||||||
10
examples/.distr
Normal file
10
examples/.distr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
hilo.b
|
||||||
|
hilo.c
|
||||||
|
hilo.mod
|
||||||
|
hilo.ocm
|
||||||
|
hilo.p
|
||||||
|
mandelbrot.c
|
||||||
|
paranoia.c
|
||||||
|
startrek.c
|
||||||
|
startrek.doc
|
||||||
|
README
|
||||||
@ -1,44 +0,0 @@
|
|||||||
include("plat/build.lua")
|
|
||||||
|
|
||||||
local conly = {
|
|
||||||
rpi = true
|
|
||||||
}
|
|
||||||
|
|
||||||
local sourcefiles = filenamesof(
|
|
||||||
"./hilo.b",
|
|
||||||
"./hilo.c",
|
|
||||||
"./hilo.mod",
|
|
||||||
"./hilo.p",
|
|
||||||
"./mandelbrot.c",
|
|
||||||
"./paranoia.c",
|
|
||||||
"./startrek.c"
|
|
||||||
)
|
|
||||||
|
|
||||||
local installmap = {}
|
|
||||||
for _, file in ipairs(sourcefiles) do
|
|
||||||
local b = basename(file)
|
|
||||||
local be = replace(b, "%.", "_")
|
|
||||||
local _, _, e = b:find("%.(%w*)$")
|
|
||||||
|
|
||||||
for _, plat in ipairs(vars.plats) do
|
|
||||||
if (e == "c") or not conly[plat] then
|
|
||||||
local exe = ackprogram {
|
|
||||||
name = be.."_"..plat,
|
|
||||||
srcs = { file },
|
|
||||||
vars = {
|
|
||||||
plat = plat,
|
|
||||||
lang = e,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
installmap["$(PLATIND)/examples/"..be.."."..plat] = exe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
installmap["$(PLATIND)/examples/"..b] = file
|
|
||||||
end
|
|
||||||
|
|
||||||
installable {
|
|
||||||
name = "pkg",
|
|
||||||
map = installmap
|
|
||||||
}
|
|
||||||
|
|
||||||
6
fast/.distr
Normal file
6
fast/.distr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Action
|
||||||
|
driver
|
||||||
|
f_c.ansi
|
||||||
|
f_c
|
||||||
|
f_m2
|
||||||
|
f_pc
|
||||||
5
fast/driver/.distr
Normal file
5
fast/driver/.distr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
afcc.1
|
||||||
|
afm2.1
|
||||||
|
afpc.1
|
||||||
|
driver.c
|
||||||
|
proto.make
|
||||||
3
fast/f_c.ansi/.distr
Normal file
3
fast/f_c.ansi/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Parameters
|
||||||
|
proto.main
|
||||||
|
proto.make
|
||||||
3
fast/f_c/.distr
Normal file
3
fast/f_c/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Parameters
|
||||||
|
proto.main
|
||||||
|
proto.make
|
||||||
3
fast/f_m2/.distr
Normal file
3
fast/f_m2/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Parameters
|
||||||
|
proto.main
|
||||||
|
proto.make
|
||||||
3
fast/f_pc/.distr
Normal file
3
fast/f_pc/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Parameters
|
||||||
|
proto.main
|
||||||
|
proto.make
|
||||||
3
fcc/.distr
Normal file
3
fcc/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Action
|
||||||
|
cemcom
|
||||||
|
driver
|
||||||
4
fcc/cemcom/.distr
Normal file
4
fcc/cemcom/.distr
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Parameters.sun3
|
||||||
|
Parameters.vax4
|
||||||
|
proto.main
|
||||||
|
proto.make
|
||||||
3
fcc/driver/.distr
Normal file
3
fcc/driver/.distr
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fcc.1
|
||||||
|
fcc.c
|
||||||
|
proto.make
|
||||||
24
first/.distr
Normal file
24
first/.distr
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
ack.pm
|
||||||
|
ack-custom.pm
|
||||||
|
c.pm
|
||||||
|
llgen.pm
|
||||||
|
yacc.pm
|
||||||
|
|
||||||
|
#create_dir
|
||||||
|
#cp_dir
|
||||||
|
#em_path.h.src
|
||||||
|
#first
|
||||||
|
#get_answer
|
||||||
|
#get_makepars
|
||||||
|
#get_sys
|
||||||
|
#get_sysvax
|
||||||
|
#install_tail
|
||||||
|
#limit_enquire
|
||||||
|
#limit_impl
|
||||||
|
#lint_params
|
||||||
|
#local.h.src
|
||||||
|
#mk_config
|
||||||
|
#mk_makefile
|
||||||
|
#mk_target
|
||||||
|
#target_comp
|
||||||
|
#util_comp
|
||||||
21
first/ack-custom.pm
Normal file
21
first/ack-custom.pm
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
-- $Source$
|
||||||
|
-- $State$
|
||||||
|
|
||||||
|
-- Custom rules used by the ACK build process.
|
||||||
|
|
||||||
|
preprocess = simple {
|
||||||
|
class = "preprocess",
|
||||||
|
outputs = {"%U%-%I%"},
|
||||||
|
command = {
|
||||||
|
"cpp -I%HEADERDIR% %in% > %out[1]%"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Revision history
|
||||||
|
-- $Log$
|
||||||
|
-- Revision 1.2 2007-02-20 00:32:58 dtrg
|
||||||
|
-- Changed the 'preprocess' rule to use the system C preprocessor.
|
||||||
|
--
|
||||||
|
-- Revision 1.1 2006/07/22 00:49:48 dtrg
|
||||||
|
-- First version in CVS.
|
||||||
|
--
|
||||||
33
first/ack.pm
Normal file
33
first/ack.pm
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
-- $Source$
|
||||||
|
-- $State$
|
||||||
|
|
||||||
|
-- Provides rules for building things with the half-built ACK itself.
|
||||||
|
|
||||||
|
ACKBUILDFLAGS = {"-m%PLATFORM%", "%OPTIMISATION%"}
|
||||||
|
ACKDEFINES = EMPTY
|
||||||
|
ACKINCLUDES = EMPTY
|
||||||
|
|
||||||
|
ackfile = simple_with_clike_dependencies {
|
||||||
|
class = "ackfile",
|
||||||
|
CINCLUDES = {REDIRECT, "ACKINCLUDES"},
|
||||||
|
command = {
|
||||||
|
"%BINDIR%bin/ack %ACKBUILDFLAGS% %ACKINCLUDES:cincludes% %ACKDEFINES:cdefines% -c -o %out% %in%"
|
||||||
|
},
|
||||||
|
outputs = {"%U%-%I%.o"},
|
||||||
|
}
|
||||||
|
|
||||||
|
ackprogram = simple {
|
||||||
|
class = "ackprogram",
|
||||||
|
command = {
|
||||||
|
"%BINDIR%bin/ack %ACKBUILDFLAGS% -o %out% %in%"
|
||||||
|
},
|
||||||
|
outputs = {"%U%-%I%"},
|
||||||
|
}
|
||||||
|
|
||||||
|
acklibrary = simple {
|
||||||
|
class = "acklibrary",
|
||||||
|
command = {
|
||||||
|
"%RM% %out% && %BINDIR%bin/aal cr %out% %in%"
|
||||||
|
},
|
||||||
|
outputs = {"%U%-%I%.a"},
|
||||||
|
}
|
||||||
@ -1,916 +0,0 @@
|
|||||||
local posix = require("posix")
|
|
||||||
|
|
||||||
-- Targets:
|
|
||||||
--
|
|
||||||
-- {
|
|
||||||
-- fullname = full name of target
|
|
||||||
-- dir = target's build directory
|
|
||||||
-- outs = target's object files
|
|
||||||
-- is = { set of rule types which made the target }
|
|
||||||
-- }
|
|
||||||
|
|
||||||
local emitter = {}
|
|
||||||
local rules = {}
|
|
||||||
local targets = {}
|
|
||||||
local buildfiles = {}
|
|
||||||
local globals
|
|
||||||
local cwd = "."
|
|
||||||
local vars = {}
|
|
||||||
local parente = {}
|
|
||||||
local loadingstack = {}
|
|
||||||
|
|
||||||
-- Forward references
|
|
||||||
local loadtarget
|
|
||||||
|
|
||||||
local function print(...)
|
|
||||||
local function print_no_nl(list)
|
|
||||||
for _, s in ipairs(list) do
|
|
||||||
if (type(s) == "table") then
|
|
||||||
io.stderr:write("{")
|
|
||||||
for k, v in pairs(s) do
|
|
||||||
print_no_nl({k})
|
|
||||||
io.stderr:write("=")
|
|
||||||
print_no_nl({v})
|
|
||||||
io.stderr:write(" ")
|
|
||||||
end
|
|
||||||
io.stderr:write("}")
|
|
||||||
else
|
|
||||||
io.stderr:write(tostring(s))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
print_no_nl({...})
|
|
||||||
io.stderr:write("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function assertString(s, i)
|
|
||||||
if (type(s) ~= "string") then
|
|
||||||
error(string.format("parameter %d must be a string", i))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function concat(...)
|
|
||||||
local r = {}
|
|
||||||
|
|
||||||
local function process(list)
|
|
||||||
for _, t in ipairs(list) do
|
|
||||||
if (type(t) == "table") and not t.is then
|
|
||||||
process(t)
|
|
||||||
else
|
|
||||||
r[#r+1] = t
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
process({...})
|
|
||||||
|
|
||||||
return r
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Test table membership (crudely).
|
|
||||||
local function contains(needle, haystack)
|
|
||||||
for _, k in ipairs(haystack) do
|
|
||||||
if (k == needle) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function inherit(high, low)
|
|
||||||
local o = {}
|
|
||||||
setmetatable(o, {
|
|
||||||
__index = function(self, k)
|
|
||||||
local x = high[k]
|
|
||||||
if x then
|
|
||||||
return x
|
|
||||||
end
|
|
||||||
return low[k]
|
|
||||||
end
|
|
||||||
})
|
|
||||||
for k, v in pairs(high) do
|
|
||||||
local _, _, kk = k:find("^%+(.*)$")
|
|
||||||
if kk then
|
|
||||||
o[kk] = concat(low[kk], v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return o
|
|
||||||
end
|
|
||||||
|
|
||||||
local function asstring(o)
|
|
||||||
local t = type(o)
|
|
||||||
if (t == "nil") then
|
|
||||||
return ""
|
|
||||||
elseif (t == "string") then
|
|
||||||
return o
|
|
||||||
elseif (t == "number") then
|
|
||||||
return o
|
|
||||||
elseif (t == "table") then
|
|
||||||
if o.is then
|
|
||||||
return asstring(o.outs)
|
|
||||||
else
|
|
||||||
local s = {}
|
|
||||||
for _, v in pairs(o) do
|
|
||||||
s[#s+1] = asstring(v)
|
|
||||||
end
|
|
||||||
return table.concat(s, " ")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error(string.format("can't turn values of type '%s' into strings", t))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function concatpath(...)
|
|
||||||
local p = table.concat({...}, "/")
|
|
||||||
return (p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/"))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Returns a list of the targets within the given collection; the keys of any
|
|
||||||
-- keyed items are lost. Lists and wildcards are expanded.
|
|
||||||
local function targetsof(...)
|
|
||||||
local o = {}
|
|
||||||
|
|
||||||
local function process(items)
|
|
||||||
for _, item in pairs(items) do
|
|
||||||
if (type(item) == "table") then
|
|
||||||
if item.is then
|
|
||||||
-- This is a target.
|
|
||||||
o[#o+1] = item
|
|
||||||
else
|
|
||||||
-- This is a list.
|
|
||||||
process(item)
|
|
||||||
end
|
|
||||||
elseif (type(item) == "string") then
|
|
||||||
-- Filename!
|
|
||||||
if item:find("^%+") then
|
|
||||||
item = cwd..item
|
|
||||||
elseif item:find("^%./") then
|
|
||||||
item = concatpath(cwd, item)
|
|
||||||
end
|
|
||||||
o[#o+1] = loadtarget(item)
|
|
||||||
else
|
|
||||||
error(string.format("member of target list is not a string or a target"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
process({...})
|
|
||||||
return o
|
|
||||||
end
|
|
||||||
|
|
||||||
local function filenamesof(...)
|
|
||||||
local targets = targetsof(...)
|
|
||||||
|
|
||||||
local f = {}
|
|
||||||
for _, r in ipairs(targets) do
|
|
||||||
if (type(r) == "table") and r.is then
|
|
||||||
if r.outs then
|
|
||||||
for _, o in ipairs(r.outs) do
|
|
||||||
f[#f+1] = o
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif (type(r) == "string") then
|
|
||||||
f[#f+1] = r
|
|
||||||
else
|
|
||||||
error(string.format("list of targets contains a %s which isn't a target",
|
|
||||||
type(r)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return f
|
|
||||||
end
|
|
||||||
|
|
||||||
local function targetnamesof(...)
|
|
||||||
local targets = targetsof(...)
|
|
||||||
|
|
||||||
local f
|
|
||||||
for _, r in pairs(targets) do
|
|
||||||
if (type(r) == "table") and r.is then
|
|
||||||
f[#f+1] = r.fullname
|
|
||||||
elseif (type(r) == "string") then
|
|
||||||
f[#f+1] = r
|
|
||||||
else
|
|
||||||
error(string.format("list of targets contains a %s which isn't a target",
|
|
||||||
type(r)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return f
|
|
||||||
end
|
|
||||||
|
|
||||||
local function dotocollection(files, callback)
|
|
||||||
if (#files == 1) and (type(files[1]) == "string") then
|
|
||||||
return callback(files[1])
|
|
||||||
end
|
|
||||||
|
|
||||||
local o = {}
|
|
||||||
local function process(files)
|
|
||||||
for _, s in ipairs(files) do
|
|
||||||
if (type(s) == "table") then
|
|
||||||
if s.is then
|
|
||||||
error("passed target to a filename manipulation function")
|
|
||||||
else
|
|
||||||
process(s)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local b = callback(s)
|
|
||||||
if (b ~= "") then
|
|
||||||
o[#o+1] = b
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
process(files)
|
|
||||||
return o
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function abspath(...)
|
|
||||||
return dotocollection({...},
|
|
||||||
function(filename)
|
|
||||||
assertString(filename, 1)
|
|
||||||
if not filename:find("^[/$]") then
|
|
||||||
filename = concatpath(posix.getcwd(), filename)
|
|
||||||
end
|
|
||||||
return filename
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function basename(...)
|
|
||||||
return dotocollection({...},
|
|
||||||
function(filename)
|
|
||||||
assertString(filename, 1)
|
|
||||||
local _, _, b = filename:find("^.*/([^/]*)$")
|
|
||||||
if not b then
|
|
||||||
return filename
|
|
||||||
end
|
|
||||||
return b
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function dirname(...)
|
|
||||||
return dotocollection({...},
|
|
||||||
function(filename)
|
|
||||||
assertString(filename, 1)
|
|
||||||
local _, _, b = filename:find("^(.*)/[^/]*$")
|
|
||||||
if not b then
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
return b
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function replace(files, pattern, repl)
|
|
||||||
return dotocollection({files},
|
|
||||||
function(filename)
|
|
||||||
return filename:gsub(pattern, repl)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function fpairs(...)
|
|
||||||
return ipairs(filenamesof(...))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function matching(collection, pattern)
|
|
||||||
local o = {}
|
|
||||||
dotocollection(collection,
|
|
||||||
function(filename)
|
|
||||||
if filename:find(pattern) then
|
|
||||||
o[#o+1] = filename
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
return o
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Selects all targets containing at least one output file that matches
|
|
||||||
-- the pattern (or all, if the pattern is nil).
|
|
||||||
local function selectof(targets, pattern)
|
|
||||||
local targets = targetsof(targets)
|
|
||||||
local o = {}
|
|
||||||
for k, v in pairs(targets) do
|
|
||||||
if v.is and v.outs then
|
|
||||||
local matches = false
|
|
||||||
for _, f in pairs(v.outs) do
|
|
||||||
if f:find(pattern) then
|
|
||||||
matches = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if matches then
|
|
||||||
o[#o+1] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return o
|
|
||||||
end
|
|
||||||
|
|
||||||
local function uniquify(...)
|
|
||||||
local s = {}
|
|
||||||
return dotocollection({...},
|
|
||||||
function(filename)
|
|
||||||
if not s[filename] then
|
|
||||||
s[filename] = true
|
|
||||||
return filename
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function startswith(needle, haystack)
|
|
||||||
return haystack:sub(1, #needle) == needle
|
|
||||||
end
|
|
||||||
|
|
||||||
local function emit(...)
|
|
||||||
local n = select("#", ...)
|
|
||||||
local args = {...}
|
|
||||||
|
|
||||||
for i=1, n do
|
|
||||||
local s = asstring(args[i])
|
|
||||||
io.stdout:write(s)
|
|
||||||
if not s:find("\n$") then
|
|
||||||
io.stdout:write(" ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function templateexpand(list, vars)
|
|
||||||
vars = inherit(vars, globals)
|
|
||||||
|
|
||||||
local o = {}
|
|
||||||
for _, s in ipairs(list) do
|
|
||||||
o[#o+1] = s:gsub("%%%b{}",
|
|
||||||
function(expr)
|
|
||||||
expr = expr:sub(3, -2)
|
|
||||||
local chunk, e = loadstring("return ("..expr..")", expr)
|
|
||||||
if e then
|
|
||||||
error(string.format("error evaluating expression: %s", e))
|
|
||||||
end
|
|
||||||
setfenv(chunk, vars)
|
|
||||||
local value = chunk()
|
|
||||||
if (value == nil) then
|
|
||||||
error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr))
|
|
||||||
end
|
|
||||||
return asstring(value)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
return o
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadbuildfile(filename)
|
|
||||||
if contains(filename, loadingstack) then
|
|
||||||
error(string.format("build file cycle; '%s' refers to itself indirectly; stack is: %s %s",
|
|
||||||
filename, asstring(loadingstack), filename))
|
|
||||||
end
|
|
||||||
|
|
||||||
loadingstack[#loadingstack+1] = filename
|
|
||||||
if not buildfiles[filename] then
|
|
||||||
buildfiles[filename] = true
|
|
||||||
|
|
||||||
local fp, data, chunk, e
|
|
||||||
io.stderr:write("loading ", filename, "\n")
|
|
||||||
fp, e = io.open(filename)
|
|
||||||
if not e then
|
|
||||||
data, e = fp:read("*a")
|
|
||||||
fp:close()
|
|
||||||
if not e then
|
|
||||||
local thisglobals = {}
|
|
||||||
thisglobals._G = thisglobals
|
|
||||||
setmetatable(thisglobals, {__index = globals})
|
|
||||||
chunk, e = loadstring(data, "@"..filename)
|
|
||||||
if not e then
|
|
||||||
setfenv(chunk, thisglobals)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if e then
|
|
||||||
error(string.format("couldn't load '%s': %s", filename, e))
|
|
||||||
end
|
|
||||||
|
|
||||||
local oldcwd = cwd
|
|
||||||
cwd = dirname(filename)
|
|
||||||
chunk()
|
|
||||||
cwd = oldcwd
|
|
||||||
end
|
|
||||||
loadingstack[#loadingstack] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadbuildfilefor(filepart, targetpart)
|
|
||||||
local normalname = concatpath(filepart, "/build.lua")
|
|
||||||
if posix.access(normalname, "r") then
|
|
||||||
loadbuildfile(normalname)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local extendedname = concatpath(filepart, "/build-"..targetpart..".lua")
|
|
||||||
if posix.access(extendedname, "r") then
|
|
||||||
loadbuildfile(extendedname)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
error(string.format("could not access either '%s' or '%s'", normalname, extendedname))
|
|
||||||
end
|
|
||||||
|
|
||||||
loadtarget = function(targetname)
|
|
||||||
if targets[targetname] then
|
|
||||||
return targets[targetname]
|
|
||||||
end
|
|
||||||
|
|
||||||
local target
|
|
||||||
if not targetname:find("%+") then
|
|
||||||
local files
|
|
||||||
if targetname:find("[?*]") then
|
|
||||||
files = posix.glob(targetname)
|
|
||||||
if not files then
|
|
||||||
files = {}
|
|
||||||
end
|
|
||||||
else
|
|
||||||
files = {targetname}
|
|
||||||
end
|
|
||||||
|
|
||||||
target = {
|
|
||||||
outs = files,
|
|
||||||
is = {
|
|
||||||
__implicitfile = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
targets[targetname] = target
|
|
||||||
else
|
|
||||||
local _, _, filepart, targetpart = targetname:find("^([^+]*)%+([%w-_]+)$")
|
|
||||||
if not filepart or not targetpart then
|
|
||||||
error(string.format("malformed target name '%s'", targetname))
|
|
||||||
end
|
|
||||||
if (filepart == "") then
|
|
||||||
filepart = cwd
|
|
||||||
end
|
|
||||||
loadbuildfilefor(filepart, targetpart)
|
|
||||||
|
|
||||||
target = targets[targetname]
|
|
||||||
if not target then
|
|
||||||
error(string.format("build file '%s' contains no target '%s'",
|
|
||||||
filename, targetpart))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return target
|
|
||||||
end
|
|
||||||
|
|
||||||
local typeconverters = {
|
|
||||||
targets = function(propname, i)
|
|
||||||
if (type(i) == "string") then
|
|
||||||
i = {i}
|
|
||||||
elseif (type(i) ~= "table") then
|
|
||||||
error(string.format("property '%s' must be a target list", propname))
|
|
||||||
end
|
|
||||||
|
|
||||||
local m = {}
|
|
||||||
for k, v in pairs(i) do
|
|
||||||
local ts = targetsof(v)
|
|
||||||
if (type(k) == "number") then
|
|
||||||
for _, t in ipairs(ts) do
|
|
||||||
m[#m+1] = t
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if (#ts ~= 1) then
|
|
||||||
error(string.format("named target '%s' can only be assigned from a single target", k))
|
|
||||||
else
|
|
||||||
m[k] = ts[1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return m
|
|
||||||
end,
|
|
||||||
|
|
||||||
strings = function(propname, i)
|
|
||||||
if (type(i) == "string") then
|
|
||||||
i = {i}
|
|
||||||
elseif (type(i) ~= "table") then
|
|
||||||
error(string.format("property '%s' must be a string list", propname))
|
|
||||||
end
|
|
||||||
return concat(i)
|
|
||||||
end,
|
|
||||||
|
|
||||||
boolean = function(propname, i)
|
|
||||||
if (type(i) ~= "boolean") then
|
|
||||||
error(string.format("property '%s' must be a boolean", propname))
|
|
||||||
end
|
|
||||||
return i
|
|
||||||
end,
|
|
||||||
|
|
||||||
string = function(propname, i)
|
|
||||||
if (type(i) ~= "string") then
|
|
||||||
error(string.format("property '%s' must be a string", propname))
|
|
||||||
end
|
|
||||||
return i
|
|
||||||
end,
|
|
||||||
|
|
||||||
table = function(propname, i)
|
|
||||||
if (type(i) ~= "table") then
|
|
||||||
error(string.format("property '%s' must be a table", propname))
|
|
||||||
end
|
|
||||||
return i
|
|
||||||
end,
|
|
||||||
|
|
||||||
object = function(propname, i)
|
|
||||||
return i
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
local function definerule(rulename, types, cb)
|
|
||||||
if rulename and rules[rulename] then
|
|
||||||
error(string.format("rule '%s' is already defined", rulename))
|
|
||||||
end
|
|
||||||
|
|
||||||
types.name = { type="string" }
|
|
||||||
types.cwd = { type="string", optional=true }
|
|
||||||
types.vars = { type="table", default={} }
|
|
||||||
|
|
||||||
for propname, typespec in pairs(types) do
|
|
||||||
if not typeconverters[typespec.type] then
|
|
||||||
error(string.format("property '%s' has unrecognised type '%s'",
|
|
||||||
propname, typespec.type))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local rulecwd = cwd
|
|
||||||
local rule = function(e)
|
|
||||||
local definedprops = {}
|
|
||||||
for propname, _ in pairs(e) do
|
|
||||||
definedprops[propname] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local args = {}
|
|
||||||
for propname, typespec in pairs(types) do
|
|
||||||
if not e[propname] then
|
|
||||||
if not typespec.optional and (typespec.default == nil) then
|
|
||||||
error(string.format("missing mandatory property '%s'", propname))
|
|
||||||
end
|
|
||||||
|
|
||||||
args[propname] = typespec.default
|
|
||||||
else
|
|
||||||
args[propname] = typeconverters[typespec.type](propname, e[propname])
|
|
||||||
definedprops[propname] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local propname, _ = next(definedprops)
|
|
||||||
if propname then
|
|
||||||
error(string.format("don't know what to do with property '%s'", propname))
|
|
||||||
end
|
|
||||||
|
|
||||||
if not args.cwd then
|
|
||||||
args.cwd = cwd
|
|
||||||
end
|
|
||||||
args.fullname = args.cwd.."+"..args.name
|
|
||||||
|
|
||||||
local oldparente = parente
|
|
||||||
parente = args
|
|
||||||
args.vars = inherit(args.vars, oldparente.vars)
|
|
||||||
local result = cb(args) or {}
|
|
||||||
parente = oldparente
|
|
||||||
|
|
||||||
result.is = result.is or {}
|
|
||||||
if rulename then
|
|
||||||
result.is[rulename] = true
|
|
||||||
end
|
|
||||||
result.fullname = args.fullname
|
|
||||||
|
|
||||||
if targets[arg.fullname] and (targets[arg.fullname] ~= result) then
|
|
||||||
error(string.format("target '%s' is already defined", args.fullname))
|
|
||||||
end
|
|
||||||
targets[result.fullname] = result
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
if rulename then
|
|
||||||
if rules[rulename] then
|
|
||||||
error(string.format("rule '%s' is already defined", rulename))
|
|
||||||
end
|
|
||||||
rules[rulename] = rule
|
|
||||||
end
|
|
||||||
return rule
|
|
||||||
end
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- DEFAULT RULES --
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local function install_make_emitter()
|
|
||||||
emit("hide = @\n")
|
|
||||||
|
|
||||||
function emitter:var(name, value)
|
|
||||||
-- Don't let emit insert spaces.
|
|
||||||
emit(name.."="..value.."\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:rule(name, ins, outs)
|
|
||||||
if (#outs == 0) then
|
|
||||||
local n = name.."-IMAGINARY-OUT"
|
|
||||||
emit(".INTERMEDIATE:", n, "\n")
|
|
||||||
outs = {n}
|
|
||||||
end
|
|
||||||
|
|
||||||
local impl = name.."-IMPL"
|
|
||||||
emit(".INTERMEDIATE:", name, "\n")
|
|
||||||
emit(".INTERMEDIATE:", impl, "\n")
|
|
||||||
|
|
||||||
for i = 1, #outs do
|
|
||||||
emit(name..":", outs[i], "\n")
|
|
||||||
end
|
|
||||||
for i = 1, #outs do
|
|
||||||
emit(outs[i]..":", impl, ";\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, #ins do
|
|
||||||
emit(impl..":", ins[i], "\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
emit(impl..":", "\n")
|
|
||||||
local dirs = uniquify(dirname(outs))
|
|
||||||
if (#dirs > 0) then
|
|
||||||
emit("\t@mkdir -p", dirs, "\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:phony(name, ins, outs)
|
|
||||||
emit(".PHONY:", name, "\n")
|
|
||||||
self:rule(name, ins, outs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:label(...)
|
|
||||||
local s = table.concat({...}, " ")
|
|
||||||
emit("\t@echo", s, "\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:exec(commands)
|
|
||||||
for _, s in ipairs(commands) do
|
|
||||||
emit("\t$(hide)", s, "\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:endrule()
|
|
||||||
emit("\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function install_ninja_emitter()
|
|
||||||
emit("rule build\n")
|
|
||||||
emit(" command = $command\n")
|
|
||||||
emit("\n")
|
|
||||||
|
|
||||||
local function unmake(collection)
|
|
||||||
return dotocollection({collection},
|
|
||||||
function(s)
|
|
||||||
return s:gsub("%$%b()",
|
|
||||||
function(expr)
|
|
||||||
return "${"..expr:sub(3, -2).."}"
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:var(name, value)
|
|
||||||
-- Don't let emit insert spaces.
|
|
||||||
emit(name.."="..unmake(value).."\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:rule(name, ins, outs)
|
|
||||||
if (#outs == 0) then
|
|
||||||
emit("build", name, ": phony", unmake(ins), "\n")
|
|
||||||
else
|
|
||||||
emit("build", name, ": phony", unmake(outs), "\n")
|
|
||||||
emit("build", unmake(outs), ": build", unmake(ins), "\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:label(...)
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:exec(commands)
|
|
||||||
emit(" command =", table.concat(unmake(commands), " && "), "\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
function emitter:endrule()
|
|
||||||
emit("\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
definerule("simplerule",
|
|
||||||
{
|
|
||||||
ins = { type="targets" },
|
|
||||||
outs = { type="strings" },
|
|
||||||
deps = { type="targets", default={} },
|
|
||||||
label = { type="string", optional=true },
|
|
||||||
commands = { type="strings" },
|
|
||||||
vars = { type="table", default={} },
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
emitter:rule(e.fullname, filenamesof(e.ins, e.deps), e.outs)
|
|
||||||
emitter:label(e.fullname, " ", e.label or "")
|
|
||||||
|
|
||||||
local vars = inherit(e.vars, {
|
|
||||||
ins = filenamesof(e.ins),
|
|
||||||
outs = filenamesof(e.outs)
|
|
||||||
})
|
|
||||||
|
|
||||||
emitter:exec(templateexpand(e.commands, vars))
|
|
||||||
emitter:endrule()
|
|
||||||
|
|
||||||
return {
|
|
||||||
outs = e.outs
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
definerule("installable",
|
|
||||||
{
|
|
||||||
map = { type="targets", default={} },
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
local deps = {}
|
|
||||||
local commands = {}
|
|
||||||
local srcs = {}
|
|
||||||
local outs = {}
|
|
||||||
local dests = {}
|
|
||||||
for dest, src in pairs(e.map) do
|
|
||||||
if src.is.installable then
|
|
||||||
if (type(dest) ~= "number") then
|
|
||||||
error("can't specify a destination filename when installing an installable")
|
|
||||||
end
|
|
||||||
deps[#deps+1] = src.fullname
|
|
||||||
outs = concat(outs, filenamesof(src))
|
|
||||||
elseif (type(dest) == "number") then
|
|
||||||
error("only references to other installables can be missing a destination")
|
|
||||||
else
|
|
||||||
local f = filenamesof(src)
|
|
||||||
if (#f ~= 1) then
|
|
||||||
error("installable can only cope with targets emitting single files")
|
|
||||||
end
|
|
||||||
|
|
||||||
deps[#deps+1] = f
|
|
||||||
dests[#dests+1] = dest
|
|
||||||
outs[#outs+1] = dest
|
|
||||||
commands[#commands+1] = "cp "..f[1].." "..dest
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
emitter:rule(e.fullname, deps, dests)
|
|
||||||
emitter:label(e.fullname, " ", e.label or "")
|
|
||||||
if (#commands > 0) then
|
|
||||||
emitter:exec(commands)
|
|
||||||
end
|
|
||||||
emitter:endrule()
|
|
||||||
|
|
||||||
return {
|
|
||||||
outs = outs
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- MAIN PROGRAM --
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local function parse_arguments(argmap, arg)
|
|
||||||
local i = 1
|
|
||||||
local files = {}
|
|
||||||
|
|
||||||
local function unrecognisedarg(arg)
|
|
||||||
argmap[" unrecognised"](arg)
|
|
||||||
end
|
|
||||||
|
|
||||||
while (i <= #arg) do
|
|
||||||
local o = arg[i]
|
|
||||||
local op
|
|
||||||
|
|
||||||
if (o:byte(1) == 45) then
|
|
||||||
-- This is an option.
|
|
||||||
if (o:byte(2) == 45) then
|
|
||||||
-- ...with a -- prefix.
|
|
||||||
o = o:sub(3)
|
|
||||||
local fn = argmap[o]
|
|
||||||
if not fn then
|
|
||||||
unrecognisedarg("--"..o)
|
|
||||||
end
|
|
||||||
i = i + fn(arg[i+1], arg[i+2])
|
|
||||||
else
|
|
||||||
-- ...without a -- prefix.
|
|
||||||
local od = o:sub(2, 2)
|
|
||||||
local fn = argmap[od]
|
|
||||||
if not fn then
|
|
||||||
unrecognisedarg("-"..od)
|
|
||||||
end
|
|
||||||
op = o:sub(3)
|
|
||||||
if (op == "") then
|
|
||||||
i = i + fn(arg[i+1], arg[i+2])
|
|
||||||
else
|
|
||||||
fn(op)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
files[#files+1] = o
|
|
||||||
end
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
argmap[" files"](files)
|
|
||||||
end
|
|
||||||
|
|
||||||
globals = {
|
|
||||||
posix = posix,
|
|
||||||
|
|
||||||
abspath = abspath,
|
|
||||||
asstring = asstring,
|
|
||||||
basename = basename,
|
|
||||||
concat = concat,
|
|
||||||
concatpath = concatpath,
|
|
||||||
cwd = function() return cwd end,
|
|
||||||
definerule = definerule,
|
|
||||||
dirname = dirname,
|
|
||||||
emit = emit,
|
|
||||||
filenamesof = filenamesof,
|
|
||||||
fpairs = fpairs,
|
|
||||||
include = loadbuildfile,
|
|
||||||
inherit = inherit,
|
|
||||||
print = print,
|
|
||||||
replace = replace,
|
|
||||||
matching = matching,
|
|
||||||
selectof = selectof,
|
|
||||||
startswith = startswith,
|
|
||||||
uniquify = uniquify,
|
|
||||||
vars = vars,
|
|
||||||
}
|
|
||||||
setmetatable(globals,
|
|
||||||
{
|
|
||||||
__index = function(self, k)
|
|
||||||
local rule = rules[k]
|
|
||||||
if rule then
|
|
||||||
return rule
|
|
||||||
else
|
|
||||||
return _G[k]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
vars.cflags = {}
|
|
||||||
parente.vars = vars
|
|
||||||
|
|
||||||
setmetatable(_G,
|
|
||||||
{
|
|
||||||
__index = function(self, k)
|
|
||||||
local value = rawget(_G, k)
|
|
||||||
if not value then
|
|
||||||
error(string.format("access of undefined variable '%s'", k))
|
|
||||||
end
|
|
||||||
return value
|
|
||||||
end
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
do
|
|
||||||
local emitter_type = install_make_emitter
|
|
||||||
parse_arguments(
|
|
||||||
{
|
|
||||||
["make"] = function()
|
|
||||||
emitter_type = install_make_emitter
|
|
||||||
return 0
|
|
||||||
end,
|
|
||||||
|
|
||||||
["ninja"] = function()
|
|
||||||
emitter_type = install_ninja_emitter
|
|
||||||
return 0
|
|
||||||
end,
|
|
||||||
|
|
||||||
|
|
||||||
[" unrecognised"] = function(arg)
|
|
||||||
error(string.format("unrecognised argument '%s'", arg))
|
|
||||||
end,
|
|
||||||
|
|
||||||
[" files"] = function(files)
|
|
||||||
emitter_type()
|
|
||||||
|
|
||||||
for _, f in ipairs(files) do
|
|
||||||
local _, _, name, value = f:find("^([%w_]+)=(.*)$")
|
|
||||||
if name then
|
|
||||||
emitter:var(name, value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, f in ipairs(files) do
|
|
||||||
if not f:find("=") then
|
|
||||||
loadbuildfile(f)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{...}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
@ -1,351 +0,0 @@
|
|||||||
# ackbuilder
|
|
||||||
|
|
||||||
## What is it?
|
|
||||||
|
|
||||||
ackbuilder is a very small build tool inspired by [bazel](https://bazel.io/)
|
|
||||||
which uses either make or [ninja](https://ninja-build.org/) as a backend.
|
|
||||||
|
|
||||||
It supports fully parallelisable builds (in both make and ninja), as well as
|
|
||||||
hopefully-robust support for rules which generate more than one output file,
|
|
||||||
which is something make is very, very bad at.
|
|
||||||
|
|
||||||
It was written because the ACK is a really horribly complex thing to build and
|
|
||||||
there wasn't anything else. ackbuilder is pretty rough and ready but it does
|
|
||||||
sort of work. Be prepared for bugs.
|
|
||||||
|
|
||||||
This document is a very rapid brain dump of how the build file works. It
|
|
||||||
doesn't cover actually running the tool (because that bit's pretty nasty) ---
|
|
||||||
go look at the top level Makefile to see that for now.
|
|
||||||
|
|
||||||
## Basic concepts
|
|
||||||
|
|
||||||
Complete example, using the built-in C rules. This should be saved in a file
|
|
||||||
called `build.lua`:
|
|
||||||
|
|
||||||
cprogram {
|
|
||||||
name = 'prog',
|
|
||||||
srcs = { "./*.c" },
|
|
||||||
}
|
|
||||||
|
|
||||||
This defines a rule `prog` which, when built, compiles all the source files in
|
|
||||||
the same directory as the `build.lua` file into an executable.
|
|
||||||
|
|
||||||
Slightly more complex example:
|
|
||||||
|
|
||||||
clibrary {
|
|
||||||
name = "library",
|
|
||||||
srcs = { "./library.c" },
|
|
||||||
hdrs = { "./library.h" },
|
|
||||||
}
|
|
||||||
|
|
||||||
cprogram {
|
|
||||||
name = 'prog2',
|
|
||||||
srcs = { "./prog2.c" },
|
|
||||||
deps = { "+library" }
|
|
||||||
}
|
|
||||||
|
|
||||||
If we move the library into another directory, we can invoke it like this:
|
|
||||||
|
|
||||||
cprogram {
|
|
||||||
name = 'prog3',
|
|
||||||
srcs = { "./prog3.c" },
|
|
||||||
deps = { "path/to/library+library" }
|
|
||||||
}
|
|
||||||
|
|
||||||
* Targets starting with `./` are relative to **the current directory** (i.e.
|
|
||||||
the one the build file is in).
|
|
||||||
|
|
||||||
* Targets starting with a path are relative to the top directory of the
|
|
||||||
project.
|
|
||||||
|
|
||||||
* Targets containing a `+` refer to a named target in another build file. So,
|
|
||||||
on encountering the library in `prog3` above, ackbuilder will look for
|
|
||||||
`path/to/library/build.lua`, load it, and then try to find a target in it
|
|
||||||
called `library`.
|
|
||||||
|
|
||||||
**Warning**: files are interpreted from top to bottom; every time a target
|
|
||||||
referring to another build file is seen for the first time, that file is
|
|
||||||
interpreted then and there. You can't have circular dependencies (these are
|
|
||||||
caught and an error is generated). You can't refer to a target defined below
|
|
||||||
you in the same source file (these are not caught, and just won't be found).
|
|
||||||
|
|
||||||
Build files each get their own private global scope. If you randomly set a
|
|
||||||
variable, it won't be seen by other build files. (Use `vars` for that; see
|
|
||||||
below.) Build files are only loaded once.
|
|
||||||
|
|
||||||
The `cprogram` and `clibrary` rules, by the way, are sophisticated enough to
|
|
||||||
automatically handle library and header paths. The exported headers by the
|
|
||||||
library are automatically imported into the program.
|
|
||||||
|
|
||||||
## `simplerule` and `normalrule`
|
|
||||||
|
|
||||||
These are the building blocks out of which all other rules are made. If you
|
|
||||||
want to run your own programs, you will be using these.
|
|
||||||
|
|
||||||
`simplerule` is the simplest. You give it inputs, and outputs, and commands,
|
|
||||||
and it does it.
|
|
||||||
|
|
||||||
simplerule {
|
|
||||||
name = 'sorted-input',
|
|
||||||
ins = { './input.txt' },
|
|
||||||
outs = { './output.txt' },
|
|
||||||
commands = {
|
|
||||||
"sort < %{ins} > %{outs}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
In a command block, `%{...}` will evaluate the Lua expression between the
|
|
||||||
braces; various useful things are in scope, including the list of inputs and
|
|
||||||
outputs.
|
|
||||||
|
|
||||||
However, this ends up leaving the output file lying around in the project
|
|
||||||
directory, which we don't want, so we usually use `normalrule` instead.
|
|
||||||
(`normalrule` is not strictly part of the ackbuilder core; it's in the standard
|
|
||||||
library along with `cprogram` and `clibrary`.)
|
|
||||||
|
|
||||||
normalrule {
|
|
||||||
name = 'sorted-input',
|
|
||||||
ins = { './input.txt' },
|
|
||||||
outleaves = { 'output.txt' },
|
|
||||||
commands = {
|
|
||||||
"sort < %{ins} > %{outs}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Note `outleaves`; there is no `./`. This is a list of leaf filenames. The rule
|
|
||||||
will create a directory in the object tree and put the files specified in it,
|
|
||||||
somewhere; you don't care where. You can refer to the output file via the
|
|
||||||
target name, so:
|
|
||||||
|
|
||||||
normalrule {
|
|
||||||
name = 'reversed',
|
|
||||||
ins = { '+sorted-input' },
|
|
||||||
outleaves = { 'reversed.txt' },
|
|
||||||
commands = {
|
|
||||||
"rev < %{ins} > %{outs}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
One common use for this is to generate C header or source files.
|
|
||||||
|
|
||||||
normalrule {
|
|
||||||
name = 'reversed_h',
|
|
||||||
ins = { '+reversed' },
|
|
||||||
outleaves = { 'reversed.h' },
|
|
||||||
commands = {
|
|
||||||
'xxd -i %{ins} > %{outs}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cprogram {
|
|
||||||
name = 'prog',
|
|
||||||
srcs = { './*.c' },
|
|
||||||
deps = { '+reversed_h' }
|
|
||||||
}
|
|
||||||
|
|
||||||
Now you can refer to `reversed.h` in one of your C files and it'll just work
|
|
||||||
(`+reversed_h`'s output directory gets added to the include path
|
|
||||||
automatically).
|
|
||||||
|
|
||||||
## Defining your own rules
|
|
||||||
|
|
||||||
Like this:
|
|
||||||
|
|
||||||
definerule("sort",
|
|
||||||
{
|
|
||||||
srcs = { type="targets" },
|
|
||||||
},
|
|
||||||
function(e)
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
ins = e.srcs,
|
|
||||||
outleaves = { 'sorted.txt' },
|
|
||||||
commands = {
|
|
||||||
"sort < %{ins} > %{outs}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
sort {
|
|
||||||
name = 'sorted',
|
|
||||||
srcs = { './input.txt' }
|
|
||||||
}
|
|
||||||
|
|
||||||
You give `definerule()` the name of the rule you want to define, a description
|
|
||||||
of the properties the rule will take, and a callback that does the work.
|
|
||||||
|
|
||||||
You can do anything you like in the callback, including defining as many
|
|
||||||
targets as you like; but remember that all targets must have unique names, so
|
|
||||||
for any temporary files you probably want something like `name =
|
|
||||||
e.name.."/intermediate"` to ensure uniqueness.
|
|
||||||
|
|
||||||
The callback should end by returning an invocation of another rule, with `name
|
|
||||||
= e.name` as above.
|
|
||||||
|
|
||||||
Rules are defined whenever a build file containing them is seen. Letting this
|
|
||||||
happen automatically doesn't always work so you probably want to explicitly
|
|
||||||
include it:
|
|
||||||
|
|
||||||
include("foo/bar/baz/build.lua")
|
|
||||||
|
|
||||||
Rule properties are typed and can be specified to be required or optional (or
|
|
||||||
have a default value). If you try to invoke a rule with a property which isn't
|
|
||||||
declared, or missing a property which should be declared, you'll get an error.
|
|
||||||
|
|
||||||
definerule("sort",
|
|
||||||
{
|
|
||||||
srcs = { type="targets" },
|
|
||||||
numeric = { type="boolean", optional=true, default=false }
|
|
||||||
}
|
|
||||||
...omitted...
|
|
||||||
|
|
||||||
(The `optional=true` part can be omitted if you specify a default which isn't
|
|
||||||
`nil`.)
|
|
||||||
|
|
||||||
Types include:
|
|
||||||
|
|
||||||
* `targets`: the most common one. When the rule is invoked, ackbuilder will
|
|
||||||
resolve these for you so that when your callback fires, the property is a
|
|
||||||
flattened list of target objects.
|
|
||||||
|
|
||||||
* `strings`: a Lua table of strings. If the invoker supplies a single string
|
|
||||||
which isn't a table, it'll get wrapped in one.
|
|
||||||
|
|
||||||
* `string`: a string.
|
|
||||||
|
|
||||||
* `boolean`: a boolean (either `true` or `false`; nothing else is allowed).
|
|
||||||
|
|
||||||
* `table`: a Lua table.
|
|
||||||
|
|
||||||
* `object`: any Lua value.
|
|
||||||
|
|
||||||
## Target objects
|
|
||||||
|
|
||||||
When a rule callback is run, any targets it needs will be resolved into target
|
|
||||||
objects. These are Lua objects with assorted useful stuff in them.
|
|
||||||
|
|
||||||
* `object.is`: contains a set telling you which rules made the object. e.g.
|
|
||||||
`object.is.cprogram` is true if `object` was built with `cprogram`. Bear in
|
|
||||||
mind that `object.is.normalrule` is _also_ going to be true.
|
|
||||||
|
|
||||||
* `object.dir`: the object's build directory. Only exists if the object was
|
|
||||||
built with `normalrule`.
|
|
||||||
|
|
||||||
There are other properties (`fullname` and `outs`). Please don't use these; use
|
|
||||||
`targetnamesof()` and `filenamesof()` as described below.
|
|
||||||
|
|
||||||
## The standard library
|
|
||||||
|
|
||||||
Your build files are supplied a pile of useful functions.
|
|
||||||
|
|
||||||
### Manipulating target lists
|
|
||||||
|
|
||||||
A target list is a possibly nested set of tables containing either target
|
|
||||||
objects or strings. All of these functions will implicitly flatten the list and
|
|
||||||
resolve any strings into target objects before doing anything else to them.
|
|
||||||
Most of these functions can be supplied with varargs parameters.
|
|
||||||
|
|
||||||
e.g. `targetsof(a, b)` is equivalent to `targetsof({a, b})` is equivalent to
|
|
||||||
`targetsof({a, {b}})`.
|
|
||||||
|
|
||||||
* `targetsof(...)`: just flattens the list and resolves any string target
|
|
||||||
names.
|
|
||||||
|
|
||||||
* `filenamesof(...)`: returns a list of output files for all the supplied
|
|
||||||
targets.
|
|
||||||
|
|
||||||
* `targetnamesof(...)`: returns a list of fully qualified target names for
|
|
||||||
all the supplied stargets.
|
|
||||||
|
|
||||||
* `selectof(targets, pattern)`: returns only those targets whose outputs
|
|
||||||
contain at least one file matching the pattern.
|
|
||||||
|
|
||||||
### Manipulating filename lists
|
|
||||||
|
|
||||||
Like the target list functions, all of these implicitly flatten any nested
|
|
||||||
tables. They all return lists; however, as a special exception, if any of the
|
|
||||||
functions which take varargs parameters have a single parameter which is a
|
|
||||||
string, they return just a string.
|
|
||||||
|
|
||||||
e.g. `abspath({f})` returns a table; `abspath(f)` returns a string.
|
|
||||||
|
|
||||||
* `abspath(...)`: attempts to return the absolute path of its arguments. This
|
|
||||||
isn't always possible due to variable references.
|
|
||||||
|
|
||||||
* `basename(...)`: returns the basenames of its arguments (the file part of
|
|
||||||
the path).
|
|
||||||
|
|
||||||
* `dirname(...)`: returns the directory name of its arguments.
|
|
||||||
|
|
||||||
* `matching(files, pattern)`: returns only those files which match a Lua
|
|
||||||
pattern.
|
|
||||||
|
|
||||||
* `replace(files, pattern, repl)`: performs a Lua pattern replace on the list
|
|
||||||
of files.
|
|
||||||
|
|
||||||
* `uniquify(...)`: removes duplicates.
|
|
||||||
|
|
||||||
### Other things
|
|
||||||
|
|
||||||
* `include(file)`: loads another build file, if it hasn't been loaded before.
|
|
||||||
|
|
||||||
## Variables
|
|
||||||
|
|
||||||
There are two types of variable, mostly for hysterical reasons.
|
|
||||||
|
|
||||||
### Makefile variables
|
|
||||||
|
|
||||||
(Despite the name, these work on ninja too.)
|
|
||||||
|
|
||||||
Filenames can contain variable references of the form `$(FOO)`. These are
|
|
||||||
expanded at build time based on definitions supplied on the ackbuilder command
|
|
||||||
line.
|
|
||||||
|
|
||||||
ackbuilder assumes that these are absolute paths and won't attempt to
|
|
||||||
manipulate them much.
|
|
||||||
|
|
||||||
I want to get rid of these at some point.
|
|
||||||
|
|
||||||
### ackbuilder variables
|
|
||||||
|
|
||||||
These are expanded by ackbuilder itself.
|
|
||||||
|
|
||||||
Every rule invocation contains a magic property, `vars`. When a rule's commands
|
|
||||||
are executed, the variables provided in the template expansion are calculated
|
|
||||||
by combining all `vars` settings in the call stack (including the top level
|
|
||||||
build file).
|
|
||||||
|
|
||||||
Easiest to explain with an example:
|
|
||||||
|
|
||||||
cprogram {
|
|
||||||
name = 'another_test',
|
|
||||||
srcs = { './*.c' },
|
|
||||||
vars = {
|
|
||||||
cflags = { '-g', '-O3' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
When `cprogram` builds each C file, the command will refer to `%{cflags}`. The
|
|
||||||
value above will be flattened into a space-separated string and substituted in.
|
|
||||||
|
|
||||||
Setting a variable this way will _override_ any definition further up the call
|
|
||||||
stack. However, you can do this:
|
|
||||||
|
|
||||||
vars.cflags = { '-g' }
|
|
||||||
|
|
||||||
cprogram {
|
|
||||||
name = 'another_test',
|
|
||||||
srcs = { './*.c' },
|
|
||||||
vars = {
|
|
||||||
["+cflags"] = { '-O3' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Now `cflags` will default to `-g` everywhere, because it's set at the top
|
|
||||||
level; but when `another_test` is built, it'll be `-g -O3`.
|
|
||||||
|
|
||||||
ackbuilder variables are only expanded in command templates, not in filenames.
|
|
||||||
|
|
||||||
<!-- # vim: set ts=2 sw=2 expandtab : -->
|
|
||||||
|
|
||||||
257
first/build.lua
257
first/build.lua
@ -1,257 +0,0 @@
|
|||||||
local function objdir(e)
|
|
||||||
return concatpath("$(OBJDIR)", e.cwd, e.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
definerule("normalrule",
|
|
||||||
{
|
|
||||||
ins = { type="targets" },
|
|
||||||
deps = { type="targets", default={} },
|
|
||||||
outleaves = { type="strings" },
|
|
||||||
label = { type="string", optional=true },
|
|
||||||
objdir = { type="string", optional=true },
|
|
||||||
commands = { type="strings" },
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
local dir = e.objdir or objdir(e)
|
|
||||||
local realouts = {}
|
|
||||||
for _, v in pairs(e.outleaves) do
|
|
||||||
realouts[#realouts+1] = concatpath(dir, v)
|
|
||||||
end
|
|
||||||
|
|
||||||
local vars = inherit(e.vars, {
|
|
||||||
dir = dir
|
|
||||||
})
|
|
||||||
|
|
||||||
local result = simplerule {
|
|
||||||
name = e.name,
|
|
||||||
ins = e.ins,
|
|
||||||
deps = e.deps,
|
|
||||||
outs = realouts,
|
|
||||||
label = e.label,
|
|
||||||
commands = e.commands,
|
|
||||||
vars = vars,
|
|
||||||
}
|
|
||||||
result.dir = dir
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
definerule("cfile",
|
|
||||||
{
|
|
||||||
srcs = { type="targets" },
|
|
||||||
deps = { type="targets", default={} },
|
|
||||||
commands = {
|
|
||||||
type="strings",
|
|
||||||
default={
|
|
||||||
"$(CC) -c -o %{outs[1]} %{ins[1]} %{hdrpaths} %{cflags}"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
local hdrpaths = {}
|
|
||||||
for _, t in pairs(e.deps) do
|
|
||||||
if t.dir then
|
|
||||||
hdrpaths[#hdrpaths+1] = "-I"..t.dir
|
|
||||||
end
|
|
||||||
end
|
|
||||||
hdrpaths = uniquify(hdrpaths)
|
|
||||||
|
|
||||||
local outleaf = basename(e.name)..".o"
|
|
||||||
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
cwd = e.cwd,
|
|
||||||
ins = e.srcs,
|
|
||||||
deps = e.deps,
|
|
||||||
outleaves = {outleaf},
|
|
||||||
label = e.label,
|
|
||||||
commands = e.commands,
|
|
||||||
vars = {
|
|
||||||
hdrpaths = hdrpaths,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
definerule("cppfile",
|
|
||||||
{
|
|
||||||
srcs = { type="targets" },
|
|
||||||
deps = { type="targets", default={} },
|
|
||||||
outleaf = { type="string" },
|
|
||||||
commands = {
|
|
||||||
type="strings",
|
|
||||||
default={
|
|
||||||
"$(CC) -E -P -o %{outs[1]} %{hdrpaths} %{cflags} -x c %{ins}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
if (#e.srcs ~= 1) then
|
|
||||||
error("you must have exactly one input file")
|
|
||||||
end
|
|
||||||
|
|
||||||
local hdrpaths = {}
|
|
||||||
for _, t in pairs(e.deps) do
|
|
||||||
hdrpaths[#hdrpaths+1] = "-I"..t.dir
|
|
||||||
end
|
|
||||||
hdrpaths = uniquify(hdrpaths)
|
|
||||||
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
cwd = e.cwd,
|
|
||||||
ins = e.srcs,
|
|
||||||
deps = e.deps,
|
|
||||||
outleaves = {e.outleaf},
|
|
||||||
label = e.label,
|
|
||||||
commands = e.commands,
|
|
||||||
vars = {
|
|
||||||
hdrpaths = hdrpaths,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
definerule("bundle",
|
|
||||||
{
|
|
||||||
srcs = { type="targets" },
|
|
||||||
commands = {
|
|
||||||
type="strings",
|
|
||||||
default={
|
|
||||||
"tar cf - %{ins} | (cd %{dir} && tar xf -)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
local outleaves = {}
|
|
||||||
local commands = {}
|
|
||||||
for _, f in fpairs(e.srcs) do
|
|
||||||
local localf = basename(f)
|
|
||||||
outleaves[#outleaves+1] = localf
|
|
||||||
commands[#commands+1] = "cp "..f.." %{dir}/"..localf
|
|
||||||
end
|
|
||||||
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
cwd = e.cwd,
|
|
||||||
ins = e.srcs,
|
|
||||||
outleaves = outleaves,
|
|
||||||
label = e.label,
|
|
||||||
commands = commands
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
definerule("clibrary",
|
|
||||||
{
|
|
||||||
srcs = { type="targets", default={} },
|
|
||||||
hdrs = { type="targets", default={} },
|
|
||||||
deps = { type="targets", default={} },
|
|
||||||
_cfile = { type="object", default=cfile },
|
|
||||||
commands = {
|
|
||||||
type="strings",
|
|
||||||
default={
|
|
||||||
"rm -f %{outs[1]}",
|
|
||||||
"$(AR) cqs %{outs[1]} %{ins}",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
local ins = {}
|
|
||||||
for _, src in fpairs(e.srcs) do
|
|
||||||
local n = basename(src):gsub("%.%w*$", "")
|
|
||||||
ins[#ins+1] = e._cfile {
|
|
||||||
name = e.name.."/"..n,
|
|
||||||
cwd = e.cwd,
|
|
||||||
srcs = {src},
|
|
||||||
deps = e.deps,
|
|
||||||
vars = {
|
|
||||||
["+cflags"] = { "-I"..e.cwd, },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local commands = {}
|
|
||||||
local outleaves = {}
|
|
||||||
if (#e.srcs > 0) then
|
|
||||||
for _, s in ipairs(e.commands) do
|
|
||||||
commands[#commands+1] = s
|
|
||||||
end
|
|
||||||
outleaves[#outleaves+1] = e.name..".a"
|
|
||||||
end
|
|
||||||
|
|
||||||
local hdrsin = {}
|
|
||||||
for dest, src in pairs(e.hdrs) do
|
|
||||||
if (type(dest) == "number") then
|
|
||||||
for _, f in ipairs(filenamesof(src)) do
|
|
||||||
hdrsin[#hdrsin+1] = f
|
|
||||||
outleaves[#outleaves+1] = basename(f)
|
|
||||||
commands[#commands+1] = "cp "..asstring(f).." %{dir}"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local fs = filenamesof(src)
|
|
||||||
if (#fs ~= 1) then
|
|
||||||
error(string.format("keyed header '%s' can only be a single file", dest))
|
|
||||||
end
|
|
||||||
local f = fs[1]
|
|
||||||
|
|
||||||
hdrsin[#hdrsin+1] = f
|
|
||||||
outleaves[#outleaves+1] = dest
|
|
||||||
commands[#commands+1] = "cp "..asstring(f).." %{dir}/"..dest
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
cwd = e.cwd,
|
|
||||||
ins = ins,
|
|
||||||
deps = {hdrsin, e.deps},
|
|
||||||
outleaves = outleaves,
|
|
||||||
label = e.label,
|
|
||||||
commands = commands,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
definerule("cprogram",
|
|
||||||
{
|
|
||||||
srcs = { type="targets", default={} },
|
|
||||||
deps = { type="targets", default={} },
|
|
||||||
_clibrary = { type="object", default=clibrary },
|
|
||||||
commands = {
|
|
||||||
type="strings",
|
|
||||||
default={
|
|
||||||
"$(CC) -o %{outs[1]} -Wl,--start-group %{ins} -Wl,--end-group"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
local libs = matching(filenamesof(e.deps), "%.a$")
|
|
||||||
if (#e.srcs > 0) then
|
|
||||||
for _, f in pairs(
|
|
||||||
matching(
|
|
||||||
filenamesof(
|
|
||||||
e._clibrary {
|
|
||||||
name = e.name .. "/main",
|
|
||||||
cwd = e.cwd,
|
|
||||||
srcs = e.srcs,
|
|
||||||
deps = e.deps,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"%.a$"
|
|
||||||
)
|
|
||||||
) do
|
|
||||||
libs[#libs+1] = f
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
cwd = e.cwd,
|
|
||||||
deps = e.deps,
|
|
||||||
ins = libs,
|
|
||||||
outleaves = { e.name },
|
|
||||||
commands = e.commands,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
238
first/c.pm
Normal file
238
first/c.pm
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
-- $Id$
|
||||||
|
-- $HeadURL: https://primemover.svn.sf.net/svnroot/primemover/pm/lib/c.pm $
|
||||||
|
-- $LastChangedDate: 2007-02-24 01:37:06 +0000 (Sat, 24 Feb 2007) $
|
||||||
|
|
||||||
|
-- pm includefile to compile *host* C programs.
|
||||||
|
|
||||||
|
-- Standard Lua boilerplate.
|
||||||
|
|
||||||
|
local io_open = io.open
|
||||||
|
local string_gsub = string.gsub
|
||||||
|
local string_gfind = string.gfind
|
||||||
|
local string_find = string.find
|
||||||
|
local table_insert = table.insert
|
||||||
|
local table_getn = table.getn
|
||||||
|
local filetime = pm.filetime
|
||||||
|
|
||||||
|
-- Define some variables.
|
||||||
|
|
||||||
|
CCOMPILER = "gcc"
|
||||||
|
CXXCOMPILER = "g++"
|
||||||
|
CC = "%CCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES:cincludes% %CINCLUDES:cincludes% %CDEFINES:cdefines% %CEXTRAFLAGS% -c -o %out% %in%"
|
||||||
|
CXX = "%CXXCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES:cincludes% %CINCLUDES:cincludes% %CDEFINES:cdefines% %CEXTRAFLAGS% -c -o %out% %in%"
|
||||||
|
CPROGRAM = "%CCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %in% %CLIBRARIES:clibraries%"
|
||||||
|
CXXPROGRAM = "%CXXCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %in% %CLIBRARIES:clibraries%"
|
||||||
|
|
||||||
|
CLIBRARY = "rm -f %out% && ar cr %out% %in% && ranlib %out%"
|
||||||
|
|
||||||
|
CBUILDFLAGS = {"-g", "-Werror", "-std=c89"}
|
||||||
|
CINCLUDES = EMPTY
|
||||||
|
CDEFINES = EMPTY
|
||||||
|
CEXTRAFLAGS = EMPTY
|
||||||
|
CLINKFLAGS = EMPTY
|
||||||
|
CDYNINCLUDES = EMPTY
|
||||||
|
CLIBRARIES = EMPTY
|
||||||
|
|
||||||
|
--- Custom string modifiers -------------------------------------------------
|
||||||
|
|
||||||
|
local function prepend(rule, arg, prefix)
|
||||||
|
if (arg == EMPTY) then
|
||||||
|
return EMPTY
|
||||||
|
end
|
||||||
|
|
||||||
|
local t = {}
|
||||||
|
for i, j in ipairs(arg) do
|
||||||
|
t[i] = prefix..j
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
function pm.stringmodifier.cincludes(rule, arg)
|
||||||
|
return prepend(rule, arg, "-I")
|
||||||
|
end
|
||||||
|
|
||||||
|
function pm.stringmodifier.cdefines(rule, arg)
|
||||||
|
return prepend(rule, arg, "-D")
|
||||||
|
end
|
||||||
|
|
||||||
|
function pm.stringmodifier.clibraries(rule, arg)
|
||||||
|
if (arg == EMPTY) then
|
||||||
|
return EMPTY
|
||||||
|
end
|
||||||
|
|
||||||
|
local t = {}
|
||||||
|
for i, j in ipairs(arg) do
|
||||||
|
if string_find(j, "%.a$") then
|
||||||
|
t[i] = j
|
||||||
|
else
|
||||||
|
t[i] = "-l"..j
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Manage C file dependencies ----------------------------------------------
|
||||||
|
|
||||||
|
local dependency_cache = {}
|
||||||
|
local function calculate_dependencies(filename, includes)
|
||||||
|
-- Cache values, so we don't recalculate dependencies needlessly.
|
||||||
|
|
||||||
|
local o = dependency_cache[filename]
|
||||||
|
if o then
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
|
||||||
|
local deps = {}
|
||||||
|
deps[filename] = true
|
||||||
|
|
||||||
|
local calcdeps = 0
|
||||||
|
calcdeps = function(filename, file)
|
||||||
|
file = file or io_open(filename)
|
||||||
|
if not file then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local localincludes = string_gsub(filename, "/[^/]*$", "")
|
||||||
|
if localincludes then
|
||||||
|
localincludes = {localincludes, unpack(includes)}
|
||||||
|
else
|
||||||
|
localincludes = includes
|
||||||
|
end
|
||||||
|
|
||||||
|
for line in file:lines() do
|
||||||
|
local _, _, f = string_find(line, '^[ \t]*#[ \t]*include[ \t]*["<]([^"]+)[">]')
|
||||||
|
if f then
|
||||||
|
for _, path in ipairs(localincludes) do
|
||||||
|
local subfilename = path.."/"..f
|
||||||
|
local subfile = io_open(subfilename)
|
||||||
|
if subfile then
|
||||||
|
if not deps[subfilename] then
|
||||||
|
deps[subfilename] = true
|
||||||
|
calcdeps(subfilename, subfile)
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Explicit close to avoid having to wait for the garbage collector
|
||||||
|
-- to free up the underlying fd.
|
||||||
|
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
calcdeps(filename)
|
||||||
|
o = {}
|
||||||
|
for i, _ in pairs(deps) do
|
||||||
|
table_insert(o, i)
|
||||||
|
end
|
||||||
|
|
||||||
|
dependency_cache[filename] = o
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This clause specialises 'simple' to add support for smart dependencies of C
|
||||||
|
-- files.
|
||||||
|
|
||||||
|
simple_with_clike_dependencies = simple {
|
||||||
|
class = "simple_with_clike_dependencies",
|
||||||
|
makedepends = {"%CDEPENDS%"},
|
||||||
|
|
||||||
|
__init = function(self, p)
|
||||||
|
simple.__init(self, p)
|
||||||
|
|
||||||
|
-- If we're a class, don't verify.
|
||||||
|
|
||||||
|
if ((type(p) == "table") and p.class) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If dynamicheaders is an object, turn it into a singleton list.
|
||||||
|
|
||||||
|
if self.dynamicheaders then
|
||||||
|
if (type(self.dynamicheaders) ~= "table") then
|
||||||
|
self:__error("doesn't know what to do with dynamicheaders, which ",
|
||||||
|
"should be a list or an object but was a ", type(self.dynamicheaders))
|
||||||
|
end
|
||||||
|
if self.dynamicheaders.class then
|
||||||
|
self.dynamicheaders = {self.dynamicheaders}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
__dependencies = function(self, inputs, outputs)
|
||||||
|
local cincludes = self:__index("CINCLUDES")
|
||||||
|
if (type(cincludes) == "string") then
|
||||||
|
cincludes = {cincludes}
|
||||||
|
end
|
||||||
|
|
||||||
|
local includes = {}
|
||||||
|
for _, i in ipairs(cincludes) do
|
||||||
|
table_insert(includes, self:__expand(i))
|
||||||
|
end
|
||||||
|
|
||||||
|
local input = self:__expand(inputs[1])
|
||||||
|
local depends = calculate_dependencies(input, includes)
|
||||||
|
if not depends then
|
||||||
|
self:__error("could not determine the dependencies for ",
|
||||||
|
pm.rendertable({input}))
|
||||||
|
end
|
||||||
|
if pm.verbose then
|
||||||
|
pm.message('"', input, '" appears to depend on ',
|
||||||
|
pm.rendertable(depends))
|
||||||
|
end
|
||||||
|
return depends
|
||||||
|
end,
|
||||||
|
|
||||||
|
__buildadditionalchildren = function(self)
|
||||||
|
self.CDYNINCLUDES = {}
|
||||||
|
if self.dynamicheaders then
|
||||||
|
for _, i in ipairs(self.dynamicheaders) do
|
||||||
|
local o = i:__build()
|
||||||
|
if o[1] then
|
||||||
|
table_insert(self.CDYNINCLUDES, (string_gsub(o[1], "/[^/]*$", "")))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- If no paths on the list, replace the list with EMPTY so it doesn't
|
||||||
|
-- expand to anything.
|
||||||
|
if (table_getn(self.CDYNINCLUDES) == 0) then
|
||||||
|
self.CDYNINCLUDES = EMPTY
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
-- These are the publically useful clauses.
|
||||||
|
|
||||||
|
cfile = simple_with_clike_dependencies {
|
||||||
|
class = "cfile",
|
||||||
|
command = {"%CC%"},
|
||||||
|
outputs = {"%U%-%I%.o"},
|
||||||
|
}
|
||||||
|
|
||||||
|
cxxfile = simple_with_clike_dependencies {
|
||||||
|
class = "cxxfile",
|
||||||
|
command = {"%CXX%"},
|
||||||
|
outputs = {"%U%-%I%.o"},
|
||||||
|
}
|
||||||
|
|
||||||
|
cprogram = simple {
|
||||||
|
class = "cprogram",
|
||||||
|
command = {"%CPROGRAM%"},
|
||||||
|
outputs = {"%U%-%I%"},
|
||||||
|
}
|
||||||
|
|
||||||
|
cxxprogram = simple {
|
||||||
|
class = "cxxprogram",
|
||||||
|
command = {"%CXXPROGRAM%"},
|
||||||
|
outputs = {"%U%-%I%"},
|
||||||
|
}
|
||||||
|
|
||||||
|
clibrary = simple {
|
||||||
|
class = "clibrary",
|
||||||
|
command = {
|
||||||
|
"%CLIBRARY%"
|
||||||
|
},
|
||||||
|
outputs = {"%U%-%I%.a"},
|
||||||
|
}
|
||||||
18
first/cp_dir
Executable file
18
first/cp_dir
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
trap "rm -f /tmp/xx$$" 0 1 2 3 15
|
||||||
|
case $2 in
|
||||||
|
/*) target_dir=$2
|
||||||
|
;;
|
||||||
|
*) target_dir=`pwd`/$2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
cd $1
|
||||||
|
tar cf /tmp/xx$$ .
|
||||||
|
if [ -d $target_dir ]
|
||||||
|
then :
|
||||||
|
else mkdir $target_dir
|
||||||
|
fi
|
||||||
|
cd $target_dir
|
||||||
|
tar xf /tmp/xx$$
|
||||||
13
first/create_dir
Executable file
13
first/create_dir
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if ( cd $1 ) 2>/dev/null
|
||||||
|
then
|
||||||
|
:
|
||||||
|
elif mkdir $1 2>/dev/null
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo $0: could not create directory $1 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
11
first/em_path.h.src
Normal file
11
first/em_path.h.src
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
/*
|
||||||
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
|
*/
|
||||||
|
/* Intended as a common directory for ALL temporary files */
|
||||||
|
#define TMP_DIR "/tmp"
|
||||||
|
|
||||||
|
/* Access to the ACK tree and parts thereof */
|
||||||
|
#define EM_DIR "/usr/em" /* The root directory for EM stuff */
|
||||||
|
#define ACK_PATH "lib/descr"
|
||||||
208
first/first
Executable file
208
first/first
Executable file
@ -0,0 +1,208 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
case $0 in
|
||||||
|
*/first)
|
||||||
|
FDIR=`expr $0 : '\(.*\)/first'`
|
||||||
|
;;
|
||||||
|
first) FDIR=.
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if echo 'a\c' | grep 'c' >/dev/null ; then
|
||||||
|
: We have BSD-like echo command.
|
||||||
|
E_FLAG='-n'
|
||||||
|
E_SFX=''
|
||||||
|
else
|
||||||
|
: We have SystemV-like echo command.
|
||||||
|
E_FLAG=''
|
||||||
|
E_SFX='\c'
|
||||||
|
fi
|
||||||
|
export E_FLAG E_SFX
|
||||||
|
|
||||||
|
echo check write-ability of /tmp ...
|
||||||
|
if ( >/tmp/aaax.$$ )
|
||||||
|
then
|
||||||
|
rm /tmp/aaax.$$
|
||||||
|
else
|
||||||
|
echo /tmp must exist and be writable.
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
echo "/tmp ok"
|
||||||
|
|
||||||
|
if [ -f macros ]
|
||||||
|
then
|
||||||
|
. macros
|
||||||
|
fi
|
||||||
|
|
||||||
|
: "Now get system name and directories"
|
||||||
|
. $FDIR/get_sys
|
||||||
|
|
||||||
|
: "Take action according to the system used"
|
||||||
|
BM=1
|
||||||
|
OLDACM=$ACM
|
||||||
|
OLDSYS=$SYS
|
||||||
|
case $SYSNAME in
|
||||||
|
vax_bsd4_1a) ACM=vax4 ; SYS=BSD4_1 ; BYTE_ORDER=0123 ; MACH=vax4 ;;
|
||||||
|
vax_bsd4_2) ACM=vax4 ; SYS=BSD4_2 ; BYTE_ORDER=0123 ; MACH=vax4 ;;
|
||||||
|
vax_sysV_2) ACM=vax4 ; SYS=SYS_5 ; BYTE_ORDER=0123 ; MACH=vax4 ;;
|
||||||
|
i386) ACM=i386 ; SYS=SYS_5 ; BYTE_ORDER=0123 ; MACH=i386 ;;
|
||||||
|
sun3) ACM=sun3 ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=m68020 ;;
|
||||||
|
sun2) ACM=sun2 ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=m68k4 ;;
|
||||||
|
m68_unisoft|m68k2) ACM=m68k2 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;;
|
||||||
|
m68_sysV_0|mantra) ACM=mantra ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=m68k4 ;;
|
||||||
|
m68020) ACM=m68020 ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=m68020 ;;
|
||||||
|
sparc) ACM=sparc ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=sparc ;;
|
||||||
|
sparc_solaris) ACM=sparc_solaris ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=sparc_solaris ;;
|
||||||
|
i86) ACM=i86 ; SYS=SYS_5; BYTE_ORDER=0123 ; MACH=i86 ;;
|
||||||
|
xenix3) ACM=xenix3 ; SYS=SYS_5; BYTE_ORDER=0123 ; MACH=i86 ;;
|
||||||
|
minix) ACM=minix ; SYS=V7; BYTE_ORDER=0123 ; MACH=i86 ;;
|
||||||
|
pmds) ACM=pmds ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;;
|
||||||
|
pmds4) ACM=pmds4 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k4 ;;
|
||||||
|
minixST) ACM=minixST ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;;
|
||||||
|
m68k4) ACM=m68k4 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k4 ;;
|
||||||
|
*) ACM=XXX ; SYS=XXX ; BYTE_ORDER=XXX ; MACH=XXX ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
: do not change the order in MACH_LIST. check limit_enquire first.
|
||||||
|
MACH_LIST="i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z80 z8000 arm"
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
for i in $MACH_LIST
|
||||||
|
do
|
||||||
|
if [ $i = "$ACM" ]
|
||||||
|
then break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $i = "$ACM" ]
|
||||||
|
then break
|
||||||
|
fi
|
||||||
|
echo "This installation script has no knowledge about $SYSNAME.
|
||||||
|
You will have to specify the default machine that you want ACK to
|
||||||
|
compile for. Choices:"
|
||||||
|
l=
|
||||||
|
x=
|
||||||
|
for i in $MACH_LIST
|
||||||
|
do
|
||||||
|
l="$l $i"
|
||||||
|
x=x$x
|
||||||
|
case $x in
|
||||||
|
xxxxxxxxxx) echo $l
|
||||||
|
x=
|
||||||
|
l=
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
ACM=$OLDACM
|
||||||
|
echo $l
|
||||||
|
echo $E_FLAG "Your choice: [$OLDACM] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$ACM";;
|
||||||
|
esac
|
||||||
|
ACM="$ANS"
|
||||||
|
done
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
case $SYS in
|
||||||
|
V7|BSD4_1|BSD4_2|SYS_5)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
SYS=$OLDSYS
|
||||||
|
echo 'What kind of Unix is the target system running?
|
||||||
|
Choices:
|
||||||
|
V7 for Unix V7, BSD 2.*
|
||||||
|
BSD4_1 for Berkeley 4.1
|
||||||
|
BSD4_2 for Berkeley 4.2, 4.3, SunOs 3, SunOs 4
|
||||||
|
SYS_5 for Xenix, System III, System V, SunOs 5'
|
||||||
|
echo $E_FLAG "Your choice (V7|BSD4_1|BSD4_2|SYS_5): [$OLDSYS] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$SYS";;
|
||||||
|
esac
|
||||||
|
SYS="$ANS"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
rm -f local.h
|
||||||
|
sed -e /ACKM/s/'".*"'/'"'$ACM'"'/ -e /BIGMACH/s/'[01]'/$BM/ -e /SYSTEM/s/'^#[ ]*define[ ]*[a-zA-Z_][a-zA-Z0-9_]*'/"# define $SYS"/ < $FDIR/local.h.src >local.h
|
||||||
|
case $BYTE_ORDER in
|
||||||
|
XXX) ;;
|
||||||
|
*) echo '/* Optional definition of BYTE_ORDER: */' >> local.h
|
||||||
|
echo "#define BYTE_ORDER 0x$BYTE_ORDER" >> local.h
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "Your default machine to compile for is $ACM"
|
||||||
|
|
||||||
|
echo "Installation of the complete ACK takes a long time. Limiting the
|
||||||
|
number of languages, runtime libraries, back-ends, and assemblers to be
|
||||||
|
installed may save a lot of time. If you want to install everything,
|
||||||
|
answer no to the next question. Otherwise, answer yes, and you will be
|
||||||
|
prompted for details"
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Do you want to limit the installation in any way? (y/n) [$LIMIT] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$LIMIT";;
|
||||||
|
esac
|
||||||
|
case X$ANS in
|
||||||
|
Xj*|Xy|X)
|
||||||
|
LIMIT=y
|
||||||
|
. $FDIR/limit_enquire
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
Xn*) . $FDIR/get_sysvax
|
||||||
|
LIMIT=n
|
||||||
|
DO_MACHINE_INDEP=y
|
||||||
|
DO_FAST=n
|
||||||
|
DISABLE_LANG=
|
||||||
|
DISABLE_SUP=
|
||||||
|
if [ $TARGET_HOME = $UTIL_HOME ]
|
||||||
|
then
|
||||||
|
case $ACM in
|
||||||
|
sun3|m68020|i386|vax*)
|
||||||
|
DO_FAST=y
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($ANS). Try again."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
. $FDIR/get_makepars
|
||||||
|
|
||||||
|
echo "TARGET_HOME=\"$TARGET_HOME\"; export TARGET_HOME" > macros
|
||||||
|
echo "UTIL_HOME=\"$UTIL_HOME\"; export UTIL_HOME" >> macros
|
||||||
|
echo "SRC_HOME=\"$SRC_HOME\"; export SRC_HOME" >> macros
|
||||||
|
echo "SYSNAME=\"$SYSNAME\"; export SYSNAME" >> macros
|
||||||
|
echo "ACM=\"$ACM\"; export ACM" >> macros
|
||||||
|
echo "CURRENT=\"$CURRENT\"; export CURRENT" >> macros
|
||||||
|
echo "SYS=\"$SYS\"; export SYS" >> macros
|
||||||
|
echo "LIMIT=\"$LIMIT\"; export LIMIT" >> macros
|
||||||
|
echo "CONFIG=\"$CONFIG\"; export CONFIG" >> macros
|
||||||
|
echo "DISABLE_LANG=\"$DISABLE_LANG\"; export DISABLE_LANG" >> macros
|
||||||
|
echo "DISABLE_SUP=\"$DISABLE_SUP\"; export DISABLE_SUP" >> macros
|
||||||
|
echo "DO_MACHINE_INDEP=\"$DO_MACHINE_INDEP\"; export DO_MACHINE_INDEP" >> macros
|
||||||
|
echo "MACH_LIST=\"$MACH_LIST\"; export MACH_LIST" >> macros
|
||||||
|
echo "SYSVAX=\"$SYSVAX\"; export SYSVAX" >> macros
|
||||||
|
echo "MACH=\"$MACH\"; export MACH" >> macros
|
||||||
|
echo "WS=\"$WS\"; export WS" >> macros
|
||||||
|
echo "PS=\"$PS\"; export PS" >> macros
|
||||||
|
echo "DO_FAST=\"$DO_FAST\"; export DO_FAST" >> macros
|
||||||
|
|
||||||
|
cat macros $FDIR/install_tail > INSTALL
|
||||||
|
chmod +x INSTALL
|
||||||
|
|
||||||
|
echo "
|
||||||
|
A shell-script called 'INSTALL' has been created. Running it
|
||||||
|
installs ACK. Note that this may take a (very) long time, so run it
|
||||||
|
in the background, with its output redirected, f.i.:
|
||||||
|
sh INSTALL > INSTALL.out 2>&1 &
|
||||||
|
"
|
||||||
|
exit 0
|
||||||
7
first/get_answer
Executable file
7
first/get_answer
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if read ANS
|
||||||
|
then echo
|
||||||
|
else echo "Sorry, got EOF when reading your answer"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
106
first/get_makepars
Executable file
106
first/get_makepars
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
know_target=0
|
||||||
|
case $SYSNAME in
|
||||||
|
vax*|i386|sun*|sparc*|m68_sysV_0|m68020|mantra|pmds4|m68k4)
|
||||||
|
WS=4 ; PS=4
|
||||||
|
know_target=1
|
||||||
|
;;
|
||||||
|
m68_unisoft|m68k2|minixST|pmds)
|
||||||
|
WS=2 ; PS=4
|
||||||
|
know_target=1
|
||||||
|
;;
|
||||||
|
i86|minix|xenix3)
|
||||||
|
WS=2 ; PS=2
|
||||||
|
know_target=1
|
||||||
|
;;
|
||||||
|
*) trap "rm -f ws.c ws.o a.out t$$" 0 1 2 3 15
|
||||||
|
cat > ws.c <<'EOF'
|
||||||
|
#include <stdio.h>
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
printf("WS=%d ; PS=%d\n", sizeof(int), sizeof(char *));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
if [ $TARGET_HOME = $UTIL_HOME ] && cc ws.c 2>/dev/null
|
||||||
|
then
|
||||||
|
: We can find out ourselves what the word-size and
|
||||||
|
: the pointer-size of the target machine is.
|
||||||
|
cc ws.c 2>/dev/null
|
||||||
|
./a.out > t$$
|
||||||
|
. t$$
|
||||||
|
rm -f t$$ a.out ws.[co]
|
||||||
|
else
|
||||||
|
: we will have to ask installer.
|
||||||
|
echo $E_FLAG "Please give the word-size of the target-machine (sizeof(int)) in bytes: [$WS] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$WS";;
|
||||||
|
esac
|
||||||
|
WS="$ANS"
|
||||||
|
echo $E_FLAG "Please give the pointer-size of the target-machine (sizeof(char *)) in bytes: [$PS] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$PS";;
|
||||||
|
esac
|
||||||
|
PS="$ANS"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "# Paths:
|
||||||
|
SRC_HOME = $SRC_HOME
|
||||||
|
TARGET_HOME = $TARGET_HOME
|
||||||
|
UTIL_HOME = $UTIL_HOME
|
||||||
|
|
||||||
|
# Machine independent part created?
|
||||||
|
DO_MACHINE_INDEP = $DO_MACHINE_INDEP
|
||||||
|
|
||||||
|
# Target machine, only needed for fast compilers
|
||||||
|
MACH = $MACH
|
||||||
|
" > make_macros
|
||||||
|
|
||||||
|
if [ $TARGET_HOME = $UTIL_HOME ]
|
||||||
|
then
|
||||||
|
if [ -f /bin/ranlib -o -f /usr/bin/ranlib -o -f /usr/ucb/ranlib ]
|
||||||
|
then
|
||||||
|
sed "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" < $FDIR/target_comp >> make_macros
|
||||||
|
else
|
||||||
|
sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros
|
||||||
|
fi
|
||||||
|
case $ACM in
|
||||||
|
sun3|sparc)
|
||||||
|
ed -s make_macros <<'EOF'
|
||||||
|
/cc-and-mkdep.sun/s/^..//
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
cat $FDIR/util_comp >> make_macros
|
||||||
|
else
|
||||||
|
case $know_target in
|
||||||
|
1) sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "/cc-and-mkdep.ack/s/^..//" -e "s/^CC=cc/CC=acc -m$ACM/" -e "s/^# AR=aal/AR=aal/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros
|
||||||
|
;;
|
||||||
|
*) if [ -f /bin/ranlib -o -f /usr/bin/ranlib -o -f /usr/ucb/ranlib ]
|
||||||
|
then
|
||||||
|
sed "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" < $FDIR/target_comp >> make_macros
|
||||||
|
else
|
||||||
|
sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
sed "s/^#U/U/" < $FDIR/util_comp >> make_macros
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat $FDIR/lint_params >> make_macros
|
||||||
|
|
||||||
|
echo "A file called 'make_macros' has been created. This file defines some
|
||||||
|
'make' variables that parameterize all Makefiles in ACK. You may want
|
||||||
|
to check it before attempting to actually install ACK."
|
||||||
|
case $know_target in
|
||||||
|
0) echo "In fact, this installation script does not know much about
|
||||||
|
your target machine, so expect some things to be wrong"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
157
first/get_sys
Executable file
157
first/get_sys
Executable file
@ -0,0 +1,157 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
rm -f em_path.h
|
||||||
|
echo "You will now be asked for the root directory of the ACK sources.
|
||||||
|
This directory will not be changed by the installation process.
|
||||||
|
"
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Please give the root of the ACK source tree,
|
||||||
|
an absolute path: [$SRC_HOME] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$SRC_HOME" ;;
|
||||||
|
esac
|
||||||
|
SRC_HOME="$ANS"
|
||||||
|
case $SRC_HOME in
|
||||||
|
/*) break;
|
||||||
|
;;
|
||||||
|
*) echo "$SRC_HOME is not an absolute path; try again"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "You will now be asked for a configuration directory. This is
|
||||||
|
the directory in which the compilations will take place. The tree that
|
||||||
|
resides in it will have the same structure as the ACK source tree, but
|
||||||
|
the directories will usually only contain Makefiles and .o files.
|
||||||
|
"
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Please give the root of the configuration tree,
|
||||||
|
an absolute path: [$CONFIG] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$CONFIG";;
|
||||||
|
esac
|
||||||
|
CONFIG="$ANS"
|
||||||
|
case $CONFIG in
|
||||||
|
/*) break;
|
||||||
|
;;
|
||||||
|
*) echo "$CONFIG is not an absolute path; try again"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "You will now be asked for the root directory of the ACK binaries. After
|
||||||
|
installation, this directory will have subdirectories bin, lib, lib.bin,
|
||||||
|
man, h, config, include, modules, doc.
|
||||||
|
Four of these directories will contain stuff that depends on the machine
|
||||||
|
for which the ACK binaries are made: bin, modules, config, and lib.bin. The
|
||||||
|
other sub-directories (lib, man, h, include and doc) will contain
|
||||||
|
machine-independent stuff.
|
||||||
|
This information may be useful if you want to use ACK on different platforms
|
||||||
|
and you have a shared file system. See the installation manual.
|
||||||
|
"
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Please give the root of the ACK binaries,
|
||||||
|
an absolute path: [$TARGET_HOME] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$TARGET_HOME";;
|
||||||
|
esac
|
||||||
|
TARGET_HOME="$ANS"
|
||||||
|
case $TARGET_HOME in
|
||||||
|
/*) break;
|
||||||
|
;;
|
||||||
|
*) echo "$TARGET_HOME is not an absolute path; try again"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
sed -e "/^#define[ ]*EM_DIR/s@\".*\"@\"$TARGET_HOME\"@" <$FDIR/em_path.h.src >em_path.h
|
||||||
|
|
||||||
|
echo "You will now be asked for the type of the system that you want
|
||||||
|
ACK binaries produced for. This is not neccessarily the system you
|
||||||
|
run this program on. In this case, if you have not done so already,
|
||||||
|
you will have to install ACK on the current machine first.
|
||||||
|
"
|
||||||
|
echo "Give me the type of the system, the current choice is:
|
||||||
|
vax_bsd4_1a VAX11 with BSD4.1a
|
||||||
|
vax_bsd4_2 VAX11 with BSD4.2
|
||||||
|
vax_sysV_2 VAX11 with System V.2
|
||||||
|
i386 Intel 80386 system running Xenix System V
|
||||||
|
sun3 Sun 3 M68020 workstation
|
||||||
|
sun2 Sun 2 M68000 workstation
|
||||||
|
m68_sysV_0 Motorola 68000 with Uniplus System V.0 Unix
|
||||||
|
m68020 Motorola M68020 VME131 running Unix System V/68 R2V2.1
|
||||||
|
sparc SUN SPARC workstation running SunOs 4
|
||||||
|
sparc_solaris SUN SPARC workstation running solaris 2
|
||||||
|
ANY Neither of the above
|
||||||
|
"
|
||||||
|
echo $E_FLAG "system type: [$SYSNAME] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$SYSNAME";;
|
||||||
|
esac
|
||||||
|
SYSNAME="$ANS"
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Is this the system you are running on? (y/n) [$CURRENT] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$CURRENT";;
|
||||||
|
esac
|
||||||
|
case X$ANS in
|
||||||
|
Xj*|Xy*|X) UTIL_HOME=$TARGET_HOME
|
||||||
|
CURRENT=y
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
Xn*) CURRENT=n
|
||||||
|
echo "You will now be asked for the root directory of ACK on the current machine.
|
||||||
|
This tree will not be changed by the installation process.
|
||||||
|
"
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Please give the root of a runnable ACK tree,
|
||||||
|
an absolute path: [$UTIL_HOME] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$UTIL_HOME" ;;
|
||||||
|
esac
|
||||||
|
UTIL_HOME="$ANS"
|
||||||
|
case $UTIL_HOME in
|
||||||
|
/*) break;
|
||||||
|
;;
|
||||||
|
*) echo "$UTIL_HOME is not an absolute path; try again"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($ANS). Try again."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo "The system to install ACK for is $SYSNAME,
|
||||||
|
the root of the ACK source tree is $SRC_HOME,
|
||||||
|
the root of the configuration tree is $CONFIG,
|
||||||
|
the root of the ACK binary tree to be created is $TARGET_HOME,
|
||||||
|
and the root of a runnable ACK binary tree is $UTIL_HOME.
|
||||||
|
If the machine to compile ACK for is the current machine, the last two names
|
||||||
|
may be identical."
|
||||||
|
echo $E_FLAG "Are you satisfied with all this? (y/n) $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case X$ANS in
|
||||||
|
Xj*|Xy*|X) break
|
||||||
|
;;
|
||||||
|
Xn*) echo Ok, I will give you another chance....
|
||||||
|
. $0
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($ANS). Try again."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
23
first/get_sysvax
Executable file
23
first/get_sysvax
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Which system-call library do you want to install for the VAX?
|
||||||
|
You can choose between
|
||||||
|
libbsd4_1a for Berkeley Unix 4.1
|
||||||
|
libbsd4_2 for Berkeley Unix 4.2 or newer, or Ultrix
|
||||||
|
libsysV_2 for Unix System V
|
||||||
|
Your choice: [$SYSVAX] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$SYSVAX";;
|
||||||
|
esac
|
||||||
|
SYSVAX="$ANS"
|
||||||
|
case $SYSVAX in
|
||||||
|
libbsd4_1a|libbsd4_2|libsysV_2)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($SYSVAX). Try again"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
93
first/install_tail
Normal file
93
first/install_tail
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PATH=::$CONFIG/bin:$UTIL_HOME/bin:/usr/ccs/bin:/usr/ucb:$PATH
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
$SRC_HOME/first/create_dir $CONFIG
|
||||||
|
$SRC_HOME/first/create_dir $CONFIG/bin
|
||||||
|
|
||||||
|
(
|
||||||
|
# Slight complication here to ensure that the #! magic at the
|
||||||
|
# beginning of TakeAction is preserved correctly.
|
||||||
|
|
||||||
|
head -1 $SRC_HOME/TakeAction
|
||||||
|
echo "PATH=:$CONFIG/bin:$UTIL_HOME/bin:$PATH; export PATH"
|
||||||
|
tail +2 $SRC_HOME/TakeAction
|
||||||
|
) > $CONFIG/bin/TakeAction
|
||||||
|
|
||||||
|
sed '/^#PARAMS/r make_macros' < $SRC_HOME/first/mk_makefile > $CONFIG/bin/mk_makefile
|
||||||
|
cp $SRC_HOME/first/create_dir $CONFIG/bin/create_dir
|
||||||
|
cp $SRC_HOME/first/cp_dir $CONFIG/bin/cp_dir
|
||||||
|
chmod +x $CONFIG/bin/*
|
||||||
|
|
||||||
|
$SRC_HOME/first/mk_config
|
||||||
|
|
||||||
|
$SRC_HOME/first/mk_target
|
||||||
|
|
||||||
|
$SRC_HOME/first/limit_impl
|
||||||
|
|
||||||
|
case $SYSNAME in
|
||||||
|
i386)
|
||||||
|
ed -s $TARGET_HOME/lib/descr/fe << 'ABC'
|
||||||
|
1,$s/-D{NAME}/-D{NAME} -DNO_PROTOTYPE/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
ABC
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
: find varargs include file
|
||||||
|
: if not present use our own
|
||||||
|
|
||||||
|
if test -f /usr/include/varargs.h
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
cp $SRC_HOME/include/_tail_cc/varargs.h $TARGET_HOME/modules/h
|
||||||
|
fi
|
||||||
|
|
||||||
|
case X$SYSVAX in
|
||||||
|
Xvax_sysV_2)
|
||||||
|
ed -s $TARGET_HOME/lib/vax4/descr << 'ABC'
|
||||||
|
/CPP_F/s/$/ -D__USG/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
ABC
|
||||||
|
ed -s $CONFIG/mach/vax4/Action << 'ABC'
|
||||||
|
/libbsd4_2/s/libbsd4_2/libsysV_2/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
ABC
|
||||||
|
( cd $CONFIG/mach/vax4
|
||||||
|
for i in libcc libcc.ansi
|
||||||
|
do
|
||||||
|
ed -s $i/Makefile << 'ABC'
|
||||||
|
/BFS/s/BFS/UFS/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
ABC
|
||||||
|
done
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
Xvax_bsd4_2)
|
||||||
|
ed -s $TARGET_HOME/lib/vax4/descr << 'ABC'
|
||||||
|
/CPP_F/s/$/ -D__BSD4_2/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
ABC
|
||||||
|
;;
|
||||||
|
Xvax_bsd4_1a)
|
||||||
|
ed -s $CONFIG/mach/vax4/Action << 'ABC'
|
||||||
|
/libbsd4_2/s/libbsd4_2/libbsd4_1a/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
ABC
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
: and finally installing ...
|
||||||
|
cd $CONFIG
|
||||||
|
set +e
|
||||||
|
exec TakeAction
|
||||||
209
first/limit_enquire
Normal file
209
first/limit_enquire
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo "The libraries will end up in the machine-independent part of the
|
||||||
|
ACK binary tree. You may already have them from a previous ACK installation
|
||||||
|
on a different machine, in particular if you have an NFS file system.
|
||||||
|
Therefore, it may not be neccessary to install them again. As this part
|
||||||
|
of the ACK installation takes the most time, you are given the opportunity
|
||||||
|
to disable installation of the machine-independent part"
|
||||||
|
echo $E_FLAG \
|
||||||
|
"Do you want to install the machine-independent part? (y/n) [$DO_MACHINE_INDEP] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$DO_MACHINE_INDEP" ;;
|
||||||
|
esac
|
||||||
|
case X$ANS in
|
||||||
|
Xj*|Xy*|X) DO_MACHINE_INDEP=y
|
||||||
|
echo "machine-independent part will be installed"
|
||||||
|
echo
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
Xn*) DO_MACHINE_INDEP=n
|
||||||
|
echo "machine-independent part will not be installed"
|
||||||
|
echo
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($ANS). Try again."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
OLD_DIS_LANG="$DISABLE_LANG"
|
||||||
|
DISABLE_LANG=
|
||||||
|
case X$OLD_DIS_LANG in
|
||||||
|
X) ;;
|
||||||
|
*) set $OLD_DIS_LANG
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
for i in Modula-2 Pascal Occam Basic ANSI-C C Fortran
|
||||||
|
do
|
||||||
|
DEF=y
|
||||||
|
if [ $# != 0 -a X$i = X$1 ]
|
||||||
|
then
|
||||||
|
DEF=n
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Do you want to install $i? (y/n) [$DEF] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$DEF";;
|
||||||
|
esac
|
||||||
|
case X$ANS in
|
||||||
|
Xj*|Xy*)
|
||||||
|
echo "$i will be installed"
|
||||||
|
echo
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
Xn*) DISABLE_LANG=$DISABLE_LANG" $i"
|
||||||
|
echo "$i will not be installed"
|
||||||
|
echo
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($ANS). Try again."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
done
|
||||||
|
OLD_DIS_SUP="$DISABLE_SUP"
|
||||||
|
DISABLE_SUP=
|
||||||
|
set $MACH_LIST
|
||||||
|
while test $# != 0
|
||||||
|
do
|
||||||
|
DEF=y
|
||||||
|
for i in $OLD_DIS_SUP
|
||||||
|
do
|
||||||
|
if [ X$i = X$1 ]
|
||||||
|
then
|
||||||
|
DEF=n
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
i86) echo "not installing i86 will disable installation of xenix3 and minix."
|
||||||
|
;;
|
||||||
|
m68k2) echo "not installing m68k2 will disable installation of pmds, minixST,
|
||||||
|
m68k4, pmds4, sun2, and mantra."
|
||||||
|
;;
|
||||||
|
m68k4) echo "not installing m68k4 will disable installation of pmds4, sun2, and mantra."
|
||||||
|
;;
|
||||||
|
m68020) echo "not installing m68020 will disable installation of sun3."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo $E_FLAG "Do you want to install the $1 support? (y/n) [$DEF] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$DEF";;
|
||||||
|
esac
|
||||||
|
case X$ANS in
|
||||||
|
Xj*|Xy*)
|
||||||
|
echo "The $1 support will be installed"
|
||||||
|
echo
|
||||||
|
case $1 in
|
||||||
|
vax4) case $SYSNAME in
|
||||||
|
vax_bsd4_1a) SYSVAX=libbsd4_1a
|
||||||
|
;;
|
||||||
|
vax_bsd4_2) SYSVAX=libbsd4_2
|
||||||
|
;;
|
||||||
|
vax_sysV_2) SYSVAX=libsysV_2
|
||||||
|
;;
|
||||||
|
*) if [ $DO_MACHINE_INDEP = y ]
|
||||||
|
then
|
||||||
|
. $FDIR/get_sysvax
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
sparc) shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
Xn*) DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
echo "The $1 support will not be installed"
|
||||||
|
echo
|
||||||
|
case $1 in
|
||||||
|
i86)
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
;;
|
||||||
|
m68k2)
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
;;
|
||||||
|
m68k4)
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
;;
|
||||||
|
sparc)
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
;;
|
||||||
|
m68020)
|
||||||
|
shift
|
||||||
|
DISABLE_SUP=$DISABLE_SUP" $1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($ANS). Try again."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $TARGET_HOME = $UTIL_HOME ]
|
||||||
|
then
|
||||||
|
case $ACM in
|
||||||
|
sun3|m68020|i386|vax*)
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
echo $E_FLAG "Do you want to install the fast compilers? (y/n) [$DO_FAST] $E_SFX"
|
||||||
|
. $FDIR/get_answer
|
||||||
|
case $ANS in
|
||||||
|
'') ANS="$DO_FAST" ;;
|
||||||
|
esac
|
||||||
|
case X$ANS in
|
||||||
|
Xj*|Xy*)
|
||||||
|
DO_FAST=y
|
||||||
|
echo "The fast compilers will be installed"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
Xn*)
|
||||||
|
DO_FAST=n
|
||||||
|
echo "The fast compilers will not be installed"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "I do not understand your answer ($ANS). Try again."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
DO_FAST=n
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
DO_FAST=n
|
||||||
|
fi
|
||||||
208
first/limit_impl
Executable file
208
first/limit_impl
Executable file
@ -0,0 +1,208 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for i in $DISABLE_LANG
|
||||||
|
do
|
||||||
|
ed -s $CONFIG/Action <<EOF
|
||||||
|
/^name "$i/;/^end/s/^/!/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
case $i in
|
||||||
|
Modula-2)
|
||||||
|
ed -s $CONFIG/Action <<EOF
|
||||||
|
/^name "$i definition/;/^end/s/^/!/
|
||||||
|
/^name "$i makefile/;/^end/s/^/!/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
ANSI-C) : install compiler anyway
|
||||||
|
ed -s $CONFIG/Action <<EOF
|
||||||
|
/^!name "$i frontend/;/^!end/s/^!//
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
C) : install compiler anyway
|
||||||
|
ed -s $CONFIG/Action <<EOF
|
||||||
|
/^!name "$i frontend/;/^!end/s/^!//
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
for i in Modula-2 Pascal Basic Occam ANSI-C C Fortran
|
||||||
|
do
|
||||||
|
if [ $DO_MACHINE_INDEP = n ]
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
for j in $DISABLE_LANG
|
||||||
|
do
|
||||||
|
case $i in
|
||||||
|
$j) i=X
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
X) continue
|
||||||
|
;;
|
||||||
|
Modula-2)
|
||||||
|
lib=libm2
|
||||||
|
;;
|
||||||
|
Pascal)
|
||||||
|
lib=libpc
|
||||||
|
;;
|
||||||
|
Basic)
|
||||||
|
lib=libbc
|
||||||
|
;;
|
||||||
|
Occam)
|
||||||
|
lib=liboc
|
||||||
|
;;
|
||||||
|
ANSI-C)
|
||||||
|
lib=libcc.ansi
|
||||||
|
;;
|
||||||
|
C)
|
||||||
|
lib=libcc
|
||||||
|
;;
|
||||||
|
Fortran)
|
||||||
|
lib=libf77
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
( cd $CONFIG/mach
|
||||||
|
for j in $MACH_LIST
|
||||||
|
do
|
||||||
|
case $j in
|
||||||
|
6800|6805|6809|s2650) continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
: do not install fortran for 2-byte integer machines
|
||||||
|
case $i in
|
||||||
|
Fortran) case $j in
|
||||||
|
em2*|i8*|m68k2|minix*|pdp|pmds|xenix3|z80*)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case $j in
|
||||||
|
sparc*)
|
||||||
|
( cd $j
|
||||||
|
cat >> Action <<EOF
|
||||||
|
name "$j $i libraries"
|
||||||
|
system "$j"
|
||||||
|
dir $lib
|
||||||
|
end
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
( cd $j
|
||||||
|
cat >> Action <<EOF
|
||||||
|
name "$j $i libraries"
|
||||||
|
dir $lib
|
||||||
|
end
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
)
|
||||||
|
done
|
||||||
|
DISABLE_INT=0
|
||||||
|
for i in $DISABLE_SUP
|
||||||
|
do
|
||||||
|
ed -s $CONFIG/Action <<EOF
|
||||||
|
/^dir .*$i\$/;?^name?;/^end/s/^/!/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
case $i in
|
||||||
|
m68k2)
|
||||||
|
DISABLE_INT=1
|
||||||
|
;;
|
||||||
|
m68k4)
|
||||||
|
case $SYSNAME in
|
||||||
|
m68_sysV_0|sun2)
|
||||||
|
DISABLE_INT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
mantra)
|
||||||
|
if test $SYSNAME = m68_sysV_0
|
||||||
|
then
|
||||||
|
DISABLE_INT=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
sun2)
|
||||||
|
if test $SYSNAME = sun2
|
||||||
|
then
|
||||||
|
DISABLE_INT=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
sun3)
|
||||||
|
if test $SYSNAME = sun3
|
||||||
|
then
|
||||||
|
DISABLE_INT=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
pmds4)
|
||||||
|
case $SYSNAME in
|
||||||
|
pmds*)
|
||||||
|
DISABLE_INT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
m68020)
|
||||||
|
case $SYSNAME in
|
||||||
|
m68020|sun3)
|
||||||
|
DISABLE_INT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
case $SYSNAME in
|
||||||
|
m68*|sun2|sun3|pmds*)
|
||||||
|
;;
|
||||||
|
*) DISABLE_INT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if test $DISABLE_INT = 1
|
||||||
|
then
|
||||||
|
ed -s $CONFIG/Action <<EOF
|
||||||
|
/68000 interpreters/;/^end/s/^/!/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $DO_MACHINE_INDEP = n ]
|
||||||
|
then
|
||||||
|
for i in $CONFIG/mach/*/Action
|
||||||
|
do
|
||||||
|
for j in libem libend libfp libdb libsys libmon libbsd4_2 libbsd4_1a libsysV_2 libce
|
||||||
|
do
|
||||||
|
if fgrep -s $j $i
|
||||||
|
then
|
||||||
|
ed -s $i <<EOF
|
||||||
|
/$j/;?^name?,/^end/s/^/!/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $DO_FAST = n ]
|
||||||
|
then
|
||||||
|
ed -s $CONFIG/Action <<'EOF'
|
||||||
|
/^name "Peephole optimizer lib/;/^end/s/^/!/
|
||||||
|
/^name "Fast/;$s/^/!/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
19
first/lint_params
Normal file
19
first/lint_params
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/make
|
||||||
|
|
||||||
|
# There are two choices for lint here: ACK lint and Unix lint.
|
||||||
|
# The current setup is for ACK lint. If you want to use the Unix lint,
|
||||||
|
# put '#' signs on the next 4 lines that have ACK in them.
|
||||||
|
|
||||||
|
LINT=/usr/bin/lint# # Unix lint
|
||||||
|
LINT=$(UTIL_HOME)/bin/lint# # ACK lint
|
||||||
|
|
||||||
|
LINTOPTIONS=# # options always passed to lint
|
||||||
|
|
||||||
|
LINTPREF=llib-l# # prefix of unix lint libraries
|
||||||
|
LINTPREF=# # ACK lint libraries do not have a prefix
|
||||||
|
|
||||||
|
LINTSUF=ln# # suffix of Unix lint libraries
|
||||||
|
LINTSUF=llb# # suffix of ACK lint libraries
|
||||||
|
|
||||||
|
MK_LINT_LIB=lint-lib.unix# # for Unix lint
|
||||||
|
MK_LINT_LIB=lint-lib.ack# # for ACK lint
|
||||||
37
first/llgen.pm
Normal file
37
first/llgen.pm
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
-- $Source$
|
||||||
|
-- $State$
|
||||||
|
|
||||||
|
-- This is unpleasant. LLgen can generate an arbitrary number of output files,
|
||||||
|
-- which means we need our own output filename generator.
|
||||||
|
|
||||||
|
LLgen = simple {
|
||||||
|
class = "LLgen",
|
||||||
|
command = {
|
||||||
|
"rm -f %out%",
|
||||||
|
"cd %out[1]:dirname% && %TOOLDIR%LLgen %in%"
|
||||||
|
},
|
||||||
|
|
||||||
|
outputs = {"%U%/" },
|
||||||
|
__outputs = function(self, inputs)
|
||||||
|
local o = simple.__outputs(self, inputs)[1]
|
||||||
|
|
||||||
|
local outputs = {o.."Lpars.h", o.."Lpars.c"}
|
||||||
|
|
||||||
|
for _, i in ipairs(inputs) do
|
||||||
|
i = string.gsub(i, "^.*/", "")
|
||||||
|
i = string.gsub(i, "%.g$", ".c")
|
||||||
|
table.insert(outputs, o..i)
|
||||||
|
end
|
||||||
|
|
||||||
|
return outputs
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Revision history
|
||||||
|
-- $Log$
|
||||||
|
-- Revision 1.2 2006-11-11 22:59:01 dtrg
|
||||||
|
-- Now uses the version of LLgen included with the ACK instead of the standalone version.
|
||||||
|
--
|
||||||
|
-- Revision 1.1 2006/07/20 23:18:18 dtrg
|
||||||
|
-- First version in CVS.
|
||||||
|
--
|
||||||
19
first/local.h.src
Normal file
19
first/local.h.src
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
/*
|
||||||
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
|
*/
|
||||||
|
/* collection of options, selected by including or excluding 'defines' */
|
||||||
|
|
||||||
|
/* Version number of the EM object code */
|
||||||
|
# define VERSION 3 /* 16 bits number */
|
||||||
|
|
||||||
|
/* The default machine used by ack, acc, apc */
|
||||||
|
# define ACKM "sun3"
|
||||||
|
|
||||||
|
/* size of local machine, either 0 (for 16 bit address space), or 1 */
|
||||||
|
# define BIGMACHINE 1
|
||||||
|
|
||||||
|
/* operating system, SYS_5, V7, BSD4_1 or BSD4_2; Do NOT delete the comment
|
||||||
|
in the next line! */
|
||||||
|
# define BSD4_2 1 /* SYSTEM */
|
||||||
133
first/mk_config
Executable file
133
first/mk_config
Executable file
@ -0,0 +1,133 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
create_dir $CONFIG
|
||||||
|
|
||||||
|
create_dir $CONFIG/bin
|
||||||
|
echo "#!/bin/sh" > $CONFIG/bin/ack_sys
|
||||||
|
echo "echo $SYSNAME" >> $CONFIG/bin/ack_sys
|
||||||
|
chmod +x $CONFIG/bin/ack_sys
|
||||||
|
|
||||||
|
cd $SRC_HOME
|
||||||
|
find . -type d -perm -555 -print > $CONFIG/dir_list
|
||||||
|
|
||||||
|
cd $CONFIG
|
||||||
|
for i in mach/*/libsys
|
||||||
|
do
|
||||||
|
rm -rf $i
|
||||||
|
done
|
||||||
|
|
||||||
|
for i in `cat dir_list`
|
||||||
|
do
|
||||||
|
create_dir $i
|
||||||
|
rm -f $i/No*
|
||||||
|
if [ -f $i/Makefile ]
|
||||||
|
then
|
||||||
|
( cd $i ; if make clean ; then exit 0 ; else exit 0 ; fi ) > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
if [ -f $SRC_HOME/$i/proto.make ]
|
||||||
|
then mk_makefile $SRC_HOME/$i/proto.make > $i/Makefile
|
||||||
|
fi
|
||||||
|
if [ -f $SRC_HOME/$i/Action ]
|
||||||
|
then
|
||||||
|
cd $SRC_HOME/$i
|
||||||
|
cp Action* $CONFIG/$i
|
||||||
|
chmod +w $CONFIG/$i/Action*
|
||||||
|
cd $CONFIG
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
cd $CONFIG
|
||||||
|
|
||||||
|
for i in lang/cem/cemcom.ansi lang/cem/cemcom lang/m2/comp
|
||||||
|
do
|
||||||
|
cp $SRC_HOME/$i/BigPars $CONFIG/$i/Parameters
|
||||||
|
chmod +w $CONFIG/$i/Parameters
|
||||||
|
done
|
||||||
|
for i in lang/pc/comp lang/cem/cpp.ansi
|
||||||
|
do
|
||||||
|
cp $SRC_HOME/$i/Parameters $CONFIG/$i/Parameters
|
||||||
|
chmod +w $CONFIG/$i/Parameters
|
||||||
|
done
|
||||||
|
|
||||||
|
cd $CONFIG/mach
|
||||||
|
for i in *
|
||||||
|
do
|
||||||
|
if [ -d $i ]
|
||||||
|
then
|
||||||
|
if [ -d $i/as ]
|
||||||
|
then
|
||||||
|
cd $i/as
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/as/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
if [ -d $i/top ]
|
||||||
|
then
|
||||||
|
cd $i/top
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/top/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
if [ -d $i/cg ]
|
||||||
|
then
|
||||||
|
cd $i/cg
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/cg/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
if [ -d $i/ncg ]
|
||||||
|
then
|
||||||
|
cd $i/ncg
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/ncg/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile
|
||||||
|
if [ -f $SRC_HOME/mach/$i/ncg/table_dir ]
|
||||||
|
then
|
||||||
|
ed -s Makefile <<EOF
|
||||||
|
/^#TABLE_DEFINE/+1r $SRC_HOME/mach/$i/ncg/table_dir
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
if [ -f $SRC_HOME/mach/$i/mach_params ]
|
||||||
|
then :
|
||||||
|
else continue
|
||||||
|
fi
|
||||||
|
for j in libem libend libmon libfp libsys libdb
|
||||||
|
do
|
||||||
|
if [ -d $i/$j ]
|
||||||
|
then
|
||||||
|
cd $i/$j
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/libg/proto.$j | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" > Makefile
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for j in libbsd4_1a libbsd4_2 libsysV_2
|
||||||
|
do
|
||||||
|
if [ -d $i/$j ]
|
||||||
|
then
|
||||||
|
cd $i/$j
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/libg/proto.libsys | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" -e "s/libsys/$j/g" > Makefile
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for j in libcc libcc.ansi libm2 libpc libbc liboc libf77
|
||||||
|
do
|
||||||
|
create_dir $i/$j
|
||||||
|
rm -f $i/$j/No*
|
||||||
|
cd $i/$j
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/libg/proto.$j | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" > Makefile
|
||||||
|
cd ../..
|
||||||
|
done
|
||||||
|
if [ $i = vax4 ]
|
||||||
|
then :
|
||||||
|
elif [ -d $i/libsys ]
|
||||||
|
then :
|
||||||
|
else
|
||||||
|
create_dir $i/libsys
|
||||||
|
rm -f $i/libsys/No*
|
||||||
|
cd $i/libsys
|
||||||
|
mk_makefile $SRC_HOME/mach/proto/libg/proto.sysmon | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" > Makefile
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
35
first/mk_makefile
Executable file
35
first/mk_makefile
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
: '$Id$'
|
||||||
|
|
||||||
|
: This shell script inserts make macros after a line
|
||||||
|
: starting with #PARAMS in "make_proto", and produces the result on
|
||||||
|
: standard output.
|
||||||
|
|
||||||
|
trap "rm -f /tmp/mk_mak$$" 0 1 2 3 15
|
||||||
|
case $# in
|
||||||
|
1) ;;
|
||||||
|
*) echo "Usage: $0 <make_proto>" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
cp $1 /tmp/mk_mak$$
|
||||||
|
|
||||||
|
ed -s /tmp/mk_mak$$ << 'EOF'
|
||||||
|
/^#PARAMS/c
|
||||||
|
#PARAMS do not remove this line!
|
||||||
|
.
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
case `ack_sys` in
|
||||||
|
sparc_solaris)
|
||||||
|
ed -s /tmp/mk_mak$$ << 'EOF'
|
||||||
|
g/^EXTRALIB/s/=/= -lelf/
|
||||||
|
w
|
||||||
|
q
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
cat /tmp/mk_mak$$
|
||||||
|
exit 0
|
||||||
41
first/mk_target
Executable file
41
first/mk_target
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
: machine-dependant stuff
|
||||||
|
|
||||||
|
create_dir $TARGET_HOME
|
||||||
|
create_dir $TARGET_HOME/config
|
||||||
|
create_dir $TARGET_HOME/lib.bin
|
||||||
|
create_dir $TARGET_HOME/modules
|
||||||
|
create_dir $TARGET_HOME/modules/h
|
||||||
|
create_dir $TARGET_HOME/bin
|
||||||
|
|
||||||
|
cp local.h em_path.h $TARGET_HOME/config
|
||||||
|
cp_dir $SRC_HOME/bin $TARGET_HOME/bin
|
||||||
|
cp $CONFIG/bin/cp_dir $TARGET_HOME/bin/cp_dir
|
||||||
|
echo "echo $SYSNAME" > $TARGET_HOME/bin/ack_sys
|
||||||
|
chmod +x $TARGET_HOME/bin/ack_sys
|
||||||
|
|
||||||
|
: machine-independant stuff
|
||||||
|
|
||||||
|
if [ $DO_MACHINE_INDEP = n ]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
create_dir $TARGET_HOME/lib
|
||||||
|
create_dir $TARGET_HOME/etc
|
||||||
|
create_dir $TARGET_HOME/h
|
||||||
|
create_dir $TARGET_HOME/include
|
||||||
|
create_dir $TARGET_HOME/doc
|
||||||
|
|
||||||
|
cp $SRC_HOME/etc/ip_spec.t $TARGET_HOME/etc/ip_spec.t
|
||||||
|
cp_dir $SRC_HOME/lib $TARGET_HOME/lib
|
||||||
|
cp_dir $SRC_HOME/h $TARGET_HOME/h
|
||||||
|
cp_dir $SRC_HOME/include $TARGET_HOME/include
|
||||||
|
|
||||||
|
cd $TARGET_HOME
|
||||||
|
find . -type f -exec chmod +w {} \;
|
||||||
|
|
||||||
|
exit 0
|
||||||
28
first/target_comp
Normal file
28
first/target_comp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# compiler set for target machine
|
||||||
|
|
||||||
|
CC=cc# # compiler to be used for compiling ACK
|
||||||
|
|
||||||
|
# always passed to $(CC) -c.
|
||||||
|
COPTIONS=-O -D_EM_WSIZE=4 -D_EM_PSIZE=4
|
||||||
|
|
||||||
|
# passed to $(CC) -c when compiling modules.
|
||||||
|
LIBOPTIONS=#
|
||||||
|
# LIBOPTIONS=-LIB -L # when $(CC) is ACK
|
||||||
|
|
||||||
|
CC_AND_MKDEP=cc-and-mkdep.all# # when $(CC) is neither ACK or SUN,
|
||||||
|
# CC_AND_MKDEP=cc-and-mkdep.ack## when $(CC) is an ACK-derived C compiler,
|
||||||
|
# CC_AND_MKDEP=cc-and-mkdep.sun## when $(CC) is a SUN C compiler
|
||||||
|
|
||||||
|
LDOPTIONS=# # always passed to $(CC) when linking
|
||||||
|
|
||||||
|
SUF=o# # suffix of files produced with $(CC) -c
|
||||||
|
|
||||||
|
AR=ar# # archiver for Unix format objects
|
||||||
|
# AR=aal# # archiver for ACK .o format objects
|
||||||
|
# AR=arch# # archiver for ACK .s format objects
|
||||||
|
|
||||||
|
RANLIB=ranlib# # when ranlib required
|
||||||
|
# RANLIB=:# # when ranlib not required
|
||||||
|
|
||||||
|
LIBSUF=a# # suffix of object libraries
|
||||||
23
first/util_comp
Normal file
23
first/util_comp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# compiler set for producing runnable binaries (possibly using $(UTIL_HOME)).
|
||||||
|
# This must describe the compiler with which $(UTIL_HOME) has been compiled.
|
||||||
|
# If $(TARGET_HOME) is identical to $(UTIL_HOME), which usually will be
|
||||||
|
# the case, this part does not have to be changed. Otherwise (when you are
|
||||||
|
# cross-compiling ACK), you will have to change this part. Probable
|
||||||
|
# replacements are given in comments. Maybe the installation script
|
||||||
|
# has already changed them, but they should be checked to be sure.
|
||||||
|
|
||||||
|
UCC=$(CC)
|
||||||
|
#UCC=cc# # compiler to be used
|
||||||
|
|
||||||
|
UCOPTIONS=$(COPTIONS)
|
||||||
|
#UCOPTIONS=-O# # always passed to $(UCC) -c.
|
||||||
|
|
||||||
|
ULDOPTIONS=$(LDOPTIONS)
|
||||||
|
#ULDOPTIONS=# # always passed to $(UCC) when linking
|
||||||
|
|
||||||
|
USUF=$(SUF)
|
||||||
|
#USUF=o# # suffix of files produced with $(UCC) -c
|
||||||
|
|
||||||
|
ULIBSUF=$(LIBSUF)
|
||||||
|
#ULIBSUF=a# # suffix of object libraries for $(UCC)
|
||||||
@ -1,44 +0,0 @@
|
|||||||
definerule("yacc",
|
|
||||||
{
|
|
||||||
srcs = { type="targets" },
|
|
||||||
commands = {
|
|
||||||
type="strings",
|
|
||||||
default={
|
|
||||||
"yacc -t -b %{dir}/y -d %{ins}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
cwd = e.cwd,
|
|
||||||
ins = e.srcs,
|
|
||||||
outleaves = { "y.tab.c", "y.tab.h" },
|
|
||||||
label = e.label,
|
|
||||||
commands = e.commands,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
definerule("flex",
|
|
||||||
{
|
|
||||||
srcs = { type="targets" },
|
|
||||||
commands = {
|
|
||||||
type="strings",
|
|
||||||
default={
|
|
||||||
"flex -s -t %{ins} > %{outs[1]}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (e)
|
|
||||||
return normalrule {
|
|
||||||
name = e.name,
|
|
||||||
cwd = e.cwd,
|
|
||||||
ins = e.srcs,
|
|
||||||
outleaves = { "lex.yy.c" },
|
|
||||||
label = e.label,
|
|
||||||
commands = e.commands
|
|
||||||
}
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
18
first/yacc.pm
Normal file
18
first/yacc.pm
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
yacc = simple {
|
||||||
|
class = "yacc",
|
||||||
|
outputs = {"%U%/%I%.c"},
|
||||||
|
|
||||||
|
command = {
|
||||||
|
"byacc -t -b %out[1]:dirname%/y -d %in%",
|
||||||
|
"mv %out[1]:dirname%/y.tab.c %out[1]%"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flex = simple {
|
||||||
|
class = "flex",
|
||||||
|
outputs = {"%U%/%I%.c"},
|
||||||
|
|
||||||
|
command = {
|
||||||
|
"flex -s -t %in% > %out%"
|
||||||
|
}
|
||||||
|
}
|
||||||
29
h/.distr
Normal file
29
h/.distr
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#Makefile
|
||||||
|
arch.h
|
||||||
|
bc_io.h
|
||||||
|
bc_string.h
|
||||||
|
#as_spec.h
|
||||||
|
cg_pattern.h
|
||||||
|
cgg_cg.h
|
||||||
|
em_abs.h
|
||||||
|
em_ego.h
|
||||||
|
em_flag.h
|
||||||
|
em_mes.h
|
||||||
|
#em_mnem.h
|
||||||
|
#em_pseu.h
|
||||||
|
em_ptyp.h
|
||||||
|
em_reg.h
|
||||||
|
#em_spec.h
|
||||||
|
out.h
|
||||||
|
stb.h
|
||||||
|
pc_err.h
|
||||||
|
pc_file.h
|
||||||
|
pc_math.h
|
||||||
|
ranlib.h
|
||||||
|
ocm_chan.h
|
||||||
|
ocm_parco.h
|
||||||
|
ocm_proc.h
|
||||||
|
m2_traps.h
|
||||||
|
#ip_spec.h
|
||||||
|
em_table
|
||||||
|
con_float
|
||||||
33
h/build.lua
33
h/build.lua
@ -1,33 +0,0 @@
|
|||||||
normalrule {
|
|
||||||
name = "em_path",
|
|
||||||
ins = {},
|
|
||||||
outleaves = { "em_path.h" },
|
|
||||||
commands = {
|
|
||||||
"echo '#define TMP_DIR \"/tmp\"' > %{outs}",
|
|
||||||
"echo '#define EM_DIR \"$(PREFIX)\"' >> %{outs}",
|
|
||||||
"echo '#define ACK_PATH \"share/ack/descr\"' >> %{outs}",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
normalrule {
|
|
||||||
name = "local",
|
|
||||||
ins = {},
|
|
||||||
outleaves = { "local.h" },
|
|
||||||
commands = {
|
|
||||||
"echo '#define VERSION 3' > %{outs}",
|
|
||||||
"echo '#define ACKM \"$(DEFAULT_PLATFORM)\"' >> %{outs}",
|
|
||||||
"echo '#define BIGMACHINE 1' >> %{outs}",
|
|
||||||
"echo '#define SYS_5' >> %{outs}",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clibrary {
|
|
||||||
name = "emheaders",
|
|
||||||
hdrs = {
|
|
||||||
"./*.h",
|
|
||||||
"./con_float",
|
|
||||||
"+em_path",
|
|
||||||
"+local",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user