################################################################################
# dpuser Makefile
################################################################################
# Type one of the following lines:
#   make                    same as 'make release'
#   make release            (static, 32/64-bit autodetect)
#   make release_shared     WIN only (shared, 32/64-bit autodetect)
#   make debug              (static, 32/64-bit autodetect)
#   make debug_shared       WIN only (shared, 32/64-bit autodetect)
#   make clean              to clean up the project
#   make dist               LINUX/MACOSX only to create a distribution as
#                           tar.gz-file
#                           (do a checkout to a new location before, since all
#                           .svn-folders will be deleted!)
#
#
#   make parsers PLATFORM=LINUX (or MACOSX or WIN)
#                          to create just the parsers and lexxers for dpuser,
#                          dpuser2c & idl2c
#   make dpuser2c_header PLATFORM=LINUX (or MACOSX or WIN)
#                          to create just the dpuser2c.h-file
#
# In dpuser a static target means that all libraries and functionality is linked
# statically into the created binary.
# A shared target means that some dpuser-functionality is moved to a dll
# (external libraries are still linked statically).
#
################################################################################
RM          = rm -f
SED         = sed
CC          = gcc
CXX         = g++
LINK        = g++
QF          =
#GDL         = -DHAS_GDL
PY          = -DHAS_PYTHON

#PLPLOT      = -DHAS_PLPLOT
PGPLOT      = -DHAS_PGPLOT
DPPGPLOT    = -DHAS_DPPGPLOT
#PG2PLPLOT   = -DHAS_PG2PLPLOT

PLPLOTLIB   =
PGPLOTLIB   =

ifeq ($(PLPLOT), -DHAS_PLPLOT)
   PLPLOTLIB = -y
endif
ifeq ($(GDL), -DHAS_GDL)
   PLPLOTLIB = -y
endif
ifeq ($(PGPLOT), -DHAS_PGPLOT)
   ifeq ($(PG2PLPLOT), -DHAS_PG2PLPLOT)
      PLPLOTLIB = -y
      DPPGPLOT =
   else
      PGPLOTLIB = -y
   endif
endif

DEFINES     = $(PLPLOT) $(PGPLOT) $(DPPGPLOT) $(PG2PLPLOT) $(GDL) $(PY) -D$(OS)
ifeq ($(QF), -qt)
   DEFINES  += -DDPQT -DNO_READLINE
endif

CFLAGS      = -pipe -O2 -D_REENTRANT -w $(DEFINES)
CXXFLAGS    = -pipe -O2 -std=c++11 -Wno-narrowing -D_REENTRANT -w $(DEFINES)
INCPATH     = -I. -I../utils -I../libfits -I../include -Iparser -I.

ifeq ($(GDL), -DHAS_GDL)
   INCPATH  += -I../include/gdl
endif

OBJECTS =     dpuser_utils.o \
              dpuser.procs.o \
              helpmap.o \
              y.mpfit.o \
              mpfitAST.o \
              lex.mpfit.o \
              dpuserType.o \
              dpstring.o \
              dpstringlist.o \
              regex_sr.o \
              mpfit.o \
	            kabsch2d.o \
              3d_stuff.o \
              cube.o \
              dpheader.o \
              fits.o \
              fits_cube.o \
              fits_dpl.o \
              fits_exc.o \
              fits_file.o \
              fits_filters.o \
              fits_funcs.o \
              fits_mem.o \
              fits_ops.o \
              fits_procs.o \
              fits_range.o \
              fits_red.o \
              JulianDay.o \
              math_utils.o \
              dpComplex.o \
              fitting.o \
              voronoi.o \
              fits_logic.o \
              astrolib.o \
							arithmetics.o \
							boolean.o \
							dpuserAST.o \
              dpuser.yacchelper.o \
              functions.o \
              y.tab.o \
              dpuser.input.o \
              procedures.o \
              lex.yy.o \
							gdl_dpuser.o \
							python_dpuser.o \
							cpgplot.o \
							qtstubs.o

ifeq ($(PGPLOT), -DHAS_PGPLOT)
   ifeq ($(DPPGPLOT), -DHAS_DPPGPLOT)
      OBJECTS += cpg3d.o
   endif
endif

################################################################################
# Platform-specific defines

ifeq ($(HOMEDRIVE), C:)
   OS             = WIN
   RM             = del
   SED_INPLACE    = ../bin/WIN/sed.exe -i
   
   ifndef $(ARCH)
   # didn't manage to do this as onliner like in the unix-case, pipe doesn't work...
      ARCH := $(shell wmic os get osarchitecture)
      $(shell @echo $(ARCH) > _bbb.txt)
      ARCH := $(shell sed  -e "s/OSArchitecture//g" -e "s/ //g" -e "s/-bit//g" -e "s/-Bit//g" _bbb.txt)
      $(shell del _bbb.txt)
   endif

   DEFINES  += -DHAVE_MINGW32

   LIBS =     ../lib/$(OS)$(ARCH)/libfftw3.a \
              ../lib/$(OS)$(ARCH)/libcpgplot.a \
              ../lib/$(OS)$(ARCH)/libpgplot.a \
              ../lib/$(OS)$(ARCH)/libpng.a \
              ../lib/$(OS)$(ARCH)/libxpa.a \
              ../lib/$(OS)$(ARCH)/libf2c.a \
              ../lib/$(OS)$(ARCH)/libreadline.a \
              ../lib/$(OS)$(ARCH)/libtermcap.a \
	      ../lib/$(OS)$(ARCH)/libcfitsio.a

   ifeq ($(GDL), -DHAS_GDL)
          LIBS  += ../lib/$(OS)$(ARCH)/libgdl.a \
                   ../lib/$(OS)$(ARCH)/libfftw3f.a \
                   ../lib/$(OS)$(ARCH)/libplplotcxx.a \
                   ../lib/$(OS)$(ARCH)/libplplot.a \
                   ../lib/$(OS)$(ARCH)/libqsastime.a \
                   ../lib/$(OS)$(ARCH)/libcsirocsa.a \
                   ../lib/$(OS)$(ARCH)/libgnurx.a \
                   ../lib/$(OS)$(ARCH)/libxdr.a \
                   -lole32 -lspoolss -lwinspool -loleaut32 -luuid
   endif
   ifeq ($(PY), -DHAS_PYTHON)
#      LIBS +=	/Programme/Python3/libs/libpython36.a
      INCPATH  += -I/Programme/Python3/include
   endif
       LIBS  += ../lib/$(OS)$(ARCH)/libgsl.a \
                ../lib/$(OS)$(ARCH)/libgslcblas.a \
								../lib/$(OS)$(ARCH)/libz.a \
                -lgdi32 -lws2_32 -lshlwapi -lcomdlg32 -lcomctl32
				 
   LDFLAG      = -static-libgcc -static-libstdc++ -static -Wl,--enable-runtime-pseudo-reloc
else
   ifeq ($(shell uname -m), x86_64)
      ARCH = 64
   else
      ARCH = 32
   endif

   ifeq ($(TERM_PROGRAM), Apple_Terminal)
      OS          = MACOSX
      ifeq ($(shell uname -m), arm64)
         ARCH = ARM64
      else
         ARCH = X64
      endif

      ifeq ($(ARCH), 32)
         LDFLAG      = -arch i386
         CXXFLAGS    := -arch i386 $(CXXFLAGS)
      else
         # -arch x86_64
         LDFLAG      = 
      endif
      SED_INPLACE = sed -i ''
      LIBS        = ../lib/MACOS$(ARCH)/libxpa.a \
                    ../lib/MACOS$(ARCH)/libfftw3.a \
                    ../lib/MACOS$(ARCH)/libcpgplot.a \
                    ../lib/MACOS$(ARCH)/libpgplot.a \
                    ../lib/MACOS$(ARCH)/libpng.a \
                    ../lib/MACOS$(ARCH)/libgsl.a \
                    ../lib/MACOS$(ARCH)/libgslcblas.a \
                    ../lib/MACOS$(ARCH)/libreadline.a \
                    ../lib/MACOS$(ARCH)/libcfitsio.a \
                    ../lib/MACOS$(ARCH)/libz.a \
                    ../lib/MACOS$(ARCH)/libncurses.a \
                    ../lib/MACOS$(ARCH)/libf2c.a
   ifeq ($(GDL), -DHAS_GDL)
            LIBS += ../lib/MACOS$(ARCH)/libgdl.a \
                    ../lib/MACOS$(ARCH)/libfftw3f.a \
                    ../lib/MACOS$(ARCH)/libplplot.a \
                    ../lib/MACOS$(ARCH)/libplplotcxx.a \
                    ../lib/MACOS$(ARCH)/libqsastime.a \
                    ../lib/MACOS$(ARCH)/libcsirocsa.a
   endif
      ifeq ($(ARCH), X64)
            LIBS += -L/opt/X11/lib \
                    -lX11
      endif
   ifeq ($(PY), -DHAS_PYTHON)
#            LIBS += -L/Library/Frameworks/Python.framework/Versions/3.6/lib -lpython3.6
#      INCPATH  += -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/include
      INCPATH  += -I../include/$(OS)/python
#       -I/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/include
   endif

   else
      OS          = LINUX
      LDFLAG      = -static-libstdc++ -static-libgcc
      SED_INPLACE = sed -i''
      LIBS        = -rdynamic \
                    ../lib/$(OS)$(ARCH)/libxpa.a \
                    ../lib/$(OS)$(ARCH)/libfftw3.a \
                    ../lib/$(OS)$(ARCH)/libreadline.a \
                    ../lib/$(OS)$(ARCH)/libncurses.a
   ifeq ($(GDL), -DHAS_GDL)
          LIBS +=   ../lib/$(OS)$(ARCH)/libgdl.a
   endif
	 ifeq ($(PLPLOTLIB), -y)
          LIBS +=   ../lib/$(OS)$(ARCH)/libplplotcxx.a \
                    ../lib/$(OS)$(ARCH)/libfftw3f.a \
                    ../lib/$(OS)$(ARCH)/libplplot.a \
                    ../lib/$(OS)$(ARCH)/libqsastime.a
   endif
   ifeq ($(PGPLOTLIB), -y)
          LIBS +=   ../lib/$(OS)$(ARCH)/libcpgplot.a \
                    ../lib/$(OS)$(ARCH)/libpgplot.a \
                    ../lib/$(OS)$(ARCH)/libf2c.a
   endif
      LIBS +=   ../lib/$(OS)$(ARCH)/libgsl.a \
                ../lib/$(OS)$(ARCH)/libgslcblas.a \
                ../lib/$(OS)$(ARCH)/libcfitsio.a \
                ../lib/$(OS)$(ARCH)/libz.a \
                ../lib/$(OS)$(ARCH)/libpng.a
   ifeq ($(PY), -DHAS_PYTHON)
#      LIBS += /usr/lib/x86_64-linux-gnu/libpython3.5m.a -lexpat -lutil
      INCPATH  += -I/usr/include/python3.5m
   endif
       LIBS +=      -lX11 -ldl -lxcb -lpthread -lXdmcp -lXau

   endif
   TARDIR     := $(shell echo $(PWD) | sed 's|/dpuser$$||g' | sed 's|\/.*\/||g')
endif

################################################################################
# main targets
all: release 

##### RELEASE TARGETS #####
ifeq ($(OS), WIN) # start WIN
release:
	$(MAKE) static "TARGET_WIN = dpuser.exe"
else # start LINUX & MACOSX
release:
	$(MAKE) static "TARGET_LINUX = dpuser"
endif # end LINUX & MACOSX

##### DEBUG TARGETS #####
ifeq ($(OS), WIN) # start WIN
debug:
	$(MAKE) static "TARGET_WIN = dpuserD.exe" "CFLAGS = $(CFLAGS) -g -DDBG" "CXXFLAGS = $(CXXFLAGS) -g -DDBG"
else # start LINUX & MACOSX
debug:
	$(MAKE) static "TARGET_LINUX = dpuserD" "CFLAGS = $(CFLAGS) -g -DDBG" "CXXFLAGS = $(CXXFLAGS) -g -DDBG"
endif # end LINUX & MACOSX

################################################################################
# sub targets

ifeq ($(OS), WIN) # start WIN
static: parsers
	$(MAKE) $(MULTIPROZGEIL) $(TARGET_WIN)
else # end WIN, start LINUX & MACOSX
static: doc/helpmap.cpp parsers
	$(MAKE) $(MULTIPROZGEIL) $(TARGET_LINUX)
endif # end LINUX & MACOSX

$(TARGET_DLL): $(DLL_OBJECTS)
	g++ -shared -o $(TARGET_DLL) $(DLL_OBJECTS) $(DLL_LIBS)

$(TARGET_WIN): $(OBJECTS)
	$(LINK) $(LDFLAG) -o $(TARGET_WIN) $(OBJECTS) $(LIBS)

$(TARGET_LINUX): $(OBJECTS)
	$(LINK) $(LDFLAG) -o $(TARGET_LINUX) $(OBJECTS) $(LIBS)

# Builds parser-, dpuser2c & idl2c-source-files
parsers: parsers_qf
	$(MAKE) -C parser PLATFORM=$(OS)

parsers_qf:
	$(MAKE) -C mpfit PLATFORM=$(OS)

aux: parsers doc/helpmap.cpp

clean:
	-$(RM) $(OBJECTS)
	$(if $(OS:WIN=), \
		-$(RM) dpuser dpuserD \
	, \
		-$(RM) dpuser.exe dpuserD.exe \
	)
	

# this target is called by QFitsView 'make clean'
clean_qf: FORCE
	$(MAKE) -C parser clean  PLATFORM=$(OS)
	$(MAKE) -C mpfit clean PLATFORM=$(OS)

FORCE:


################################################################################
# Creates a distribution
ifeq ($(OS), WIN) # start WIN
dist:
	@echo "*************************************************************"
	@echo "ERROR: Distribution can only be generated under LINUX or MAC!"
	@echo "*************************************************************"
else # end WIN, start LINUX & MACOSX
dist: clean
	cd ../QFitsView && make -i clean
	find .. -type d -name ".svn" -exec rm -rf {} +
	find .. -type d -name "obsolete" -exec rm -rf {} +
	find .. -regextype posix-extended -regex '.*\.(a|lib|dll|exe)' -exec rm {} +
	rm -rf ../include/*
	rm -rf ../bin/*
	rm -rf ../external/*z
	tar cfvz ../../dpuser.tar.gz ../../$(TARDIR)
endif # end LINUX & MACOSX

################################################################################
# Compile rules
dpuser.o:              dpuser.cpp \
                       dpuser.h \
                       dpuser.yacchelper.h \
                       dpuser.procs.h \
                       procedures.h \
                       functions.h \
                       dpuser_utils.h \
                       dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpuser.o dpuser.cpp

dpuser.input.o:        dpuser.input.cpp \
                       dpuser.h \
                       dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpuser.input.o dpuser.input.cpp

procedures.o:          procedures.cpp \
                       dpuser.h \
                       procedures.h \
                       dpuser.procs.h \
                       dpuser_utils.h \
                       dpuser.yacchelper.h \
                       functions.h \
                       dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o procedures.o procedures.cpp

dpuser.procs.o:        dpuser.procs.cpp \
                       dpuser.h \
                       functions.h \
                       dpuser_utils.h \
                       procedures.h \
                       dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpuser.procs.o dpuser.procs.cpp

dpuser.yacchelper.o:    dpuser.yacchelper.cpp \
                        dpuser.h \
                        functions.h \
                        procedures.h \
                        dpuser_utils.h \
                        dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpuser.yacchelper.o dpuser.yacchelper.cpp

functions.o:            functions.cpp \
                        dpuser.h \
                        functions.h \
                        procedures.h \
                        dpuser_utils.h \
                        dpuser.yacchelper.h \
                        dpuserType.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o functions.o functions.cpp

dpuser_utils.o:         dpuser_utils.cpp \
                        dpuser_utils.h \
                        dpuser.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpuser_utils.o dpuser_utils.cpp

lex.yy.o:               parser/lex.yy.cpp \
                        dpuser.h \
                        dpuser.yacchelper.h \
                        procedures.h \
                        functions.h \
                        dpuser_utils.h \
                        dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o lex.yy.o parser/lex.yy.cpp

y.tab.o:                parser/y.tab.cpp \
                        dpuser.h \
                        dpuser.yacchelper.h \
                        dpuser.procs.h \
                        procedures.h \
                        functions.h \
                        dpuser_utils.h \
                        dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o y.tab.o parser/y.tab.cpp

dpuserType.o:           dpuserType.cpp \
                        dpuser.h \
                        dpuser_utils.h \
                        dpuserType.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpuserType.o dpuserType.cpp

y.mpfit.o:              mpfit/y.mpfit.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o y.mpfit.o mpfit/y.mpfit.cpp

lex.mpfit.o:            mpfit/lex.mpfit.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o lex.mpfit.o mpfit/lex.mpfit.cpp

mpfitAST.o:             mpfit/mpfitAST.cpp \
                        mpfit/mpfitAST.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mpfitAST.o mpfit/mpfitAST.cpp

cpg3d.o:                ../utils/cpg3d.c 
	$(CC) -c $(CFLAGS) $(INCPATH) -o cpg3d.o ../utils/cpg3d.c

dpstring.o:             ../utils/dpstring.cpp \
                        ../utils/dpstring.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpstring.o ../utils/dpstring.cpp

dpstringlist.o:         ../utils/dpstringlist.cpp \
                        ../utils/dpstringlist.h \
                        ../utils/dpstring.h \
                        ../utils/osdir/osdir.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpstringlist.o ../utils/dpstringlist.cpp

regex_sr.o:            ../utils/regex/regex_sr.cpp \
                       ../utils/regex/regex_sr.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o regex_sr.o ../utils/regex/regex_sr.cpp

mpfit.o:               ../utils/cmpfit/mpfit.cpp \
                       ../utils/cmpfit/mpfit.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mpfit.o ../utils/cmpfit/mpfit.cpp

kabsch2d.o:            ../utils/kabsch/kabsch2d.cpp \
                       ../utils/kabsch/kabsch2d.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o kabsch2d.o ../utils/kabsch/kabsch2d.cpp

cpgplot.o:            ../utils/cpgplot.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o cpgplot.o ../utils/cpgplot.cpp

arithmetics.o:         arithmetics.cpp \
                       dpuserAST.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o arithmetics.o arithmetics.cpp

boolean.o:         boolean.cpp \
                       dpuserAST.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o boolean.o boolean.cpp

dpuserAST.o:           dpuserAST.cpp \
                       dpuserAST.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpuserAST.o dpuserAST.cpp

gdl_dpuser.o:           gdl_dpuser.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o gdl_dpuser.o gdl_dpuser.cpp

python_dpuser.o:        python_dpuser.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o python_dpuser.o python_dpuser.cpp

3d_stuff.o:             ../libfits/3d_stuff.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h \
                        ../libfits/platform.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o 3d_stuff.o ../libfits/3d_stuff.cpp

cube.o:                 ../libfits/cube.c \
                        ../libfits/cube.h
	$(CC) -c $(CFLAGS) $(INCPATH) -o cube.o ../libfits/cube.c

dpheader.o:             ../libfits/dpheader.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpheader.o ../libfits/dpheader.cpp

fits.o:                 ../libfits/fits.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h \
                        ../libfits/platform.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits.o ../libfits/fits.cpp

fits_cube.o:            ../libfits/fits_cube.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/platform.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_cube.o ../libfits/fits_cube.cpp

fits_dpl.o:             ../libfits/fits_dpl.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h \
                        ../libfits/cube.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_dpl.o ../libfits/fits_dpl.cpp

fits_exc.o:             ../libfits/fits_exc.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_exc.o ../libfits/fits_exc.cpp

fits_file.o:            ../libfits/fits_file.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/platform.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_file.o ../libfits/fits_file.cpp

fits_filters.o:         ../libfits/fits_filters.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_filters.o ../libfits/fits_filters.cpp

fits_funcs.o:           ../libfits/fits_funcs.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_funcs.o ../libfits/fits_funcs.cpp

fits_mem.o:             ../libfits/fits_mem.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_mem.o ../libfits/fits_mem.cpp

fits_ops.o:             ../libfits/fits_ops.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h \
                        ../libfits/platform.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_ops.o ../libfits/fits_ops.cpp

fits_procs.o:           ../libfits/fits_procs.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h \
                        ../libfits/platform.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_procs.o ../libfits/fits_procs.cpp

fits_range.o:           ../libfits/fits_range.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_range.o ../libfits/fits_range.cpp

fits_red.o:             ../libfits/fits_red.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h \
                        ../libfits/fitting.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_red.o ../libfits/fits_red.cpp

JulianDay.o:            ../libfits/JulianDay.cpp \
                        ../libfits/JulianDay.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o JulianDay.o ../libfits/JulianDay.cpp

math_utils.o:           ../libfits/math_utils.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o math_utils.o ../libfits/math_utils.cpp

dpComplex.o:            ../libfits/dpComplex.cpp \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o dpComplex.o ../libfits/dpComplex.cpp

fitting.o:              ../libfits/fitting.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/fitting.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fitting.o ../libfits/fitting.cpp

voronoi.o:              ../libfits/voronoi.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o voronoi.o ../libfits/voronoi.cpp

fits_logic.o:           ../libfits/fits_logic.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o fits_logic.o ../libfits/fits_logic.cpp

astrolib.o:             ../libfits/astrolib.cpp \
                        dpuser_utils.h \
                        dpuser.h \
                        ../libfits/astrolib.h \
                        ../libfits/fits.h \
                        ../libfits/dpComplex.h \
                        ../libfits/defines.h \
                        ../libfits/math_utils.h \
                        ../libfits/fitting.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o astrolib.o ../libfits/astrolib.cpp

helpmap.o:               doc/helpmap.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o helpmap.o doc/helpmap.cpp

qtstubs.o:               qtstubs.cpp
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o qtstubs.o qtstubs.cpp

ifeq ($(OS), LINUX)
doc/helpmap.cpp:	doc/functions_doc.h 	doc/procedures_doc.h

	cd doc && ./makec++.sh
else
doc/helpmap.cpp:
	@echo "*************************************************************"
	@echo "WARNING: Documentation can only be generated under LINUX!"
	@echo "*************************************************************"
endif
