mirror of
https://github.com/extism/extism.git
synced 2026-01-08 21:38:13 -05:00
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>
35 lines
1.1 KiB
Makefile
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
|