/*! \page user_programs Building your own programs


To build your own programs  we recommend use of attached scripts
that are generated according to your system configuration.
They provide compiler flags (parameter <tt>--cflags</tt> )
or/and linker flags with all dependencies (parameter <tt>--libs</tt>).
<table>
<tr>
  <th> script name </th> <th> version of CAPD library </th>
</tr><tr>
  <td> capd-config </td> <td> double precision without graphics  </td>
</tr><tr>
  <td> capd-gui-config </td> <td> with \e krak graphical library </td>
</tr><tr>
  <td> mpcapd-config </td> <td> with multiple precision support </td>
</tr><tr>
  <td> mpcapd-gui-config </td> <td> with \e krak and multiple precision  </td>
</tr>
</table>
Those scripts are installed into <code><prefix>/bin</code> directory.
We assume that this location is on the search path of your system so that
scripts can be called by its name (if not in the example below you need
to provide full path to them).

\section user_programs_simple One file programs

Assume that you want to build your <code>MyProgram.cpp</code> that uses double version of CAPD.

Then the instruction might be something like
\code
  g++ -O2 MyProgram.cpp -o MyProgram  `capd-config --cflags --libs`
\endcode
if  <tt>g++</tt> is your C++ compiler.


\subsection user_programs_simple2 Compilation without scripts

It is possible to compile your program without our scripts.
But then command line strongly depends on your system configuration.

Assume that the CAPD library was installed to <tt>/home/user/capd</tt>
and it uses intervals from \e filib library then the instruction might be
\code
g++ -O2 -D__USE_FILIB__ -frounding-math -I/home/user/capd -L/home/user/capd  MyProgram.cpp -o MyProgram -lcapd -lprim
\endcode
\note
Observe that without option <tt>-frounding-math</tt> compiler can optimize code so that it is not rigorous anymore.
\note
Option -D__USE_FILIB__ is an internal CAPD flag to use \e filib intervals. If you forgot to pass it to compiler
then header files will differ from those used to compile CAPD library.

Proper options for current configuration are returned by <tt>capd-config --cflags</tt>.

The command line becomes more complicated if your program uses graphics and/or multiprecision
(e.g. see output of <tt>mpcapd-gui-config --cflags</tt>).



\section user_programs_advanced Multifile project

The example can be found in <tt>capd/capdMake/examples/projectStarter</tt> directory.

Assume that in the some directory we have project that contains:
- \b MyProgram.cpp, \b YourProgram.cpp - source files that contains \e main function
- \b utils.cpp, \b utils.h, \b output.cpp, \b output.h - source and header files that are used by the above programs,
- the CAPD library was installed to <tt>/home/user/capd</tt>

To compile all source files  create in the project directory a file \e Makefile that contains the following code
(all indents need to be made by tabulators not spaces!!!)
\code
# a list of all the programs in your project
PROGS = MyProgram YourProgram

# a list of all your units to be linked with your programs (space separated)
OTHERS = utils output

# directory where capd scripts are (e.g. capd-config)
CAPDBINDIR =/home/user/capd/bin/

# setting compiler and linker flags
CAPDFLAGS = `${CAPDBINDIR}capd-config --cflags`
CAPDLIBS = `${CAPDBINDIR}capd-config --libs`
CXXFLAGS += ${CAPDFLAGS} -O2 -Wall

# directory where object and dependancy files will be created
OBJDIR = .obj/

#============ the following should not be changed =========

OTHERS_OBJ = ${OTHERS:%=${OBJDIR}%.o}
OBJ_FILES = ${OTHERS_OBJ} ${PROGS:%=${OBJDIR}%.o}

.PHONY: all
all: ${PROGS}

# rule to link executables
${PROGS}: % : ${OBJDIR}%.o ${OTHERS_OBJ}
  ${CXX} -o $@ $< ${OTHERS_OBJ} ${CAPDLIBS}

# include files with dependencies
-include ${OBJ_FILES:%=%.d}

#rule to compile .cpp files and generate corresponding files with dependencies
${OBJ_FILES}: ${OBJDIR}%.o : %.cpp
  @mkdir -p ${OBJDIR}
  $(CXX) ${CXXFLAGS} -MT $@ -MD -MP -MF ${@:%=%.d} -c -o $@ $<

# rule to clean all object files, dependencies and executables
.PHONY: clean
clean:
  rm -f ${OBJDIR}*.o ${OBJDIR}*.o.d ${PROGS}
\endcode

Then by calling <tt>make</tt> you will compile all source files and link all programs defined by <tt>PROGS</tt> variable.
It will also create a list of dependencies (list of header files that it uses) for each source file so that next time
source file will be recompiled only if itself or some of its dependencies has changed.

*/
