Files
extism/libextism/Makefile
Gavin Hayes c4b82e3eda fix(libextism): improve static linking pkgconfig (#726)
This includes three fixes:

* link static library by absolute path (should fix static linking on
Mac/ with `lld`)
* link static library with `-framework Security` on Mac
* link `libpthread` , this should be a no-op on systems with modern
libc, but should fix static linking on systems with glibc pre 2.34 see
https://developers.redhat.com/articles/2021/12/17/why-glibc-234-removed-libpthread
and error
http://www.cpantesters.org/cpan/report/669fdfc8-25a4-11ef-9502-51fb6d8775ea

---------

Co-authored-by: zach <zachshipko@gmail.com>
Co-authored-by: zach <zach@dylibso.com>
2024-06-11 16:22:55 -04:00

35 lines
1.1 KiB
Makefile

.PHONY: build
build:
$(CC) -g -o example example.c -lextism
.PHONY: static
static:
$(CC) -g -o example example.c -l:libextism.a -lm -lpthread
# if needed, set PKG_CONFIG_PATH= to the directory with extism*.pc installed
LDFLAGS=`pkg-config --libs extism`
.PHONY: pkg-config
pkg-config:
$(CC) -g -o example example.c $(LDFLAGS)
LDFLAGS_STATIC=`pkg-config --static --libs extism-static`
.PHONY: pkg-config-static
pkg-config-static:
$(CC) -g -o example example.c $(LDFLAGS_STATIC)
# This produces an entirely static binary
#
# MUSL libc is highly recommended over glibc for this purpose as some glibc
# functionality such as getaddrinfo, iconv depends on dynamically loading glibc.
#
# To build and install libextism with musl for x86_64 in the parent directory:
# make RUST_TARGET=x86_64-unknown-linux-musl && sudo make RUST_TARGET=x86_64-unknown-linux-musl install
# Then, from this directory you can build with CC=musl-gcc make fully-static
.PHONY: fully-static
fully-static:
$(CC) -static -g -o example example.c $(LDFLAGS_STATIC)
.PHONY: clean
clean:
rm -f example