Merge pull request #246 from davidgiven/llgen
Fix the LLgen standalone build scripts
This commit is contained in:
commit
00cb4144f2
59
util/LLgen/Makefile
Normal file
59
util/LLgen/Makefile
Normal file
|
@ -0,0 +1,59 @@
|
|||
OBJDIR = .obj
|
||||
PREFIX = /usr/local
|
||||
CFLAGS = \
|
||||
-Os -g \
|
||||
-DNON_CORRECTING \
|
||||
-DLIBDIR=\"$(PREFIX)/share/LLgen/\"
|
||||
|
||||
SRCS = \
|
||||
src/alloc.c \
|
||||
src/cclass.c \
|
||||
src/check.c \
|
||||
src/compute.c \
|
||||
src/gencode.c \
|
||||
src/global.c \
|
||||
src/LLgen.c \
|
||||
src/Lpars.c \
|
||||
src/machdep.c \
|
||||
src/main.c \
|
||||
src/name.c \
|
||||
src/reach.c \
|
||||
src/savegram.c \
|
||||
src/sets.c \
|
||||
src/tokens.c
|
||||
|
||||
DOCS = \
|
||||
doc/LLgen.n \
|
||||
doc/LLgen_NCER.n \
|
||||
|
||||
OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(SRCS))
|
||||
DEPS = $(patsubst %.c, $(OBJDIR)/%.d, $(SRCS))
|
||||
PDFS = $(patsubst doc/%.n, $(OBJDIR)/%.pdf, $(DOCS))
|
||||
|
||||
all: LLgen doc
|
||||
|
||||
LLgen: $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $(OBJS)
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -MMD -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.pdf: doc/%.n doc/LLgen.refs
|
||||
@mkdir -p $(dir $@)
|
||||
groff -R -G -e -g -p -ms -Tpdf $< > $@
|
||||
|
||||
doc:: $(PDFS)
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR)
|
||||
|
||||
install: LLgen doc/LLgen.1 $(PDFS) $(wildcard lib/*)
|
||||
install -D -s LLgen -t $(PREFIX)/bin
|
||||
install -D doc/LLgen.1 -t $(PREFIX)/man/man1
|
||||
install -D $(OBJDIR)/LLgen.pdf -t $(PREFIX)/doc/LLgen
|
||||
install -D $(OBJDIR)/LLgen_NCER.pdf -t $(PREFIX)/doc/LLgen
|
||||
install -D $(wildcard lib/*) -t $(PREFIX)/share/LLgen
|
||||
|
||||
-include $(DEPS)
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
LLGEN V1.0.4
|
||||
============
|
||||
|
||||
Copyright © 1991-2005 by the Vrije Universiteit, Amsterdam, the Netherlands.
|
||||
2006-07-26
|
||||
Copyright ǒ 1991-2005 by the Vrije Universiteit, Amsterdam, the Netherlands.
|
||||
2021-02-03
|
||||
|
||||
INTRODUCTION
|
||||
============
|
||||
|
@ -23,24 +23,19 @@ LLgen depends on the following software:
|
|||
non-gcc test systems. Please contact the support mailing list (see
|
||||
below) if this is a problem.
|
||||
|
||||
groff: used to build the documentation.
|
||||
groff and grap: this is used to build the documentation.
|
||||
|
||||
LLgen uses Prime Mover as its build tool. To build, do:
|
||||
LLgen uses make as its build tool. To build, do:
|
||||
|
||||
./pm install
|
||||
make install
|
||||
|
||||
This will compile LLgen and install it into /usr/local (which you must be able
|
||||
to write to). If you want it installed elsewhere, use -D to change the PREFIX
|
||||
variable:
|
||||
to write to). If you want it installed elsewhere, change the PREFIX variable:
|
||||
|
||||
./pm -DPREFIX="/home/dg/" install
|
||||
make install PREFIX=/home/dg
|
||||
|
||||
(If you do change the prefix, you must supply it whenever you invoke pm,
|
||||
whether you're installing or just building. And there must be a trailing / in
|
||||
the path you give it.)
|
||||
|
||||
Invoking ./pm by itself will compile it but not install it; look in the bin
|
||||
directory for an image of the installation directory.
|
||||
(If you do change the prefix, you must do a `make clean` first, or else the
|
||||
installed binary will look for its libraries in the wrong place.)
|
||||
|
||||
USING LLGEN
|
||||
===========
|
||||
|
@ -48,12 +43,11 @@ USING LLGEN
|
|||
Please see the white papers in PREFIX/share/doc/LLgen, or the man page (called
|
||||
LLgen).
|
||||
|
||||
LLgen itself uses a parser compiled in LLgen, so you can study the files in
|
||||
the src directory for examples. If you wish to modify LLgen's own parser, the
|
||||
LLgen itself uses a parser compiled in LLgen, so you can study the files in the
|
||||
src directory for examples. If you wish to modify LLgen's own parser, the
|
||||
bootstrap.sh script will update LLgen's source from the parser *.g files.
|
||||
LLgen itself may then be recompiled with pm in the usual way. (Although you
|
||||
may want to keep a copy of a known good LLgen around in case you break
|
||||
something!)
|
||||
LLgen itself may then be recompiled in the usual way. (Although you may want to
|
||||
keep a copy of a known good LLgen around in case you break something!)
|
||||
|
||||
SUPPORT
|
||||
=======
|
||||
|
@ -70,16 +64,12 @@ There is a mailing list available at:
|
|||
LICENSE
|
||||
=======
|
||||
|
||||
LLgen is © 1991-2005 by the Vrije Universiteit and is distributed under a
|
||||
LLgen is ǒ 1991-2005 by the Vrije Universiteit and is distributed under a
|
||||
license equivalent to the three-clause BSD license. See the COPYING file
|
||||
for details.
|
||||
|
||||
Prime Mover is © 2006 David Given and is distributed under the MIT license.
|
||||
Do './pm --license' for details.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
David Given
|
||||
dg@cowlark.com
|
||||
2006-07-21
|
||||
2021-02-03
|
||||
|
||||
/* $Id$ */
|
||||
|
|
143
util/LLgen/c.pm
143
util/LLgen/c.pm
|
@ -1,143 +0,0 @@
|
|||
-- 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 table_insert = table.insert
|
||||
local table_getn = table.getn
|
||||
local filetime = pm.filetime
|
||||
|
||||
-- Define some variables.
|
||||
|
||||
CCOMPILER = "gcc"
|
||||
CC = "%CCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES% %CINCLUDES% %CDEFINES% %CEXTRAFLAGS% -c -o %out% %in%"
|
||||
CPROGRAM = "%CCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %in% %CLIBRARIES%"
|
||||
CDEPENDS = "%CCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES% %CINCLUDES% %CDEFINES% %CEXTRAFLAGS% -MM -MG %in% > %out%"
|
||||
AR = "%RM% %out% && ar cr %out% %in% && ranlib %out%"
|
||||
|
||||
CBUILDFLAGS = "-g -O"
|
||||
CINCLUDES = {}
|
||||
CDEFINES = {}
|
||||
CEXTRAFLAGS = ""
|
||||
CLINKFLAGS = ""
|
||||
CDYNINCLUDES = ""
|
||||
CLIBRARIES = ""
|
||||
|
||||
--- Manage C file dependencies ----------------------------------------------
|
||||
|
||||
local dependency_cache = {}
|
||||
local function load_dependency_file(fn)
|
||||
local o = dependency_cache[fn]
|
||||
if o then
|
||||
return o
|
||||
end
|
||||
|
||||
-- Read in the dependency file.
|
||||
|
||||
local f = io_open(fn)
|
||||
if not f then
|
||||
print("failed to open "..fn)
|
||||
return nil
|
||||
end
|
||||
f = f:read("*a")
|
||||
|
||||
-- Massage the dependency file into a string containing one unescaped
|
||||
-- filename per line.
|
||||
|
||||
f = string_gsub(f, "^.*[^\\]: *", "")
|
||||
f = string_gsub(f, "\\\r?\n", "")
|
||||
f = string_gsub(f, "([^\\]) +", "%1\n")
|
||||
f = string_gsub(f, "\\", "")
|
||||
|
||||
-- Parse the string.
|
||||
|
||||
o = {}
|
||||
for l in string_gfind(f, "[^\n]+") do
|
||||
table_insert(o, l)
|
||||
end
|
||||
|
||||
dependency_cache[fn] = 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 obj = simple {
|
||||
CDYNINCLUDES = self.CDYNINCLUDES,
|
||||
command = self.makedepends,
|
||||
outputs = {"%U%-%I%.d"},
|
||||
unpack(inputs)
|
||||
}
|
||||
local o = obj:__build()
|
||||
local depends = load_dependency_file(o[1])
|
||||
if not depends then
|
||||
self:__error("could not determine the dependencies for ",
|
||||
pm.rendertable(inputs))
|
||||
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
|
||||
self.CDYNINCLUDES = self.CDYNINCLUDES..' "-I'..string_gsub(o[1], "/[^/]*$", "")..'"'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
-- These are the publically useful clauses.
|
||||
|
||||
cfile = simple_with_clike_dependencies {
|
||||
class = "cfile",
|
||||
command = {"%CC%"},
|
||||
outputs = {"%U%-%I%.o"},
|
||||
}
|
||||
|
||||
cprogram = simple {
|
||||
class = "cprogram",
|
||||
command = {"%CPROGRAM%"},
|
||||
outputs = {"%U%-%I%"},
|
||||
}
|
||||
|
||||
clibrary = simple {
|
||||
class = "clibrary",
|
||||
command = {
|
||||
"%AR%"
|
||||
},
|
||||
outputs = {"%U%-%I%.a"},
|
||||
}
|
|
@ -9,7 +9,10 @@
|
|||
. if t .ds <, ,\
|
||||
\}\
|
||||
\}
|
||||
.cs 5 22u
|
||||
.R1
|
||||
database doc/LLgen.refs
|
||||
accumulate
|
||||
.R2
|
||||
.ND
|
||||
.EQ
|
||||
delim @@
|
||||
|
|
BIN
util/LLgen/pm
BIN
util/LLgen/pm
Binary file not shown.
|
@ -1,37 +0,0 @@
|
|||
-- $Source$
|
||||
-- $State$
|
||||
|
||||
local d = ROOTDIR.."util/LLgen/"
|
||||
|
||||
tool_LLgen = cprogram {
|
||||
CDEFINES = {PARENT, 'NON_CORRECTING', 'LIBDIR="'..d..'lib"'},
|
||||
|
||||
cfile (d.."src/main.c"),
|
||||
cfile (d.."src/gencode.c"),
|
||||
cfile (d.."src/compute.c"),
|
||||
cfile (d.."src/check.c"),
|
||||
cfile (d.."src/reach.c"),
|
||||
cfile (d.."src/global.c"),
|
||||
cfile (d.."src/name.c"),
|
||||
cfile (d.."src/sets.c"),
|
||||
cfile (d.."src/alloc.c"),
|
||||
cfile (d.."src/machdep.c"),
|
||||
cfile (d.."src/cclass.c"),
|
||||
cfile (d.."src/savegram.c"),
|
||||
|
||||
-- These use pre-LLgen'd version of the files. If LLgen.g gets updated,
|
||||
-- they need rebuilding. Use the bootstrap script to do this.
|
||||
|
||||
cfile (d.."src/LLgen.c"),
|
||||
cfile (d.."src/Lpars.c"),
|
||||
cfile (d.."src/tokens.c"),
|
||||
|
||||
outputs = {"%U%/LLgen"},
|
||||
install = pm.install("%TOOLDIR%LLgen")
|
||||
}
|
||||
|
||||
-- Revision history
|
||||
-- $Log$
|
||||
-- Revision 1.1 2006-11-11 22:58:30 dtrg
|
||||
-- Added a pmfile to allow LLgen to be built as part of the ACK again.
|
||||
--
|
Loading…
Reference in a new issue