build: Makefile to generate compile_flags.txt for clangd
authorametama <ametama@wafflesoft.org>
Wed, 17 Dec 2025 21:51:03 +0000 (22:51 +0100)
committerametama <ametama@wafflesoft.org>
Wed, 17 Dec 2025 21:51:03 +0000 (22:51 +0100)
.gitignore
Makefile

index 240b3f9b5f443ae00f8c9b48b59c13238690ded8..95963100ef4155412e3df3e0e41aeb95b6af38d7 100644 (file)
@@ -1,2 +1,2 @@
-opt
+apso
 compile_flags.txt
index d93f90f1775380b15862f46f591cb3989d87444a..0a4bff35ea02708bc94b5283bf33d578859da8e2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,8 @@
-opt: src/particle_swarm.c src/vector.c
-       gcc -Iinclude `pkg-config --cflags gtk4` -lm -fopenmp src/vector.c src/particle_swarm.c -o opt `pkg-config --libs gtk4`
+all: compile_flags executable
+
+compile_flags:
+       echo "-Iinclude `pkg-config --cflags gtk4` -lm -fopenmp `pkg-config --libs gtk4`" | perl -pe 's|(-.*?)\s|\1\n|g' > compile_flags.txt
+       echo "-o apso" >> compile_flags.txt
+
+executable: $(wildcard src/*.c)
+       gcc $(shell cat compile_flags.txt) $(shell ls src/*.c)