Makefile

changeset 34
fa9bda32de17
parent 32
51d6e45a7592
child 35
35120de6ee53
equal deleted inserted replaced
33:1a2d7298bc82 34:fa9bda32de17
36 #ifndef CONF 36 #ifndef CONF
37 CONF = gcc 37 CONF = gcc
38 #endif 38 #endif
39 39
40 VERSION_PREFIX=1.0. 40 VERSION_PREFIX=1.0.
41 SRCDIR=src/
42 BUILDDIR=build/
43 OBJ = $(shell ls ${SRCDIR} | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
44 BIN = ${BUILDDIR}cline
41 45
42 include ${CONF}.mk 46 include ${CONF}.mk
43 47
44 .PHONY: setup run-compile teardown 48 .PHONY: setup run-compile teardown
45 49
50 -${MAKE} compile 54 -${MAKE} compile
51 55
52 compile: ${OBJ} 56 compile: ${OBJ}
53 ${LD} -o ${BIN} ${OBJ} ${LDFLAGS} 57 ${LD} -o ${BIN} ${OBJ} ${LDFLAGS}
54 58
55 setup: 59 setup: ${BUILDDIR}
56 mkdir -p ${BUILDDIR}
57 rm -f ${BUILDDIR}cline.o 60 rm -f ${BUILDDIR}cline.o
58 mv cline.h cline.src 61 mv ${SRCDIR}cline.h ${SRCDIR}cline.src
59 cat cline.src | sed "s/VERSION.*/VERSION=\"${VERSION_PREFIX}$(shell hg identify -n) ($(shell hg identify -i))\";/g" > cline.h 62 cat ${SRCDIR}cline.src | sed "s/VERSION.*/VERSION=\"${VERSION_PREFIX}$(shell hg identify -n) ($(shell hg identify -i))\";/g" > ${SRCDIR}cline.h
63
64 ${BUILDDIR}:
65 mkdir ${BUILDDIR}
60 66
61 teardown: 67 teardown:
62 rm -f cline.h 68 rm -f ${SRCDIR}cline.h
63 mv cline.src cline.h 69 mv ${SRCDIR}cline.src ${SRCDIR}cline.h
64 70
65 ${BUILDDIR}%.o: %.c 71 ${BUILDDIR}%.o: ${SRCDIR}%.c
66 ${CC} ${CFLAGS} -c -o ${BUILDDIR}$*.o $< 72 ${CC} ${CFLAGS} -c -o ${BUILDDIR}$*.o $<
67 73
68 clean: 74 clean:
69 rm -f ${BUILDDIR}*.o 75 rm -f ${BUILDDIR}*.o
70 76

mercurial