aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--common.mk29
l---------opdracht-1/build1
-rw-r--r--opdracht-1/makefile3
-rwxr-xr-xopdracht-2/build3
-rw-r--r--opdracht-2/makefile9
-rw-r--r--opdracht-2/reset-2.sql2
-rw-r--r--opdracht-2/reset.sql2
-rwxr-xr-xrender-opdracht12
9 files changed, 44 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index 9b41e02..3fc3088 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
opdracht-*/*.md
+opdracht-*/.tmp.sql
opdracht-*/opdracht.pdf
opdracht-*/opdracht-*.md
diff --git a/common.mk b/common.mk
new file mode 100644
index 0000000..8a0327d
--- /dev/null
+++ b/common.mk
@@ -0,0 +1,29 @@
+RM = rm -f
+MYSQL = mysql -Hu root mysql
+M4 = m4
+
+RESET_SQL += reset.sql
+QUERY_SQL += $(wildcard q*.sql)
+TESTS_SQL += $(wildcard t*.sql)
+
+TESTS_MD = $(patsubst %.sql,%.md, $(TESTS_SQL))
+
+.PHONY: $(TARGET).m4 $(TESTS_SQL) .tmp.sql clean reset
+
+all: $(TARGET).md
+
+.tmp.sql: $(RESET_SQL) $(QUERY_SQL)
+ cat $(RESET_SQL) $(QUERY_SQL) > .tmp.sql
+
+reset: .tmp.sql
+ $(MYSQL) < .tmp.sql
+
+%.md: %.sql reset
+ $(MYSQL) < $< &> $@
+
+$(TARGET).md: $(TESTS_MD) $(TARGET).m4
+ $(M4) $(TARGET).m4 > $(TARGET).md
+
+clean:
+ $(RM) $(wildcard *.md) .tmp.sql
+
diff --git a/opdracht-1/build b/opdracht-1/build
deleted file mode 120000
index 1fb5c6e..0000000
--- a/opdracht-1/build
+++ /dev/null
@@ -1 +0,0 @@
-../render-opdracht \ No newline at end of file
diff --git a/opdracht-1/makefile b/opdracht-1/makefile
new file mode 100644
index 0000000..b91dfe8
--- /dev/null
+++ b/opdracht-1/makefile
@@ -0,0 +1,3 @@
+TARGET := opdracht-1
+
+include ../common.mk
diff --git a/opdracht-2/build b/opdracht-2/build
deleted file mode 100755
index 6f370cb..0000000
--- a/opdracht-2/build
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-cat ../opdracht-1/reset.sql ../opdracht-1/q*.sql reset-2.sql > reset.sql
-source ../render-opdracht
diff --git a/opdracht-2/makefile b/opdracht-2/makefile
new file mode 100644
index 0000000..19a0072
--- /dev/null
+++ b/opdracht-2/makefile
@@ -0,0 +1,9 @@
+TARGET = opdracht-2
+RESET_SQL += ../opdracht-1/.tmp.sql
+
+all: $(TARGET).md
+
+../opdracht-1/.tmp.sql:
+ make -C ../opdracht-1
+
+include ../common.mk
diff --git a/opdracht-2/reset-2.sql b/opdracht-2/reset-2.sql
deleted file mode 100644
index 08ec0f3..0000000
--- a/opdracht-2/reset-2.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-drop table Status;
-
diff --git a/opdracht-2/reset.sql b/opdracht-2/reset.sql
index e69de29..3e90143 100644
--- a/opdracht-2/reset.sql
+++ b/opdracht-2/reset.sql
@@ -0,0 +1,2 @@
+drop table if exists Status;
+
diff --git a/render-opdracht b/render-opdracht
deleted file mode 100755
index cc4fa48..0000000
--- a/render-opdracht
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-bye () {
- echo "run me as root!"
- exit 1
-}
-
-[ $(id -g) -ne 0 ] && bye
-cat reset.sql q*.sql | mysql -u root mysql
-for file in t*.sql; do
- mysql -Hu root mysql < "$file" &> "${file/%.sql}.md"
-done
-m4 `basename $PWD`.m4 > `basename $PWD`.md