sql-space-invaders/Makefile
Ari Archer ffd58def6e
Add SQL logic
Signed-off-by: Ari Archer <ari@ari.lt>
2025-02-03 20:09:33 +02:00

34 lines
1.5 KiB
Makefile

LIBS := -lsqlite3
ifeq ($(NOQA),)
CFLAGS += -std=c99 -Wall -Wextra -Wpedantic -pedantic -Wshadow -Werror -Wconversion -Wformat -Wuninitialized -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wredundant-decls -Wfloat-equal -Wcast-qual -Wnested-externs -Wvla -Winline -Wmissing-format-attribute -Wmissing-noreturn -pedantic-errors -Wformat-security -Wsign-conversion
endif
SRC_DIR := src
OBJ_DIR := obj
SQL_DIR := src/sql
SRC_FILES := $(wildcard $(SRC_DIR)/*.c)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))
sql-space-invaders: $(OBJ_FILES)
$(CC) -o $@ $(CFLAGS) $(F_CFLAGS) $^ $(LIBS) $(LDFLAGS) $(F_LDFLAGS)
game.db: $(SQL_DIR)/schema.sql $(SQL_DIR)/player.sql $(SQL_DIR)/invaders.sql $(SQL_DIR)/state.sql $(SQL_DIR)/bullets.sql $(SQL_DIR)/init.sql
for sql in $^; do \
echo Applying $$sql; \
sqlite3 $@ <$$sql; \
done
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/include/%.h | $(OBJ_DIR)
$(CC) -c -o $@ $(CFLAGS) $< $(LDFLAGS)
.PHONY: clean
clean:
rm -rf sql-space-invaders $(OBJ_DIR) game.db
strip:
strip --remove-section=.note.gnu.gold-version --remove-section=.note --remove-section=.gnu.version --remove-section=.eh_frame --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag --strip-symbol=__gmon_start__ --remove-section=.comment --remove-section=.eh_frame_ptr --strip-unneeded --strip-all --strip-debug --merge-notes --strip-dwo --discard-all --discard-locals --verbose sql-space-invaders