Skip to content

Commit

Permalink
Makefile: Use .dylib for MacOS LIB_EXT
Browse files Browse the repository at this point in the history
- On MacOS, shared libraries actually use .dylib extension
- Optimize test/cli build targets when lib isn't going to be built
  • Loading branch information
LekKit authored Mar 16, 2024
1 parent 92b7c93 commit 18b27c1
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,15 @@ endif
$(info Detected OS: $(GREEN)$(OS)$(RESET))
override OS := $(call tolower,$(OS))

# Set up OS options
# Windows-specific build options
ifeq ($(OS),windows)
# Use LDFLAG -mwindows for GUI-only
override LDFLAGS += -static
BIN_EXT := .exe
LIB_EXT := .dll
else

# Emscripten-specific build options
ifeq ($(OS),emscripten)
override CFLAGS += -pthread
override LDFLAGS += -s TOTAL_MEMORY=512MB -s PROXY_TO_PTHREAD
Expand All @@ -122,14 +130,14 @@ USE_SDL ?= 1
USE_NET ?= 0
else

ifeq ($(OS),windows)
# Use LDFLAG -mwindows for GUI-only
override LDFLAGS += -static
BIN_EXT := .exe
LIB_EXT := .dll
# POSIX build options
BIN_EXT :=
ifeq ($(OS),darwin)
LIB_EXT := .dylib
else

LIB_EXT := .so
endif

# Check for lib presence before linking (there is no pthread on Android, etc)
ifneq (,$(findstring main, $(shell $(CC) -pthread $(CFLAGS) $(LDFLAGS) -lpthread 2>&1)))
override CFLAGS += -pthread
Expand All @@ -140,7 +148,13 @@ endif
ifneq (,$(findstring main, $(shell $(CC) $(CFLAGS) $(LDFLAGS) -lrt 2>&1)))
override LDFLAGS += -lrt
endif
ifneq (,$(findstring main, $(shell $(CC) $(CFLAGS) $(LDFLAGS) -latomic 2>&1)))
override LDFLAGS += -latomic
else
override CFLAGS += -DNO_LIBATOMIC
endif

# Set some addiional options based on POSIX flavor
ifeq ($(OS),darwin)
USE_SDL ?= 2
endif
Expand All @@ -153,13 +167,6 @@ override LDFLAGS += -L/usr/X11R6/lib
endif

endif

ifneq (,$(findstring main, $(shell $(CC) $(CFLAGS) $(LDFLAGS) -latomic 2>&1)))
override LDFLAGS += -latomic
else
override CFLAGS += -DNO_LIBATOMIC
endif

endif

# Detect compiler type, version
Expand Down Expand Up @@ -459,8 +466,8 @@ ifeq ($(USE_SPINLOCK_DEBUG),1)
override CFLAGS += -DUSE_SPINLOCK_DEBUG
endif

# Do not pass lib-related flags for dev builds (Faster)
ifneq (,$(MAKECMDGOALS))
# Do not pass lib-related flags for dev/cli/test builds (Faster)
ifneq (,$(findstring lib, $(MAKECMDGOALS)))
override CFLAGS += -DUSE_LIB -fPIC -ffat-lto-objects
# Build JNI bindings inside librvvm dynlib
ifeq ($(USE_JNI),1)
Expand Down

0 comments on commit 18b27c1

Please sign in to comment.