# Start by defining some useful macros
#
SRC_DIR       = ./src
SHELL         = /bin/sh
CXX           = g++
CXX_FLAGS     = -O2
INCLUDE_FLAGS = -I$(SRC_DIR)
LINK_LIBS     = -lm -lstdc++

# Define the list of object files that are needed to build
# the nclsimplest application
#
NCL_OBJS      = nxsblock.o \
                nxsexception.o \
                nxsreader.o \
                nxsstring.o \
                nxstaxablock.o \
                nxstoken.o \
                nxstreesblock.o \
                nxsdatablock.o \
                nxscharactersblock.o \
                nxsdiscretematrix.o \
                nxsdiscretedatum.o \
                nxsassumptionsblock.o \
                nxsdistancesblock.o \
                nxsdistancedatum.o \
                nxssetreader.o

# Use .PHONY to create targets that are always rebuilt, even
# when their timestamps indicate that they are up-to-date
#
.PHONY : all clean cleanall
all : $(NCL_OBJS) id_gappy
clean :
	rm -f *.o
cleanall : clean
	rm -f composition

# The following rule rebuilds any .o file whose corresponding
# .cpp file is not up-to-date. The $< means 'first depencency'
#
%.o : $(SRC_DIR)/%.cpp
	$(CXX) $(INCLUDE_FLAGS) $(CXX_FLAGS) -c $<

# Now comes the rule for building the main target
# The $@ means 'target file name'
# The $< means 'first depencency'
#
id_gappy : id_gappy.o $(NCL_OBJS)
	$(CXX) $(LINK_FLAGS) -o $@ $< $(NCL_OBJS) $(LINK_LIBS)
