SHELL = @SHELL@
srcdir = @srcdir@
VPATH = @srcdir@
PLATFORM = @with_platform@
PLATFORM_DIR = $(srcdir)/../${PLATFORM}
CC = @CC@
.SUFFIXES:
.SUFFIXES: .c .o

PKG_CONFIG = @PKG_CONFIG@
LIBS = @LIBS@
USE_LIBS= @USE_LIBS@
#PROF = -fprofile-arcs -pg

CFLAGS = -g -I. -I${srcdir} ${PROF} @CFLAGS@  \
	 `${PKG_CONFIG} --cflags glib-2.0 `
LDFLAGS = ${PROF} @LDFLAGS@ `${PKG_CONFIG} --libs glib-2.0 ${USE_LIBS}` ${LIBS}
EXEC = ${PLATFORM_DIR}/${PROG}

############ Things to change for different programs

PROG = OroboROX

SRCS = main.c client.c stacking.c frame.c i18n.c mouse.c settings.c events.c ping.c margins.c \
	   hints.c keyboard.c pixmap.c workspaces.c xinerama.c startup_notification.c \
	   xerror.c focus.c 

OBJECTS = main.o client.o stacking.o frame.o i18n.o mouse.o settings.o events.o ping.o margins.o \
	      hints.o keyboard.o pixmap.o workspaces.o xinerama.o startup_notification.o \
		  xerror.o focus.o

############ Things to keep the same

${PROG}: ${OBJECTS}
	${CC} -o "${PROG}" ${OBJECTS} ${LDFLAGS}
	[ -d "${PLATFORM_DIR}" ] || mkdir "${PLATFORM_DIR}"
	mv "${PROG}" "${PLATFORM_DIR}"
	-(cd "${PLATFORM_DIR}" && \
	 objcopy --only-keep-debug OroboROX OroboROX.dbg && \
	 strip OroboROX && \
	 objcopy --add-gnu-debuglink=OroboROX.dbg OroboROX)

clean:
	rm -f *.o Makefile.bak
	rm -rf ${srcdir}/autom4te.cache

depend:
	makedepend -- ${CFLAGS} -- ${SRCS}

Makefile: Makefile.in config.status
	./config.status

config.h: config.h.in
	./config.status

config.status: configure
	APP_DIR="$(srcdir)/.." $(srcdir)/configure --with-platform="${PLATFORM}" --enable-rox

configure: configure.in
	cd $(srcdir) && autoconf
