ARCH = $(shell uname) 
BIN = PieDock
OBJECTS = Surface.o \
	RgbaSurface.o \
	RgbaSurfaceSizeMap.o \
	XSurface.o \
	PngSurface.o \
	Blender.o \
	Resampler.o \
	WildcardCompare.o \
	Icon.o \
	IconMap.o \
	Hotspot.o \
	TransparentWindow.o \
	Cartouche.o \
	Text.o \
	Menu.o \
	PieMenu.o \
	PieMenuWindow.o \
	WindowManager.o \
	ModMask.o \
	Settings.o \
	Application.o \
	main.o

CXX = g++
FLAGS = -O2 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 -I/usr/local/include
LIBS = -lX11 -lXft -lfreetype -lpng -lz -L/usr/X11R6/lib -L/usr/local/lib

# Determine the OS and if it is SunOS define _SUNOS_ and link the socket
# lib which are not linked by default.
ifeq ($(strip $(ARCH)),SunOS)
FLAGS += -D_SUNOS_
LIBS += -lnsl -lsocket
endif

.SUFFIXES:	.o .cpp

.cpp.o:
	$(CXX) $(FLAGS) -c -o $@ $<

$(BIN): $(OBJECTS)
	@echo $(OBJECTS)
	$(CXX) -o $@ $(OBJECTS) $(LIBS)

clean:
	rm -f $(BIN) *.o core

user-install:
	mkdir -p ~/bin
	cp $(BIN) ~/bin
	cp -i res/PieDockrc.sample ~/.PieDockrc
	mkdir -p ~/.PieDock
	cp -i res/*.png ~/.PieDock
