##############################
# makefile (june/2003)       #
# makefile for MathEx  test  #
##############################

###########################
#  using cc               #
###########################
# compiler:
# using cc
# CC      = cc
# compile flags:
# -c is compile
# g is gdb debug option??
# -o specify output file name (a.o is default)
# CFLAGS  = -c -g -o
# link option:
# -o specify the output file name ( a.out is default)
# LFLAGS  = -o
# library (-l specify the library to linked):
# m is math library
# LIBS    = -lm

########################################
#  using gcc with optimization         #
########################################
# gcc is same as g++ except that       # 
# compile as C or C++ acordding to     #
# file extensions                      #
# g++: all file are treated as C++     #
# gcc: .cc, .C .cxx are treated as C++ #
#      .c is treated as C              #
######################################## 
# compiler: gcc
# CC        = gcc
# compile flogs (-c):
# Wall: Emit all warning message
# c: compile
# o: output file
# O3 Optimization of level 3
# CFLAGS = -Wall -O3 -c -o
# link flags: 
# -o says the output file name
# LFLAGS    = -o
# library (-l):
# LIBS      = -lm -lstdc++
# m is math library
# stdc++ is C++ standard libray

########################################
#  using gcc in debug mode             #
########################################
# gcc is same as g++ except that       # 
# compile as C or C++ acordding to     #
# file extensions                      #
# g++: all file are treated as C++     #
# gcc: .cc, .C .cxx are treated as C++ #
#      .c is treated as C              #
######################################## 
# compiler:
# using g++ with debug mode
# CC        = g++
# compile option flags:
# Wall: Emit all warnning message
# c: compile
# o: output file is ... 
# ggdb: native and gdb extensive debug information
# CFLAGS = -Wall -ggdb -c -o
# link option:
# -o says output file name
# ggdb: native and gdb extensive debug information
# LFLAGS    = -ggdb -o
# used libraries (l option):
# LIBS      = -lm -lstdc++
# m is math library
# stdc++ is C++ standard libray

##############################
#  current compiler settings #
##############################
CC        = g++
CFLAGS = -Wall -ggdb -c -o
LFLAGS    = -ggdb -o
# for g++ link  as C++. Thus, is not need to specify stdc++
# LIBS      = -lm  -lstdc++
LIBS      = -lm

################################
# macro for used files, etc
################################
# list of object file for clearing (make clear)
OBJECTS=mathex.o inttest.o \
	userfunctest.o tabletest.o \
	curvetest.o

# example program list (not used)
PROGS=inttest userfunctest tabletest curvetest

# object files for inttest executable
INTTESTOBJECTS= mathex.o inttest.o

# object files for userfunctest executable
USERFUNCTESTOBJECTS= mathex.o userfunctest.o

# object files for tabletest executable
TABLETESTOBJECTS= mathex.o tabletest.o

# object files for curvetest executable
CURVETESTOBJECTS= mathex.o curvetest.o

#######################
# main call for make
#######################
mathex:
	make inttest
	make userfunctest
	make tabletest
	make curvetest

##########################
# sample program linking
##########################
inttest: $(INTTESTOBJECTS)
	$(CC) $(INTTESTOBJECTS) $(LFLAGS) inttest $(LIBS)

userfunctest: $(USERFUNCTESTOBJECTS)
	$(CC) $(USERFUNCTESTOBJECTS) $(LFLAGS) userfunctest $(LIBS)

tabletest: $(TABLETESTOBJECTS)
	$(CC) $(TABLETESTOBJECTS) $(LFLAGS) tabletest $(LIBS)

curvetest: $(CURVETESTOBJECTS)
	$(CC) $(CURVETESTOBJECTS) $(LFLAGS) curvetest $(LIBS)

###########################
# compile each file
###########################

# mathex use mathex.h
mathex.o:  mathex.cpp mathex.h
	$(CC) mathex.cpp $(CFLAGS) mathex.o
# inttest use mathex.h
inttest.o:  inttest.cpp mathex.h
	$(CC) inttest.cpp $(CFLAGS) inttest.o

# userfunctest use mathex.h
userfunctest.o:  userfunctest.cpp mathex.h
	$(CC) userfunctest.cpp $(CFLAGS) userfunctest.o

# tabletest use mathex.h
tabletest.o:  tabletest.cpp mathex.h
	$(CC) tabletest.cpp $(CFLAGS) tabletest.o

# curvetest use mathex.h
curvetest.o:  curvetest.cpp mathex.h
	$(CC) curvetest.cpp $(CFLAGS) curvetest.o

#########################
# remove object file
# use make clear
#########################
clear:
	rm $(OBJECTS)

# end of makefile