aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2020-09-09 19:36:13 +0100
committerTomasz Kramkowski <tk@the-tk.com>2020-09-09 19:36:13 +0100
commitb435a5824bf88b9bddddb81e645623caa2e334bc (patch)
tree2f26f5e00ed0825bec0980c0f815e814dcfa0650
parentfaa44a2bac0a9ddef75e68990486ccae7377ac36 (diff)
downloadpack-b435a5824bf88b9bddddb81e645623caa2e334bc.tar.gz
pack-b435a5824bf88b9bddddb81e645623caa2e334bc.tar.xz
pack-b435a5824bf88b9bddddb81e645623caa2e334bc.zip
Switch to using redo
-rw-r--r--.gitignore2
-rw-r--r--Makefile9
-rw-r--r--all.do2
-rwxr-xr-xconfigure5
-rw-r--r--default.o.do5
-rw-r--r--link4
-rw-r--r--loadargs8
-rwxr-xr-xscripts/clean2
-rw-r--r--test_gen.do3
-rw-r--r--unpack_test.do3
-rw-r--r--unpack_test.inc.do3
-rw-r--r--unpack_test.o.do4
12 files changed, 41 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 981c059..c29b68d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
+*.d
*.o
*_test
*.inc
*_gen
+*.args
diff --git a/Makefile b/Makefile
deleted file mode 100644
index d8037f6..0000000
--- a/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright (C) 2020 Tomasz Kramkowski <tk@the-tk.com>
-# SPDX-License-Identifier: MIT
-unpack_test: unpack_test.o unpack.o common.o trace.o
-unpack_test.o: unpack_test.c pack.h trace.h common.h unpack_test.inc
-trace.o: trace.c trace.h
-common.o: common.c common.h
-unpack_test.inc: test_gen
- ./$< >$@
-test_gen: test_gen.o
diff --git a/all.do b/all.do
new file mode 100644
index 0000000..ff9812a
--- /dev/null
+++ b/all.do
@@ -0,0 +1,2 @@
+#!/bin/sh
+redo-ifchange "$0" "unpack_test"
diff --git a/configure b/configure
new file mode 100755
index 0000000..70a0698
--- /dev/null
+++ b/configure
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for f in args/"$1"/*; do
+ ln -sf "$f"
+done
diff --git a/default.o.do b/default.o.do
new file mode 100644
index 0000000..9135cb8
--- /dev/null
+++ b/default.o.do
@@ -0,0 +1,5 @@
+#!/bin/bash
+redo-ifchange "$0" "default.o.do" "$2.c"
+. loadargs "compile"
+gcc -std=c11 -MD -MF "$2.d" -c -o "$3" "${args[@]}" "$2.c"
+redo-ifchange "$2.d" $(sed ':a;/\\$/{s/[^:]*: //;N;s/ \\\n//;ba}' <"$2.d")
diff --git a/link b/link
new file mode 100644
index 0000000..2b99b87
--- /dev/null
+++ b/link
@@ -0,0 +1,4 @@
+#/fake/bash
+redo-ifchange "$0" "link" "${deps[@]}"
+. loadargs "link"
+gcc -o "$3" "${deps[@]}"
diff --git a/loadargs b/loadargs
new file mode 100644
index 0000000..3ec8b0d
--- /dev/null
+++ b/loadargs
@@ -0,0 +1,8 @@
+#/fake/bash
+if [ -r "$1.args" ]; then
+ redo-ifchange "$1.args"
+ mapfile -t args <"$1.args"
+else
+ redo-ifcreate "$1.args"
+ args=()
+fi
diff --git a/scripts/clean b/scripts/clean
new file mode 100755
index 0000000..97d7b0f
--- /dev/null
+++ b/scripts/clean
@@ -0,0 +1,2 @@
+#!/bin/sh
+find . \( -name '*.d' -o -name '*.o' -o -name '*_gen' -o -name '*.inc' \) -delete
diff --git a/test_gen.do b/test_gen.do
new file mode 100644
index 0000000..ed0f2e4
--- /dev/null
+++ b/test_gen.do
@@ -0,0 +1,3 @@
+#!/bin/bash
+deps=(test_gen.o)
+. ./link
diff --git a/unpack_test.do b/unpack_test.do
new file mode 100644
index 0000000..9c810c6
--- /dev/null
+++ b/unpack_test.do
@@ -0,0 +1,3 @@
+#!/bin/bash
+deps=(unpack_test.o common.o unpack.o trace.o)
+. ./link
diff --git a/unpack_test.inc.do b/unpack_test.inc.do
new file mode 100644
index 0000000..c6d5c1b
--- /dev/null
+++ b/unpack_test.inc.do
@@ -0,0 +1,3 @@
+#!/bin/sh
+redo-ifchange "$0" "test_gen"
+./test_gen
diff --git a/unpack_test.o.do b/unpack_test.o.do
new file mode 100644
index 0000000..a7c32b8
--- /dev/null
+++ b/unpack_test.o.do
@@ -0,0 +1,4 @@
+#!/bin/bash
+redo-ifchange "unpack_test.inc"
+set -- "$1" "${2%.o}" "$3"
+. ./default.o.do