diff --git a/.gitignore b/.gitignore index 1d74e21..3fce4e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .vscode/ + +*/Makefile diff --git a/2023/Makefile b/2023/Makefile deleted file mode 100644 index d93ad8e..0000000 --- a/2023/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -MKDIR = mkdir - -LATEST_DAY := $(patsubst day%,%,$(lastword $(sort $(wildcard day[0-9]*)))) - -ifeq ($(LATEST_DAY),) - NEW_DAY := 1 -else - NEW_DAY := $(shell echo $$(( $(LATEST_DAY) + 1 )) ) -endif - - -all: create_day - -create_day: - $(MKDIR) "day$(NEW_DAY)" diff --git a/Makefile b/Makefile index f796384..3be4b53 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ MKDIR = mkdir -CP = cp +LN = ln -s LATEST_YEAR := $(lastword $(sort $(wildcard [0-9]*))) +LATEST_DAY := $(patsubst day%,%,$(lastword $(sort $(wildcard day[0-9]*)))) ifeq ($(LATEST_YEAR),) NEW_YEAR := $(shell date -u +%Y) @@ -9,9 +10,21 @@ else NEW_YEAR := $(shell echo $$(( $(LATEST_YEAR) + 1 )) ) endif +ifeq ($(LATEST_DAY),) + NEW_DAY := 1 +else + NEW_DAY := $(shell echo $$(( $(LATEST_DAY) + 1 )) ) +endif -all: create_year + +all: $(if $(wildcard $(LATEST_YEAR)),create_year,create_day) create_year: $(MKDIR) "$(NEW_YEAR)" - $(CP) "$(LATEST_YEAR)/Makefile" "$(NEW_YEAR)" + cd "$(NEW_YEAR)" && $(LN) "../Makefile" . + +create_day: + $(MKDIR) "day$(NEW_DAY)" + +recreate_makefile: + $(LN) "../Makefile" .