1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

stdbuf: build shared library on Macs

This commit is contained in:
Alex Lyon 2017-10-09 16:44:29 -07:00
parent de07c6218b
commit 8c846e2aa9
No known key found for this signature in database
GPG key ID: B517F04B325131B1

View file

@ -7,12 +7,16 @@ RUSTC ?= rustc
SYSTEM := $(shell uname)
DYLIB_EXT :=
ifeq ($(SYSTEM),Linux)
DYLIB_EXT := so
DYLIB_FLAGS := -shared
DYLIB_EXT := so
DYLIB_FLAGS := -shared
DYLIB_LINK_START := -Wl,--whole-archive
DYLIB_LINK_END := -Wl,--no-whole-archive
endif
ifeq ($(SYSTEM),Darwin)
DYLIB_EXT := dylib
DYLIB_FLAGS := -dynamiclib -undefined dynamic_lookup
DYLIB_EXT := dylib
DYLIB_FLAGS := -dynamiclib -undefined dynamic_lookup
DYLIB_LINK_START := -Wl,-all_load
DYLIB_LINK_END := -Wl,-noall_load
endif
all: $(BUILDDIR)/libstdbuf.$(DYLIB_EXT)
@ -23,5 +27,5 @@ $(BUILDDIR):
$(BUILDDIR)/libstdbuf.$(DYLIB_EXT): build.rs libstdbuf/libstdbuf.rs libstdbuf.c libstdbuf.h | $(BUILDDIR)
cp $(BUILDDIR)/../../../deps/liblibstdbuf-*.a $(BUILDDIR)/liblibstdbuf.a && \
$(CC) -c -Wall -Werror -fPIC libstdbuf.c -o $(BUILDDIR)/libstdbuf.o && \
$(CC) $(DYLIB_FLAGS) -o $@ $(BUILDDIR)/libstdbuf.o -Wl,--whole-archive $(BUILDDIR)/liblibstdbuf.a -Wl,--no-whole-archive
$(CC) $(DYLIB_FLAGS) -o $@ $(BUILDDIR)/libstdbuf.o $(DYLIB_LINK_START) $(BUILDDIR)/liblibstdbuf.a $(DYLIB_LINK_END)