#############################################################################
#
# Makefile for the Uniform Expansion Project software.
#
#############################################################################

# Copyright (C) 2007-2013 by Pawel Pilarczyk.
#
# This file is part of my research software package.  This is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this software; see the file "license.txt".  If not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.

# Started in 2006. Last revision: February 3, 2013.

# the subdirectory in which CAPD has been installed
capd_dir = ../capd4/

# the subdirectory in which CHomP has been installed
chomp_dir = ../chomp/

# inclusion of the subdirectory in which BOOST is installed
# (necessary only if a non-standard location is used)
boost_incl = 

# the suffix of executable files (e.g., .exe in Windows, none in Linux)
exe =

# additional libraries necessary to link the programs correctly
extralibs =
# -lwsock32

# additional flags for the C++ compiler
extraflags = -Wall -frounding-math -O2

# additional flags for the C++ linker
linkflags = -s

# automatically prepared CAPD flags for the C++ complier and for the linker
capdflags = `$(capd_dir)bin/capd-config --cflags`
capdlibs = `$(capd_dir)bin/capd-config --libs`

# compilation flags
ccflags = -O2 $(capdflags) $(extraflags)

# include paths
incpaths = -I$(capd_dir)include -I$(chomp_dir)include $(boost_incl)

# paths to libraries
libpaths = -L$(capd_dir)lib -L$(chomp_dir)lib

# library files from the CHomP package
chomplibs = -lchomp

# all the library files collected together
libs = $(capdlibs) $(chomplibs) $(extralibs)

# the choice of teh C++ compiler
cxx = g++

# options for the C++ compiler
ccopt = -Wall -ansi -pedantic -frounding-math

# the compilation command
compile = $(cxx) $(ccflags) $(ccopt) -c $(incpaths)

# the linking command
link = $(cxx) $(linkflags) $(ccopt) $(libpaths)

# the list of programs to compile and link
programs = unifexp

# the list of header files whose modification must cause the re-linkage
headers = $(wildcard *.h)

# the default target: all the programs
.phony: all
all: $(programs:%=%$(exe))

# additional CPP files with the definitions of map functions
# (note that usually just the header files suffice, so this list is empty)
mapfiles =

# linking the main program, together with the compiled map files (if any)
$(programs:%=%$(exe)): %$(exe): %.o $(mapfiles:%=%.o)
	$(link) $< $(mapfiles:%=%.o) -o $@ $(libs)

# the list of all the object files
objfiles = $(programs) $(mapfiles)

# compilation of all the object files
$(objfiles:%=%.o): %.o: %.cpp $(headers) makefile \
	$(chomp_dir)include/chomp/struct/*.h
	$(compile) $< -o $@

