#*******************************************************************************
# E.S.O. - VLT project
#
# "@(#) $Id: Makefile_SunOS,v 1.38 2004/07/15 16:38:34 vltsccm Exp $"
#
# Makefile of fposs
#
# who       when        what
# --------  ----------  --------------------------------------------------------
# pbaksai   2014/07/22  CCB-000755: Support for 64 bits.
#                       - Fixed location of X11 lib.
#                       - Fixed detection of Tcl/Tk version.
# pbaksai   2014/07/10  CCB-000755: Support for 64 bits.
#                       - Detect Tcl/Tk version using tclsh. Falls back to 8.3
#                       - TK_VERSION must be equal to TCL_VERSION
# rschmutz  2004-07-14  Added pafchecksum & crc32.
# rschmutz  2004-05-22  Adapted to APR2004 (Tcl/Tk 8.4).
# rschmutz  28/01/03    Create configure_expert.
# rschmutz  23/11/02    This header created - previous history see below.
#
#*******************************************************************************
# REMARKS
#    None
#-------------------------------------------------------------------------------
#
#              C o n f i g u r e   M a k e f i l e   ( S o l a r i s )
#
#   This is a specialised makefile used to build those parts of the 
#   AAO fibre configuration program 'configure' that require system-dependent
#   treatment. This version is for use on a Solaris system. It has been 
#   developed on the AAO programmer's workstation (aaoprog), which is a Solaris
#   5.6 system (although a 'uname' returns SunOS, hence the name of the file).
#   This machine has Tcl/Tk installed in the standard locations, so the 
#   relevant include files and libraries are found in the default paths. 
#   However, it should work on any system that has tcl/tk installed. 
#
#   Note that this makefile builds a version of configure that only supports
#   ESO's FLAMES instrument.
#
#   Author(s): Keith Shortridge, AAO (KS)
#
#   History:
#
#   21st Sep 2000.  Original version, KS.
#    1st Mar 2001.  Increased to version 0.6. KS.
#    3rd May 2001.  Added convertPAF. KS.
#    8th May 2001.  Added full release target. KS.
#   28th May 2001.  Introduced configure_full.o and config_method_full.o
#                   targets. KS.
#   29th May 2001.  Added the proper mess.c code, replacing the dummy file
#                   used to date.
#    7th Jun 2001.  Added internals.txt and DOCO_FILES. KS.
#   15th Aug 2001.  Up to version 0.7. Added vlt1.fld to operational files. KS.
#   20th Aug 2001.  Added -Wall -ansi flags. Merged the SDS makefile with
#                   this, so all of configure is held in one directory.
#                   Added the various .h file dependencies. KS.
#   21st Aug 2001.  Now generates Tcl/Tk directories, and supports the
#                   'release' target. Up to version 0.8. KS.
#   27th Aug 2001.  Added sdslist target. Now uses revised FLAMES model
#                   code - fpmdl.c etc replaced by fpcolMdl.c. KS.
#    4th Sep 2001.  Removed tdfxy.h - no longer used. KS.
#   17th Sep 2001.  RELEASE_FILES now includes MISC_FILES and TCL_FILES. 
#                   OzPosModel{n}.sds files no longer used. KS.
#    8th Oct 2001.  Modified list of documentation files. Version up to 1.0. KS.
#   30th Oct 2001.  Added fpcolMdl_err.h and tdfxy.h to list of include 
#                   files. KS.
#   16th Nov 2001.  Temporarily added M67.fld and internals documents to
#                   set of release files. KS.
#    8th Jan 2002.  Most Makefile targets now in the common Makefile, this
#                   file (renamed from Makefile_Solaris to Makefile_SunOS) now
#                   only handles the system-dependent compilation and build
#                   targets.
#   11th Feb 2002.  fpDefines.h moved to fpcol sub-directory. tdfxy.h no longer
#                   needed (it had worked its way back in again in the last
#                   change). Reference to tcl/tk 8.0 removed - this should
#                   work for any version.
#   10th Apr 2002.  Added fpcolMdlFit.c. KS.
#    5th Jun 2002.  Added rules for 6dF and 2dF targets. KS.
#    1st Aug 2002.  Added fpcolMdlCalModel.c. KS.
#
#*******************************************************************************
#  location of additional sources
#
SDS_SRC = sds
SLA_SRC = sla
DRAMA_SRC = drama
FPCOL_SRC = fpcol
PAFCHK_MODULE = ../../pafchk

X11_LIB := $(shell (test -f /usr/lib/libX11.so && echo /usr/lib) || \
                   (test -f /usr/lib/libX11.so.6 && echo /usr/lib) || \
                   (test -d /usr/X11R?/lib && echo /usr/X11R?/lib) || \
                   echo ../tcltk/lib)
TCL_LIB = /usr/local/lib
TCL_VERSION := $(shell echo "puts [info tclversion]" | tclsh 2>/dev/null)
ifeq "$(TCL_VERSION)" ""
TCL_VERSION := $(shell (test -n "$$TCLTK_VERSION" && echo $$TCLTK_VERSION) || echo 8.3)
endif
TK_VERSION = $(TCL_VERSION)

#*******************************************************************************
#  Standard C settings. We use gcc with optimise selected and with the maximum
#  warnings (but see rule for configure.o for one exception). The DFLAMES_ONLY
#  flag prevents the inclusion of code to support the AAO's 2dF and 6dF
#  instruments, limiting support to ESO's FLAMES system.

COPT = -O
CWARNINGS = -Wall -ansi -DUSE_COMPAT_CONST
CINCLUDES = -I$(SDS_SRC) -I$(DRAMA_SRC) -I$(SLA_SRC) -I$(FPCOL_SRC) -I$(PAFCHK_MODULE)/include -I.
CFLAGS = -DFLAMES_ONLY -DDRAMA_BUILD $(CWARNINGS) $(COPT) $(CINCLUDES)
CC = gcc

#*******************************************************************************
#  'configure' - the default taget for this Makefile - builds the
#  main FPOSS configure program.
   
TCL_FILES = configure.tcl mimic.tcl procs.tcl util.tcl

../bin/configure : ../lib/configure
	@echo "TCL_VERSION = >$(TCL_VERSION)<"
	@echo "TCL_LIB = >$(TCL_LIB)<"
	@echo "X11_LIB = >$(X11_LIB)<"
	/bin/cp $(TCL_FILES) ../lib
	/bin/cp configure.sh ../bin/configure
	/usr/bin/chmod +x ../bin/configure
	/bin/cp configure_expert.sh ../bin/configure_expert
	/usr/bin/chmod +x ../bin/configure_expert
	/bin/rm -f ../lib/configure_expert
	/bin/ln -s configure ../lib/configure_expert

../lib/configure : libsds.a configure.o config_method.o config.o FpilExtras.o \
           mess.o fpil.o fpilcons.o fpilmodel.o fpcolFpil.o fpcolBase.o \
           fpcolMdl.o fpcolMdlFit.o fpcolMdlCalModel.o \
           tdFparse.o tdFconvertSds.o \
           configversion.o convertPAF.o sla.o pafchkChecksum.o crc32.o
	$(CC) $(COPT) -o ../lib/configure configure.o config_method.o config.o \
           FpilExtras.o \
           mess.o fpil.o fpilcons.o fpilmodel.o fpcolFpil.o fpcolBase.o \
           fpcolMdl.o fpcolMdlFit.o fpcolMdlCalModel.o \
           tdFparse.o tdFconvertSds.o \
           configversion.o convertPAF.o sla.o pafchkChecksum.o crc32.o libsds.a \
           -L$(TCL_LIB) -ltk$(TK_VERSION) -ltcl$(TCL_VERSION) \
           -L$(X11_LIB) -lX11 -lsocket -lnsl -lm -ldl
           
#  Under Solaris we have a special rule for building configure.c that
#  misses out the -Wall flag. This is because, at AAO at least, the version
#  of Xlib.h supplied with Solaris contains a host of lines that default
#  variable type to int in declarations (yes, really), and the only way to
#  suppress the resulting plethora of warnings is to omit the -Wall flag.
#  (It's a pity to do this, but configure is compiled with this flag on 
#  Linux and HPUX, so it's unlikely that any warnings will be missed in
#  practice.)

configure.o : configure.c
	$(CC) -c -DFLAMES_ONLY $(COPT) $(CINCLUDES) -o configure.o configure.c
   
#  These rules control the building of the SDS library, libsds.a
          
SDS_OBJECTS = arg.o ers_imp.o sds.o erssprintf.o ersvsprintf.o \
   sdsutil.o sdstclinit.o sdstcl.o
         
libsds.a : $(SDS_OBJECTS)
	ar -rv libsds.a $(SDS_OBJECTS)

#  sdslist is a utility program for examining SDS files. It isn't needed
#  by configure, but can be a useful diagnostic tool.
   
sdslist : $(SDS_SRC)/sdslist.c $(SDS_SRC)/sdsutil.c $(DRAMA_SRC)/status.h \
          $(SDS_SRC)/sds.h libsds.a
	$(CC) $(CFLAGS) $(SDS_SRC)/sdslist.c $(SDS_SRC)/sdsutil.c -o sdslist libsds.a

#  Include file dependencies
   
arg.o : $(SDS_SRC)/arg.c $(DRAMA_SRC)/status.h $(DRAMA_SRC)/Ers.h \
        $(SDS_SRC)/sds.h $(SDS_SRC)/arg.h
	$(CC) $(CFLAGS) -c $(SDS_SRC)/arg.c

config.o : config.c $(DRAMA_SRC)/drama.h $(SDS_SRC)/sds.h $(SDS_SRC)/arg.h \
           $(DRAMA_SRC)/Ers.h tdFconfig.h config_err.h

config_method.o : config_method.c $(DRAMA_SRC)/status.h tdFconfigMethod.h \
                  config_err.h

configure.o : configure.c $(DRAMA_SRC)/drama.h $(DRAMA_SRC)/status.h \
              $(SDS_SRC)/sds.h $(DRAMA_SRC)/Ers.h $(DRAMA_SRC)/mess.h \
              $(SDS_SRC)/sdstcl.h $(SDS_SRC)/arg.h $(SDS_SRC)/arg_err.h \
              tdFconvert.h convertPAF.h $(SDS_SRC)/sds_err_msgt.h \
              $(SDS_SRC)/arg_err_msgt.h conf_err_msgt.h config_err_msgt.h \
              fpil_err_msgt.h conf_err.h $(FPCOL_SRC)/fpcolFpil.h

convertPAF.o : convertPAF.c $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h \
               $(SLA_SRC)/slalib.h $(SLA_SRC)/slamac.h tdFconvert.h \
               $(DRAMA_SRC)/Ers.h convertPAF.h

ers_imp.o : $(DRAMA_SRC)/ers_imp.c $(DRAMA_SRC)/Ers.h
	$(CC) $(CFLAGS) -c $(DRAMA_SRC)/ers_imp.c

erssprintf.o : $(DRAMA_SRC)/erssprintf.c $(DRAMA_SRC)/Ers.h
	$(CC) $(CFLAGS) -c $(DRAMA_SRC)/erssprintf.c

ersvsprintf.o : $(DRAMA_SRC)/ersvsprintf.c $(DRAMA_SRC)/Ers.h
	$(CC) $(CFLAGS) -c $(DRAMA_SRC)/ersvsprintf.c

fpcolBase.o : $(FPCOL_SRC)/fpcolBase.c $(FPCOL_SRC)/fpcolBase.h \
              $(FPCOL_SRC)/fpcolInstDescr.h
	$(CC) $(CFLAGS) -c $(FPCOL_SRC)/fpcolBase.c

fpcolFpil.o : $(FPCOL_SRC)/fpcolFpil.c $(FPCOL_SRC)/fpcolFpil.h \
              $(DRAMA_SRC)/drama.h $(SDS_SRC)/sds.h \
              $(DRAMA_SRC)/Ers.h $(FPCOL_SRC)/fpDefines.h \
              $(FPCOL_SRC)/fpcolBase.h $(FPCOL_SRC)/fpcolFpil.h \
              $(FPCOL_SRC)/fpcolMdl.h $(FPCOL_SRC)/fpcolInstDescr.h
	$(CC) $(CFLAGS) -c $(FPCOL_SRC)/fpcolFpil.c
    
fpil.o : fpil.c fpil.h fpil_err.h

fpilcons.o : fpilcons.c $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h fpil.h fpil_err.h

FpilExtras.o : FpilExtras.c fpil.h

fpilmodel.o : fpilmodel.c $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h fpil.h \
              fpil_err.h

fpcolMdl.o : $(FPCOL_SRC)/fpcolMdl.c $(FPCOL_SRC)/fpcolMdl.h \
             $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h \
             $(SLA_SRC)/slalib.h $(SLA_SRC)/slamac.h $(DRAMA_SRC)/Ers.h
	$(CC) $(CFLAGS) -c $(FPCOL_SRC)/fpcolMdl.c

fpcolMdlFit.o : $(FPCOL_SRC)/fpcolMdlFit.c $(FPCOL_SRC)/fpcolMdl.h
	$(CC) $(CFLAGS) -c $(FPCOL_SRC)/fpcolMdlFit.c
   
fpcolMdlCalModel.o : $(FPCOL_SRC)/fpcolMdlCalModel.c \
                     $(FPCOL_SRC)/fpcolMdlCalModel.h
	$(CC) $(CFLAGS) -c $(FPCOL_SRC)/fpcolMdlCalModel.c

mess.o : $(DRAMA_SRC)/mess.c $(DRAMA_SRC)/status.h $(DRAMA_SRC)/drama.h \
         $(DRAMA_SRC)/mess.h
	$(CC) $(CFLAGS) -c $(DRAMA_SRC)/mess.c

sds.o : $(SDS_SRC)/sds.c $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h
	$(CC) $(CFLAGS) -c $(SDS_SRC)/sds.c

sdslist.o : $(SDS_SRC)/sdslist.c $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h
	$(CC) $(CFLAGS) -c $(SDS_SRC)/arg.c

sdstcl.o : $(SDS_SRC)/sdstcl.c $(SDS_SRC)/sdstcl.h $(SDS_SRC)/arg.h \
           $(DRAMA_SRC)/Ers.h $(SDS_SRC)/sds_err.h
	$(CC) $(CFLAGS) -c $(SDS_SRC)/sdstcl.c

sdstclinit.o : $(SDS_SRC)/sdstclinit.c $(SDS_SRC)/sdstcl.h \
               $(SDS_SRC)/arg_err.h $(DRAMA_SRC)/Ers.h
	$(CC) $(CFLAGS) -c $(SDS_SRC)/sdstclinit.c

sdstest.o : $(SDS_SRC)/sdstest.c $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h
	$(CC) $(CFLAGS) -c $(SDS_SRC)/sdstest.c

sdsutil.o : $(SDS_SRC)/sdsutil.c $(DRAMA_SRC)/status.h $(SDS_SRC)/sds.h
	$(CC) $(CFLAGS) -c $(SDS_SRC)/sdsutil.c

sla.o : $(SLA_SRC)/sla.c $(SLA_SRC)/slalib.h $(SLA_SRC)/slamac.h
	$(CC) $(CFLAGS) -c $(SLA_SRC)/sla.c

tdFconvertSds.o : tdFconvertSds.c $(SDS_SRC)/sds.c $(DRAMA_SRC)/status.h \
                  $(SDS_SRC)/sds.h conf_err.h tdFconvert.h

tdFparse.o : tdFparse.c $(DRAMA_SRC)/status.h $(SLA_SRC)/slalib.h \
             $(DRAMA_SRC)/Ers.h \
             $(SDS_SRC)/sds.h tdFconvert.h conf_err.h

pafchkChecksum.o : $(PAFCHK_MODULE)/src/pafchkChecksum.c $(PAFCHK_MODULE)/include/pafchk.h 
	$(CC) $(CFLAGS) -c $(PAFCHK_MODULE)/src/pafchkChecksum.c

crc32.o :  $(PAFCHK_MODULE)/src/crc32.c $(PAFCHK_MODULE)/include/zconf.h $(PAFCHK_MODULE)/include/zlib.h
	$(CC) $(CFLAGS) -c $(PAFCHK_MODULE)/src/crc32.c

#*******************************************************************************
#___oOo___
