# makefile for EULER
# This makefile is for Linux
# After that:
# make
# ./euler
# view docs/index.html with any Web browser.


#INSTALL_DIR = /usr/local


# Changes for other systems:
# Change 8x13 to your favorite text font.
# Define -DRS6000 on IBM RS6000 machines.
# else provide -DSY_CLK_TCK=50 (clock ticks on your machine)
# else the program will time seconds only.
# Define -DSUN for Sun keybords
# Define -DFPE, if NaN and INF are not available by hardware
#               and program does crash on 1/0.
# Define -DCHDIR, if chdir makes troubles on make noxeuler.
# Define -DBACKSPACE, if backspace does not work, only delete
# Define -DSPECIAL_ALIGNMENT, if allignment is necessary
#               (in the CC command line)
# Additionally define -DALIGNMENT=xx, if xx is different from 8
#               (the default alignment factor)
#               (in the CC command line)

# If you do not have M_PI or PI and need pi with more than 16 digits
# define it -DPI=3.1415... (not necessary for 8 byte doubles)

CC=gcc -Wall -O2 -DINSTALL_DIR=\"$(INSTALL_DIR)\"


# This is for printing the DOC on your local printer
# Set the number to the intended page length in lines
# PRINTERPAGE=50

# CFLAGS=-DCHDIR -DFONT=\"6x13\" -DGFONT=\"6x13\" -DSY_CLK_TCK=50 -DFPE

OBJS=	binary.o builtin.o command.o edit.o express.o\
		fft.o funcs.o graphics.o input.o interval.o\
		linear.o mainloop.o matrix.o output.o polynom.o scalp.o\
		spread.o stack.o udf.o help.o special.o\
		feval.o meta.o metaps.o


euler: $(OBJS) main.o rc.o earray.o term.o metagtk.o colbut.o
	$(CC) -o euler main.o rc.o earray.o term.o metagtk.o colbut.o $(OBJS) -lm `gtk-config --libs`
	
imported: import.cpp
	g++ -o import import.cpp
	./import *.cpp *.h help.txt euler.cfg
	./import ../progs/*.e ../progs/*.en
	./import ../docs/*.html
	./import x11/*.cpp x11/*.h
	touch imported

#
#	object file dependances
#
binary.o :	sysdep.h stack.h output.h binary.h binary.c
	$(CC) -c  binary.c

builtin.o :	sysdep.h stack.h builtin.h builtin.c
	$(CC) -c  builtin.c

command.o :	stack.h command.h builtin.h udf.h express.h command.c
	$(CC) -c  command.c

edit.o :	sysdep.h graphics.h edit.c
	$(CC) -c  edit.c

express.o :	sysdep.h stack.h output.h funcs.h interval.h builtin.h express.h\
			spread.h udf.h matrix.h command.h input.h express.c
	$(CC) -c  express.c

feval.o :	stack.h output.h builtin.h udf.h mainloop.h feval.c
	$(CC) -c  feval.c

fft.o : sysdep.h stack.h output.h linear.h fft.h fft.c
	$(CC) -c  fft.c

funcs.o :	sysdep.h stack.h output.h builtin.h funcs.h linear.h polynom.h\
			interval.h spread.h express.h udf.h mainloop.h edit.h funcs.c
	$(CC) -c  funcs.c

graphics.o :sysdep.h stack.h output.h funcs.h express.h matrix.h meta.h\
			graphics.h graphics.c
	$(CC) -c  graphics.c

help.o :	output.h help.h help.c
	$(CC) -c  help.c

input.o :	sysdep.h input.c
	$(CC) -c  input.c

interval.o : interval.h spread.h stack.h interval.c
	$(CC) -c  interval.c

linear.o :	sysdep.h stack.h output.h interval.h mainloop.h\
			linear.h linear.c
	$(CC) -c  linear.c

mainloop.o : sysdep.h funcs.h graphics.h version.h\
	interval.h builtin.h stack.h meta.h mainloop.c
	$(CC) `glib-config --cflags` -c  mainloop.c

matrix.o :	stack.h output.h funcs.h interval.h linear.h mainloop.h\
			matrix.h matrix.c
	$(CC) -c  matrix.c

meta.o:		sysdep.h meta.h meta.c
	$(CC) -c meta.c

metaps.o:	sysdep.h meta.h metaps.h metaps.c
	$(CC) -c metaps.c

output.o :	sysdep.h output.c
	$(CC) -c  output.c

polynom.o : polynom.h funcs.h linear.h interval.h\
	express.h stack.h polynom.c
	$(CC) -c  polynom.c

psgraph.o : psgraph.h psgraph.c
	$(CC) -c psgraph.c

scalp.o :	interval.h express.h stack.h scalp.c
	$(CC) -c  scalp.c

special.o : stack.h spread.h special.c
	$(CC) -c  special.c

spread.o : stack.h output.h spread.h builtin.h udf.h spread.c
	$(CC) -c  spread.c

stack.o : sysdep.h stack.h stack.c
	$(CC) -c  stack.c

udf.o : sysdep.h stack.h udf.c help.h
	$(CC) -c  udf.c

main.o : main.c rc.h earray.h term.h metagtk.h metaps.h
	$(CC) `gtk-config --cflags` -c  main.c

rc.o :		rc.c rc.h
	$(CC) `gtk-config --cflags` -c  rc.c

earray.o : earray.c earray.h
	$(CC) `gtk-config --cflags` -c  earray.c

term.o : term.c term.h earray.h
	$(CC) `gtk-config --cflags` -c term.c

metagtk.o : metagtk.c metagtk.h meta.h
	$(CC) `gtk-config --cflags` -c metagtk.c

colbut.o : colbut.c colbut.h
	$(CC) `gtk-config --cflags` -c colbut.c

#
#	install
#
install:
	if [ ! -d "$(INSTALL_DIR)/share/euler" ]; then mkdir $(INSTALL_DIR)/share/euler ; fi
	if [ ! -d "$(INSTALL_DIR)/share/doc" ]; then mkdir $(INSTALL_DIR)/share/doc ; fi
	if [ ! -d "$(INSTALL_DIR)/share/doc/euler" ]; then mkdir $(INSTALL_DIR)/share/doc/euler ; fi
	cp -f euler $(INSTALL_DIR)/bin
	cp -fr ../progs $(INSTALL_DIR)/share/euler
	cp -fr ../docs/* $(INSTALL_DIR)/share/doc/euler/
	cp -f help.txt $(INSTALL_DIR)/share/euler

#
#	uninstall
#
uninstall:
	rm -f $(INSTALL_DIR)/bin/euler
	rm -fr $(INSTALL_DIR)/share/euler
	rm -fr $(INSTALL_DIR)/share/doc/euler

#
#	clean up everything
#
clean:
	rm *.o euler
