#
# platform_specific_includes.mk.i386-linux
#
# This file is included in other Makefiles and defines
# platform specific macros

	GKS_INCLUDES = \
		-I../../ppl/include/xgks \
		-I../../xgks/src/lib \
		-Ipplinc/xgks \
		-I../../xgks/port 

	INCLUDES = \
		-I. \
		-I../../fmt/cmn \
		-I../common \
		-I../../ppl/include \
		-I../../fer/common \
		$(GKS_INCLUDES) \
		-I$(READLINE_DIR)/include \
		-I$(NETCDF4_DIR)/include \
		-I/usr/local/include

	FINCLUDES = \
		-I../../ppl/tmap_inc \
		-I../include \
		-I../../fmt/cmn \
		-I../common \
		-I../../ppl/include \
		-I../../fer/common

	PLATFORM = $(shell uname -s -r) 32-bit

	CC = gcc
	FC = gfortran
	F77 = gfortran

	RANLIB = /usr/bin/ranlib

	CPP = /lib/cpp

	CPP_FLAGS = \
		$(INCLUDES) \
		-m32 \
		-fPIC \
		-Dunix \
		-Dgfortran \
		-DNO_OPEN_SHARED \
		-DNO_OPEN_RECORDTYPE \
		-DX_REFRESH \
		-Dreclen_in_bytes \
		-DNO_OPEN_READONLY \
		-DMANDATORY_FORMAT_WIDTHS\
		-DNO_OPEN_CARRIAGECONTROL \
		-Dxgks \
		-DSTAR_1_SUPPORTED \
		-DFULL_GUI_VERSION \
		-DX_REFRESH \
		-DXT_CODE \
		-DLINUX \
		-DNO_PASSED_CONCAT \
		-Dcrptd_cat_argument \
		-DG77_SIGNAL \
		-DG77 \
		-DNEED_IAND \
		-DNO_PREPEND_STRING \
		-DNO_DOUBLE_ESCAPE_SLASH \
		-Ddouble_p 


# Flags for compiling all C code
	CFLAGS = \
		$(CPP_FLAGS) \
		-Dlint \
		-DVOID_SIGHANDLER \
		-D_POSIX_VERSION \
		-DLINUX \
		-DFULL_GUI_VERSION \
		-DX_REFRESH \
		-DXT_CODE 

# Flags for compiling the PlotPlus FORTRAN code (ppl subdirectory)
	PPLUS_FFLAGS = \
		$(CPP_FLAGS) \
		-fno-automatic \
		-DFORTRAN_90 \
		-fno-second-underscore \
		-fdollar-ok \
		-ffixed-line-length-132 \
		$(FINCLUDES)

# Flags for compiling non-PlotPlus FORTRAN code
	FFLAGS = \
		$(CPP_FLAGS) \
		-fno-automatic \
		-DFORTRAN_90 \
		-fno-second-underscore \
		-fdollar-ok \
		-ffixed-line-length-132 \
		-fdefault-real-8 \
		-fdefault-double-8 \
		-fimplicit-none \
		$(FINCLUDES)

	OPT_FLAGS	= -O -DNDEBUG
	PPLUS_OPT_FLAGS	= -O0
	DBG_FLAGS	= -O0 -g
	PROF_FLAGS	= -O0 -g -pg

	# Below this line are macro definitions used only for the final linking of the executable
	#

	LD = gcc

	LDFLAGS = \
		-v \
		--verbose \
		-m32 \
		-fPIC \
		-export-dynamic

	SYSLIB = \
		-lX11 \
		-lcurl \
		-ldl \
		-lz \
		-Wl,-Bstatic -lgfortran -Wl,-Bdynamic \
		-lm

# -static-libgfortran can be used with gfortran 4.4 but not 4.1
# /usr/lib/gcc/i386-redhat-linux/4.1.1/libgfortran.a

	GKSLIB = ../xgks/src/lib/libxgks.a

# For netCDF4 using new hdf5 and new zlib

	CDFLIB = \
		$(NETCDF4_DIR)/lib/libnetcdff.a \
		$(NETCDF4_DIR)/lib/libnetcdf.a \
		$(HDF5_DIR)/lib/libhdf5_hl.a \
		$(HDF5_DIR)/lib/libhdf5.a

	LINUX_OBJS = \
		special/linux_routines.o \
		dat/*.o \
		../fmt/src/x*.o \
		../ppl/plot/ppldata.o

# For statically linking in the readline and history libraries
#	READLINELIB = -L$(READLINE_DIR)/lib -Wl,-Bstatic -lreadline -lhistory -Wl,-Bdynamic
# For linking against the shared-object libraries (if they exist)
	READLINELIB = -L$(READLINE_DIR)/lib -lreadline -lhistory

## cancel the default rule for .f -> .o to prevent objects from being built
## from .f files that are out-of-date with respect to their corresponding .F file
#%.o : %.f
#
## use cpp to preprocess the .F files to .f files and then compile the .f files
#%.o : %.F
#	rm -f $*.f
#	$(CPP) -P -traditional $(CPP_FLAGS) $(<F) | sed -e 's/de    /de /g' | sed -e 's/de         /de /g' > $*.f
#	$(F77) $(FFLAGS) -c $*.f	 

# Directly compile the .F source files to the .o object files
# since gfortran can handle the C compiler directives in Fortran code
%.o : %.F
	$(FC) $(FFLAGS) -c $*.F -o $*.o

#
# End of platform_specific_includes.mk.i386-linux
#

