-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
93 lines (70 loc) · 2.04 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Shrink makefile
# See <https://github.com/howerj/shrink> for more information
#
VERSION=0x010300
CFLAGS=-std=c99 -Wall -Wextra -pedantic -g -O2 -DSHRINK_VERSION="${VERSION}"
TARGET=shrink
DESTDIR =install
.PHONY: clean all test check install dist
all: ${TARGET}
lib${TARGET}.a: ${TARGET}.o
ar rcs $@ $^
${TARGET}.o: ${TARGET}.c ${TARGET}.h
main.o: main.c lib${TARGET}.a ${TARGET}.h
${TARGET}: main.o lib${TARGET}.a
${CC} ${CFLAGS} $^ -o $@
-strip $@
${TARGET}.1: readme.md
-pandoc -s -f markdown -t man $< -o $@
.git:
git clone https://github.com/howerj/shrink shrink-repo
mv shrink-repo/.git .
rm -rf shrink-repo
install: ${TARGET} lib${TARGET}.a ${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 -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}
check:
cppcheck --enable=all *.c
clean:
git clean -dffx
# Tests
TEST_FILES=readme.md random.bin zero.bin
zero.bin:
dd if=/dev/zero of=$@ count=2048
random.bin:
dd if=/dev/urandom of=$@ count=2048
%.lzss %.big: % ${TARGET}
./${TARGET} -v -c $< $<.lzss
./${TARGET} -v -d $<.lzss $<.big
cmp $< $<.big
%.rle %.wle: % ${TARGET}
./${TARGET} -v -r -c $< $<.rle
./${TARGET} -v -r -d $<.rle $<.wle
cmp $< $<.wle
%.elias %.saile : % ${TARGET}
./${TARGET} -v -e -c $< $<.elias
./${TARGET} -v -e -d $<.elias $<.saile
cmp $< $<.saile
%.mtf %.ftm: % ${TARGET}
./${TARGET} -v -m -c $< $<.mtf
#od -vtu1 -An -w1 my.file | sort -n | uniq -c
./${TARGET} -v -m -d $<.mtf $<.ftm
cmp $< $<.ftm
%.lzp %.plz : % ${TARGET}
./${TARGET} -v -z -c $< $<.lzp
./${TARGET} -v -z -d $<.lzp $<.plz
cmp $< $<.plz
WLE:=${TEST_FILES:=.wle}
BIG:=${TEST_FILES:=.big}
FTM:=${TEST_FILES:=.ftm}
SAL:=${TEST_FILES:=.saile}
LZP:=${TEST_FILES:=.plz}
test: ${TARGET} ${WLE} ${BIG} ${FTM} ${SAL} ${LZP}
./${TARGET} -t