Makefile

changeset 16
bc9a0fefd892
parent 14
ee9333c91dda
child 18
cae1294702aa
--- a/Makefile	Mon Sep 19 08:11:08 2011 +0200
+++ b/Makefile	Tue Sep 20 15:19:28 2011 +0200
@@ -1,23 +1,32 @@
 CC = gcc
 BUILDDIR = build/
-OBJ = $(shell ls | grep \.c | sed 's/^\([^.]*\)\.c/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
+OBJ = $(shell ls | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
 BIN = ${BUILDDIR}cline
 
-all: addrnum ${OBJ} remrnum
+.PHONY: setup run-compile teardown
+
+all: setup run-compile teardown
+	
+	
+run-compile:
+	-${MAKE} compile
+
+compile: ${OBJ}
 	${CC} -o ${BIN} ${OBJ}
 
-addrnum:
-	rm build/cline.o
+setup:
+	mkdir -p ${BUILDDIR}
+	rm -f build/cline.o
 	mv cline.h cline.src
-	cat cline.src | sed "s/VERSION.*/VERSION=\"$(shell hg identify -i)\";/g" > cline.h
+	cat cline.src | sed "s/VERSION.*/VERSION=\"$(shell hg identify -n) ($(shell hg identify -i))\";/g" > cline.h
 	
-remrnum:
-	rm cline.h
+teardown:
+	rm -f cline.h
 	mv cline.src cline.h
 
 ${BUILDDIR}%.o: %.c
-	mkdir -p ${BUILDDIR}
 	${CC} -c -std=c99 -o ${BUILDDIR}$*.o $<
 
 clean:
-	rm build/*
+	rm -f build/*
+	
\ No newline at end of file

mercurial