Makefile

changeset 34
fa9bda32de17
parent 32
51d6e45a7592
child 35
35120de6ee53
--- a/Makefile	Tue Oct 02 10:49:25 2012 +0200
+++ b/Makefile	Fri Dec 28 15:44:28 2012 +0100
@@ -38,6 +38,10 @@
 #endif
 
 VERSION_PREFIX=1.0.
+SRCDIR=src/
+BUILDDIR=build/
+OBJ = $(shell ls ${SRCDIR} | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
+BIN = ${BUILDDIR}cline
 
 include ${CONF}.mk
 
@@ -52,17 +56,19 @@
 compile: ${OBJ}
 	${LD} -o ${BIN} ${OBJ} ${LDFLAGS}
 
-setup:
-	mkdir -p ${BUILDDIR}
+setup: ${BUILDDIR}
 	rm -f ${BUILDDIR}cline.o
-	mv cline.h cline.src
-	cat cline.src | sed "s/VERSION.*/VERSION=\"${VERSION_PREFIX}$(shell hg identify -n) ($(shell hg identify -i))\";/g" > cline.h
+	mv ${SRCDIR}cline.h ${SRCDIR}cline.src
+	cat ${SRCDIR}cline.src | sed "s/VERSION.*/VERSION=\"${VERSION_PREFIX}$(shell hg identify -n) ($(shell hg identify -i))\";/g" > ${SRCDIR}cline.h
+	
+${BUILDDIR}:
+	mkdir ${BUILDDIR}
 	
 teardown:
-	rm -f cline.h
-	mv cline.src cline.h
+	rm -f ${SRCDIR}cline.h
+	mv ${SRCDIR}cline.src ${SRCDIR}cline.h
 
-${BUILDDIR}%.o: %.c
+${BUILDDIR}%.o: ${SRCDIR}%.c
 	${CC} ${CFLAGS} -c -o ${BUILDDIR}$*.o $<
 
 clean:

mercurial