# Makefile for mtk
# Copyright Andrew Ross - 28/06/95


####### Install

# The directories structure here is designed for Deban. 
# You may want to alter things.

#You may want to change these for your system
BINDIR  =	$(DESTDIR)/usr/X11R6/bin
MANDIR	=	$(DESTDIR)/usr/X11R6/man

INSTALLBINOPTS = -c -s -o root -g root -m 0755
INSTALLMANOPTS = -c -o root -g root -m 0644 

####### Directories

#Check that these are correct for your system

# Uncomment one of these for the path of your qt include files
INCDIR	=	/usr/X11R6/include/qt  # Debian uses this
#INCDIR	=	/usr/lib/qt/include  # Try uncommenting this for Redhat
#INCDIR	=	/usr/local/lib/qt/include  # Might have includes in /usr/local

# You may need this to allow gcc to find the libqt.so file
LIBDIR =	-L/usr/X11R6/lib    # Debian puts libqt.so here

export INCDIR

####### Compiler

CFLAGS  =	-O2 -fhandle-exceptions # Uncomment for optimised compilation
#CFLAGS	=	-g -Wall  -fhandle-exceptions # Uncomment for debugging information
LFLAGS	=	$(LIBDIR) -lm -lqt -lstdc++ 
#LFLAGS	=	$(LIBDIR) -lm -lqt -lstdc++ -g # include debugging flags
INC     =	-I$(INCDIR)
CC	=	gcc
MATHFLAGS = 	# Uncomment for GNU libm with extra functions
# MATHFLAGS = -DANSI_MATH	# Uncomment for just ANSI libm functions 

export CFLAGS INC CC MATHFLAGS

###### Commands

RM =	rm -f
TOUCH = touch
AR =	ar r
RANLIB = ranlib
INSTALL = install

export RM TOUCH AR RANLIB

##################################################################
# You shouldn't need to edit below this line
##################################################################

####### Files

DIALOG_DIR =	dialogs
DIALOG_LIB =	dialogs.a

EQUATION_DIR =	equations
EQUATION_LIB =	equations.a

WINDOWS_DIR =	windows
WINDOWS_LIB =	windows.a

TARGET	=	mtk

export DIALOG_LIB EQUATION_LIB WINDOWS_LIB TARGET

####### Build rules

default: $(TARGET)

all: $(TARGET)

$(TARGET): dialog equation window main

main: $(DIALOG_DIR)/$(DIALOG_LIB) $(EQUATION_DIR)/$(EQUATION_LIB) \
	$(WINDOWS_DIR)/$(WINDOWS_LIB)
	$(CC) $(WINDOWS_DIR)/$(WINDOWS_LIB) $(DIALOG_DIR)/$(DIALOG_LIB) \
	$(EQUATION_DIR)/$(EQUATION_LIB) \
	$(LFLAGS) -o $(TARGET) 

dialog: 
	@$(MAKE) -C $(DIALOG_DIR) $(DIALOG_LIB)

equation: 
	@$(MAKE) -C $(EQUATION_DIR) $(EQUATION_LIB)

window:
	@$(MAKE) -C $(WINDOWS_DIR) $(WINDOWS_LIB)

install: install.bin install.man

install.bin:
	$(INSTALL) $(INSTALLBINOPTS) mtk $(BINDIR)/mtk

install.man:
	$(INSTALL) $(INSTALLMANOPTS) mtk.1 $(MANDIR)/man1/mtk.1

depend: 
	@$(MAKE) -C $(DIALOG_DIR) $@
	@$(MAKE) -C $(EQUATION_DIR) $@ 
	@$(MAKE) -C $(WINDOWS_DIR) $@ 

clean:
	@$(MAKE) -C $(DIALOG_DIR) $@
	@$(MAKE) -C $(EQUATION_DIR) $@ 
	@$(MAKE) -C $(WINDOWS_DIR) $@ 
	/bin/rm -f *.bak *~ *%  core $(TARGET)

ifeq (.depend,$(wildcard .depend))
include .depend
endif
