Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit b369cd6

Browse files
committed
build: improve the clean target
* Uses a sentinel file for the obj directory. * Removes the binary with 'make clean'. * Uses 'rm -f` to ensure the clean target always succeeds.
1 parent 76c5e02 commit b369cd6

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Makefile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ PKG_CONFIG ?= pkg-config
2121

2222
XFILES :=
2323

24+
OBJDIR := obj
25+
2426
SOURCES := $(SRCDIR)/*.cpp
2527

2628
PREFIX ?= /usr
@@ -83,15 +85,19 @@ ifeq ($(TARGET),gtk)
8385
endif
8486

8587
all: $(FNAME_$(TARGET))
86-
obj:
87-
mkdir obj
88-
clean: | obj
89-
rm obj/* || true
88+
89+
$(OBJDIR)/.tag:
90+
@mkdir -p $(OBJDIR)
91+
@touch $@
92+
93+
clean:
94+
rm -rf $(OBJDIR)
95+
rm -f $(FNAME_$(TARGET))
9096

9197
ifeq ($(TARGET),windows)
92-
XFILES += obj/rc.o
93-
obj/rc.o: flips.rc flips.h | obj
94-
windres flips.rc obj/rc.o
98+
XFILES += $(OBJDIR)/rc.o
99+
$(OBJDIR)/rc.o: flips.rc flips.h $(OBJDIR)/.tag
100+
windres flips.rc $(OBJDIR)/rc.o
95101
endif
96102

97103
MOREFLAGS := $(CFLAGS_$(TARGET))

0 commit comments

Comments
 (0)