# -g - extra debug information
# -O1 - more precise backtraces
# -fPIC - required when using -shared option, required for use with Cython
# -Wall - show important warnings
# -Werror - treat warnings as errors

# Cython compiler options:
# -fPIC -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions \
#   -Wl,-z,relro

UNAME_S = $(shell uname -s)
CCFLAGS = -fPIC -DBROWSER_PROCESS $(CEF_CCFLAGS)

ifeq ($(UNAME_S), Linux)
	SRC_MORE = print_handler_gtk.cpp \
			main_message_loop/main_message_loop_external_pump_linux.cpp
else ifeq ($(UNAME_S), Darwin)
    SRC_MORE = main_message_loop/main_message_loop_external_pump_mac.mm
endif

SRC = cefpython_app.cpp v8function_handler.cpp v8utils.cpp \
		javascript_callback.cpp \
		main_message_loop/main_message_loop.cpp \
		main_message_loop/main_message_loop_std.cpp \
		main_message_loop/main_message_loop_external_pump.cpp \
		$(SRC_MORE)

OBJ = $(filter %.o, $(SRC:.cpp=.o) $(SRC:.mm=.o))
.SUFFIXES: .cpp .mm .o

OUT = libcefpythonapp.a

INC = -I./../ -I./../common/ -I$(PYTHON_INCLUDE) \
	-I/usr/include/gtk-2.0 \
	-I/usr/include/gtk-unix-print-2.0 \
	-I/usr/include/glib-2.0 \
	-I/usr/include/cairo \
	-I/usr/include/pango-1.0 \
	-I/usr/include/gdk-pixbuf-2.0 \
	-I/usr/include/atk-1.0 \
	-I/usr/lib/x86_64-linux-gnu/gtk-2.0/include \
	-I/usr/lib/x86_64-linux-gnu/gtk-unix-print-2.0 \
	-I/usr/lib/x86_64-linux-gnu/glib-2.0/include \
	-I/usr/lib/i386-linux-gnu/gtk-2.0/include \
	-I/usr/lib/i386-linux-gnu/gtk-unix-print-2.0 \
	-I/usr/lib/i386-linux-gnu/glib-2.0/include \
	-I/usr/lib64/gtk-2.0/include \
	-I/usr/lib64/gtk-unix-print-2.0 \
	-I/usr/lib64/glib-2.0/include \
	-I/usr/lib/gtk-2.0/include \
	-I/usr/lib/gtk-2.0/gtk-unix-print-2.0 \
	-I/usr/lib/glib-2.0/include

$(OUT): $(OBJ)
	@echo [CEFPYTHONAPP] Creating library $(OUT) from $(OBJ)...
	ar rcs $(OUT) $(OBJ)

.cpp.o:
	@echo [CEFPYTHONAPP] Building $@ from $<...
	$(CXX) $(CCFLAGS) $(INC) -c $< -o $@

.mm.o:
	@echo [CEFPYTHONAPP] Building $@ from $<...
	$(CXX) $(CCFLAGS) $(INC) -c $< -o $@
