summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-09-02 16:36:42 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-09-02 16:36:42 -0400
commitdad361554242b1d5197d02144177ac2a74e79926 (patch)
tree66a5afdda20efc3811249cac63ac3a3ba80ec831 /Makefile
parent62acbc356048ca04367fe3a83fc68f78bec14686 (diff)
Makefile: install pkg-config and headers
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile75
1 files changed, 61 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 10bf91c..88a8a84 100644
--- a/Makefile
+++ b/Makefile
@@ -27,29 +27,29 @@ ifeq ($(BUILD_MODE),release)
LIB_EXT := a
BLT_BUILD_MODE := release64
BLT_BUILD_DIR := Release
- OPT_FLAGS ?= -O3 -s
+ OPT_FLAGS ?= -O3 -s -DNDEBUG
else ifeq ($(BUILD_MODE),release-debug)
OBJ_EXT := rso
LIB_EXT := rsa
BLT_BUILD_MODE := debug64
BLT_BUILD_DIR := Debug
- OPT_FLAGS ?= -O2 -g
+ OPT_FLAGS ?= -O2 -g -DDEBUG
else ifeq ($(BUILD_MODE),debug)
OBJ_EXT := so
LIB_EXT := sa
BLT_BUILD_MODE := debug64
BLT_BUILD_DIR := Debug
- OPT_FLAGS ?= -O0 -g
+ OPT_FLAGS ?= -O0 -g -DDEBUG
else
$(error Unknown build mode: $(BUILD_MODE))
endif
#echo $@ : $(@F) : $< : $^
define cc-command
- $(CC) -std=c2x -c -o $@ -DNDEBUG $(OPT_FLAGS) $(CFLAGS) $(INCS) $<
+ $(CC) -std=c2x -c -o $@ $(OPT_FLAGS) $(CFLAGS) $(INCS) $<
endef
define cxx-command
- $(CXX) -std=c++23 -c -o $@ -DDEBUG $(OPT_FLAGS) $(CXXFLAGS) $(INCS) $<
+ $(CXX) -std=c++23 -c -o $@ $(OPT_FLAGS) $(CXXFLAGS) $(INCS) $<
endef
define cc-encode-binary-command
$(1): $(2)
@@ -256,8 +256,12 @@ $(DIR_OBJ)/libpke-test.$(LIB_EXT): $(DIR_OBJ)/pke-test-asset-manager.$(OBJ_EXT)
$(DIR_OBJ)/libpke-runtime.$(LIB_EXT): $(DIR_OBJ)/libpke.$(LIB_EXT)
$(DIR_OBJ)/libpke-runtime.$(LIB_EXT): $(DIR_OBJ)/libpke-imgui.$(LIB_EXT)
$(DIR_OBJ)/libpke-runtime.$(LIB_EXT): $(DIR_OBJ)/libpke-bullet3.$(LIB_EXT)
-$(DIR_OBJ)/libpke-runtime.$(LIB_EXT):
- libtool --tag=CXX --mode=link $(CC) -o $@ $^ --static
+ mkdir -p tmp
+ ar x --output tmp $(DIR_OBJ)/libpke.$(LIB_EXT)
+ ar x --output tmp $(DIR_OBJ)/libpke-imgui.$(LIB_EXT)
+ ar x --output tmp $(DIR_OBJ)/libpke-bullet3.$(LIB_EXT)
+ ar rcs $@ tmp/*.o
+ rm -rf tmp
$(DIR_EXE)/pke-editor: $(DIR_OBJ)/libpke-editor.$(LIB_EXT)
$(DIR_EXE)/pke-editor: $(DIR_OBJ)/libpke.$(LIB_EXT)
@@ -289,17 +293,60 @@ clean:
rm -f *.o *.so *.plist config.h $(FILES_BIN_GCH)
rm -rf ./$(DIR_EXE_release) ./$(DIR_EXE_release-debug) ./$(DIR_EXE_debug) ./$(DIR_OBJ)
+$(DIR_OBJ)/pke.hpp: prepare
+ echo "#ifndef PKE_PKE_HPP\n#define PKE_PKE_HPP\n" > $(DIR_OBJ)/pke.hpp
+ find ./src -name "*.h" -and -name "*type*" -or -name "*.hpp" -and -name "*type*" -printf "#include \"%f\"\n" | sort >> $(DIR_OBJ)/pke.hpp
+ echo "\n" >> $(DIR_OBJ)/pke.hpp
+ find ./src -name "*.h" -not -name "*type*" -or -name "*.hpp" -not -name "*type*" -printf "#include \"%f\"\n" | sort >> $(DIR_OBJ)/pke.hpp
+ echo "\n#endif /* PKE_PKE_HPP */" >> $(DIR_OBJ)/pke.hpp
+
+$(DIR_OBJ)/pke.pc: prepare
+ @echo -n 'Creating pke.pc ...'
+ @echo 'prefix=$${pcfiledir}/../..' > $(DIR_OBJ)/pke.pc
+ @echo 'exec_prefix=$${prefix}' >> $(DIR_OBJ)/pke.pc
+ @echo 'libdir=$${exec_prefix}/lib' >> $(DIR_OBJ)/pke.pc
+ @echo 'includedir=$${prefix}/include' >> $(DIR_OBJ)/pke.pc
+ @echo '\nName: libpke' >> $(DIR_OBJ)/pke.pc
+ @echo 'Description: pke Static Library' >> $(DIR_OBJ)/pke.pc
+ @echo 'Version: $(PKE_VERSION)' >> $(DIR_OBJ)/pke.pc
+ @echo 'Libs: -L$${libdir} -lpke-runtime' >> $(DIR_OBJ)/pke.pc
+ @echo 'Cflags: -I$${includedir}' >> $(DIR_OBJ)/pke.pc
+ @echo '\nRequires: bullet' >> $(DIR_OBJ)/pke.pc
+ @echo -n 'Requires.private: ' >> $(DIR_OBJ)/pke.pc
+ @echo 'vulkan glfw3 glm libpipewire-0.3 libspa-0.2' >> $(DIR_OBJ)/pke.pc
+ @echo ' Done.'
+
.PHONY: install
-install: bin/pke-runtime obj/libpke-runtime.a obj/libpke-editor.o
+install: bin/pke-runtime
+install: obj/libpke-runtime.a
+install: obj/libpke-editor.o
+install: $(DIR_OBJ)/pke.hpp
+install: $(DIR_OBJ)/pke.pc
mkdir -p $(DESTDIR)$(PREFIX)/bin
- mkdir -p $(DESTDIR)$(PREFIX)/lib/pke
+ mkdir -p $(DESTDIR)$(PREFIX)/lib
+ mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
+ mkdir -p $(DESTDIR)$(PREFIX)/usr/include/pke
cp -f bin/pke-runtime $(DESTDIR)$(PREFIX)/bin
- cp -f obj/libpke-runtime.a $(DESTDIR)$(PREFIX)/lib/pke
- cp -f obj/libpke-editor.o $(DESTDIR)$(PREFIX)/lib/pke
+ cp -f obj/libpke-runtime.a $(DESTDIR)$(PREFIX)/lib
+ cp -f obj/libpke-editor.o $(DESTDIR)$(PREFIX)/lib
+ cp -f obj/pke.hpp $(DESTDIR)$(PREFIX)/usr/include/pke
+ cp -f obj/pke.pc $(DESTDIR)$(PREFIX)/lib/pkgconfig
+ cp -f sub/imgui/*.h $(DESTDIR)$(PREFIX)/usr/include/pke
+ cp -f sub/stb/stb_image.h $(DESTDIR)$(PREFIX)/usr/include/pke
+ cp -f sub/cgltf/cgltf.h $(DESTDIR)$(PREFIX)/usr/include/pke
+ cp -f src/*.h $(DESTDIR)$(PREFIX)/usr/include/pke
+ cp -f src/*.hpp $(DESTDIR)$(PREFIX)/usr/include/pke
chmod 755 $(DESTDIR)$(PREFIX)/bin/pke-runtime
- chmod 755 $(DESTDIR)$(PREFIX)/lib/pke/libpke-runtime.a
- chmod 755 $(DESTDIR)$(PREFIX)/lib/pke/libpke-editor.o
+ chmod 755 $(DESTDIR)$(PREFIX)/lib/libpke-runtime.a
+ chmod 755 $(DESTDIR)$(PREFIX)/lib/libpke-editor.o
+ chmod 644 $(DESTDIR)$(PREFIX)/lib/pkgconfig/pke.pc
+ chmod 644 $(DESTDIR)$(PREFIX)/usr/include/pke/*.h
+ chmod 644 $(DESTDIR)$(PREFIX)/usr/include/pke/*.hpp
.PHONY: uninstall
uninstall:
- rm -f $(DESTDIR)$(PREFIX)/bin/st
+ rm -f $(DESTDIR)$(PREFIX)/bin/pke-runtime
+ rm -f $(DESTDIR)$(PREFIX)/lib/libpke-runtime.a
+ rm -f $(DESTDIR)$(PREFIX)/lib/libpke-editor.o
+ rm -f $(DESTDIR)$(PREFIX)/lib/pkgconfig/pke.pc
+ rm -rf $(DESTDIR)$(PREFIX)/usr/include/pke