Reworked configuration.

This commit is contained in:
Tomas Rivera
2026-04-01 11:07:06 +02:00
parent 7289af7f7f
commit 60e10be2b1
4 changed files with 91 additions and 42 deletions
+22 -5
View File
@@ -1,3 +1,5 @@
CONFIG_DIR := $(HOME)/.config/notewrapper
CONFIG_FILE := $(CONFIG_DIR)/config.json
CC = gcc
SRC = startup.c
TARGET = notewrapper
@@ -7,11 +9,26 @@ DEBUG ?= 0
ifeq ($(DEBUG),1)
CFLAGS += -g
endif
.PHONY: all clean run
all: $(TARGET)
.PHONY: all clean run install_config
# existing targets
all: install_config $(TARGET)
$(TARGET): $(SRC)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
@$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
run: $(TARGET)
./$(TARGET)
@./$(TARGET)
clean:
rm -f $(TARGET)
@rm -f $(TARGET)
# new target for configuration
install_config:
@mkdir -p $(CONFIG_DIR)
@if [ ! -f $(CONFIG_FILE) ]; then \
cp ./config.json $(CONFIG_FILE); \
echo "config.json installed to $(CONFIG_FILE)"; \
else \
echo "$(CONFIG_FILE) already exists, skipping installing default config file"; \
fi