-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile
68 lines (50 loc) · 1.51 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# CDB makefile - default target should build everything
#
VERSION =0x050100ul
CFLAGS =-Wall -Wextra -fPIC -std=c99 -O3 -pedantic -fwrapv -DCDB_VERSION="${VERSION}" ${DEFINES} ${EXTRA}
TARGET =cdb
AR =ar
ARFLAGS =rcs
RANLIB =ranlib
DESTDIR =install
ifeq ($(OS),Windows_NT)
DLL=dll
else # Assume Unixen
DLL=so
CFLAGS+=-D_FILE_OFFSET_BITS=64
endif
.PHONY: all test clean dist install
all: ${TARGET}
cdb.o: cdb.c cdb.h makefile
host.o: host.c host.h cdb.h makefile
main.o: main.c host.o cdb.h makefile
lib${TARGET}.a: ${TARGET}.o ${TARGET}.h
${AR} ${ARFLAGS} $@ $<
${RANLIB} $@
lib${TARGET}.${DLL}: ${TARGET}.o ${TARGET}.h
${CC} ${CFLAGS} -shared ${TARGET}.o -o $@
${TARGET}: main.o host.o lib${TARGET}.a
${CC} $^ -o $@
-strip ${TARGET}
test.cdb: ${TARGET}
./${TARGET} -t test.cdb
test: test.cdb
${TARGET}.1: readme.md
-pandoc -s -f markdown -t man $< -o $@
.git:
git clone https://github.com/howerj/cdb cdb-repo
mv cdb-repo/.git .
rm -rf cdb-repo
install: ${TARGET} lib${TARGET}.a lib${TARGET}.${DLL} ${TARGET}.1 .git
install -p -D ${TARGET} ${DESTDIR}/bin/${TARGET}
install -p -m 644 -D lib${TARGET}.a ${DESTDIR}/lib/lib${TARGET}.a
install -p -D lib${TARGET}.${DLL} ${DESTDIR}/lib/lib${TARGET}.${DLL}
install -p -m 644 -D ${TARGET}.h ${DESTDIR}/include/${TARGET}.h
-install -p -m 644 -D ${TARGET}.1 ${DESTDIR}/man/${TARGET}.1
mkdir -p ${DESTDIR}/src
cp -a .git ${DESTDIR}/src
cd ${DESTDIR}/src && git reset --hard HEAD
dist: install
tar zcf ${TARGET}-${VERSION}.tgz ${DESTDIR}
clean: .git
git clean -dffx