From 97072ec32127f05202695df2349a4145671dba02 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Tue, 6 Aug 2013 05:21:50 +0000 Subject: [PATCH] Convert to plain old make --- common.mk | 41 +++++++++++++++++++++++++++++++++++++++++ example/makefile | 9 +++++++++ example/mkfile | 7 ------- gallery/makefile | 15 +++++++++++++++ gallery/mkfile | 12 ------------ knot/makefile | 14 ++++++++++++++ knot/mkfile | 12 ------------ makefile | 32 +++----------------------------- 8 files changed, 82 insertions(+), 60 deletions(-) create mode 100644 common.mk create mode 100644 example/makefile delete mode 100644 example/mkfile create mode 100644 gallery/makefile delete mode 100644 gallery/mkfile create mode 100644 knot/makefile delete mode 100644 knot/mkfile diff --git a/common.mk b/common.mk new file mode 100644 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 index 0000000..2a9e77d --- /dev/null +++ b/example/makefile @@ -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 index bd43d89..0000000 --- a/example/mkfile +++ /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 index 0000000..15f624d --- /dev/null +++ b/gallery/makefile @@ -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 index 2a57660..0000000 --- a/gallery/mkfile +++ /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 index 0000000..6487dca --- /dev/null +++ b/knot/makefile @@ -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 index dc787dd..0000000 --- a/knot/mkfile +++ /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 diff --git a/makefile b/makefile index edc6978..aaa5d93 100644 --- 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 -- 2.43.2