ackbuilder rules files now require absolute paths in external variables
authorDavid Given <dg@cowlark.com>
Mon, 18 Jul 2016 21:16:27 +0000 (23:16 +0200)
committerDavid Given <dg@cowlark.com>
Mon, 18 Jul 2016 21:16:27 +0000 (23:16 +0200)
(otherwise commands which change directory don't work).

Makefile
first/ackbuilder.lua
lang/cem/cemcom.ansi/build.lua
util/LLgen/build.lua

index 4cdb47e..7cc12c2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -39,11 +39,11 @@ CC = gcc
 # You shouldn't need to change anything below this point unless you are
 # actually developing ACK.
 
-OBJDIR = $(BUILDDIR)/obj
-BINDIR = $(BUILDDIR)/bin
-LIBDIR = $(BUILDDIR)/lib
-INCDIR = $(BUILDDIR)/include
-INSDIR = $(BUILDDIR)/staging
+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
@@ -91,11 +91,11 @@ endif
 
 $(BUILDDIR)/rules.ninja: first/ackbuilder.lua $(BUILD_FILES)
        @mkdir -p $(BUILDDIR)
-       lua5.2 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja
+       @lua5.2 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja
 
 $(BUILDDIR)/rules.mk: first/ackbuilder.lua $(BUILD_FILES)
        @mkdir -p $(BUILDDIR)
-       lua5.2 first/ackbuilder.lua first/build.lua build.lua --make > $(BUILDDIR)/rules.mk
+       @lua5.2 first/ackbuilder.lua first/build.lua build.lua --make > $(BUILDDIR)/rules.mk
 
 clean:
        @rm -rf $(BUILDDIR)
index 935346c..a799c8a 100644 (file)
@@ -65,7 +65,7 @@ end
 
 local function concatpath(...)
        local p = table.concat({...}, "/")
-       return p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/")
+       return (p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/"))
 end
 
 local function filenamesof(targets, pattern)
@@ -153,7 +153,7 @@ local function abspath(collection)
                end
        )
 end
-       
+
 local function basename(collection)
        return dotocollection(collection,
                function(filename)
@@ -648,6 +648,8 @@ local function parse_arguments(argmap, arg)
 end
 
 globals = {
+       posix = posix,
+
        abspath = abspath,
        asstring = asstring,
        basename = basename,
index 8dfd6ab..5f8476a 100644 (file)
@@ -13,7 +13,7 @@ normalrule {
        }
 }
 
-local str_files = basename(posix.glob("lang/cem/cemcom.ansi/*.str"))
+local str_files = basename(posix.glob(cwd().."/*.str"))
 local str_targets = {}
 
 for _, f in ipairs(str_files) do
index 0a2c29f..ff0b7f6 100644 (file)
@@ -6,7 +6,7 @@ cprogram {
        -- do this.
 
        srcs = { "./src/*.c" },
-       cflags = { "-DLIBDIR=\\\""..abspath("util/LLgen/lib").."\\\"", "-DNON_CORRECTING" },
+       cflags = { "-DLIBDIR=\\\""..posix.getcwd().."/"..cwd().."/lib\\\"", "-DNON_CORRECTING" },
 }
 
 definerule("llgen",