#
#   Configuration file for linux (32-bit reals).
#
AR      = ar
ARFLAGS = rv
#
LARGE_FILE = -Dlinux -DFOPEN64
#
DEBUG = 
CC      = gcc
CFLAGS  = $(DEBUG) -DLITTLE_ENDIAN -DPOINTER_64 -DINTEGER_IS_INT $(LOCAL_CFLAGS) $(LARGE_FILE)
FASTCFLAGS = $(CFLAGS)
#
FC      = s.f90
FFLAGS = $(DEBUG)  -Dlinux -DLITTLE_ENDIAN -DPOINTER_64 -DINTEGER_IS_INT
#

.SUFFIXES: .o .c .F

.F.o:
	$(FC) $(FFLAGS) -c $<

.c.o:
	$(CC) $(CFLAGS) -c $<
#
#   Sources for libemos/pbio for linux
#

HEADERS      = \
   bufrgrib.h \
   fort2c.h

SOURCES.F    = \
   blokex.F \
   pbbufr.F \
   pbcrex.F \
   pbgrib.F \
   pbionum.F \
   emosnum.F \
   pbpseu.F

SOURCES.f    = 

SOURCES.c    = \
   PBGroutines.c \
   extras.c   \
   fort2c.c   \
   lwsize.c   \
   mvchars.c  \
   pbio.c     \
   readany.c  \
   readbufr.c \
   readcrex.c \
   readgrib.c \
   readnext.c \
   readprod.c \
   recheckLength.c

FASTSRC.c    = \
   gbyte_le.c
#
# Header file dependencies
#
PBGroutines.o: PBGroutines.h
crexrd.o: /usr/include/stdio.h
extras.o: /usr/include/stdio.h
fort2c.o: fort2c.h
gbyte.o: /usr/include/stdio.h /usr/include/limits.h fortint.h
newpbio.o: bufrgrib.h fort2c.h fortint.h /usr/include/sys/types.h /usr/include/sys/stat.h /usr/include/fcntl.h
pbsize.o: /usr/include/stdio.h /usr/include/unistd.h bufrgrib.h fortint.h fileRead.h
readany.o: bufrgrib.h fortint.h fileRead.h
readbufr.o: bufrgrib.h fortint.h fileRead.h
readgrib.o: bufrgrib.h fortint.h fileRead.h sizeRoutines.h
readnext.o: bufrgrib.h fortint.h fileRead.h
readprod.o: bufrgrib.h fortint.h /usr/include/stdio.h /usr/include/unistd.h /usr/include/string.h /usr/include/memory.h fileRead.h sizeRoutines.h
recheckLength.o: /usr/include/stdio.h /usr/include/string.h 
setpar.o: /usr/include/limits.h fortint.h
#
#                                 Makefile for libemos/pbio
#
LIB = gribex
#
LIBRARY      = ../lib/$(EC_ARCH)/lib$(LIB).a
#
#include ../config/config.$(ARCH)$(CNAME)$(R64)$(A64)
#
#include ../options/options_$(ARCH)
#
TARGETS      = all clean
#
#include sources.$(ARCH)
#
OBJECTS.F    = $(SOURCES.F:.F=.o) 
OBJECTS.c    = $(SOURCES.c:.c=.o)
OBJECTS      = $(OBJECTS.F) $(OBJECTS.c)
FASTOBJ.o    = $(FASTSRC.c:.c=.o)
FASTOBJ      = $(FASTOBJ.o)
#
#
.PRECIOUS: $(LIBRARY) 

all: $(LIBRARY)

$(FASTOBJ.o): $(FASTSRC.c)
	$(CC) $(FASTCFLAGS) -c $(FASTSRC.c)

$(LIBRARY): $(OBJECTS) $(FASTOBJ)
	mkdir -p ../lib/$(EC_ARCH)
	$(AR) $(ARFLAGS) $@ $?

#include make.dep

clean:
	\rm -f *.o 
