1- # SPDX-FileCopyrightText: 2021-2023 Yoran Heling <[email protected] >1+ # SPDX-FileCopyrightText: Yorhel <[email protected] >22# SPDX-License-Identifier: MIT
33
44# Optional semi-standard Makefile with some handy tools.
@@ -9,12 +9,12 @@ ZIG ?= zig
99PREFIX ?= /usr/local
1010BINDIR ?= ${PREFIX}/bin
1111MANDIR ?= ${PREFIX}/share/man/man1
12- ZIG_FLAGS ?= -Doptimize=ReleaseFast
12+ ZIG_FLAGS ?= --release
1313
1414NCDU_VERSION =$(shell grep 'program_version = "' src/main.zig | sed -e 's/^.* "\(.\+\) ".*$$/\1/')
1515
16- .PHONY : build
17- build : release doc
16+ .PHONY : build test
17+ build : release
1818
1919release :
2020 $(ZIG ) build ${ZIG_FLAGS}
@@ -25,21 +25,13 @@ debug:
2525clean :
2626 rm -rf zig-cache zig-out
2727
28- distclean : clean
29- rm -f ncdu.1
30-
31- doc : ncdu.1
32-
33- ncdu.1 : ncdu.pod src/main.zig
34- pod2man --center " ncdu manual" --release " ncdu-${NCDU_VERSION} " ncdu.pod > ncdu.1
35-
3628install : install-bin install-doc
3729
3830install-bin : release
3931 mkdir -p ${BINDIR}
4032 install -m0755 zig-out/bin/ncdu ${BINDIR} /
4133
42- install-doc : doc
34+ install-doc :
4335 mkdir -p ${MANDIR}
4436 install -m0644 ncdu.1 ${MANDIR} /
4537
@@ -52,10 +44,10 @@ uninstall-bin:
5244uninstall-doc :
5345 rm -f ${MANDIR} /ncdu.1
5446
55- dist : doc
47+ dist :
5648 rm -f ncdu-${NCDU_VERSION} .tar.gz
5749 mkdir ncdu-${NCDU_VERSION}
58- 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
50+ for f in ` git ls-files | grep -v ^\. gitignore` ; do mkdir -p ncdu-${NCDU_VERSION} /` dirname $$ f` ; ln -s " ` pwd` /$$ f" ncdu-${NCDU_VERSION} /$$ f; done
5951 tar -cophzf ncdu-${NCDU_VERSION} .tar.gz --sort=name ncdu-${NCDU_VERSION}
6052 rm -rf ncdu-${NCDU_VERSION}
6153
@@ -73,14 +65,14 @@ static-%.tar.gz:
7365 CC=" ${ZIG} cc --target=$* " \
7466 LD=" ${ZIG} cc --target=$* " \
7567 AR=" ${ZIG} ar" RANLIB=" ${ZIG} ranlib" \
76- CPPFLAGS=-D_GNU_SOURCE && make && make install.libs
68+ CPPFLAGS=-D_GNU_SOURCE && make -j8 && make install.libs
7769 @# zig-build - cleaner approach but doesn't work, results in a dynamically linked binary.
7870 @# cd static-$* && PKG_CONFIG_LIBDIR="`pwd`/inst/pkg" zig build -Dtarget=$*
7971 @# --build-file ../build.zig --search-prefix inst/ --cache-dir zig -Drelease-fast=true
8072 @# Alternative approach, bypassing zig-build
8173 cd static-$* && ${ZIG} build-exe -target $* \
8274 -Iinst/include -Iinst/include/ncursesw -lc inst/lib/libncursesw.a\
83- --cache-dir zig-cache -static -fstrip -O ReleaseFast ../src/main.zig ../src/ncurses_refs.c
75+ --cache-dir zig-cache -static -fstrip -O ReleaseFast ../src/main.zig
8476 cd static-$* && mv main ncdu && tar -czf ../static-$* .tar.gz ncdu
8577 rm -rf static-$*
8678
@@ -101,3 +93,8 @@ static:\
10193 static-linux-x86 \
10294 static-linux-aarch64 \
10395 static-linux-arm
96+
97+ test :
98+ zig build test
99+ mandoc -T lint ncdu.1
100+ reuse lint
0 commit comments