Better organize Makefile

This commit is contained in:
Alex Kotov 2021-11-17 07:34:53 +05:00
parent a0f3f1000e
commit 6fceae2d49
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -17,10 +17,9 @@ CONFIGMKS = \
VERSION = 6.2 VERSION = 6.2
SRC = \ MODULES_SRC = \
src/atoms.c \ src/atoms.c \
src/drw.c \ src/drw.c \
src/dwm.c \
src/helpers.c \ src/helpers.c \
src/layouts.c \ src/layouts.c \
src/menu.c \ src/menu.c \
@ -29,54 +28,47 @@ SRC = \
src/tags.c \ src/tags.c \
src/util.c src/util.c
HDR = \
src/atoms.h \
src/drw.h \
src/config.def.h \
src/helpers.h \
src/layouts.h \
src/menu.h \
src/settings.h \
src/spawn.h \
src/tags.h \
src/util.h
DWM_SRC = \ DWM_SRC = \
src/dwm/handlers.c \ src/dwm/handlers.c \
src/dwm/layouts.c \ src/dwm/layouts.c \
src/dwm/swallow.c \ src/dwm/swallow.c \
src/dwm/systray.c src/dwm/systray.c
OBJ = ${SRC:.c=.o} MODULES_HDR = $(MODULES_SRC:.c=.h)
DWM_HDR = ${DWM_SRC:.c=.h} DWM_HDR = $(DWM_SRC:.c=.h)
polytreewm: ${OBJ} SRC = $(MODULES_SRC) src/dwm.c
${CC} -o $@ ${OBJ} ${LDFLAGS} HDR = $(MODULES_HDR) src/config.def.h
OBJ = $(SRC:.c=.o)
polytreewm: $(OBJ)
$(CC) -o $@ $(OBJ) $(LDFLAGS)
%.o: %.c %.o: %.c
${CC} -c $< -o $@ ${CFLAGS} $(CC) -c $< -o $@ $(CFLAGS)
dwm.o: ${DWM_SRC} ${DWM_HDR} dwm.o: $(DWM_SRC) $(DWM_HDR)
${OBJ}: ${CONFIGMKS} ${HDR} $(OBJ): $(CONFIGMKS) $(HDR)
clean: clean:
rm -f polytreewm ${OBJ} rm -f polytreewm $(OBJ)
distclean: clean distclean: clean
rm -f $(CONFIGMKS_TO_REMOVE) rm -f $(CONFIGMKS_TO_REMOVE)
install: all install: all
mkdir -p ${DESTDIR}${BINDIR} mkdir -p $(DESTDIR)$(BINDIR)
cp -f polytreewm ${DESTDIR}${BINDIR} cp -f polytreewm $(DESTDIR)$(BINDIR)
chmod 755 ${DESTDIR}${BINDIR}/polytreewm chmod 755 $(DESTDIR)$(BINDIR)/polytreewm
mkdir -p ${DESTDIR}${MANDIR}/man1 mkdir -p $(DESTDIR)$(MANDIR)/man1
sed "s/VERSION/${VERSION}/g" < polytreewm.1 > ${DESTDIR}${MANDIR}/man1/polytreewm.1 sed "s/VERSION/$(VERSION)/g" < polytreewm.1 > $(DESTDIR)$(MANDIR)/man1/polytreewm.1
chmod 644 ${DESTDIR}${MANDIR}/man1/polytreewm.1 chmod 644 $(DESTDIR)$(MANDIR)/man1/polytreewm.1
uninstall: uninstall:
rm -f \ rm -f \
${DESTDIR}${BINDIR}/polytreewm \ $(DESTDIR)$(BINDIR)/polytreewm \
${DESTDIR}${MANDIR}/man1/polytreewm.1 $(DESTDIR)$(MANDIR)/man1/polytreewm.1
.PHONY: all clean distclean install uninstall .PHONY: all clean distclean install uninstall