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/ |
41 SRCDIR=src |
42 BUILDDIR=build/ |
42 BUILDDIR=build |
43 OBJ = $(shell ls ${SRCDIR} | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ') |
43 OBJ = arguments.o bfile_heuristics.o cline.o regex_parser.o scanner.o settings.o stream.o string_list.o suffix_fnc.o |
44 BIN = ${BUILDDIR}cline |
44 BIN = $(BUILDDIR)/cline |
45 |
45 |
46 include ${CONF}.mk |
46 include $(CONF).mk |
47 |
47 |
48 .PHONY: setup run-compile teardown |
48 all: $(BUILDDIR) compile |
49 |
49 |
50 all: setup run-compile teardown |
50 compile: $(OBJ:%=$(BUILDDIR)/%) |
|
51 $(LD) -o $(BIN) $^ $(LDFLAGS) |
51 |
52 |
52 |
53 $(BUILDDIR): |
53 run-compile: |
54 mkdir $(BUILDDIR) |
54 -${MAKE} compile |
|
55 |
55 |
56 compile: ${OBJ} |
56 $(BUILDDIR)/%.o: $(SRCDIR)/%.c |
57 ${LD} -o ${BIN} ${OBJ} ${LDFLAGS} |
57 $(CC) $(CFLAGS) -c -o $@ $< |
58 |
|
59 setup: ${BUILDDIR} |
|
60 rm -f ${BUILDDIR}cline.o |
|
61 mv ${SRCDIR}cline.h ${SRCDIR}cline.src |
|
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} |
|
66 |
|
67 teardown: |
|
68 rm -f ${SRCDIR}cline.h |
|
69 mv ${SRCDIR}cline.src ${SRCDIR}cline.h |
|
70 |
|
71 ${BUILDDIR}%.o: ${SRCDIR}%.c |
|
72 ${CC} ${CFLAGS} -c -o ${BUILDDIR}$*.o $< |
|
73 |
58 |
74 clean: |
59 clean: |
75 rm -f ${BUILDDIR}*.o |
60 rm -f $(BUILDDIR)/*.o |
76 |
61 |