# $Id: Makefile,v 1.4 1998/09/29 20:46:36 ortalo Exp $
# -----------------------------------------------------------------------------
#
#	Copyright (C) 1997 by The GGI Project
#
# -----------------------------------------------------------------------------
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU Library General Public License as 
#	published by the Free Software Foundation; either version 2, or 
#	(at your option) any later version.
#
#	You should have received a copy of the GNU Library General Public 
#	License	along with this program; see the file COPYING.LGPL .  
#	If not, write to the Free Software Foundation, 675 Mass Ave, 
#	Cambridge, MA 02139, USA.
#
# ----------------------------------------------------------------------------

VERSION=$(shell cat ./.version)
SOMAJOR=$(shell cat ./.version | cut -d. -f1)
SOMINOR=$(shell cat ./.version | cut -d. -f2-)
SHLIBGWT=libgwt.$(DLLEXT).$(SOMAJOR).$(SOMINOR)
SONAME=libgwt.$(DLLEXT).$(SOMAJOR)
LIBGWT=libgwt.$(DLLEXT)
BINNAME=libgwt-$(SOMAJOR).$(SOMINOR)

SUBDIRS=

SOURCES=init.c window.c zorder.c region.c tt_region.c hide.c geometry.c draw.c invalidate.c

LIBGWT_TOPLEVEL=$(shell pwd)
LIBGGI_TOPLEVEL=$(LIBGWT_TOPLEVEL)/../libggi
TOPLEVEL=$(shell cd ../../ ; pwd)
CONFLEVEL=$(TOPLEVEL)/config

#include $(CONFLEVEL)/rules/defs

MFLAGS += GGILIBS=$(GGILIBS)

# Not yet useful -- ortalo
# make config the default target if no configuration file exists

ifeq ($(LIBGGI_TOPLEVEL)/.config,$(wildcard $(LIBGGI_TOPLEVEL)/.config))
include $(LIBGGI_TOPLEVEL)/.config
else
default-target: config
endif

include Makerules

ifeq ($(OS),OSF1)
define _SHLIBLDFLAGS
$(_SHLIBLDLIBS) $(SHLIBLDFLAGS) $($(OS)SHLIBLDFLAGS:-Wl,-hidden= )
endef
endif

# Real build target
$(SHLIBGWT):: $(SHLIBOBJECTS)
ifndef HOST_LIBGGI_RULE
	$(SHLIBLINKER) $(_SHLIBLDFLAGS) -o $@ $(SHLIBOBJECTS)
	rm -f $(SONAME) libgwt.$(DLLEXT)
	ln -s $@ $(SONAME)
	ln -s $@ libgwt.$(DLLEXT)
else
	$(HOST_LIBGGI_RULE)
endif

install::
#	$(MKDIRTREE) $(INST_CONFIG)
	$(MKDIRTREE) $(INST_LIB)
	$(MKDIRTREE) $(INST_INCLUDE)
# Not useful yet -- ortalo
#	install libgwt.conf $(INST_CONFIG)
	$(INSTALL) $(SHLIBGWT) $(INST_LIB)
	ln -sf $(SHLIBGWT)  $(INST_LIB)/$(SONAME)
	ln -sf $(SONAME) $(INST_LIB)/libgwt.$(DLLEXT)
	$(INSTALL) -m 0644 include/ggi/gwt.h $(INST_INCLUDE)
	$(LDCONFIG)

.PHONY:	demos

demos:
	$(MAKE) -C demos $(MFLAGS)

.config:
	cd $(LIBGGI_TOPLEVEL) && ./scripts/configure

config:
	cd $(LIBGGI_TOPLEVEL) && ./scripts/configure
