enby/deps/Makefile

173 lines
5.4 KiB
Makefile
Raw Normal View History

.DEFAULT_GOAL := all
2025-09-27 20:34:39 +10:00
include ../config.mk
BUILD := build
2025-09-27 20:34:39 +10:00
INCLUDE := include
DEPS := imgui hammer
2025-09-27 20:34:39 +10:00
# Dear ImGui
IMGUI_UPSTREAM := https://github.com/ocornut/imgui.git
IMGUI_BRANCH := docking
IMGUI_REF := v1.92.3-docking
IMGUI_SRC := imgui
2025-09-27 20:34:39 +10:00
# Hammer
# HAMMER_UPSTREAM := https://github.com/UpstandingHackers/hammer.git
# HAMMER_BRANCH := master
# HAMMER_REF := cc733ffb77cb13071322353d0e17a7e57a15ebe6
# XXX: WARNING: pin HAMMER_REF to avoid bad commits breaking enby
HAMMER_UPSTREAM := https://forge.imbored.dev/emileclarkb/hammer.git
HAMMER_BRANCH := main
HAMMER_REF := $(HAMMER_BRANCH)
HAMMER_SRC := hammer/src
# = DEARIMGUI - VALID BACKENDS =
# = backends/imgui_impl_%.o =
# allegro5 glfw sdlgpu3
# android glut sdlrenderer2
# dx9 opengl2 sdlrenderer3
# dx10 opengl3 vulkan
# dx11 sdl2 wgpu
# dx12 sdl3 win32
IMGUI_ENABLE_BACKENDS := sdl3 opengl3
2025-09-27 20:34:39 +10:00
# = HAMMER - VALID PARSERS =
# = parsers/%.o =
# action and attr_bool bind
# bits butnot ch charset
# choice difference end endianness
# epsilon ignore ignoreseq indirect
# int_range many not nothing
# optional permutation sequence token
# unimplemented whitespace xor value
HAMMER_ENABLE_PARSERS := action and attr_bool bind \
bits butnot ch charset \
choice difference end endianness \
epsilon ignore ignoreseq indirect \
int_range many not nothing \
optional permutation sequence token \
unimplemented whitespace xor value
# = HAMMER - VALID BACKENDS =
# = backends/%.o =
# packrat llk regex glr lalr lr lr0
HAMMER_ENABLE_BACKENDS = packrat llk regex glr lalr lr lr0
IMGUI_BACKENDS := $(foreach backend, $(IMGUI_ENABLE_BACKENDS), backends/imgui_impl_$(backend).o)
IMGUI_OBJS := imgui.o imgui_demo.o \
imgui_draw.o imgui_tables.o imgui_widgets.o \
imgui_freetype.o imgui_stdlib.o \
$(IMGUI_BACKENDS)
2025-09-27 20:34:39 +10:00
HAMMER_PARSERS := $(foreach parser, $(HAMMER_ENABLE_PARSERS), parsers/$(parser).o)
HAMMER_BACKENDS := $(foreach backend, $(HAMMER_ENABLE_BACKENDS), backends/$(backend).o)
2025-09-27 20:34:39 +10:00
HAMMER_TESTS := t_benchmark t_bitreader t_bitwriter t_parser \
t_grammar t_regression t_mm t_misc
HAMMER_HEADERS := hammer.h glue.h allocator.h \
backends/regex.h backends/contextfree.h platform.h \
internal.h parsers/parser_internal.h compiler_specifics.h
HAMMER_OBJS = hammer.o glue.o benchmark.o \
cfgrammar.o desugar.o registry.o \
allocator.o system_allocator.o sloballoc.o \
bitreader.o bitwriter.o pprint.o \
datastructures.o $(HAMMER_PARSERS) $(HAMMER_BACKENDS)
ifeq ($(PLATFORM), WINDOWS_NT)
HAMMER_OBJS += platform_win32.o tsearch.o
else
HAMMER_OBJS += platform_bsdlike.o
endif
# === MACRO DEFINITIONS ===
define libpath =
$(addprefix lib, $(1).a)
endef
SYNC := $(addsuffix -sync, $(DEPS))
STATICLIBS := $(foreach dep, $(DEPS), $(call libpath, $(dep)))
# === BUILD TARGETS ===
2025-09-27 20:34:39 +10:00
$(BUILD): $(addprefix $(BUILD)/, $(DEPS))
$(BUILD)/imgui:
mkdir -p $@ $@/backends
$(BUILD)/hammer:
mkdir -p $@ $@/parsers $@/backends
$(INCLUDE): $(INCLUDE)/hammer
$(INCLUDE)/hammer: $(addprefix $(HAMMER_SRC)/, $(HAMMER_HEADERS))
mkdir -p $@
cp $^ $@
2025-09-27 20:34:39 +10:00
$(IMGUI_SRC)/%: imgui
test -f $@
$(HAMMER_SRC)/%: hammer
test -f $@
# NOTE: $(INCLUDE) will force gmake to call the sync target
all: $(BUILD) $(INCLUDE) $(STATICLIBS)
libimgui.a: imgui $(addprefix $(BUILD)/imgui/, $(IMGUI_OBJS))
ar rcs $@ $(filter %.o, $^)
2025-09-27 20:34:39 +10:00
libhammer.a: hammer $(addprefix $(BUILD)/hammer/, $(HAMMER_OBJS))
ar rcs $@ $(filter %.o, $^)
$(BUILD)/imgui/imgui_stdlib.o: $(IMGUI_SRC)/misc/cpp/imgui_stdlib.cpp
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
$(BUILD)/imgui/imgui_freetype.o: $(IMGUI_SRC)/misc/freetype/imgui_freetype.cpp
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
$(BUILD)/imgui/%.o: $(IMGUI_SRC)/%.cpp
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
$(BUILD)/imgui/backends/%.o: $(IMGUI_SRC)/backends/%.cpp
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
2025-09-27 20:34:39 +10:00
$(BUILD)/hammer/%.o: $(HAMMER_SRC)/%.c
$(CC) -c $^ -o $@ -I$(HAMMER_SRC)
$(BUILD)/hammer/parsers/%.o: $(HAMMER_SRC)/parsers/%.c
$(CC) -c $^ -o $@ -I$(HAMMER_SRC) -I$(HAMMER_SRC)/parsers
$(BUILD)/hammer/backends/%.o: $(HAMMER_SRC)/backends/%.c
$(CC) -c $^ -o $@ -I$(HAMMER_SRC) -I$(HAMMER_SRC)/backends
2025-09-27 20:34:39 +10:00
# === SYNC TARGETS ===
.PHONY: sync $(SYNC)
sync: $(SYNC)
imgui:
mkdir -p $@
2025-09-27 20:34:39 +10:00
git -C $@ init
git -C $@ remote add upstream $(IMGUI_UPSTREAM)
$(MAKE) $@-sync
imgui-sync: imgui
2025-09-27 20:34:39 +10:00
git -C $< fetch upstream --tags --verbose
git -C $< -c advice.detachedHead=false checkout $(IMGUI_REF)
hammer:
mkdir -p $@
git -C $@ init
git -C $@ remote add upstream $(HAMMER_UPSTREAM)
$(MAKE) $@-sync
hammer-sync: hammer
git -C $< fetch upstream --verbose
git -C $< -c advice.detachedHead=false checkout $(HAMMER_REF)
# === UTILITY TARGETS ===
2025-09-27 20:34:39 +10:00
CLEAN_DEP = $(@:clean-%=%)
.PHONY: clean clean-%
clean: $(CLEAN_DEPS)
rm -rf $(INCLUDE) $(BUILD) $(STATICLIBS)
clean-%:
rm -rf $(INCLUDE)/$(CLEAN_DEP) $(BUILD)/$(CLEAN_DEP) $(call libpath, $(CLEAN_DEP))
PURGE_DEP = $(@:purge-%=%)
.PHONY: purge purge-%
purge: $(PURGE_DEPS) clean
rm -rf $(DEPS)
2025-09-27 20:34:39 +10:00
purge-%: clean-%
rm -rf $(PURGE_DEP)