Xinqi Bao's Git

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