# Database Internals Project Makefile
# 
# Copyright (C) 2000
# Kevin Pulo, kev@zip.com.au
# Garrick Welsh, penpen@zip.com.au
# 
# This program 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 of the License, or
# (at your option) any later version.
# 
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# 
# Requires GNU make.
# 
# $Id: Makefile,v 1.8 2000/05/26 13:00:50 kev Exp $

.PHONY: all doc clean

CXX     = g++
CC      = gcc
LD      = g++

PIC     = -fPIC
#CFLAGS  = -O3 -Wall -fomit-frame-pointer -funroll-all-loops
CFLAGS  = -O -g -Wall
CXXFLAGS= $(CFLAGS)


LEDA_ROOT = /local/usr/leda
 
XLIB_PATH = -L/usr/openwin/lib -L/usr/X11R6/lib
#XLIB_LIBS = -lX11 -lsocket -lthread
XLIB_LIBS = -lX11

LEDA_LIBS = $(XLIB_PATH) -L$(LEDA_ROOT) -lD3 -lW -lP -lG -lL $(XLIB_LIBS) -lm -ldl
LEDA_INCL = -I$(LEDA_ROOT)/incl


CXX_OBJECTS := $(patsubst %.cc,%.o,$(wildcard *.cc))
C_OBJECTS := $(patsubst %.c,%.o,$(wildcard *.c))


# Programs to build
PROGRAMS = cluster display generate


all:  $(PROGRAMS)


# The main dependancies.
cluster display: LIBS = $(LEDA_LIBS)
cluster: algorithms.o cluster_test.o cluster_random.o cluster_kmeans.o cluster_tb.o cluster_ech.o generic_cluster.o
display: generic_cluster.o
algorithms.o: cluster_test.hh cluster_random.hh cluster_kmeans.hh cluster_tb.hh cluster_ech.hh
cluster.o: cluster.hh algorithms.hh
cluster_test.o: cluster.hh
cluster_random.o: cluster.hh
cluster_kmeans.o: cluster.hh cluster_random.hh
cluster_tb.o: cluster.hh
cluster_ech.o: cluster.hh



$(CXX_OBJECTS): %.o: %.cc $(wildcard %.hh)
	$(CXX) $(CXXFLAGS) $(LEDA_INCL) -c $<

$(C_OBJECTS): %.o: %.c $(wildcard %.h)
	$(CC) $(CFLAGS) $(LEDA_INCL) -c $<

$(PROGRAMS): %: %.o
	$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)


doc:
	doc++ --dir docs --html $(patsubst %.o,%.cc,$(CXX_OBJECTS)) $(patsubst %.o,%.c,$(C_OBJECTS))


clean:
	rm -f core $(CXX_OBJECTS) $(C_OBJECTS) $(PROGRAMS)

