summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile54
1 files changed, 54 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8aa59db
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,54 @@
+.POSIX:
+
+CONFIGFILE = config.mk
+include $(CONFIGFILE)
+
+HDR =\
+ common.h
+
+BIN_ =\
+ backlight\
+ stopwatch
+
+OBJ =\
+ common.o\
+ $(BIN_:=.o)
+
+BIN = $(BIN_:=.bin)
+MAN1 = $(BIN_:=.1)
+
+
+all: $(BIN)
+$(OBJ): $(@:.o=.c) $(HDR)
+$(BIN): $(@:.bin=.o) common.o
+
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+.o.bin:
+ $(CC) -o $@ $< common.o $(LDFLAGS)
+
+install: $(BIN)
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
+ for f in $(BIN_); do\
+ ! test -d "$(DESTDIR)$(PREFIX)/bin/$$f" &&\
+ cp -- "$$f.bin" "$(DESTDIR)$(PREFIX)/bin/$$f" || exit 1;\
+ done
+ cp -- $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"
+
+post-install:
+ chown -- '0:$(VIDEO_GROUP)' "$(DESTDIR)$(PREFIX)/bin/backlight"
+ chmod -- 4754 "$(DESTDIR)$(PREFIX)/bin/backlight"
+
+uninstall:
+ -cd -- "$(DESTDIR)$(PREFIX)/bin" && rm -f -- $(BIN_)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man1" && rm -f $(MAN1)
+
+clean:
+ -rm -rf -- *.o *.su *.bin
+
+.SUFFIXES:
+.SUFFIXES: .bin .o .c
+
+.PHONY: all install post-install uninstall clean