#color scheme
COLOR_NONE=\x1b[0m
COLOR_COMPILE=\x1b[32;01m
COLOR_BUILD=\x1b[35;01m
COLOR_CLEAN=\x1b[31;01m

#architecture
ARCHITECTURE=$(shell uname -m)

#lib name
LIB_NAME=liblgi-1.0.so

#libraries
LIBS=cairo

#objects
OBJECTS=layer.o widget.o message.o events.o exceptions.o x11window.o

#cflags
CCFLAGS=`pkg-config $(LIBS) --cflags`

#link
CCLINK=`pkg-config $(LIBS) --libs`	

#custom setup
CCFLAGS+=-pthread -std=c++0x -fPIC -I ../include/lgi-1.0

#debug settings
ifdef DEBUG
CCFLAGS+=-g
else
CCFLAGS+=-O2
endif

#use MMX, SSE and SSE2 on 32-bit architectures
ifeq ($(ARCHITECTURE),i686)
CCFLAGS+=-march=pentium4
endif

#extra libs
CCLINK+=-lX11 -lXcursor -lGL

all: $(LIB_NAME)

$(LIB_NAME): $(OBJECTS)
	@echo -e '$(COLOR_BUILD)* Building [$@]$(COLOR_NONE)'
	g++  -shared -o $(LIB_NAME) $(OBJECTS) $(CCLINK)


%.o : %.cpp
	@echo -e '$(COLOR_COMPILE)* Compiling [$<]$(COLOR_NONE)'
	g++ -c $< $(CCFLAGS)

%.o : %.c
	@echo -e '$(COLOR_COMPILE)* Compiling [$<]$(COLOR_NONE)'
	g++ -c $< $(CCFLAGS)

clean:
	@echo -e '$(COLOR_BUILD)* Cleaning$(COLOR_NONE)'
	rm -f $(LIB_NAME)
	rm -f $(OBJECTS)


.PHONY: all pot clean