Xinqi Bao's Git

Makefile: add distclean target
[slstatus.git] / Makefile
index 00c35c4..c68a271 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,29 +2,34 @@
 # slstatus - suckless status monitor
 .POSIX:
 
+include os.mk
 include config.mk
 
 REQ = util
 COM =\
-       components/battery\
-       components/cpu\
+       components/$(OS)/battery \
+       components/$(OS)/cpu \
        components/datetime\
        components/disk\
-       components/entropy\
+       components/$(OS)/entropy \
        components/hostname\
        components/ip\
        components/kernel_release\
        components/keyboard_indicators\
        components/load_avg\
        components/num_files\
-       components/ram\
+       components/$(OS)/ram \
        components/run_command\
-       components/swap\
-       components/temperature\
-       components/uptime\
+       components/$(OS)/swap \
+       components/$(OS)/temperature \
+       components/$(OS)/uptime \
        components/user\
        components/volume\
-       components/wifi
+       components/$(OS)/wifi
+
+SLSCFLAGS  = -I$(X11INC) -D_DEFAULT_SOURCE $(CFLAGS)
+SLSLDFLAGS = -L$(X11LIB) $(LDFLAGS)
+SLSLIBS    = -lX11 $(OSLIBS) $(LIBS)
 
 all: slstatus
 
@@ -36,14 +41,18 @@ config.h:
        cp config.def.h $@
 
 .o:
-       $(CC) -o $@ $(LDFLAGS) $< $(COM:=.o) $(REQ:=.o) $(LDLIBS)
+       $(CC) -o $@ $(SLSLDFLAGS) $< $(COM:=.o) $(REQ:=.o) $(SLSLIBS)
 
 .c.o:
-       $(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<
+       $(CC) -o $@ -c $(SLSCFLAGS) $<
 
 clean:
        rm -f slstatus slstatus.o $(COM:=.o) $(REQ:=.o)
 
+distclean:
+       for os in Linux OpenBSD; do make OS="$$os" clean; done
+       rm -f os.mk
+
 dist:
        rm -rf "slstatus-$(VERSION)"
        mkdir -p "slstatus-$(VERSION)/components"