Improve Makefile
This commit is contained in:
parent
1b22e91f25
commit
4a6c8bce19
1 changed files with 21 additions and 10 deletions
31
Makefile
31
Makefile
|
@ -46,24 +46,38 @@ DWM_HDR = $(DWM_SRC:.c=.h)
|
||||||
MAIN_HDR = $(MODULES_HDR) src/main.h src/config.def.h
|
MAIN_HDR = $(MODULES_HDR) src/main.h src/config.def.h
|
||||||
|
|
||||||
MODULES_OBJ = $(MODULES_SRC:.c=.o)
|
MODULES_OBJ = $(MODULES_SRC:.c=.o)
|
||||||
TEST_OBJ = $(TEST_SRC:.c=.o) tests/main.o
|
TEST_OBJ = $(TEST_SRC:.c=.o)
|
||||||
MAIN_OBJ = src/main.o
|
ALL_OBJ = $(MODULES_OBJ) $(TEST_OBJ) tests/main.o src/main.o
|
||||||
ALL_OBJ = $(MODULES_OBJ) $(TEST_OBJ) $(MAIN_OBJ)
|
|
||||||
|
|
||||||
TEST_EXE = $(TEST_SRC:.c=.test)
|
TEST_EXE = $(TEST_SRC:.c=.test)
|
||||||
ALL_EXE = polytreewm $(TEST_EXE)
|
ALL_EXE = polytreewm $(TEST_EXE)
|
||||||
|
|
||||||
polytreewm: $(MAIN_OBJ) $(MODULES_OBJ)
|
###############
|
||||||
|
# Executables #
|
||||||
|
###############
|
||||||
|
|
||||||
|
polytreewm: src/main.o $(MODULES_OBJ)
|
||||||
$(CC) -o $@ $^ $(LDFLAGS)
|
$(CC) -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
|
%.test: %.o tests/main.o $(MODULES_OBJ)
|
||||||
|
$(CC) -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
|
################
|
||||||
|
# Object files #
|
||||||
|
################
|
||||||
|
|
||||||
%.o: %.c $(CONFIGMKS) $(HDR)
|
%.o: %.c $(CONFIGMKS) $(HDR)
|
||||||
$(CC) -c $< -o $@ $(CFLAGS)
|
$(CC) -c $< -o $@ $(CFLAGS)
|
||||||
|
|
||||||
%.test: %.o $(MODULES_OBJ) tests/main.o
|
|
||||||
$(CC) -o $@ $^ $(LDFLAGS)
|
|
||||||
|
|
||||||
dwm.o: $(DWM_SRC) $(DWM_HDR)
|
dwm.o: $(DWM_SRC) $(DWM_HDR)
|
||||||
|
|
||||||
|
#########
|
||||||
|
# Tasks #
|
||||||
|
#########
|
||||||
|
|
||||||
|
test: $(TEST_EXE)
|
||||||
|
@echo "$(TEST_EXE)" | awk '{ OFS="\n"; $$1=$$1 } 1' | /bin/sh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ALL_OBJ) $(ALL_EXE)
|
rm -f $(ALL_OBJ) $(ALL_EXE)
|
||||||
|
|
||||||
|
@ -84,7 +98,4 @@ uninstall:
|
||||||
$(DESTDIR)$(BINDIR)/polytreewm \
|
$(DESTDIR)$(BINDIR)/polytreewm \
|
||||||
$(DESTDIR)$(MANDIR)/man1/polytreewm.1
|
$(DESTDIR)$(MANDIR)/man1/polytreewm.1
|
||||||
|
|
||||||
test: $(TEST_EXE)
|
|
||||||
@echo "$(TEST_EXE)" | awk '{ OFS="\n"; $$1=$$1 } 1' | sh
|
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall test
|
.PHONY: all clean distclean install uninstall test
|
||||||
|
|
Loading…
Reference in a new issue