prototype1/Makefile

245 lines
8.7 KiB
Makefile
Raw Normal View History

2025-12-05 03:20:31 +03:00
find_headers = $(shell find src/$(1) -type f -name '*.h' )
find_assets = $(shell find src/$(1) -type f \( -name "*.vert" -o -name "*.frag" -o -name "*.geom" -o -name "*.comp" \) )
2025-09-04 23:21:26 +03:00
HEADERS_src_l1 := $(call find_headers,l1)
2025-12-05 03:20:31 +03:00
#HEADERS_gen_l1 := $(HEADERS_src_l1) gen/l1/dorothy.txt
HEADERS_gen_l1 := gen/l1/dorothy.txt
2025-09-04 23:21:26 +03:00
HEADERS_src_l1_5 = $(HEADERS_gen_l1) $(call find_headers,l1_5)
2025-12-05 03:20:31 +03:00
#HEADERS_gen_l1_5 := $(HEADERS_src_l1_5) gen/l1_5/dorothy.txt
HEADERS_gen_l1_5 := gen/l1_5/dorothy.txt
2026-02-11 19:34:27 +03:00
ASSETS_src_l_adele = $(call find_assets,l_adele)
2025-12-05 03:20:31 +03:00
ASSETS_gen_l_adele = gen/l_adele/dorothy.txt
2025-06-08 04:55:08 +03:00
2025-09-04 23:21:26 +03:00
HEADERS_src_l2 := $(HEADERS_gen_l1_5) $(call find_headers,l2)
2025-12-05 03:20:31 +03:00
#HEADERS_gen_l2 := $(HEADERS_src_l2) gen/l2/dorothy.txt
HEADERS_gen_l2 := gen/l2/dorothy.txt
2025-09-04 23:21:26 +03:00
2026-01-23 16:33:48 +03:00
HEADERS_src_l3 := $(HEADERS_gen_l2) $(call find_headers,l3)
2025-09-04 23:21:26 +03:00
cflags := -Wall -Wextra -Werror=implicit-function-declaration -Werror=return-type -Wno-unused-parameter \
--std=c99 -g -ggdb -O0 -D_FORTIFY_SOURCE=0 \
-fno-trapping-math -D_POSIX_C_SOURCE=200112L -D_GNU_SOURCE
cc := gcc
2025-06-08 04:55:08 +03:00
wl_protocols := $(shell pkg-config --variable=pkgdatadir wayland-protocols)
libpipewire_flags := $(shell pkg-config --cflags --libs libpipewire-0.3)
2025-06-08 04:55:08 +03:00
xdg_shell_private_c := gen/l_wl_protocols/xdg-shell-private.c
xdg_shell_client_h := gen/l_wl_protocols/xdg-shell-client.h
xdg_shell_private_o := out/l_wl_protocols/xdg-shell-private.o
l_wl_protocols := $(xdg_shell_client_h) $(xdg_shell_private_c)
$(xdg_shell_private_o): $(l_wl_protocols)
mkdir -p out/l_wl_protocols
$(cc) $(cflags) -o $@ -c $(xdg_shell_private_c) -lwayland-client
2025-12-05 03:20:31 +03:00
2025-09-04 23:21:26 +03:00
out/l1/codegen: src/l1/anne/codegen.c $(HEADERS_src_l1)
mkdir -p out/l1
$(cc) $(cflags) -D PROTOTYPE1_L1_CODEGEN_BOOTSTRAP_USE_CHICKEN_VECU8 -o $@ $<
2025-09-04 23:21:26 +03:00
gen/l1/dorothy.txt: out/l1/codegen
mkdir -p gen
cd gen && ../out/l1/codegen
2025-09-04 23:21:26 +03:00
out/l1_5/codegen: src/l1_5/anne/codegen.c $(HEADERS_src_l1_5)
mkdir -p out/l1_5
$(cc) $(cflags) -o $@ $<
2025-09-04 23:21:26 +03:00
gen/l1_5/dorothy.txt: out/l1_5/codegen
mkdir -p gen
2025-09-04 23:21:26 +03:00
cd gen && ../out/l1_5/codegen
gen/l_wl_protocols/xdg-shell-client.h: $(wl_protocols)/stable/xdg-shell/xdg-shell.xml
mkdir -p gen/l_wl_protocols
wayland-scanner client-header $< $@
gen/l_wl_protocols/xdg-shell-private.c: $(wl_protocols)/stable/xdg-shell/xdg-shell.xml
mkdir -p gen/l_wl_protocols
wayland-scanner private-code $< $@
2026-02-03 03:02:28 +03:00
.PHONY: gen_l_wl_protocols
gen_l_wl_protocols : $(l_wl_protocols)
out/l2/codegen: src/l2/anne/codegen.c $(HEADERS_src_l2)
mkdir -p out/l2
$(cc) $(cflags) -o $@ $< -lm -lpng
gen/l2/dorothy.txt: out/l2/codegen
mkdir -p gen
cd gen && ../out/l2/codegen
# First argument is path (relative to src/l_adele), second argument is a name of shader files in shader folder
compile_vert_shader = glslc -o gen/l_adele/$(1)/vert.spv src/l_adele/$(1)/$(2).vert
compile_frag_shader = glslc -o gen/l_adele/$(1)/frag.spv src/l_adele/$(1)/$(2).frag
2025-12-05 03:20:31 +03:00
define compile_shader
mkdir -p gen/l_adele/$(1)
$(call compile_vert_shader,$(1),$(2))
$(call compile_frag_shader,$(1),$(2))
2025-12-05 03:20:31 +03:00
endef
gen/l_adele/dorothy.txt: $(ASSETS_src_l_adele)
$(call compile_shader,lucy,lucy)
$(call compile_shader,alice/0gen,0gen)
$(call compile_shader,alice/0sh,0sh)
$(call compile_shader,alice/1,1)
$(call compile_shader,drawer_2d/plain,plain)
2025-12-05 03:20:31 +03:00
touch gen/l_adele/dorothy.txt
out/l2/t0: src/l2/tests/data_structures/t0.c $(HEADERS_gen_l1_5)
mkdir -p out/l2
$(cc) $(cflags) -o $@ $<
.PHONY: run_l2_t0
run_l2_t0: out/l2/t0
cd src/l2/tests/data_structures && ../../../../out/l2/t0
2025-09-04 23:21:26 +03:00
out/l2/r1: src/l2/tests/r1/r1.c $(HEADERS_src_l2) $(l_wl_protocols)
mkdir -p out/l2
$(cc) $(cflags) -o $@ $< $(xdg_shell_private_c) -lwayland-client -lrt -lxkbcommon -lm
.PHONY: run_r1
run_r1: out/l2/r1
./out/l2/r1
out/l2/r2: src/l2/tests/r2/r2a.c $(HEADERS_src_l2) $(l_wl_protocols)
mkdir -p out/l2
$(cc) $(cflags) -o $@ $< $(xdg_shell_private_c) -lwayland-client -lrt -lxkbcommon -lm $(libpipewire_flags)
.PHONY: run_r2
run_r2: out/l2/r2
./out/l2/r2
2025-09-04 23:21:26 +03:00
out/l2/r3: src/l2/tests/r3/r3.c $(HEADERS_src_l2) $(l_wl_protocols)
mkdir -p out/l2
$(cc) $(cflags) -o $@ $< $(xdg_shell_private_c) -lwayland-client -lrt -lxkbcommon -lm -lvulkan
.PHONY: run_r3
run_r3: out/l2/r3
./out/l2/r3
# Jesus sees your abomination
alice_bundle_link_flags := -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
out/l3/r4b: src/l3/r4/r4b.c $(HEADERS_src_l3) $(l_wl_protocols) $(ASSETS_gen_l_adele)
2026-01-23 16:33:48 +03:00
mkdir -p out/l3
$(cc) $(cflags) -o $@ $< $(xdg_shell_private_c) $(alice_bundle_link_flags)
2026-01-23 16:33:48 +03:00
.PHONY: run_r4b
run_r4b: out/l3/r4b
./out/l3/r4b
2025-09-04 23:21:26 +03:00
.PHONY: clean
clean:
rm -rf gen out
# ======================= Daria ВСЁ ===========================
# =============================================================
# -------------------------------------------------------------
# -------------------------------------------------------------
# ------------------------ ИНОАГЕНТЫ --------------------------
out/l2/allie/glue.o: src/l2/allie_glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2)
mkdir -p out/l2/allie
$(cc) $(cflags) -o $@ -c $<
full_allie_obj := out/l2/allie/glue.o $(xdg_shell_private_o)
out/l2/allie/liballie.a: $(full_allie_obj)
ar rcs $@ $^
# -------------------------------------------------------------
# =============================================================
# ====================== ПЛЮСЫ ================================
find_hpp_cpp = $(shell find src/$(1) -type f -name '*.hpp' )
HEADERS_src_l1_allie_cpp := $(call find_hpp_cpp,l1/allie_cpp)
HEADERS_src_l2_allie_hpp := $(call find_hpp_cpp,l2/allie_cpp) gen/l1/allie_cpp/dorothy.txt
HEADERS_src_l3_allie_hpp := $(call find_hpp_cpp,l3/r4) $(HEADERS_src_l2_allie_hpp)
cxx_cpp := g++
cxxflags_cpp := -Wall -Wextra -Werror=return-type -Wno-unused-parameter \
--std=c++20 -g -ggdb -O0 -D_FORTIFY_SOURCE=0 \
-fno-trapping-math -D_POSIX_C_SOURCE=200112L -D_GNU_SOURCE
out/l1/allie_cpp/codegen: src/l1/allie_cpp/anne/codegen.cpp $(HEADERS_src_l1_allie_cpp)
mkdir -p out/l1/allie_cpp
$(cxx_cpp) $(cxxflags_cpp) -o $@ $<
gen/l1/allie_cpp/dorothy.txt: out/l1/allie_cpp/codegen
mkdir -p gen
cd gen && ../out/l1/allie_cpp/codegen
out/l2/allie_cpp/glue.o: src/l2/allie_cpp/glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2)
mkdir -p out/l2/allie_cpp/
$(cc) $(cflags) -o $@ -c $<
full_allie_cpp_obj := out/l2/allie_cpp/glue.o $(xdg_shell_private_o)
# todo: add a call to a function that obtains all .hpp files from l2/allie_cpp
out/l3/allie_cpp/r4c: src/l3/r4/r4c.cpp $(HEADERS_src_l3_allie_hpp) $(full_allie_cpp_obj)
mkdir -p out/l3/allie_cpp
$(cxx_cpp) $(cxxflags_cpp) -o $@ $< $(full_allie_cpp_obj) $(alice_bundle_link_flags)
.PHONY: run_r4c
run_r4c: out/l3/allie_cpp/r4c
./out/l3/allie_cpp/r4c
# ======================== ПЛЮСЫ ВСЁ ==========================
# =============================================================
# -------------------------------------------------------------
# -------------------------------------------------------------
# =============================================================
# ========================== ХАСКЕЛЬ ==========================
#find_haskell_hs = $(shell find src/$(1) -type f -name '*.hs' )
#
## Whoever needs this will also need out/l_wl_protocols
#out/l2/allie_hs/glue.o: src/l2/allie_hs/glue.c $(HEADERS_src_l2) $(xdg_shell_client_h) gen/l_adele/dorothy.txt $(HEADERS_gen_l2)
# mkdir -p out/l2/allie_hs/
# $(cc) $(cflags) -o $@ -c $< -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
#
#full_allie_hs_obj := out/l2/allie_hs/glue.o $(xdg_shell_private_o)
#
## todo: write a function that gets all .hs files from l2/allie_hs. Call it
#out/l3/allie_hs/r4: src/l3/r4/R4.hs src/l2/allie_hs/Alice.hs \
# src/l2/allie_hs/Geom.hs $(full_allie_hs_obj)
# mkdir -p out/l3/allie_hs
# ghc -isrc/l2/allie_hs -hidir out/l3/ -odir out/l3 -o $@ $< $(full_allie_hs_obj) \
# -lvulkan -lm -lxkbcommon -lwayland-client -lpng -lfreetype
#
#.PHONY: run_r4
#run_r4: out/l3/allie_hs/r4
# ./out/l3/allie_hs/r4
# ========================== ХАСКЕЛЬ ВСЁ ======================
# =============================================================
# -------------------------------------------------------------
# -------------------------------------------------------------
# =============================================================
# ============================= РАСТ ==========================
rustflags := -L native=$(abspath out/l2/allie/) -l static=allie $(alice_bundle_link_flags)
.PHONY: target/debug/r4d
target/debug/r4d: src/l3/r4/r4d.rs $(full_allie_obj) out/l2/allie/liballie.a
mkdir -p out/l3/allie_rs
echo "$(rustflags)"
RUSTFLAGS="$(rustflags)" cargo build --bin r4d
.PHONY: run_r4d
run_r4d: target/debug/r4d
./target/debug/r4d
# ========================== РАСТ ВСЁ =========================
# =============================================================
# -------------------------------------------------------------