Makefile

changeset 16
bc9a0fefd892
parent 14
ee9333c91dda
child 18
cae1294702aa
equal deleted inserted replaced
15:9a262e046ab8 16:bc9a0fefd892
1 CC = gcc 1 CC = gcc
2 BUILDDIR = build/ 2 BUILDDIR = build/
3 OBJ = $(shell ls | grep \.c | sed 's/^\([^.]*\)\.c/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ') 3 OBJ = $(shell ls | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
4 BIN = ${BUILDDIR}cline 4 BIN = ${BUILDDIR}cline
5 5
6 all: addrnum ${OBJ} remrnum 6 .PHONY: setup run-compile teardown
7
8 all: setup run-compile teardown
9
10
11 run-compile:
12 -${MAKE} compile
13
14 compile: ${OBJ}
7 ${CC} -o ${BIN} ${OBJ} 15 ${CC} -o ${BIN} ${OBJ}
8 16
9 addrnum: 17 setup:
10 rm build/cline.o 18 mkdir -p ${BUILDDIR}
19 rm -f build/cline.o
11 mv cline.h cline.src 20 mv cline.h cline.src
12 cat cline.src | sed "s/VERSION.*/VERSION=\"$(shell hg identify -i)\";/g" > cline.h 21 cat cline.src | sed "s/VERSION.*/VERSION=\"$(shell hg identify -n) ($(shell hg identify -i))\";/g" > cline.h
13 22
14 remrnum: 23 teardown:
15 rm cline.h 24 rm -f cline.h
16 mv cline.src cline.h 25 mv cline.src cline.h
17 26
18 ${BUILDDIR}%.o: %.c 27 ${BUILDDIR}%.o: %.c
19 mkdir -p ${BUILDDIR}
20 ${CC} -c -std=c99 -o ${BUILDDIR}$*.o $< 28 ${CC} -c -std=c99 -o ${BUILDDIR}$*.o $<
21 29
22 clean: 30 clean:
23 rm build/* 31 rm -f build/*
32

mercurial