From 744f1b4d36f1671c03f63820246746a5b52f24be Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 16 Sep 2021 16:05:05 +0200 Subject: Improve makefile and fix warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8cbdd23..f7ac48a 100644 --- a/Makefile +++ b/Makefile @@ -3,19 +3,18 @@ CONFIGFILE = config.mk include $(CONFIGFILE) -all: adjbacklight test +BIN = adjbacklight test +OBJ = $(BIN:=.o) -adjbacklight.o: adjbacklight.c arg.h - $(CC) -c -o adjbacklight.o adjbacklight.c $(CCFLAGS) $(CPPFLAGS) -adjbacklight: adjbacklight.o - $(CC) -o adjbacklight adjbacklight.o $(LDFLAGS) +all: adjbacklight test +$(OBJ): arg.h -test.o: test.c adjbacklight.c arg.h - $(CC) -c -o test.o test.c $(CCFLAGS) $(CPPFLAGS) +.c.o: + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -test: test.o - $(CC) -o test test.o $(LDFLAGS) +.o: + $(CC) -o $@ $< $(LDFLAGS) check: test ./test.sh @@ -23,10 +22,8 @@ check: test install: adjbacklight mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1" - mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/adjbacklight" cp -- adjbacklight "$(DESTDIR)$(PREFIX)/bin" cp -- adjbacklight.1 "$(DESTDIR)$(MANPREFIX)/man1" - cp -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/adjbacklight" post-install: chown -- '0:$(VIDEO_GROUP)' "$(DESTDIR)$(PREFIX)/bin/adjbacklight" @@ -35,10 +32,8 @@ post-install: uninstall: -rm -- "$(DESTDIR)$(PREFIX)/bin/adjbacklight" -rm -- "$(DESTDIR)$(MANPREFIX)/man1/adjbacklight.1" - -rm -- "$(DESTDIR)$(PREFIX)/share/licenses/adjbacklight/LICENSE" - -rmdir -- "$(DESTDIR)$(PREFIX)/share/licenses/adjbacklight" clean: - -rm -rf -- adjbacklight test *.o .testdir + -rm -rf -- adjbacklight test .testdir *.o *.su .PHONY: all check install post-install uninstall clean -- cgit v1.2.3-70-g09d2