summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-18 00:45:11 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-18 00:45:11 +1100
commit85e5e0a460cd7a01d6e3e32b19e8aadd91f82b6a (patch)
tree052efbcef94ed807a787ca7684335057ec7cbd5c
parent8ef0b871725cf6fe31ceab34ae0b40aa905e05bf (diff)
add fPIC to all builds (for now)
-rw-r--r--Makefile8
1 files changed, 5 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 6ef7a24..cd2e7c3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
CC := clang
INCLUDES := -I./include -Ideps/glfw-3.3.8/include/GLFW -Ideps/stb_image
-CFLAGS := -Wall -Wextra -O2 $(INCLUDES)
+CFLAGS := -Wall -Wextra -O2 -fPIC $(INCLUDES)
+# TODO(low prio): split static object files and shared object files so we can remove -fPIC from static lib builds
LDFLAGS := -lglfw
# Detect OS
@@ -28,6 +29,7 @@ METAL_LIB := $(SHADER_OUT_DIR)/default.metallib
# Library outputs
STATIC_LIB := $(BUILD_DIR)/libceleritas.a
+SHARED_FLAGS := -fPIC
ifeq ($(UNAME_S),Darwin)
SHARED_LIB := $(BUILD_DIR)/libceleritas.dylib
SHARED_FLAGS := -dynamiclib
@@ -36,7 +38,7 @@ ifeq ($(UNAME_S),Darwin)
OBJS += $(OBJ_DIR)/backend_mtl.o
else
SHARED_LIB := $(BUILD_DIR)/libceleritas.so
- SHARED_FLAGS := -shared -fPIC
+ SHARED_FLAGS := -shared
endif
## Makefile notes
@@ -61,7 +63,7 @@ $(STATIC_LIB): $(OBJS)
@mkdir -p $(BUILD_DIR)
ar rcs $@ $^
-shared: $(SHARED_LIB)
+shared: $(SHARED_LIB) CFLAGS +=
static: $(STATIC_LIB)