aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-09-16 16:05:05 +0200
committerMattias Andrée <maandree@kth.se>2021-09-16 16:05:05 +0200
commit744f1b4d36f1671c03f63820246746a5b52f24be (patch)
treefc5c86167c63d1771add281ac77a7ad8f588f206
parentUpdate man page (diff)
downloadadjbacklight-744f1b4d36f1671c03f63820246746a5b52f24be.tar.gz
adjbacklight-744f1b4d36f1671c03f63820246746a5b52f24be.tar.bz2
adjbacklight-744f1b4d36f1671c03f63820246746a5b52f24be.tar.xz
Improve makefile and fix warnings8.2.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--Makefile23
-rw-r--r--adjbacklight.c6
-rw-r--r--config.mk6
3 files changed, 16 insertions, 19 deletions
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
diff --git a/adjbacklight.c b/adjbacklight.c
index d79d11b..57495d8 100644
--- a/adjbacklight.c
+++ b/adjbacklight.c
@@ -134,11 +134,11 @@ adjbrightness(const char *device, double pcur, long int cur, long int max, doubl
switch (strlen(suf)) {
case 2:
pcur = adj * pcur / 100 + pcur * inc;
- cur = (long int)(pcur * (double)max + 0.5);
+ cur = (long int)(pcur * (double)max + (double)0.5f);
break;
case 1:
pcur = adj / 100 + pcur * inc;
- cur = (long int)(pcur * (double)max + 0.5);
+ cur = (long int)(pcur * (double)max + (double)0.5f);
break;
case 0:
cur = (long int)adj + cur * inc;
@@ -155,7 +155,7 @@ adjbrightness(const char *device, double pcur, long int cur, long int max, doubl
static void
bars(long int max, long int init, long int cur)
{
- long int mid = (long int)((double)cur * (double)(cols - 2) / (double)max + 0.5);
+ long int mid = (long int)((double)cur * (double)(cols - 2) / (double)max + (double)0.5f);
printf("\033[%iD\033[6A", cols);
printf("\033[2K┌%s┐\n", line);
diff --git a/config.mk b/config.mk
index 60571ad..9f9195f 100644
--- a/config.mk
+++ b/config.mk
@@ -1,8 +1,10 @@
-PREFIX = /usr/local
+PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
VIDEO_GROUP = video
-CCFLAGS = -std=c99 -Wall -Wextra -O2
+CC = cc
+
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
+CFLAGS = -std=c99 -Wall -O2
LDFLAGS = -s