PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
MANDIR ?= ${PREFIX}/share/man/man1
NCDU_VERSION=$(shell grep 'program_version = "' src/main.zig | sed -e 's/^.*"\(.\+\)".*$$/\1/')
release:
zig build -Drelease-fast
debug:
zig build
clean:
rm -rf zig-cache zig-out
distclean: clean
rm -f ncdu.1
doc: ncdu.1
ncdu.1: ncdu.pod src/main.zig
pod2man --center "ncdu manual" --release "ncdu-${NCDU_VERSION}" ncdu.pod >ncdu.1
install: install-bin install-doc
install-bin: release
mkdir -p ${BINDIR}
install -m0755 zig-out/bin/ncdu ${BINDIR}/
install-doc: doc
mkdir -p ${MANDIR}
install -m0644 ncdu.1 ${MANDIR}/
uninstall: uninstall-bin uninstall-doc
uninstall-bin:
rm -f ${BINDIR}/ncdu
uninstall-doc:
rm -f ${MANDIR}/ncdu.1
dist: doc
rm -f ncdu-${NCDU_VERSION}.tar.gz
mkdir ncdu-${NCDU_VERSION}
for f in ncdu.1 `git ls-files | grep -v ^\.gitignore`; do mkdir -p ncdu-${NCDU_VERSION}/`dirname $$f`; ln -s "`pwd`/$$f" ncdu-${NCDU_VERSION}/$$f; done
tar -cophzf ncdu-${NCDU_VERSION}.tar.gz --sort=name ncdu-${NCDU_VERSION}
rm -rf ncdu-${NCDU_VERSION}
static:
mkdir -p static-${TARGET}/nc static-${TARGET}/inst/pkg
cd static-${TARGET}/nc && ../../ncurses/configure --prefix="`pwd`/../inst"\
--with-pkg-config-libdir="`pwd`/../inst/pkg"\
--without-cxx --without-cxx-binding --without-ada --without-manpages --without-progs\
--without-tests --enable-pc-files --without-pkg-config --without-shared --without-debug\
--without-gpm --without-sysmouse --enable-widec --with-default-terminfo-dir=/usr/share/terminfo\
--with-terminfo-dirs=/usr/share/terminfo:/lib/terminfo:/usr/local/share/terminfo\
--with-fallbacks="screen linux vt100 xterm xterm-256color" --host=${TARGET}\
CC="zig cc --target=${TARGET}"\
LD="zig cc --target=${TARGET}"\
AR="zig ar" RANLIB="zig ranlib"\
CPPFLAGS=-D_GNU_SOURCE && make && make install.libs
@
@${TARGET}
@
@
cd static-${TARGET} && zig build-exe -target ${TARGET}\
-Iinst/include -Iinst/include/ncursesw -lc inst/lib/libncursesw.a\
--cache-dir zig-cache -static --strip -O ReleaseFast ../src/main.zig ../src/ncurses_refs.c
cd static-${TARGET} && mv main ncdu && tar -czf ../ncdu-${NCDU_VERSION}-$(shell echo ${TARGET} | sed s/-musl//).tar.gz ncdu
rm -rf static-${TARGET}
static-target-%:
$(MAKE) static TARGET=$*
static-all:\
static-target-x86_64-linux-musl \
static-target-aarch64-linux-musl \
static-target-i386-linux-musl \
static-target-arm-linux-musleabi