1 CFLAGS=-Wall -W -Wextra -Werror -Wno-implicit-fallthrough -std=c99 -Ilib -Isqlite -Ielf -I. -Ilzma/api
3 ZPMVER:=$(shell git tag --list 'v[0-9]*' | sed -e 's/^v//' | sort -nr | head -1)
4 ifeq ($(strip $(ZPMVER)),)
8 LZMAFLAGS=-Ilzma/api -Ilzma/tuklib -Ilzma/lzma -Ilzma/common -Ilzma/check -Ilzma/lz -Ilzma/rangecoder -Ilzma/simple -Ilzma/delta -DHAVE_CHECK_CRC64 -DHAVE_CHECK_CRC32 -DHAVE_ENCODER_LZMA2 -DHAVE_DECODER_LZMA2 -DHAVE_MF_BT4
12 LZMACHECKSRC=lzma/check/check.c lzma/check/crc32_fast.c lzma/check/crc64_fast.c lzma/check/crc32_table.c lzma/check/crc64_table.c
13 LZMASRC=$(shell ls lzma/lzma/*.c lzma/common/*.c lzma/lz/*.c) $(LZMACHECKSRC) lzma/rangecoder/price_table.c
14 LZMAOBJ=$(filter-out lzma/common/stream_encoder_mt.o, $(LZMASRC:%.c=%.o))
17 find xz/src/liblzma -type d -name .deps -prune \
18 -o -type f -printf '%P\n' \
19 | xargs -IZ echo Z Z Z \
20 | xargs printf 'test -e lzma/%s && cp xz/src/liblzma/%s lzma/%s\n' \
23 #lzma/lz/lz_decoder.o: lzma/lz/lz_decoder.c
24 #lzma/lz/lz_encoder.o: lzma/lz/lz_encoder.c
27 $(CC) $(CFLAGS) $(LZMAFLAGS) -c -o $@ $<
29 lib/liblzma.a: $(LZMAOBJ)
34 ZPKGBIN=zpm-addfile zpm-extract zpm-init zpm-vercmp zpm-stat zpm-hash \
35 zpm-findpkg zpm-shell zpm-soneed
37 SCRIPTS=zpm zpm-install zpm-merge zpm-list zpm-preserve zpm-test zpm-log \
40 PROGRAMS=$(SCRIPTS) $(COMPILED)
44 printf '%s\n' $(LZMAOBJ)
47 package: zpm-$(ZPMVER)-1.zpm
49 ZPM:= ./zpm -P scripts:bin:.
51 zpm-$(ZPMVER)-1.zpm: programs
53 $(ZPM) newpackage -f $@ -v $(ZPMVER) zpm
54 $(ZPM) addtopackage -u root -g root -f $@ -P /sbin -v $(ZPMVER) zpm $(PROGRAMS)
56 tarball: zpm-$(ZPMVER)-1.tar.xz
58 zpm-$(ZPMVER)-1.tar.xz: programs
60 tar -cJf $@ --transform='s|^|bin/|' \
67 gcc -std=c99 -Wall -c -o $@ $<
70 PATH=$(curdir)/t:$(curdir):$(PATH) t/$(T).t
72 t/ctap/prove: t/ctap/prove.o
73 $(CC) $(CFLAGS) -o $@ $+
75 test: $(ZPKGBIN) t/ctap/prove
76 PATH=$(curdir)/t:$(curdir):$(PATH) t/ctap/prove t/*.t
78 programs: elftype zpm-soname zpm-soneed zpm-addfile zpm-extract zpm-init \
79 zpm-vercmp zpm-findpkg zpm-merge
81 uncompress: uncompress.o
82 $(CC) $(CFLAGS) -o $@ $+ -llzma
84 elftype: elf/elftype.c
85 $(CC) $(CFLAGS) -o $@ $+
87 zpm-soname: elf/soname.c
88 $(CC) -Ielf $(CFLAGS) -o $@ $+
90 zpm-soneed: elf/needed.c
91 $(CC) -Ielf $(CFLAGS) -o $@ $+
93 zpm-addfile: zpm-addfile.o libzpm.a libelf.a
94 $(CC) -Ielf $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
96 zpm-hash: zpm-hash.o libzpm.a
97 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
99 zpm-init: zpm-init.o libzpm.a
100 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
102 zpm-extract: zpm-extract.o libzpm.a
103 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
105 zpm-findpkg: zpm-findpkg.o libzpm.a
106 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
109 echo "char createdb[] = {" > $@
113 sqlite/sqlite3.o: sqlite/sqlite3.c sqlite/config.h
114 $(CC) -Wall -std=c99 -Ilib -D_HAVE_SQLITE_CONFIG_H=1 -c -o $@ $<
116 sqlite/shell.o: sqlite/shell.c sqlite/config.h
117 $(CC) -Wall -std=c99 -Ilib -D_POSIX_C_SOURCE=200112L -D_HAVE_SQLITE_CONFIG_H=1 -c -o $@ $<
121 zpm-vercmp: zpm-vercmp.o lib/vercmp.o
122 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
124 zpm-shell: sqlite/sqlite3.o sqlite/shell.o
125 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
127 libzpm.a: lib/sha256.o lib/db.o lib/compress.o lib/uncompress.o lib/zpm.o \
128 sqlite/sqlite3.o lib/zpm_hash.o \
134 libelf.a: elf/libelf.o
138 test -d $(DESTDIR)/bin || install -d $(DESTDIR)/bin
139 install -D $(PROGRAMS) $(DESTDIR)/bin
142 rm -f *.o sqlite/*.o lib/*.o $(LZMAOBJ) liblzma.a \
143 libelf.a libzpm.a zpm-addfile soname \
145 local.db t/ctap/prove.o
150 ZPMDB=tmp/db.zpm ./zpm -P. install -R tmp -f zpm-0.1.2-1.zpm -u nw -g nw
153 ZPMDB=tmp/db.zpm ./zpm -P. install -R tmp -f zpm-$(ZPMVER)-1.zpm -u nw -g nw