]> Pileus Git - ~andy/ct/commitdiff
Convert to plain old make
authorAndy Spencer <andy753421@gmail.com>
Tue, 6 Aug 2013 05:21:50 +0000 (05:21 +0000)
committerAndy Spencer <andy753421@gmail.com>
Tue, 6 Aug 2013 05:21:50 +0000 (05:21 +0000)
common.mk [new file with mode: 0644]
example/makefile [new file with mode: 0644]
example/mkfile [deleted file]
gallery/makefile [new file with mode: 0644]
gallery/mkfile [deleted file]
knot/makefile [new file with mode: 0644]
knot/mkfile [deleted file]
makefile

diff --git a/common.mk b/common.mk
new file mode 100644 (file)
index 0000000..43996c7
--- /dev/null
+++ b/common.mk
@@ -0,0 +1,41 @@
+# Utilities
+GCC      ?= gcc
+LEX      ?= flex
+YACC     ?= bison
+CT       ?= ct
+
+CFLAGS   ?= -Wall -Werror -g --std=c99
+
+ifdef PKGS
+CPPFLAGS += $(shell pkg-config --cflags $(PKGS))
+LDFLAGS  += $(shell pkg-config --libs   $(PKGS))
+endif
+
+# Targets
+all: $(PROG)
+
+clean:
+       rm -f $(PROG) *.o *.a parse.h parse.c scan.c
+
+# C Rules
+$(PROG): $(SOURCES:%.c=%.o)
+       $(GCC) $(CFLAGS) -o $@ $+ $(LDFLAGS)
+
+%.o: %.c makefile
+       $(GCC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+# Lex / Yacc rules
+%.c: %.l parse.h makefile
+       $(LEX) -o $@ $<
+
+%.c %.h: %.y makefile
+       $(YACC) -d -o $*.c $*.y
+
+# CT Rules
+%.c: %.ct makefile
+       $(CT) -o $@ $<
+
+# Miscellaneous
+.SECONDARY:
+
+# vim: ft=make
diff --git a/example/makefile b/example/makefile
new file mode 100644 (file)
index 0000000..2a9e77d
--- /dev/null
@@ -0,0 +1,9 @@
+# Settings
+CT      = ../ct
+PROG    = main
+SOURCES = main.c html.c
+
+default: main
+       ./main
+
+include ../common.mk
diff --git a/example/mkfile b/example/mkfile
deleted file mode 100644 (file)
index bd43d89..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-PROGS=main
-CLEAN=html.c
-
-default:V: run
-main: main.o html.o
-
-<../mkcommon
diff --git a/gallery/makefile b/gallery/makefile
new file mode 100644 (file)
index 0000000..15f624d
--- /dev/null
@@ -0,0 +1,15 @@
+# Settings
+CT        = ../ct
+PROG      = gallery
+SOURCES   = gallery.c html.c ../lib.c
+CPPFLAGS  = -I..
+PKGS      = glib-2.0
+
+# Targets
+test: gallery
+       QUERY_STRING=foo ./gallery
+
+# Rules
+../lib.o: CFLAGS += -Wno-format
+
+include ../common.mk
diff --git a/gallery/mkfile b/gallery/mkfile
deleted file mode 100644 (file)
index 2a57660..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-PROGS    = gallery
-PKGS     = glib-2.0
-CLEAN    = html.c
-CPPFLAGS = -I..
-CFLAGS   = --std=c99 -Wall -Wno-format -g
-
-default:V: gallery
-       QUERY_STRING=foo ./gallery
-
-gallery: gallery.o html.o ../lib.o
-
-<../mkcommon
diff --git a/knot/makefile b/knot/makefile
new file mode 100644 (file)
index 0000000..6487dca
--- /dev/null
@@ -0,0 +1,14 @@
+# Settings
+CT        = ../ct
+PROG      = knot
+SOURCES   = knot.c html.c
+CPPFLAGS  = -I..
+
+# Targets
+test: crown.html hitch.html overhand.html
+
+# Rules
+%.html: %.txt knot makefile
+       ./knot < $< > $@
+
+include ../common.mk
diff --git a/knot/mkfile b/knot/mkfile
deleted file mode 100644 (file)
index dc787dd..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-PROGS=knot
-CLEAN=html.c *.html
-
-knots=`{ls *.txt}
-default:V: ${knots:%.txt=%.html}
-
-knot: knot.o html.o knot.h 
-
-%.html: $PROGS %.txt
-       ./$PROGS < $stem.txt > $stem.html
-
-<../mkcommon
index edc6978633f397919d9195a6c25aa3a9bd10a916..aaa5d932fdc61d1b9409e5ba5876c6ac302b422c 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,35 +1,9 @@
 # Settings
 PROG     = ct
-CC       = gcc
-YACC     = bison
-LEX      = flex
-
-CFLAGS   = -Wall -Werror -g --std=c99
-CPPFLAGS = $(shell pkg-config --cflags glib-2.0)
-LDFLAGS  = $(shell pkg-config --libs   glib-2.0)
-
-# Targets
-default: test
-
-all: $(PROG)
+SOURCES  = ct.o parse.o scan.o
+PKGS     = glib-2.0
 
 test: $(PROG)
        ./$(PROG) example/html.ct
 
-clean:
-       rm -f $(PROG) *.o *.a parse.h parse.c scan.c
-
-# Rules
-$(PROG): ct.o parse.o scan.o
-       $(CC) $(CFLAGS) -o $@ $+ $(LDFLAGS)
-
-%.o: %.c parse.h
-       $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
-
-%.c: %.l parse.h
-       $(LEX) -o $@ $<
-
-%.c %.h: %.y
-       $(YACC) -d -o $*.c $*.y
-
-.SECONDARY:
+include common.mk