Xinqi Bao's Git

Rewrite Makefile to accomodate file split
[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
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
35 battery.o: battery.c config.mk $(HDR) $(REQ:=.h)
36 cpu.o: cpu.c config.mk $(HDR) $(REQ:=.h)
37 datetime.o: datetime.c config.mk $(HDR) $(REQ:=.h)
38 disk.o: disk.c config.mk $(HDR) $(REQ:=.h)
39 entropy.o: entropy.c config.mk $(HDR) $(REQ:=.h)
40 hostname.o: hostname.c config.mk $(HDR) $(REQ:=.h)
41 ip.o: ip.c config.mk $(HDR) $(REQ:=.h)
42 kernel_release.o: kernel_release.c config.mk $(HDR) $(REQ:=.h)
43 keyboard_indicators.o: keyboard_indicators.c config.mk $(HDR) $(REQ:=.h)
44 load_avg.o: load_avg.c config.mk $(HDR) $(REQ:=.h)
45 num_files.o: num_files.c config.mk $(HDR) $(REQ:=.h)
46 ram.o: ram.c config.mk $(HDR) $(REQ:=.h)
47 run_command.o: run_command.c config.mk $(HDR) $(REQ:=.h)
48 swap.o: swap.c config.mk $(HDR) $(REQ:=.h)
49 temperature.o: temperature.c config.mk $(HDR) $(REQ:=.h)
50 uptime.o: uptime.c config.mk $(HDR) $(REQ:=.h)
51 user.o: user.c config.mk $(HDR) $(REQ:=.h)
52 volume.o: volume.c config.mk $(HDR) $(REQ:=.h)
53 wifi.o: wifi.c config.mk $(HDR) $(REQ:=.h)
54
55 .o:
56 $(CC) -o $@ $(LDFLAGS) $< $(COM:=.o) $(REQ:=.o) $(LDLIBS)
57
58 .c.o:
59 $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
60
61 clean:
62 rm -f slstatus slstatus.o $(COM:=.o) $(REQ:=.o)
63
64 dist:
65 rm -rf "slstatus-$(VERSION)"
66 mkdir -p "slstatus-$(VERSION)"
67 cp -R LICENSE Makefile README config.mk config.def.h \
68 $(HDR) slstatus.c $(COM:=.c) $(REQ:=.c) $(REQ:=.h) \
69 slstatus.1 "slstatus-$(VERSION)"
70 tar -cf - "slstatus-$(VERSION)" | gzip -c > "slstatus-$(VERSION).tar.gz"
71 rm -rf "slstatus-$(VERSION)"
72
73 install: all
74 mkdir -p "$(DESTDIR)$(PREFIX)/bin"
75 cp -f slstatus "$(DESTDIR)$(PREFIX)/bin"
76 chmod 755 "$(DESTDIR)$(PREFIX)/bin/slstatus"
77 mkdir -p "$(DESTDIR)$(MANPREFIX)/man1"
78 cp -f slstatus.1 "$(DESTDIR)$(MANPREFIX)/man1"
79 chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/slstatus.1"
80
81 uninstall:
82 rm -f "$(DESTDIR)$(PREFIX)/bin/slstatus"
83 rm -f "$(DESTDIR)$(MANPREFIX)/man1/slstatus.1"