aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 65b8d54494c5a84babcfe89340c620a4a7541c58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
.POSIX:

all:

CONFIGFILE = config.mk
include $(CONFIGFILE)

include mk/gasroot-gtk2=$(INCLUDE_GTK2).mk
include mk/gasroot-gtk3=$(INCLUDE_GTK3).mk

BIN =\
	$(BIN_GTK2)\
	$(BIN_GTK3)\
	gasroot-setuid

OBJ = common.o $(BIN:=.o)
HDR = common.h arg.h

SUDOCMD = @:
# developers will set this to "sudo" or similar

all: $(BIN)
common: gasroot-setuid
$(OBJ): $(HDR)
$(BIN): common.o

.c.o:
	$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -D'PATH_TO_SETUID="$(PATH_TO_SETUID)"'

gasroot-setuid: gasroot-setuid.o
	$(CC) -o $@ $@.o common.o $(LDFLAGS) $(LDFLAGS_SETUID)
	$(SUDOCMD) sh -c 'chown 0:wheel gasroot-setuid && chmod 4750 gasroot-setuid'

install-common: gasroot-setuid
	mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
	mkdir -p -- "$(DESTDIR)$(PREFIX)$(LIBEXECDIR)"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man8/"
	cp -- gasroot.8 "$(DESTDIR)$(MANPREFIX)/man8/"
	cp -- gasroot-setuid "$(DESTDIR)$(PREFIX)$(LIBEXECDIR)/"

install: install-common
	test -f "$(DESTDIR)$(PREFIX)/bin/$(DEFAULT_GASROOT)"
	test ! -d "$(DESTDIR)$(PREFIX)/bin/gasroot"
	ln -sf -- $(DEFAULT_GASROOT) "$(DESTDIR)$(PREFIX)/bin/gasroot"

post-install:
	chown -- '0:wheel' "$(DESTDIR)$(PREFIX)$(LIBEXECDIR)/gasroot-setuid"
	chmod -- 4750 "$(DESTDIR)$(PREFIX)$(LIBEXECDIR)/gasroot-setuid"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/bin/gasroot"
	-rm -f -- "$(DESTDIR)$(PREFIX)$(LIBEXECDIR)/gasroot-setuid"
	-rmdir -- "$(DESTDIR)$(PREFIX)$(LIBEXECDIR)"
	-rm -f -- "$(DESTDIR)$(MANPREFIX)/man8/gasroot.8"

clean:
	-rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda
	-rm -f -- gasroot gasroot-setuid gasroot-gtk2 gasroot-gtk3

.SUFFIXES:
.SUFFIXES: .o .c

.PHONY: all install install-common post-install uninstall clean