Xinqi Bao's Git

Simplify Makefile
[slstatus.git] / Makefile
1 # See LICENSE file for copyright and license details
2 # slstatus - suckless status monitor
3 .POSIX:
4
5 include config.mk
6
7 REQ = util
8 HDR = arg.h config.h
9 COM =\
10 battery\
11 cpu\
12 datetime\
13 disk\
14 entropy\
15 hostname\
16 ip\
17 kernel_release\
18 keyboard_indicators\
19 load_avg\
20 num_files\
21 ram\
22 run_command\
23 swap\
24 temperature\
25 uptime\
26 user\
27 volume\
28 wifi
29
30 all: slstatus
31
32 slstatus: slstatus.o $(COM:=.o) $(REQ:=.o)
33 slstatus.o: slstatus.c slstatus.h $(HDR) $(REQ:=.h)
34 $(COM:=.o): config.mk $(HDR) $(REQ:=.h)
35
36 config.h:
37 cp config.def.h $@
38
39 .o:
40 $(CC) -o $@ $(LDFLAGS) $< $(COM:=.o) $(REQ:=.o) $(LDLIBS)
41
42 .c.o:
43 $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
44
45 clean:
46 rm -f slstatus slstatus.o $(COM:=.o) $(REQ:=.o)
47
48 dist:
49 rm -rf "slstatus-$(VERSION)"
50 mkdir -p "slstatus-$(VERSION)"
51 cp -R LICENSE Makefile README config.mk config.def.h \
52 $(HDR) slstatus.c $(COM:=.c) $(REQ:=.c) $(REQ:=.h) \
53 slstatus.1 "slstatus-$(VERSION)"
54 tar -cf - "slstatus-$(VERSION)" | gzip -c > "slstatus-$(VERSION).tar.gz"
55 rm -rf "slstatus-$(VERSION)"
56
57 install: all
58 mkdir -p "$(DESTDIR)$(PREFIX)/bin"
59 cp -f slstatus "$(DESTDIR)$(PREFIX)/bin"
60 chmod 755 "$(DESTDIR)$(PREFIX)/bin/slstatus"
61 mkdir -p "$(DESTDIR)$(MANPREFIX)/man1"
62 cp -f slstatus.1 "$(DESTDIR)$(MANPREFIX)/man1"
63 chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/slstatus.1"
64
65 uninstall:
66 rm -f "$(DESTDIR)$(PREFIX)/bin/slstatus"
67 rm -f "$(DESTDIR)$(MANPREFIX)/man1/slstatus.1"