-CC=clang
+CC=clang --target=x86_64-pc-linux-musl
#CC=/usr/musl/bin/musl-gcc
-CFLAGS=-Wall -W -Wextra -Werror -Wno-implicit-fallthrough -std=c99 -Ilib -Isqlite -Ielf -I. -Ilzma/api
+CFLAGS=-Wall -W -Wextra -Werror -Wno-implicit-fallthrough -std=c99 -Ilib -Isqlite -Ielf -I. -Ilzma/api --target=x86_64-pc-linux-musl
ZPMVER:=$(shell git describe --tags --match 'v[0-9]*' | sed -e 's/^v//' | sed -e 's/-g.\+//' | sed -e 's/-/./g')
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
-LDFLAGS=-L. -static
+LDFLAGS=-fuse-ld=lld -L. -static
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
LZMASRC=$(shell ls lzma/lzma/*.c lzma/common/*.c lzma/lz/*.c) $(LZMACHECKSRC) lzma/rangecoder/price_table.c
ZPKGBIN=zpm-addfile zpm-extract zpm-init zpm-vercmp zpm-stat zpm-hash \
zpm-findpkg zpm-shell zpm-soneed zpm-foreach-path zpm-parse \
zpm-script zpm-soname zpm-syncfs zpm-packagehash zpm-verify \
- zpm-elftype zpm-quote zpm-note zpm-search
+ zpm-elftype zpm-quote zpm-note zpm-search zpm-add
SCRIPTS=zpm zpm-install zpm-merge zpm-list zpm-preserve zpm-test zpm-log \
zpm-contents zpm-uninstall zpm-pathmod zpm-rmpackage zpm-newpackage \
- zpm-pkg zpm-add zpm-pkgfile zpm-gc zpm-repo zpm-update zpm-confgit
+ zpm-pkg zpm-pkgfile zpm-gc zpm-repo zpm-update zpm-confgit
+
+MANPAGES=doc/zpm.8 $(addprefix doc/zpm-, list.8 contents.8 hash.8 quote.8 pathmod.8 note.8 vercmp.8 repo.8)
COMPILED=$(ZPKGBIN)
PROGRAMS=$(SCRIPTS) $(COMPILED)
ZPM:= ./zpm -P.
-zpm-$(ZPMVER)-1.zpm: programs doc/zpm.8
+zpm-$(ZPMVER)-1.zpm: programs $(MANPAGES)
rm -f $@
$(ZPM) newpackage -C zpm-$(ZPMVER)-1
$(ZPM) add -v -u root -g root -f $@ -P /sbin zpm-$(ZPMVER)-1 $(sort $(PROGRAMS))
- $(ZPM) add -v -u root -g root -f $@ -P /usr/share/man/man8 -S doc doc/zpm.8
+ $(ZPM) add -v -u root -g root -f $@ -P /usr/share/man/man8 -S doc $(MANPAGES)
tarball: zpm-$(ZPMVER)-1.tar.xz
PATH=$(curdir)/t:$(curdir):$(PATH) t/$(T).t
t/ctap/prove: t/ctap/prove.o
- $(CC) $(CFLAGS) -o $@ $+
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
test: $(ZPKGBIN) t/ctap/prove
@PATH=$(curdir)/t:$(curdir):$(PATH) t/ctap/prove t/*.t
zpm-parse: zpm-parse.o lib/parse.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
+zpm-add: zpm-add.o lib/parse.o libzpm.a
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ -lzpm -lelf
+
zpm-quote: zpm-quote.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
-db.sql: schema/main.sql schema/syncconflicts.sql
+db.sql: schema/main.sql schema/syncconflicts.sql schema/syncinfo.sql
echo 'begin;' > $@
cat $+ >> $@
echo 'commit;' >> $@
libelf.a: elf/libelf.o
ar rcuv $@ $?
-install: $(COMPILED) doc/zpm.8
+install: $(COMPILED) $(MANPAGES)
test -d $(DESTDIR)/sbin || install -d $(DESTDIR)/sbin
install $(PROGRAMS) $(DESTDIR)/sbin
mkdir -p $(DESTDIR)/usr/share/man/man8
- install -m644 doc/zpm.8 $(DESTDIR)/usr/share/man/man8
+ install -m644 $(MANPAGES) $(DESTDIR)/usr/share/man/man8
scan-prep: clean sqlite/sqlite3.o sqlite/shell.o lib/liblzma.a
@echo scan-build -v -o report make -j10
rm -f *.o sqlite/*.o lib/*.o $(LZMAOBJ) liblzma.a \
libelf.a libzpm.a zpm-addfile soname \
*.xz \
- local.db t/ctap/prove.o $(ZPKGBIN) \
- db.sql
+ local.db \
+ t/ctap/*.o \
+ $(ZPKGBIN) \
+ db.sql \
+ elf/*.o lib/jsw/*.o