# Base directory to install to
PREFIX?=/usr/local

# Base directory for man pages (if different from PREFIX)
MANPREFIX?=$(PREFIX)

# X11 base directory
X11BASE?=/usr/X11R6


# Include debugging symbols in output (stripped when doing "make install")
CXXFLAGS+=-g

# Warn about a lot of things (probably g++ specific parameters)
WARNS=-Wall -W -Wpointer-arith -Wcast-align -Wconversion -Wno-system-headers

# This is where X11 includes reside
CXXFLAGS+=-I$(X11BASE)/include


# These are our sources
SRCS=\
CommandLine.cc \
ERegEx.cc \
FDHolder.cc \
FDSet.cc \
HistoryDataHandler.cc \
HistoryPainter.cc \
PanelSelector.cc \
Request.cc \
ResourceFile.cc \
SampleTransformer.cc \
SimpleCalendar.cc \
SSLClientSocket.cc \
SSLPtr.cc \
SSL_CTXPtr.cc \
SpeedDataHandler.cc \
StatsFetcher.cc \
StatusPainter.cc \
UsageDataHandler.cc \
wmium.cc \
WMDockWindow.cc \
XpmCharSetLCD6x8.cc \
XpmField.cc \
XpmGraphField.cc \
XpmResourceMeter.cc \
XResource.cc \


# And here we create their .o counterpart names
OBJS=$(SRCS:.cc=.o)

# This is where we can find the X11 libs
LIBDIR=-L$(X11BASE)/lib
# And these are the libs we need to link against, OpenSSL, X11, & Xpm libs
LIBS=-lssl -lcrypto -lX11 -lXpm -lXext

# Here are the various targets, nothing fancy at all...
.cc.o:
	$(CXX) $(CXXFLAGS) $(WARNS) -c $< -o $@

.PHONY=build clean cleandepend cleanall depend install all

all: wmium
build: wmium

wmium: $(OBJS)
	$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LIBDIR) $(LIBS)
	@echo "" && echo "Build complete. Use 'make install' to install."
	@echo ""
	@echo "Current install path is $(PREFIX), set PREFIX to override."
	@echo "Example: make PREFIX=/opt install" && echo ""

depend:
	makedepend -f .depend -- $(CXXFLAGS) -- $(SRCS)

clean:
	@-rm *.o wmium

cleandepend:
	@-cp /dev/null .depend

cleanall: clean cleandepend

install: wmium
	install -d $(PREFIX)/bin
	install -d $(PREFIX)/etc
	install -d $(MANPREFIX)/man/man1
	install -s wmium $(PREFIX)/bin
	install -m 0644 ../dot.wmiumrc.sample $(PREFIX)/etc
	install -m 0644 wmium.1 $(MANPREFIX)/man/man1
	@echo ""
	@echo "Installation complete."
	@echo ""
	@echo "To run wmium, you should copy $(PREFIX)/etc/dot.wmiumrc.sample to ~/.wmiumrc and edit the username and password found therein. These are the same as for your DSL account."
	@echo ""
	@echo "To see what commandline options are availble, run 'wmium -h'."
	@echo ""

# Include the dependencies file explicitly
include .depend

