# This file is part of statist
# 
# It is distributed under the GNU General Public License.
# See the file COPYING for details.
# 
# (c) 1997 Dirk Melcher
# old email: Dirk.Melcher@usf.Uni-Osnabrueck.DE
#
#
# maintainted by Bernhard Reiter: http://www.usf.Uni-Osnabrueck.DE/~breiter/
# $Id: Makefile,v 1.6 2001/11/15 20:21:53 breiter Exp breiter $
#*************************************************************/
# Makefile fuer UNIX-Version und gnuplot-Graphik
# Makefile for unix with gnuplot grafics.

# and now for the language setting,
# you can add	LANG=LANG_EN or LANG=LANG_DE to the make arguments
# Command line arguments to make override the default (which is in here)
LANG=LANG_DE
LANGUAGE=-DLANG=$(LANG)

#decide between "main", "shlib" and "lib"
all: main

#all: lib
#all: shlib
# only use the next line, if you want to create a lib ("shlib" or "lib" )
#STATISTX = -DSTATIST_X

# fr systeme mit gcc oder egcs als compiler
# choose your compiler, the example flags are for the gcc
CC = gcc
LIBTOOL = ar crus

COMPILERCFLAGS = -c -Wall 
#COMPILERCFLAGS = -c -Wall -g 
#COMPILERCFLAGS = -c -Wall -g -DDEBUG 

# fr DEC's cc 
#CC = cc
#COMPILERCFLAGS= -c 
##COMPILERCFLAGS= -g -c

LIBS = -lm
LFLAGS = -o
#LFLAGS = -g -o

#we have to define NO_GETTEXT, because the simple statist uses its own macro
EXTRACFLAGS=-DNO_GETTEXT

CFLAGS= $(COMPILERCFLAGS) $(EXTRACFLAGS) $(LANGUAGE) $(STATISTX)

#MAIN = $(HOME)/tools/statist
MAIN=statist
SH_LIB = libstatist.so.1.0.1
STAT_LIB = libstatist.a


OBJECTS = statist.o menue.o procs.o funcs.o data.o plot.o memory_handling.o
LIB_OBJECTS = menue.o procs.o funcs.o data.o plot.o memory_handling.o

main:   $(MAIN)

check: main
	echo Running tests... in the appropriate directory
	(cd ../tests ; \
	$(MAKE) $(MAKEFLAGS) check \
	)

shlib:	$(SH_LIB)

lib:	$(STAT_LIB)


$(MAIN) : $(OBJECTS) Makefile
	$(CC) $(LFLAGS) $(MAIN) $(OBJECTS) $(LIBS)

# change AB:
$(SH_LIB):		$(LIB_OBJECTS) Makefile
	$(CC) -shared $(LIB_OBJECTS) -o $(SH_LIB)

$(STAT_LIB):	$(LIB_OBJECTS) Makefile
	 $(LIBTOOL) $(STAT_LIB) $(LIB_OBJECTS)

statist.o : statist.c statist.h menue.h data.h funcs.h 
	$(CC) $(CFLAGS) statist.c

menue.o : menue.c menue.h procs.h data.h statist.h 
	$(CC) $(CFLAGS) menue.c

procs.o : procs.c procs.h funcs.h statist.h 
	$(CC) $(CFLAGS) procs.c

funcs.o : funcs.c funcs.h statist.h 
	$(CC) $(CFLAGS) funcs.c

data.o : data.c data.h statist.h 
	$(CC) $(CFLAGS) data.c

plot.o : plot.c plot.h statist.h funcs.h  
	$(CC) $(CFLAGS) plot.c


clean: 
	-rm -f $(OBJECTS) $(MAIN) *.log *.aux core $(STAT_LIB) $(SH_LIB)
	(cd ../tests ; \
	$(MAKE) $(MAKEFLAGS) clean \
	)
