diff options
author | Yorhel <git@yorhel.nl> | 2021-07-19 16:29:20 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-07-19 16:44:53 +0200 |
commit | f473f3605ee0b72ba3cf13033ae47214518414c7 (patch) | |
tree | be33b528bdb2d1e7addbb06c5125982c0e8b6a4a | |
parent | b96587c25feff6e52f0b5a5104359046c8c139d4 (diff) |
Fix building of static binaries
It's a bit ugly, but appears to work. I've not tested the 32bit arm
version, but the others run.
The static binaries are about twice as large as the ncdu 1.x
counterparts.
-rw-r--r-- | Makefile | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -55,8 +55,6 @@ dist: doc # ASSUMPTION: the ncurses source tree has been extracted into ncurses/ -# BUG: Zig writes to zig-* in this directory, not the TARGET-specific build one. -# BUG: Doesn't seem to do any static linking :( static: mkdir -p static-${TARGET}/nc static-${TARGET}/inst/pkg cd static-${TARGET}/nc && ../../ncurses/configure --prefix="`pwd`/../inst"\ @@ -70,16 +68,21 @@ static: LD="zig cc --target=${TARGET}"\ AR="zig ar" RANLIB="zig ranlib"\ CPPFLAGS=-D_GNU_SOURCE && make && make install.libs - cd static-${TARGET} && PKG_CONFIG_LIBDIR="`pwd`/inst/pkg" zig build -Dtarget=${TARGET}\ - --build-file ../build.zig --search-prefix inst/ --cache-dir zig -Drelease-fast=true - @# Alternative approach, bypassing zig-build, but this still refuses to do static linking ("UnableToStaticLink") - @# cd static-${TARGET} && zig build-exe -target ${TARGET} -lc -Iinst/include -Iinst/include/ncursesw -Linst/lib -lncursesw -static ../src/main.zig ../src/ncurses_refs.c - #rm -rf static-${TARGET} + @# zig-build - cleaner approach but doesn't work, results in a dynamically linked binary. + @#cd static-${TARGET} && PKG_CONFIG_LIBDIR="`pwd`/inst/pkg" zig build -Dtarget=${TARGET} + @# --build-file ../build.zig --search-prefix inst/ --cache-dir zig -Drelease-fast=true + @# Alternative approach, bypassing zig-build + 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 \ # Works, but doesn't link statically - # static-target-aarch64-linux-musl \ # Same - # static-target-i386-linux-musl # Broken, linker errors + static-target-x86_64-linux-musl \ + static-target-aarch64-linux-musl \ + static-target-i386-linux-musl \ + static-target-arm-linux-musleabi |