1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57: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) SYSTEM := $(shell uname)
DYLIB_EXT := DYLIB_EXT :=
ifeq ($(SYSTEM),Linux) ifeq ($(SYSTEM),Linux)
DYLIB_EXT := so DYLIB_EXT := so
DYLIB_FLAGS := -shared DYLIB_FLAGS := -shared
DYLIB_LINK_START := -Wl,--whole-archive
DYLIB_LINK_END := -Wl,--no-whole-archive
endif endif
ifeq ($(SYSTEM),Darwin) ifeq ($(SYSTEM),Darwin)
DYLIB_EXT := dylib DYLIB_EXT := dylib
DYLIB_FLAGS := -dynamiclib -undefined dynamic_lookup DYLIB_FLAGS := -dynamiclib -undefined dynamic_lookup
DYLIB_LINK_START := -Wl,-all_load
DYLIB_LINK_END := -Wl,-noall_load
endif endif
all: $(BUILDDIR)/libstdbuf.$(DYLIB_EXT) all: $(BUILDDIR)/libstdbuf.$(DYLIB_EXT)
@ -23,5 +27,5 @@ $(BUILDDIR):
$(BUILDDIR)/libstdbuf.$(DYLIB_EXT): build.rs libstdbuf/libstdbuf.rs libstdbuf.c libstdbuf.h | $(BUILDDIR) $(BUILDDIR)/libstdbuf.$(DYLIB_EXT): build.rs libstdbuf/libstdbuf.rs libstdbuf.c libstdbuf.h | $(BUILDDIR)
cp $(BUILDDIR)/../../../deps/liblibstdbuf-*.a $(BUILDDIR)/liblibstdbuf.a && \ cp $(BUILDDIR)/../../../deps/liblibstdbuf-*.a $(BUILDDIR)/liblibstdbuf.a && \
$(CC) -c -Wall -Werror -fPIC libstdbuf.c -o $(BUILDDIR)/libstdbuf.o && \ $(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)