adventofcode/Makefile

31 lines
633 B
Makefile
Raw Normal View History

2024-12-03 20:25:14 +01:00
MKDIR = mkdir
2024-12-03 20:36:04 +01:00
LN = ln -s
2024-12-03 20:25:14 +01:00
LATEST_YEAR := $(lastword $(sort $(wildcard [0-9]*)))
2024-12-03 20:36:04 +01:00
LATEST_DAY := $(patsubst day%,%,$(lastword $(sort $(wildcard day[0-9]*))))
2024-12-03 20:25:14 +01:00
ifeq ($(LATEST_YEAR),)
NEW_YEAR := $(shell date -u +%Y)
else
NEW_YEAR := $(shell echo $$(( $(LATEST_YEAR) + 1 )) )
endif
2024-12-03 20:36:04 +01:00
ifeq ($(LATEST_DAY),)
NEW_DAY := 1
else
NEW_DAY := $(shell echo $$(( $(LATEST_DAY) + 1 )) )
endif
2024-12-03 20:25:14 +01:00
2024-12-03 20:36:04 +01:00
all: $(if $(wildcard $(LATEST_YEAR)),create_year,create_day)
2024-12-03 20:25:14 +01:00
create_year:
$(MKDIR) "$(NEW_YEAR)"
2024-12-03 20:36:04 +01:00
cd "$(NEW_YEAR)" && $(LN) "../Makefile" .
create_day:
$(MKDIR) "day$(NEW_DAY)"
recreate_makefile:
2024-12-03 20:39:32 +01:00
cd "$(LATEST_YEAR)" && $(LN) "../Makefile" .