2025-04-16 13:09:54 +08:00
|
|
|
.DEFAULT_GOAL = build/main.out
|
|
|
|
|
CXX = clang++
|
2025-04-28 13:58:27 +08:00
|
|
|
CXXFLAGS += -std=c++26 -Wno-experimental-header-units -Wno-unused-command-line-argument
|
2025-04-16 13:09:54 +08:00
|
|
|
LDFLAGS += -std=c++26
|
|
|
|
|
SYSTEMHEADER_FLAGS = -Wno-deprecated-builtins -Wno-pragma-system-header-outside-header -Wno-keyword-compat
|
2025-04-28 13:58:27 +08:00
|
|
|
module_pair = $(if $(findstring user,$1),$(patsubst build/user/%.pcm,%=,$1))$1
|
|
|
|
|
build_module_path = $(if $1,$(let first rest,$1,$(if $(rest),-fmodule-file=$(call module_pair,$(first)) $(call build_module_path,$(rest)),-fmodule-file=$(call module_pair,$(first)))))
|
|
|
|
|
object_build = $(filter-out %.pcm,$^) $(call build_module_path,$(filter %.pcm,$^))
|
|
|
|
|
autodir = @mkdir -p $(@D)
|
2025-04-16 13:09:54 +08:00
|
|
|
|
2025-04-28 13:58:27 +08:00
|
|
|
build/main.out: build/main.o build/builder.o
|
2025-04-28 18:55:59 +08:00
|
|
|
$(call autodir)
|
|
|
|
|
$(CXX) $(LDFLAGS) $^ -o $@
|
2025-04-16 13:09:54 +08:00
|
|
|
|
2025-04-28 13:58:27 +08:00
|
|
|
build/main.o:: main.cxx build/system/print.pcm build/user/builder.pcm
|
|
|
|
|
build/builder.o:: builder.cxxm build/system/type_traits.pcm
|
|
|
|
|
build/user/builder.pcm:: build/system/type_traits.pcm
|
|
|
|
|
|
|
|
|
|
build/%.o::
|
2025-04-28 18:55:59 +08:00
|
|
|
$(call autodir)
|
|
|
|
|
$(CXX) $(CXXFLAGS) -c $(call object_build)
|
|
|
|
|
@mv $(patsubst build/%,%,$@) $@
|
2025-04-16 13:09:54 +08:00
|
|
|
|
2025-04-28 13:58:27 +08:00
|
|
|
build/user/%.pcm:: %.cxxm
|
2025-04-28 18:55:59 +08:00
|
|
|
$(call autodir)
|
|
|
|
|
$(CXX) $(CXXFLAGS) --precompile -o $@ $(call object_build)
|
2025-04-28 13:58:27 +08:00
|
|
|
|
|
|
|
|
build/system/%.pcm:
|
2025-04-28 18:55:59 +08:00
|
|
|
$(call autodir)
|
|
|
|
|
$(CXX) $(CXXFLAGS) -xc++-system-header --precompile $(patsubst build/system/%.pcm,%,$@) -o $@ $(SYSTEMHEADER_FLAGS)
|
2025-04-16 13:09:54 +08:00
|
|
|
|
2025-04-28 19:15:29 +08:00
|
|
|
.PHONY: clean run bear
|
2025-04-16 13:09:54 +08:00
|
|
|
clean:
|
2025-04-28 18:55:59 +08:00
|
|
|
@-rm -rf ./build
|
2025-04-16 13:09:54 +08:00
|
|
|
bear: clean
|
2025-04-28 18:55:59 +08:00
|
|
|
bear --append -- $(MAKE)
|
2025-04-16 13:09:54 +08:00
|
|
|
|
|
|
|
|
run: $(.DEFAULT_GOAL)
|
2025-04-28 18:55:59 +08:00
|
|
|
@./$(.DEFAULT_GOAL)
|