Skip to content

Commit aa692b7

Browse files
Fix build on non-ELF systems (macOS): don't build the shared library
Detect if this is an ELF system by checking if /bin/sh is ELF. This can be configured manually with: make BUILD_SHARED=0 or make BUILD_SHARED=1 Signed-off-by: Thiago Macieira <[email protected]>
1 parent 110d6bc commit aa692b7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ TINYCBOR_SOURCES = \
3333
#
3434
CBORDUMP_SOURCES = tools/cbordump/cbordump.c
3535

36+
BUILD_SHARED = $(shell file -L /bin/sh 2>/dev/null | grep -q ELF && echo 1)
37+
3638
INSTALL_TARGETS += $(bindir)/cbordump
3739
INSTALL_TARGETS += $(libdir)/libtinycbor.a
38-
ifneq ($(shell uname -s), Linux)
40+
ifeq ($(BUILD_SHARED),1)
3941
INSTALL_TARGETS += $(libdir)/libtinycbor.so
4042
INSTALL_TARGETS += $(libdir)/libtinycbor.so.0
4143
INSTALL_TARGETS += $(libdir)/libtinycbor.so.$(VERSION)
@@ -101,7 +103,9 @@ ifneq ($(cjson-pass)$(system-cjson-pass),)
101103
endif
102104

103105
# Rules
104-
all: .config lib/libtinycbor.a lib/libtinycbor.so bin/cbordump tinycbor.pc
106+
all: .config lib/libtinycbor.a \
107+
$(if $(subst 0,,$(BUILD_SHARED)),lib/libtinycbor.so) \
108+
bin/cbordump tinycbor.pc
105109
all: $(if $(JSON2CBOR_SOURCES),bin/json2cbor)
106110
check: tests/Makefile | lib/libtinycbor.a
107111
$(MAKE) -C tests check

0 commit comments

Comments
 (0)