#####################
# Jana2000 makefile #
#####################


FORCE = FORCE                  # don't change this setting
PREPARE =                      # don't change this setting
PROG =                         # don't change this setting
INFO = unknown compiler        # don't change this setting
UNDERSCORES = undef            # don't change this setting
LOWER_CASE = undef             # don't change this setting
UPPER_CASE = undef             # don't change this setting
MIXED_CASE = undef             # don't change this setting
FTN_SUFFIX = f                 # don't change this setting
FOPT1 =                        # don't change this setting
FSPLIT = ../$(SPECIDIR)/sekej  # don't change this setting
# don't change following settings
CN1 =#
CN2 =#
CN3 =#
CN4 =#
CN5 =#
CN6 =#
CN7 =#
CN8 =#
CN9 =#
CN10 =#
CN11 =#
CN12 =#
CN13 =#
CN14 =#
CN15 =#
CN16 =#
CN17 =#
CN18 =#
CN19 =#
CN20 =#
WARN = -w
WATCH = none
CCKR = 
PSCOMMAND = ps -ef

#####################################
# Please check following 5 settings #
#####################################

## --> 1. list of programs to compile
COMPONENTS = chargeden contour datred dist editm40 editm50 editm9 fourier \
             glib grapht jana2000 janalib crystlib pictur pwdlib refine
## --> 2. path to source directories of Jana (relative or absolute)
JPATH = source
FGPATH = source/fg
## --> 3. the command calling C compiler (without options)
CCOM = cc 
## --> 4. the command starting Bourne shell
## (if the make cannot load the shell, try to find it by command
##  "whereis sh")
SHELL = /bin/sh
## --> 5. The application home directory 
## (path for outline fonts, configuration files etc.)
## The files for fg graphic library are in JANADIR/source/fg
## The files for Jana2000 are in JANADIR/source/data
JANADIR = `pwd`


#############################################################
# Please look for the section corresponding to you computer #
#############################################################
# If your computer is not on the list, please contact the 
# the authors in order to add it

### IMPORTANT ####
# There are both f77 and f90 sections for each workstation,
# but some f90 compilers crashes or gives unusable 
# results, although Jana2000 is written in pure f77. 
#

 
###################################
# Silicon Graphics - f77 compiler #
#################################

## Remove 1. character of each line of the editable section ###

### ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f77
#   ## Fortran compiler options
# FOPTS = -O2 -NC110 -Nc30 -Nq4000 -Nn10000 $(WARN) $(DALSIOPTS)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN1 = a#             # please don't change this setting
# CCKR = -cckr         # please don't change this setting
# INFO = Silicon Graphics - f77 compiler # please don't change this setting
#
## ******** end of editable section ********
  
###################################
# Silicon Graphics - f90 compiler #
###################################
 
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f90
#   ## Fortran compiler options
# FOPTS = -O2 -col72 $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo 
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN2 = a#             # please don't change this setting
# CCKR = -cckr         # please don't change this setting
# FOPT1 = -col72 -n32  # please don't change this setting
# INFO = Silicon Graphics - f90 compiler # please don't change this setting
#
## ******** end of editable section ********


######################
# SUN - f77 compiler #
######################

## Remove 1. character of each line of the editable section ###

## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f77
#   ## Fortran compiler options
# FOPTS = -fast -Nl99 -Nc30 $(WARN) -Nn3000 $(DALSIOPTS)
#   ##FOPTS = -g -Nl99 -Nc30 $(WARN) -Nn3000 $(DALSIOPTS)
#   ## path to the C include files
# INCLUDE = -I$$OPENWINHOME/include
#   ## C compiler options
# COPTS = $(INCLUDE)
#   ## libraries to link
#   ## if the linker doesn't work, try to remove -L option
# ## LINKLIBS = -L$$OPENWINHOME/lib -lX11 -lV77 
# LINKLIBS = -L$$OPENWINHOME/lib -lX11
#   ## RANLIB is used for compatibility with SunOS 4.x
# RANLIB = ranlib
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
# 
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN3 = a#             # please don't change this setting
# INFO = SUN - f77 compiler # please don't change this setting
# 
## ******** end of editable section ********


######################
# SUN - apf77 compiler #
######################

## Remove 1. character of each line of the editable section ###

## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = apf77
#   ## Fortran compiler options
# FOPTS = -fast $(WARN) -Xfstmt $(DALSIOPTS)
#   ## path to the C include files
# INCLUDE = -I$$OPENWINHOME/include
#   ## C compiler options
# CCOM = apcc
# COPTS = -fast $(INCLUDE)
#   ## libraries to link
#   ## if the linker doesn't work, try to remove -L option
# ## LINKLIBS = -L$$OPENWINHOME/lib -lX11 -lV77 
# LINKLIBS = -L$$OPENWINHOME/lib -lX11
#   ## RANLIB is used for compatibility with SunOS 4.x
# RANLIB = ranlib
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
# 
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN4 = a#             # please don't change this setting
# INFO = SUN - apf77 compiler # please don't change this setting
# 
## ******** end of editable section ********


######################
# SUN - f90 compiler #
######################

## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
# 
#   ## The command calling Fortran compiler (without options)
# FCOM = f90
#   ## Fortran compiler options
# FOPTS = -O3 -fast -fixed $(WARN)
#   ## path to the C include files
# INCLUDE = -I$$OPENWINHOME/include
#   ## C compiler options
# COPTS = $(WARN) $(INCLUDE)
#   ## libraries to link
#   ## if the linker doesn't work, try to remove -L option
# LINKLIBS = -L$$OPENWINHOME/lib -lX11
#   ## RANLIB is used for compatibility with SunOS 4.x
# RANLIB = ranlib
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
# 
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN5 = a#             # please don't change this setting
# FOPT1 = -fixed       # please don't change this setting
# INFO = SUN - f90 compiler # please don't change this setting
# 
## ******** end of editable section ********

#####################
# HP - f77 compiler #
#####################
 
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f77
#   ## Fortran compiler options
# FOPTS = +O3 +Nc30 +U77 +E1 $(WARN) +B
#   ## path to the C include files
# INCLUDE = -I/usr/include/X11R5
#   ## C compiler options
# COPTS = +O3 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = /usr/lib/X11R5/libX11.a
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN6 = a#             # please don't change this setting
# INFO = HP - f77 compiler # please don't change this setting
#
## ******** end of editable section ********

######################
# DEC - f77 compiler #
######################
 
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f77
#   ## Fortran compiler options
# FOPTS = -O3 -col72 -nofor_main -fpe2 $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -lX11
#   ## RANLIB
# RANLIB = ranlib
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN7 = a#             # please don't change this setting
# INFO = DEC - f77 compiler # please don't change this setting
#
## ******** end of editable section ********

######################
# DEC - f90 compiler #
######################
 
### Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f90
#   ## Fortran compiler options
# FOPTS = -fast -fixed -nofor_main $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -lX11
#   ## RANLIB
# RANLIB = ranlib
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN8 = a#             # please don't change this setting
# FOPT1 = -fixed       # please don't change this setting
# INFO = DEC - f90 compiler # please don't change this setting
#
## ******** end of editable section ********

######################
# IBM - f77 compiler #
######################
 
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f77
#   ## Fortran compiler options
# FOPTS = -O2 $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -lX11
#   ## RANLIB
# RANLIB = ranlib
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN9 = a#             # please don't change this setting
# INFO = IBM - f77 compiler # please don't change this setting
#
## ******** end of editable section ********

######################
# IBM - f90 compiler #
######################
 
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = f90
#   ## Fortran compiler options
# FOPTS = -O3 -qfixed -qstrict $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O3 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -lX11
#   ## RANLIB
# RANLIB = ranlib
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#   ## Source file suffix requested by Fortran compiler
# FTN_SUFFIX = f90
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN10 = a#             # please don't change this setting
# FOPT1 = -qfixed      # please don't change this setting
# INFO = IBM - f90 compiler # please don't change this setting
#
## ******** end of editable section ********
 
########################
# LINUX - g77 compiler #
########################
 
## Remove 1. character of each line of the editable section ###
# 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = g77
#   ## Fortran compiler options
# FOPTS = -O2 $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11/lib -L/usr/X11R5/lib -L/usr/X11R6/lib \
#            -L/usr/X11R6/lib64 -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = LINUX - g77 compiler # please don't change this setting
# 
# # ******** end of editable section ********

#############################
# LINUX - gfortran compiler #
#############################
 
## Remove 1. character of each line of the editable section ###
# 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
#   ## gfortran is a successor of g77. It is part of gcc starting
#   ## from version 4
# FCOM = gfortran
#   ## Fortran compiler options
# FOPTS = -O2 $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11/lib -L/usr/X11R5/lib -L/usr/X11R6/lib \
#            -L/usr/X11R6/lib64 -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = LINUX - gfortran compiler # please don't change this setting
# 
## ******** end of editable section ********

########################
# LINUX - g95 compiler #
########################
 
## Remove 1. character of each line of the editable section ###
# 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = g95
#   ## Fortran compiler options
# FOPTS = -O2 $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11/lib -L/usr/X11R5/lib -L/usr/X11R6/lib \
#            -L/usr/X11R6/lib64 -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = LINUX - g95 compiler # please don't change this setting
# 
## ******** end of editable section ********

##########################
# LINUX - ifort compiler #
##########################

## Remove 1. character of each line of the editable section ###

## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
#   ## ifort is new name for Intel ifc
# FCOM = ifort
#   ## Fortran compiler options
# FOPTS = -O2 -ip -Vaxlib $(WARN) -nofor-main
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11R6/lib -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
# 
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = LINUX - ifort Intel compiler # please don't change this setting
#
## ******** end of editable section ********

########################
# LINUX - ifc compiler #
########################

## Remove 1. character of each line of the editable section ###

## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
#   ## ifc is old name for Intel ifort
# FCOM = ifc
#   ## Fortran compiler options
# FOPTS = -O2 -ip -Vaxlib $(WARN) -nofor-main
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11R6/lib -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = LINUX - ifc Intel compiler # please don't change this setting
#
## ******** end of editable section ********

 
###############################
# LINUX - f90 absoft compiler #
###############################
  
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#  ## The command calling Fortran compiler (without options)
# FCOM = f90
#   ## Fortran compiler options
# FOPTS = -YCOM_PFX= -YCOM_SFX=_ -YCOM_NAMES=LCS -YEXT_SFX=_ -YEXT_NAMES=LCS $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11/lib -L/usr/X11R5/lib -L/usr/X11R6/lib -lX11 -L/usr/absoft/lib -lU77
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = LINUX - f90 absoft compiler # please don't change this setting
#
## ******** end of editable section ********
 
###############################
# LINUX - Lahey lf95 compiler #
###############################

## Remove 1. character of each line of the editable section ###

## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = lf95
#   ## Fortran compiler options
# FOPTS = -O --fix --nap --nchk --ng --npca --nsav --ntrace --tpp
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11/lib -L/usr/X11R5/lib -L/usr/X11R6/lib -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN12= a#             # please don't change this setting
# INFO = LINUX - lf95 compiler # please don't change this setting
#
## ******** end of editable section ********

##########################
# LINUX - pgf77 compiler #
##########################
 
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#   ## The command calling Fortran compiler (without options)
# FCOM = pgf77
#   ## Fortran compiler options
# FOPTS = -Mnomain -O2 -fast $(WARN)
#   ## path to the C include files
# INCLUDE =
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11R6/lib -lX11
#   ## RANLIB is not used, but cannot be empty
# RANLIB = echo
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = LINUX - pgf77 compiler # please don't change this setting
#
## ******** end of editable section ********
 
####################################
# Darwin (MacOS X) - g77 compiler #
####################################
 
## Remove 1. character of each line of the editable section ###
 
## ******** start of editable section ********
#
#  ## The command calling Fortran compiler (without options)
# FCOM = g77
#   ## Fortran compiler options
# FOPTS = -O2 -noprebind $(WARN)
#   ## path to the C include files
# INCLUDE = -I/usr/X11/include -I/usr/X11R5/include -I/usr/X11R6/include
#   ## C compiler options
# COPTS = -O2 $(WARN) $(INCLUDE)
#   ## libraries to link
# LINKLIBS = -L/usr/X11/lib -L/usr/X11R5/lib -L/usr/X11R6/lib -lX11 -lSystemStubs
#   ## RANLIB requested
# RANLIB = ranlib
#   ## Fortran compiler adds underscore to each module
# UNDERSCORES = define
#   ## Fortran compiler changes the source code to lowercase
# LOWER_CASE = define
#
# FORCE =              # please don't change this setting
# PREPARE = prepare    # please don't change this setting
# PROG = jana2000      # please don't change this setting
# CN11= a#             # please don't change this setting
# INFO = Darwin - g77 compiler # please don't change this setting
# PSCOMMAND = ps -aguxww
#
## ******** end of editable section ********
 
###############################################################
# Try to start make. Please contact the authors if it doesn't #
# run correctly.                                              #
# E-mail petricek@fzu.cz or dusek@fzu.cz                      #
###############################################################

# Please don't change the rest of the file unless it is 
# necessary

SPECIDIR = specific
SPECIFIC = $(SPECIDIR)/specific.h
FHEAD = $(SPECIDIR)/Fhead.h

## knihovny ##
# JAKOLIB udava, co se bude prekladat jako knihovna. Fg stoji mimo.
# LIBS udava, co se bude linkovat a v jakem poradi. X11 stoji mimo. 
 
JAKOLIB = pictur.a janalib.a crystlib.a pwdlib.a glib.a
LIBS = jlibrary.a fg.a
OBJLIST = chargeden.o contour.o datred.o dist.o editm40.o editm50.o editm9.o \
          fourier.o grapht.o jana2000.o refine.o

TOUCHLIBS = \
  echo $(JAKOLIB) | \
    awk '{for(i=1;i<=NF;i++)print $$i}' | \
    awk -F. '{ \
    if($$1 == "fg"){ \
      print "touch source/fg/fg.src"; \
    }else{ \
      print "touch source/"$$1".f" \
    } \
  }' > ./pppp; . ./pppp; rm ./pppp
 
#OBJLIST = ` \
#  for component in $(COMPONENTS); do \
#    jeknih="ne"; \
#    for knih in $(JAKOLIB); do \
#      if test $$component.a = $$knih; then  \
#        jeknih="ano"; \
#        break; \
#      fi;  \
#    done; \
#    if test $$jeknih = "ne"; then \
#      echo $$component.o; \
#      rm -f $$component.a; \
#    else \
#      rm -f $$component.o; \
#    fi; \
#  done`
 
# makra pro preklad, linkovani a vyrobu knihoven
BADDIR =  if test `pwd | awk -F/ '{if($$NF == "source"){ \
            print "BADDIR";}else{print "blabla"} }'` \
            = "BADDIR"; then \
            echo "************************************"; \
            echo "make cannot work in directory source"; \
            echo "************************************"; \
            echo " "; \
            (spatny_prikaz_smeruje_ke_krachu) 2> /dev/null; fi
SETNAME = NAME=`echo $@ | awk -F. '{print $$1}'` ; \
          export NAME; \
          PTH=$(JPATH); export PTH; \
          CPTEST="echo nothing";export CPTEST
CPFILES = cp $(SPECIDIR)/*.cmn $(SPECIDIR)/*.h .; \
          cp $(JPATH)/*.cmn $(FGPATH)/*.cmn $(FGPATH)/*.h .; \
          cp $(JPATH)/data/*.h .; cp $(SPECIDIR)/pom.inc .; \
          $$CPTEST > /dev/null
RMFILES = touch pppp; \
          rm -f *.u *.cmn *.h *.c *.f *.$(FTN_SUFFIX) pppp MainUnit.o \
          pom.inc tellbits; if test -s declare; then rm -f dcl*.dcl; fi

MAKEOBJ =  $(ORAM); \
           $(RMFILES);$(CPFILES);cp $$PTH/$$NAME.f .; \
           if test -f $$NAME.o; then rm -f $$NAME.o; fi; \
           if test $@ = jana2000.o; then cat $$NAME.f | \
             $(CHNGMAIN) > pppp; mv pppp $$NAME.f; fi; \
           $(CHNGSUFF); \
           if test -s declare; then \
             cat $$NAME.f | declare > pppp; mv pppp $$NAME.f; fi; \
           $(FCOM) $(FOPTS) -c $$NAME.$(FTN_SUFFIX);\
           $(RMFILES)
EXESPOL =  $(ORAM); \
           ($(WRITE_FHEAD)) > $(FHEAD); \
           $(RMFILES);$(CPFILES);cp $$PTH/$$NAME.f .; \
           cat $$NAME.f | $(CHNGMAIN) > pppp; mv pppp $$NAME.f; \
           $(CHNGSUFF); \
           $(FCOM) $(FOPTS) -c $$NAME.$(FTN_SUFFIX);\
           cp $(SPECIDIR)/MainUnit.c .; \
           $(CCOM) $(COPTS) -c MainUnit.c
MAKEEXE =  $(EXESPOL); \
           $(FCOM) $(FOPTS) -o $$NAME MainUnit.o $$NAME.o $(LIBS) $(LINKLIBS); \
           $(RMFILES); \
           chmod 755 $$NAME
MAKEJ2000 =  echo ' '; \
           if test $(WATCH) != "none" -a `$(PSCOMMAND) | grep $(WATCH) | grep -v grep  | grep -v WATCH | grep -v "csh -c set" | grep -v "Building jana2000" | wc -l` != 0; then \
             echo $(KR)'! /bin/sh' > pppp; \
             echo 'echo Please close running version of JANA:' >> pppp; \
             echo 'echo '$(WATCH) >> pppp; \
             echo 'echo Then close this window in order to allow' >> pppp; \
             echo 'echo the installation procedure to make the' >> pppp; \
             echo 'echo final building of JANA' >> pppp; \
             echo 'echo -----------------------------------------' >> pppp; \
             echo 'echo Pressing of Ctrl-C or Ctrl-D will close this window' >> pppp; \
             echo 'cat' >> pppp; \
             chmod 775 pppp; \
             xterm -e ./pppp; \
             rm ./pppp; \
           fi; \
           if test -f $$NAME; then rm -f $$NAME; fi; \
           echo 'Building jana2000 ... '; \
           ($(WRITE_FHEAD)) > $(FHEAD); \
           cp $(SPECIDIR)/MainUnit.c $(SPECIDIR)/*.h $(FGPATH)/*.h .; \
           $(CCOM) $(COPTS) -c MainUnit.c; \
           $(FCOM) $(FOPTS) -o $$NAME MainUnit.o $(OBJLIST) \
             $(LIBS) $(LINKLIBS); \
           $(RMFILES); \
           chmod 755 $$NAME; echo ' '
KUSY =     ne
 
MAKELIB  = $(ORAM); \
           $(RMFILES);$(CPFILES); \
           rm -rf ttmp; mkdir ttmp; cp *.cmn *.h pom.inc ttmp/.; \
           if test $(KUSY) = 'ne' -a -s declare; then \
             cat $$PTH/$$NAME.f | declare > ttmp/$$NAME.x.f; \
             mv dcl*.dcl ttmp/.; \
           else \
             cp $$PTH/$$NAME.f ttmp/$$NAME.x.f; \
           fi; \
           $(RMFILES); cd ttmp; \
           cat $$NAME.x.f | $(FSPLIT) > /dev/null; \
           mv $$NAME.x.f $$NAME.sav; \
           rm -f zz*.f; \
           if test $(KUSY) = 'jo' -a -s ../declare; then \
             cp ../declare* ../fch_dcl .; \
             for file in *.f; do \
               cat $$file | declare > pppp; \
               mv pppp $$file; \
             done; \
           fi; \
           $(CHNGSUFF); \
           $(FCOM) $(FOPTS) -c *.$(FTN_SUFFIX); \
           touch ../$@; $(BUILDLIB); $(RMFILES); cd ..; rm -rf ttmp
CMOD =     *.c
FMOD =     *.$(FTN_SUFFIX)
FGSPLIT =  ../$(SPECIDIR)/splitfg
MAKEFG =   $(ORAM); \
           $(RMFILES);$(CPFILES); \
           rm -rf ttmp; mkdir ttmp; mv *.cmn *.h ttmp/.; $(RMFILES); \
           cp $(FGPATH)/fg.src ttmp/fg.src; cd ttmp; \
           (cat fg.src | $(FGSPLIT) > /dev/null) \
             2> /dev/null ; rm -f fg.src; \
           $(CCOM) $(COPTS) -c $(CMOD); \
           $(CHNGSUFF); \
           $(FCOM) $(FOPTS) -c $(FMOD);\
           ar r ../$@ *.o; rm -f *.o; $(RANLIB) ../$@; \
           cd ..; rm -rf ttmp
BUILDLIB =  \
           echo "Updating jlibrary.a .... "; \
           ar r ../jlibrary.a *.o ; rm -f *.o; \
           $(RANLIB) ../jlibrary.a > /dev/null
             
 
KR = `cat $(FGPATH)/kriminal`

SETMXBITS = \
  echo $(KR)"include <stdio.h>" > pppp.c; \
  echo "main()" >> pppp.c; \
  echo "{" >> pppp.c; \
  echo 'printf("%d",(int)(sizeof(long)*8));' >> pppp.c; \
  echo 'return (0);' >> pppp.c; \
  echo "}" >> pppp.c; \
  $(CCOM) $(COPTS) -o tellbits pppp.c
 
WRITE_SPECIFIC = \
  echo '/* specific.h */'; \
  echo $(KR)"$(UNDERSCORES) NeedUnderscores"; \
  echo $(KR)"$(LOWER_CASE) LOWER_CASE"; \
  echo $(KR)"$(UPPER_CASE)  UPPER_CASE"; \
  echo $(KR)"$(MIXED_CASE)  MIXED_CASE"; \
  echo " "; \
  echo $(KR)"if __STDC__ || defined(__cplusplus) || defined(c_plusplus)"; \
  echo $(KR)"define NeedPrototypes"; \
  echo $(KR)"else"; \
  echo $(KR)"undef NeedPrototypes"; \
  echo $(KR)"endif"

WRITE_SPECICMN = \
  echo 'C The length in bits of the XID identifier'; \
  echo '      integer Mxbits'; \
  echo '      parameter(Mxbits='`./tellbits`')'; \
  echo 'C The identifier of operating system (1=UNIX,2=VAX)'; \
  echo '      integer OpSyst'; \
  echo '      parameter (OpSyst=1)'
 
WRITE_FHEAD = \
  echo '/* The name of the main Fortran subroutine */'; \
  echo $(KR)"define UNITM  "$$NAME; \
  echo $(KR)"define UNITL  "`echo $$NAME | $(TO_LOWER)`; \
  echo $(KR)"define UNITU  "`echo $$NAME | $(TO_UPPER)`; \
  echo $(KR)"define UNITM_ "$$NAME"_"; \
  echo $(KR)"define UNITL_ "`echo $$NAME | $(TO_LOWER)`"_"; \
  echo $(KR)"define UNITU_ "`echo $$NAME | $(TO_UPPER)`"_"

# zmena program na subroutine
CHNGMAIN = awk '{ \
  if(substr($$0,1,6) == "      " && $$1 == "program"){ \
    $$1 = "      subroutine"; \
  } \
  print $$0;  \
}'

# `ar' on some computers needs names not longer than 14 chars
# (it goes through file `pppp' as the pipeline could be too long)
#CUTNAMES = \
#  (ls *.o | \
#   awk 'BEGIN{c=0} \
#    {if(length($$0) > 14){c++;print "mv "$$0" "substr($$0,1,9)c".o"}}' \
#     ) > pppp; \
#   echo ' ' >> pppp; \
#   . ./pppp; rm pppp
#
#   awk '{l=length($$2); z=substr($$2,1,l-2); \
#          if(l == 0)next; \
#          print $$1" "$$3" "$$2; \
#          print "echo "$$1" "$$3" "$$2; \
#          }' s=$(FTN_SUFFIX) pppp > ../$@.scr; \
#   rm pppp

# Change of suffix - IBM f90 cannot work with .f
CHNGSUFF = ( \
  echo "echo nothing > /dev/null"; \
  \ls *.f | \
  awk -F. '{if(s != "f")print "mv "$$0" "$$1"."s}' \
    s=$(FTN_SUFFIX)) > pppp; \
  . ./pppp; rm pppp

TO_LOWER = \
  awk '{for(i=1;i<=length($$0);i++){ \
    c = substr($$0,i,1); \
    n = 0; \
    if(c == "A"){printf("%s","a");n=1} \
    if(c == "B"){printf("%s","b");n=1} \
    if(c == "C"){printf("%s","c");n=1} \
    if(c == "D"){printf("%s","d");n=1} \
    if(c == "E"){printf("%s","e");n=1} \
    if(c == "F"){printf("%s","f");n=1} \
    if(c == "G"){printf("%s","g");n=1} \
    if(c == "H"){printf("%s","h");n=1} \
    if(c == "I"){printf("%s","i");n=1} \
    if(c == "J"){printf("%s","j");n=1} \
    if(c == "K"){printf("%s","k");n=1} \
    if(c == "L"){printf("%s","l");n=1} \
    if(c == "M"){printf("%s","m");n=1} \
    if(c == "N"){printf("%s","n");n=1} \
    if(c == "O"){printf("%s","o");n=1} \
    if(c == "P"){printf("%s","p");n=1} \
    if(c == "Q"){printf("%s","q");n=1} \
    if(c == "R"){printf("%s","r");n=1} \
    if(c == "S"){printf("%s","s");n=1} \
    if(c == "T"){printf("%s","t");n=1} \
    if(c == "U"){printf("%s","u");n=1} \
    if(c == "V"){printf("%s","v");n=1} \
    if(c == "W"){printf("%s","w");n=1} \
    if(c == "X"){printf("%s","x");n=1} \
    if(c == "Y"){printf("%s","y");n=1} \
    if(c == "Z"){printf("%s","z");n=1} \
    if(n == 0)printf("%s",c); \
  } \
  printf("\n"); \
  }'

TO_UPPER = \
  awk '{for(i=1;i<=length($$0);i++){ \
    c = substr($$0,i,1); \
    n = 0; \
    if(c == "a"){printf("%s","A");n=1} \
    if(c == "b"){printf("%s","B");n=1} \
    if(c == "c"){printf("%s","C");n=1} \
    if(c == "d"){printf("%s","D");n=1} \
    if(c == "e"){printf("%s","E");n=1} \
    if(c == "f"){printf("%s","F");n=1} \
    if(c == "g"){printf("%s","G");n=1} \
    if(c == "h"){printf("%s","H");n=1} \
    if(c == "i"){printf("%s","I");n=1} \
    if(c == "j"){printf("%s","J");n=1} \
    if(c == "k"){printf("%s","K");n=1} \
    if(c == "l"){printf("%s","L");n=1} \
    if(c == "m"){printf("%s","M");n=1} \
    if(c == "n"){printf("%s","N");n=1} \
    if(c == "o"){printf("%s","O");n=1} \
    if(c == "p"){printf("%s","P");n=1} \
    if(c == "q"){printf("%s","Q");n=1} \
    if(c == "r"){printf("%s","R");n=1} \
    if(c == "s"){printf("%s","S");n=1} \
    if(c == "t"){printf("%s","T");n=1} \
    if(c == "u"){printf("%s","U");n=1} \
    if(c == "v"){printf("%s","V");n=1} \
    if(c == "w"){printf("%s","W");n=1} \
    if(c == "x"){printf("%s","X");n=1} \
    if(c == "y"){printf("%s","Y");n=1} \
    if(c == "z"){printf("%s","Z");n=1} \
    if(n == 0)printf("%s",c); \
  } \
  printf("\n"); \
  }'

# frames $$NAME
ORAM = if test $(KUSY) = 'jo'; then \
         echo ' '; \
         echo 'Partial compilation of JANA'; \
         echo 'Warning: the dependencies are ignored'; \
         echo $(INFO); fi; \
         echo ' '; echo $$NAME | awk '{l = length($$0); h = ""; \
             for(i=1;i<=l+4;i++)h=h"*"; \
             print h; print "* "$$0" *"; print h}'

# makes fg_userfiles
# (include files cannot be listed with path as it can be long 
#  and continuation line is not permitted for `include' 
#  command)
MKFGUS = echo "      character*28 AP_homedir"; \
         echo "      parameter (AP_homedir = '"`pwd`"/')"; \
         echo "      include '"fg_params.cmn"'"; \
         echo "      include '"fg_homedir.cmn"'"; \
         echo "      include '"fg_set.cmn"'"; \
         echo "      include '"fg_work.cmn"'"; \
         echo "      include '"fg_X11val.cmn"'"; \
         echo "      include '"fg_struct.cmn"'"; \
         echo "      include '"fg_tree.cmn"'"; \
         echo "      include '"fg_save.cmn"'"
 
# makes fg_homedir
MKFGHOM = NAME=`pwd`; \
          export NAME;cd $(FGPATH); \
          echo "      character*200 Fg_homedir"; \
          echo "      parameter (Fg_homedir = '"`pwd`"/')"

MKAPPHOM = echo "C application home directory"; \
           echo "      character*(Mxpathl) Appl_homedir";\
           echo "      parameter (Appl_homedir = '"$(JANADIR)"')"

MKPOMINCL = hostname | \
            awk -F. '{ \
            print "C"; \
            if(1 == 0){ \
            if($$0 == "sun175.fzu.cz") { \
              print "      nejakapromenna = .true."; \
            }else if($$0 == "indy22.fzu.cz") { \
              print "      nejakapromenna = .true."; \
            }else{ \
              print "      nejakapromenna = .false."; \
            }}}'

# prostredek na sekani radek delsich nez 72 znaku
SPLITLINES = awk '{ \
  i = length($$0); \
  if(i < 73) { \
    print $$0; \
  } else { \
    printf substr($$0,1,65)""a; \
    for(j=66;j<=i;j=j+61) { \
      m = 61; \
      if((j+m) > i) m = i-j+1; \
      printf("\n     &//%s%s",a,substr($$0,j,m)) \
    } \
    printf("\n"); \
  } \
}' a=`echo \'''` -

WRITE_HELP = \
echo "make ............ standard usage for user compilation"; \
echo "make clean_up ... removes all the files used for compilation but"; \
echo "                  useless for execution (including libraries). "; \
echo "make xx ......... skips creating of the \`specific' files, "; \
echo "                  assuming they are already prepared."; \
echo "make prepare .... prepares \`specific' directory and files"; \
echo "make copy ....... creates copy of all include files in the "; \
echo "                  current directory"; \
echo "make name ....... compilation of the program \`name'"; \
echo "                  requires to run \`make prepare' before"

CUT_SPL = \
  awk 'BEGIN{pis=0} \
  { if($$0 == "%sekej_f% splitfg") { \
      pis = 1; \
      next; \
    } \
    if($$0 == "%end_f% splitfg")pis=0; \
    if(pis == 1)print $$0; \
   }' -

CUT_MAIN = \
  awk 'BEGIN{pis=0} \
  { if($$0 == "%sekej_c% MainUnit") { \
      pis = 1; \
      print krimi"include \"fginit.h\""; \
      next; \
    } \
    if($$0 == "%end_c% MainUnit")pis=0; \
    if(pis == 1)print $$0; \
   }' krimi=$(KR) -

CNFL = $(CN1)$(CN2)$(CN3)$(CN4)$(CN5)$(CN6)$(CN7)\
$(CN8)$(CN9)$(CN10)$(CN11)$(CN12)$(CN13)$(CN14)\
$(CN15)$(CN16)$(CN17)$(CN18)$(CN19)$(CN20)

CPFCHFILES = \
$(SETNAME);cp $$PTH/$$NAME.f $$HOME/tmp_ftn/pppp.f; \
BACK=`pwd`; cd $$HOME/tmp_ftn; cat pppp.f | declare > $$NAME.f; \
rm -f pppp.f; cd $$BACK
 
#TOUCHFILES = \
#  touch $@; \
#  NAMECMN=`echo $@ | awk -F/ '{print $$2}' | awk -F% '{print $$1"."$$2}'`; \
#  export NAMECMN; \
#   if test -f d/proslo; then \
#     echo " "; \
#     echo "--> "$$NAMECMN" has new creation date"; \
#   fi; \
#  grep -l "      include \'$$NAMECMN\'"  \
#    $(JPATH)/*.cmn $(JPATH)/*.f $(JPATH)/fg/*.cmn $(JPATH)/fg/*.src \
#    $(JPATH)/../specific/fg_userfiles.cmn  > pppp; \
#  touch `cat pppp` d/pppp; \
#  if test -f d/proslo; then \
#    touch jlibrary.s; \
#     cat pppp | awk -F/ '{print "The creation date of "$$NF" has been updated."}'; \
#  fi; \
#  if test `cat pppp | grep \.cmn | wc -l` != 0; then \
#    echo "cmn" > d/ppppcmn; fi

TOUCHFILES = \
  touch $@; \
  NAMECMN=`echo $@ | awk -F/ '{print $$2}' | awk -F% '{print $$1"."$$2}'`; \
  export NAMECMN; \
  grep -l "      include "\'$$NAMECMN\'  \
    $(JPATH)/*.cmn $(JPATH)/*.f $(JPATH)/fg/*.cmn $(JPATH)/fg/*.src \
    $(JPATH)/../specific/fg_userfiles.cmn  > pppp; \
  touch `cat pppp` d/pppp; \
  if test -f d/proslo; then \
    touch jlibrary.s; \
  fi; \
  if test `cat pppp | grep \.cmn | wc -l` != 0; then \
    echo "cmn" > d/ppppcmn; fi


# if test `cat pppp | grep \.cmn | wc -l` != 0; then \
# make -f Makefile commony | grep -v directory ; fi

## ******** end of editable section ********

#### end of macros definitions ####

all:		$(FORCE) $(CNFL) BADDIR $(PREPARE) commony $(PROG)
		@$(RMFILES)

xx:             $(PROG)
		@$(RMFILES)

reset_all:      clean_up all

reset:          clean_fg all

clean_up:       BADDIR
		@$(RMFILES)
		@rm -rf $(SPECIDIR)
		@rm -rf tmp_prek
		@rm -i *.o
		@rm -i *.a
		@rm -i *.scr
		@rm -r -i d

CLEAN_up:       BADDIR
		@$(RMFILES)
		@rm -rf $(SPECIDIR)
		@rm -rf tmp_prek
		@rm -f *.scr
		@rm -f *.o
		@rm -f *.a
		@rm -f -r d

clean_fg:       BADDIR
		@$(RMFILES)
		@rm -rf $(SPECIDIR)
		@rm -rf tmp_prek
		@rm -f fg.a

commony:        always d/atoms%cmn d/basic%cmn d/const%cmn d/contour%cmn \
                d/datred%cmn d/dist%cmn d/editm40%cmn d/editm50%cmn \
                d/editm9%cmn d/fepc%cmn d/memexport%cmn\
                d/fgids%cmn d/fourier%cmn d/glib%cmn \
                d/grapht%cmn d/molec%cmn d/params%cmn d/pictur%cmn \
                d/powder%cmn d/refine%cmn \
                d/fg%cmn d/fg_X11val%cmn d/fg_params%cmn d/fg_save%cmn \
                d/fg_set%cmn d/fg_struct%cmn d/fg_tree%cmn d/fg_work%cmn \
                d/fg_userfiles%cmn
		@if test `cat d/ppppcmn | grep cmn | wc -l` != 0; \
                  then make -f Makefile commony; fi
		@touch d/proslo

always:
		    @echo " " > d/ppppcmn
		    @echo "testing dependencies on include files ...."
		    @if test ! -s jlibrary.a; then \
                      $(TOUCHLIBS); \
                    fi

d/atoms%cmn:        $(JPATH)/atoms.cmn
		    -@$(TOUCHFILES)

d/basic%cmn:        $(JPATH)/basic.cmn
		    -@$(TOUCHFILES)

d/const%cmn:        $(JPATH)/const.cmn
		    -@$(TOUCHFILES)

d/memexport%cmn:    $(JPATH)/memexport.cmn
		    -@$(TOUCHFILES)

d/contour%cmn:      $(JPATH)/contour.cmn
		    -@$(TOUCHFILES)

d/datpre%cmn:       $(JPATH)/datpre.cmn
		    -@$(TOUCHFILES)

d/datred%cmn:       $(JPATH)/datred.cmn
		    -@$(TOUCHFILES)

d/dist%cmn:         $(JPATH)/dist.cmn
		    -@$(TOUCHFILES)

d/editm40%cmn:      $(JPATH)/editm40.cmn
		    -@$(TOUCHFILES)

d/editm50%cmn:      $(JPATH)/editm50.cmn
		    -@$(TOUCHFILES)

d/editm9%cmn:      $(JPATH)/editm9.cmn
		    -@$(TOUCHFILES)
 
d/fepc%cmn:         $(JPATH)/fepc.cmn
		    -@$(TOUCHFILES)

d/fgids%cmn:        $(JPATH)/fgids.cmn
		    -@$(TOUCHFILES)

d/fourier%cmn:      $(JPATH)/fourier.cmn
		    -@$(TOUCHFILES)

d/grapht%cmn:       $(JPATH)/grapht.cmn
		    -@$(TOUCHFILES)

d/molec%cmn:        $(JPATH)/molec.cmn
		    -@$(TOUCHFILES)

d/params%cmn:       $(JPATH)/params.cmn
		    -@$(TOUCHFILES)

d/pictur%cmn:       $(JPATH)/pictur.cmn
		    -@$(TOUCHFILES)

d/picfce%cmn:       $(JPATH)/picfce.cmn
		    -@$(TOUCHFILES)

d/powder%cmn:       $(JPATH)/powder.cmn
		    -@$(TOUCHFILES)

d/profil%cmn:       $(JPATH)/profil.cmn
		    -@$(TOUCHFILES)

d/refine%cmn:       $(JPATH)/refine.cmn
		    -@$(TOUCHFILES)

d/fg_X11val%cmn:    $(JPATH)/fg/fg_X11val.cmn
		    -@$(TOUCHFILES)

d/fg_params%cmn:    $(JPATH)/fg/fg_params.cmn
		    -@$(TOUCHFILES)

d/fg_save%cmn:      $(JPATH)/fg/fg_save.cmn
		    -@$(TOUCHFILES)

d/fg_set%cmn:       $(JPATH)/fg/fg_set.cmn
		    -@$(TOUCHFILES)

d/fg_struct%cmn:    $(JPATH)/fg/fg_struct.cmn
		    -@$(TOUCHFILES)

d/fg_tree%cmn:      $(JPATH)/fg/fg_tree.cmn
		    -@$(TOUCHFILES)

d/fg_userfiles%cmn:      $(JPATH)/../specific/fg_userfiles.cmn
		    -@$(TOUCHFILES)

d/fg_work%cmn:      $(JPATH)/fg/fg_work.cmn
		    -@$(TOUCHFILES)

d/fg%cmn:           $(JPATH)/fg/fg.cmn
		    -@$(TOUCHFILES)

d/glib%cmn:         $(JPATH)/glib.cmn
		    -@$(TOUCHFILES)

jana2000:       $(OBJLIST) $(LIBS) 
		@$(SETNAME);$(MAKEJ2000)

JANA2000:
		@$(SETNAME);$(MAKEJ2000);mv JANA2000 jana2000

jlibrary.a:     $(JAKOLIB)
		@touch jlibrary.a
 
jana2000.o:     $(JPATH)/jana2000.f
		@$(SETNAME);$(MAKEOBJ)
 
jana2000.a:     $(JPATH)/jana2000.f
		@$(SETNAME);$(MAKELIB)
 
chargeden.o:    $(JPATH)/chargeden.f 
		@$(SETNAME);$(MAKEOBJ)

chargeden.a:    $(JPATH)/chargeden.f 
		@$(SETNAME);$(MAKELIB)

contour.o:      $(JPATH)/contour.f 
		@$(SETNAME);$(MAKEOBJ)

contour.a:      $(JPATH)/contour.f
		@$(SETNAME);$(MAKELIB)

datred.o:       $(JPATH)/datred.f
		@$(SETNAME);$(MAKEOBJ)
 
datred.a:       $(JPATH)/datred.f
		@$(SETNAME);$(MAKELIB)
 
dist.o:         $(JPATH)/dist.f
		@$(SETNAME);$(MAKEOBJ)

dist.a:         $(JPATH)/dist.f
		@$(SETNAME);$(MAKELIB)

editm40.o:      $(JPATH)/editm40.f
		@$(SETNAME);$(MAKEOBJ)

editm40.a:      $(JPATH)/editm40.f
		@$(SETNAME);$(MAKELIB)

editm50.o:      $(JPATH)/editm50.f
		@$(SETNAME);$(MAKEOBJ)

editm50.a:      $(JPATH)/editm50.f
		@$(SETNAME);$(MAKELIB)

editm9.o:      $(JPATH)/editm9.f
		@$(SETNAME);$(MAKEOBJ)

editm9.a:      $(JPATH)/editm9.f
		@$(SETNAME);$(MAKELIB)

fourier.o:      $(JPATH)/fourier.f
		@$(SETNAME);$(MAKEOBJ)
 
fourier.a:      $(JPATH)/fourier.f
		@$(SETNAME);$(MAKELIB)
 
grapht.o:       $(JPATH)/grapht.f
		@$(SETNAME);$(MAKEOBJ)

grapht.a:       $(JPATH)/grapht.f
		@$(SETNAME);$(MAKELIB)
 
refine.o:       $(JPATH)/refine.f
		@$(SETNAME);$(MAKEOBJ)

refine.a:       $(JPATH)/refine.f
		@$(SETNAME);$(MAKELIB)

pictur.o:       $(JPATH)/pictur.f
		@$(SETNAME);$(MAKEOBJ)

pictur.a:       $(JPATH)/pictur.f
		@$(SETNAME);$(MAKELIB)

janalib.a:      $(JPATH)/janalib.f
		@$(SETNAME);$(MAKELIB)

crystlib.a:      $(JPATH)/crystlib.f
		@$(SETNAME);$(MAKELIB)

pwdlib.a:       $(JPATH)/pwdlib.f
		@$(SETNAME);$(MAKELIB)

glib.a:         $(JPATH)/glib.f
		@$(SETNAME);$(MAKELIB)

fg.a:           $(FGPATH)/fg.src $(FGPATH)/fg.h $(JPATH)/data/bitdata.h
		@$(SETNAME);$(MAKEFG)

drawcgm.a:
		@$(SETNAME);$(ORAM)
		@cd source/gplot; make CCKR=$(CCKR) FCOM=$(FCOM); \
                mv $@ ../.. ; cd ../..
 
prepare:
		@$(SETNAME);$(ORAM)
		@echo $(INFO)
		@$(RMFILES)
		@if test ! -d d; then mkdir d; fi
		@rm -rf $(SPECIDIR)
		@mkdir $(SPECIDIR)
		@($(WRITE_SPECIFIC)) > $(SPECIFIC)
		@$(SETMXBITS)
		@echo `./tellbits`" bits compilation"
		@($(WRITE_SPECICMN)) > $(SPECIDIR)/specific.cmn
		@($(MKFGUS)) | $(SPLITLINES) > $(SPECIDIR)/fg_userfiles.cmn
		@touch d/fg_userfiles%cmn
		@touch d/ppppcmn
		@($(MKFGHOM)) | $(SPLITLINES) > $(SPECIDIR)/fg_homedir.cmn
		@($(MKAPPHOM)) | $(SPLITLINES) > $(SPECIDIR)/appl_homedir.cmn
		@($(MKPOMINCL)) > $(SPECIDIR)/pom.inc
		@tail -200 $(FGPATH)/fg.src | ($(CUT_SPL)) > splitfg.f
		@$(CHNGSUFF)
		@($(FCOM) $(FOPT1) -o splitfg splitfg.$(FTN_SUFFIX)) \
                  2> /dev/null
		@chmod 755 splitfg
		@head -200 $(FGPATH)/fg.src | ($(CUT_MAIN)) > MainUnit.c
		@($(FCOM) $(FOPT1) -o sekej $(JPATH)/sekej.f ) 2> /dev/null
		@chmod 755 sekej
		@mv *.$(FTN_SUFFIX) *.c splitfg sekej $(SPECIDIR)/.
		@$(RMFILES)

copy:
		@$(SETNAME);$(CPFILES)
 
Xtest:          source/Xtest.c
		echo $(CCOM) $(COPTS) -c source/Xtest.c
		@$(CCOM) $(COPTS) -c source/Xtest.c
		@$(FCOM) $(FOPTS) -o Xtest Xtest.o $(LINKLIBS)

filtr:          source/filtr.f source/filtr.cmn
		@cp source/filtr.f source/filtr.cmn .
		@$(FCOM) -o filtr filtr.f $(LIBS)
		@rm filtr.f filtr.cmn

FCHFILES = contour.lis datred.lis dist.lis editm40.lis fg.lis fourier.lis \
           glib.lis grapht.lis jana2000.lis janalib.lis pictur.lis prelim.lis \
           pwdlib.lis refine.lis chargeden.lis

fch:            BADDIR prepare commony cpfch J2000.lis

J2000.lis:      $(FCHFILES)
		@fchprjs

cpfch:
		@if test -d $$HOME/tmp_ftn; then rm -r $$HOME/tmp_ftn; fi
		@mkdir $$HOME/tmp_ftn;
		@$(CPFILES); cp *.cmn pom.inc $$HOME/tmp_ftn/.;
		@cp declare declare_filt* fch_dcl $$HOME/tmp_ftn/.;
		@$(RMFILES);

contour.lis:    $(JPATH)/contour.f
		@$(CPFCHFILES);
		@fchprj contour;rm -f $$HOME/tmp_ftn/dcl*.dcl

chargeden.lis:  $(JPATH)/chargeden.f
		@$(CPFCHFILES);
		@fchprj chargeden;rm -f $$HOME/tmp_ftn/dcl*.dcl

datred.lis:     $(JPATH)/datred.f
		@$(CPFCHFILES);
		@fchprj datred;rm -f $$HOME/tmp_ftn/dcl*.dcl

dist.lis:       $(JPATH)/dist.f
		@$(CPFCHFILES);
		@fchprj dist;rm -f $$HOME/tmp_ftn/dcl*.dcl

editm40.lis:    $(JPATH)/editm40.f
		@$(CPFCHFILES);
		@fchprj editm40;rm -f $$HOME/tmp_ftn/dcl*.dcl

fg.lis:         $(FGPATH)/fg.src
		@$(SETNAME);cp $$PTH/fg/fg.src $$HOME/tmp_ftn/.;
		@fchprj fg;rm -f $$HOME/tmp_ftn/dcl*.dcl

fourier.lis:    $(JPATH)/fourier.f
		@$(CPFCHFILES);
		@fchprj fourier;rm -f $$HOME/tmp_ftn/dcl*.dcl

glib.lis:       $(JPATH)/glib.f
		@$(CPFCHFILES);
		@fchprj glib;rm -f $$HOME/tmp_ftn/dcl*.dcl

pwdlib.lis:     $(JPATH)/pwdlib.f
		@$(CPFCHFILES);
		@fchprj pwdlib;rm -f $$HOME/tmp_ftn/dcl*.dcl

grapht.lis:     $(JPATH)/grapht.f
		@$(CPFCHFILES);
		@fchprj grapht;rm -f $$HOME/tmp_ftn/dcl*.dcl

jana2000.lis:   $(JPATH)/jana2000.f
		@$(CPFCHFILES);
		@fchprj jana2000;rm -f $$HOME/tmp_ftn/dcl*.dcl

janalib.lis:    $(JPATH)/janalib.f
		@$(CPFCHFILES);
		@fchprj janalib;rm -f $$HOME/tmp_ftn/dcl*.dcl

pictur.lis:     $(JPATH)/pictur.f
		@$(CPFCHFILES);
		@fchprj pictur;rm -f $$HOME/tmp_ftn/dcl*.dcl

prelim.lis:     $(JPATH)/prelim.f
		@$(CPFCHFILES);
		@fchprj prelim;rm -f $$HOME/tmp_ftn/dcl*.dcl

refine.lis:     $(JPATH)/refine.f
		@$(CPFCHFILES);
		@fchprj refine;rm -f $$HOME/tmp_ftn/dcl*.dcl

help:
		@$(SETNAME);$(ORAM)
		@$(WRITE_HELP)

a:
		@echo 'nothing' > /dev/null

FORCE:
		@echo '****************************'
		@echo 'No computer selected.'
		@echo 'You should edit the Makefile.'
		@echo '****************************'
		@(malicek je chytra hlava \
                  kamaradum rady dava \
                  ty jdi sem a ty jdi tam \
                  pockejte az zavolam) 2> /dev/null

BADDIR:
		@$(BADDIR) 

aa:    msg
aaa:     msg
aaaa:     msg
aaaaa:     msg
aaaaaa:     msg
aaaaaaa:     msg
aaaaaaaa:     msg
aaaaaaaaa:     msg
aaaaaaaaaa:     msg
aaaaaaaaaaa:     msg
aaaaaaaaaaaa:     msg
aaaaaaaaaaaaa:     msg
aaaaaaaaaaaaaa:     msg
aaaaaaaaaaaaaaa:     msg
aaaaaaaaaaaaaaaa:     msg
aaaaaaaaaaaaaaaaa:     msg
aaaaaaaaaaaaaaaaaa:     msg
aaaaaaaaaaaaaaaaaaa:     msg
aaaaaaaaaaaaaaaaaaaa:     msg
msg:
		@echo '*******************************'
		@echo 'More than one computer selected'
		@echo 'You should check the makefile.'
		@echo '*******************************'
		@(malicek je chytra hlava \
                  kamaradum rady dava \
                  ty jdi sem a ty jdi tam \
                  pockejte az zavolam) 2> /dev/null

PRECIOUS:      pwdlib.a janalib.a glib.a fg.a pictur.a datred.a 
 


