# GNUmakefile -- makefile for pager
# Copyright (C) 2002 Daniel Pfeiffer <occitan@esperanto.org>
# Copyright (C) 2000 Satyaki Das <satyaki@theforce.stanford.edu>
#                    Hakon Alstadheim <hakon.alstadheim@oslo.mail.telia.com>
#                    Andreas Bsching <crunchy@tzi.de>
#
# This file is part of sawfish.
#
# sawfish is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# sawfish is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with sawfish; see the file COPYING.   If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

SAWFISH_CLIENT_LIB_DIR := `rep-config --execdir`/sawfish

CFLAGS = -DUSE_SAWFISH_LIBCLIENT -DFRAMEOVER
LDFLAGS = -Wl,-rpath $(SAWFISH_CLIENT_LIB_DIR) $(SAWFISH_CLIENT_LIB_DIR)/client.so

ifndef GTK1
  GTK1 := $(shell pkg-config gtk+-2.0 >/dev/null 2>&1 || echo 1)
endif

ifdef GTK1
  CFLAGS += `gtk-config --cflags`
  LDFLAGS += `gtk-config --libs`
else
  CFLAGS += `pkg-config --cflags gtk+-2.0` -DHAVE_GTK2
  LDFLAGS += `pkg-config --libs gtk+-2.0`
endif


ifndef PRE_SAWFISH1_2
  SAWFISH_VERSION := $(word 3,$(shell sawfish --version))
  ifeq "$(SAWFISH_VERSION)" "2.0.pre1"
    PRE_SAWFISH1_2 := $(shell [ -f /etc/redhat-release ] && fgrep 8.0 /etc/redhat-release)
  else
    PRE_SAWFISH1_2 := $(filter-out 0,$(shell echo '1.2 > $(SAWFISH_VERSION)' | bc))
  endif
endif
ifdef PRE_SAWFISH1_2
  CFLAGS += -DPRE_SAWFISH1_2
endif

all: pager pager.jlc

%.jlc: %.jl
	sawfish --batch --no-rc compiler -f compile-batch $^

private-install: all
	-mkdir -p $(HOME)/.sawfish/lisp/sawfish/wm/ext/
	cp -p pager.jl pager.jlc $(HOME)/.sawfish/lisp/sawfish/wm/ext/
	mv pager $(HOME)/.sawfish/

clean:
	rm -f pager pager.jlc
