From e8900524316df9df6d128844b6d3b4346eeab535 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 03:11:19 +0200 Subject: [PATCH] Restructure the Makefile (refactor) --- Makefile | 54 +++++++++++++++++++++++++++++------------------------- config.mk | 5 ----- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 551b924..7f7108c 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,18 @@ include config.mk +VERSION := "1.2.0-non-git" +ifneq ($(wildcard ./.git/.),) +VERSION := $(shell git describe --tags) +endif + CFLAGS += -I. LDFLAGS += -L. SRC := $(sort $(shell find src/ -name '*.c')) OBJ := ${SRC:.c=.o} +TEST_SRC := $(sort $(shell find test/ -name '*.c')) +TEST_OBJ := $(TEST_SRC:.c=.o) all: doc dunst service @@ -19,6 +26,25 @@ ${OBJ}: config.mk dunst: ${OBJ} main.o ${CC} ${CFLAGS} -o $@ ${OBJ} main.o ${LDFLAGS} +dunstify: dunstify.o + ${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS} + +test: test/test + cd test && ./test + +test/test: ${OBJ} ${TEST_OBJ} + ${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS} + +doc: docs/dunst.1 +docs/dunst.1: docs/dunst.pod + pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ + +service: + @sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service + @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service + +clean: clean-dunst clean-dunstify clean-doc clean-tests + clean-dunst: rm -f dunst ${OBJ} main.o rm -f org.knopwob.dunst.service @@ -31,15 +57,10 @@ clean-dunstify: clean-doc: rm -f docs/dunst.1 -clean: clean-dunst clean-dunstify clean-doc test-clean +clean-tests: + rm -f test/test test/*.o -doc: docs/dunst.1 -docs/dunst.1: docs/dunst.pod - pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ - -service: - @sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service - @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service +install: install-dunst install-doc install-service install-dunst: dunst doc mkdir -p ${DESTDIR}${PREFIX}/bin @@ -56,8 +77,6 @@ install-service: service install -m644 org.knopwob.dunst.service ${DESTDIR}${PREFIX}/share/dbus-1/services install -Dm644 dunst.systemd.service ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service -install: install-dunst install-doc install-service - uninstall: rm -f ${DESTDIR}${PREFIX}/bin/dunst rm -f ${DESTDIR}${MANPREFIX}/man1/dunst.1 @@ -65,19 +84,4 @@ uninstall: rm -f ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service rm -rf ${DESTDIR}${PREFIX}/share/dunst -test: test/test - cd test && ./test - -TEST_SRC := $(shell find test/ -name '*.c') -TEST_OBJ := $(TEST_SRC:.c=.o) - -test/test: ${OBJ} ${TEST_OBJ} - ${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS} - -test-clean: - rm -f test/test test/*.o - -dunstify: dunstify.o - ${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS} - .PHONY: all clean dist install uninstall diff --git a/config.mk b/config.mk index c50a4ea..96613a7 100644 --- a/config.mk +++ b/config.mk @@ -2,11 +2,6 @@ PREFIX ?= /usr/local MANPREFIX = ${PREFIX}/share/man -VERSION := "1.2.0-non-git" -ifneq ($(wildcard ./.git/.),) -VERSION := $(shell git describe --tags) -endif - # Warning: This is deprecated behavior # uncomment to disable parsing of dunstrc # or use "CFLAGS=-DSTATIC_CONFIG make" to build