# Makefile for GNU F77 compiler runtime, libc interface.
# Copyright (C) 1995-1998 Free Software Foundation, Inc.
#   Contributed by Dave Love (d.love@dl.ac.uk).
#
#This file is part of the GNU Fortran libU77 library.
#
#The GNU Fortran libU77 library is free software; you can redistribute
#it and/or modify it under the terms of the GNU Library General Public
#License as published by the Free Software Foundation; either version 2,
#or (at your option) any later version.
#
#GNU Fortran is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU Library General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with GNU Fortran; see the file COPYING.  If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#02111-1307, USA.

#### Start of system configuration section. ####

# $(srcdir) must be set to the g77 runtime libU77 source directory
srcdir = @srcdir@
VPATH = @srcdir@

# configure sets this to all the -D options appropriate for the
# configuration.
DEFS = @DEFS@
LIBS = @LIBS@

LIBG2C = ../libg2c.a

F2C_H_DIR = @srcdir@/..
G2C_H_DIR = ..
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
AR = @AR@
ARFLAGS = rc
@SET_MAKE@

SHELL = /bin/sh

#### End of system configuration section. ####

# fio.h is in libI77.  config.h is in `.'.
ALL_CFLAGS = -I. -I$(srcdir) -I$(F2C_H_DIR)/libI77 -I$(G2C_H_DIR) \
             -I$(F2C_H_DIR) $(CPPFLAGS) $(DEFS) $(CFLAGS)

# This could probably be done more elegantly, but it's currently
# just for running the u77-test test.
G77DIR = ../../../gcc/

.SUFFIXES:
.SUFFIXES: .c .o

.c.o:
	$(CC) -c -DSkip_f2c_Undefs $(ALL_CFLAGS) $<

OBJS =  VersionU.o gerror_.o perror_.o ierrno_.o itime_.o time_.o \
	unlink_.o fnum_.o getpid_.o getuid_.o getgid_.o kill_.o rand_.o \
	srand_.o irand_.o sleep_.o idate_.o ctime_.o etime_.o \
	dtime_.o  isatty_.o ltime_.o fstat_.o stat_.o \
	lstat_.o access_.o link_.o getlog_.o ttynam_.o getcwd_.o symlnk_.o \
        vxttime_.o vxtidate_.o gmtime_.o fdate_.o secnds_.o \
	bes.o dbes.o \
	chdir_.o chmod_.o lnblnk_.o hostnm_.o rename_.o fgetc_.o fputc_.o \
        umask_.o sys_clock_.o date_.o second_.o flush1_.o mclock_.o \
	alarm_.o datetime_.o
SRCS =  Version.c gerror_.c perror_.c ierrno_.c itime_.c time_.c \
	unlink_.c fnum_.c getpid_.c getuid_.c getgid_.c kill_.c rand_.c \
	srand_.c irand_.c sleep_.c idate_.c ctime_.c etime_.c \
	dtime_.c isatty_.c ltime_.c fstat_.c stat_.c \
	lstat_.c access_.c link_.c getlog_.c ttynam_.c getcwd_.c symlnk_.c \
        vxttime_.c vxtidate_.c gmtime_.c fdate_.c secnds_.c \
	bes.c dbes.c \
	chdir_.c chmod_.c lnblnk_.c hostnm_.c rename_.c fgetc_.c fputc_.c \
	umask_.c sys_clock_.c date_.c second_.c flush1_.c mclock_.c \
	alarm_.c datetime_.c

all: ../s-libu77

../s-libu77: $(OBJS)
	echo timestamp > ../s-libu77

archive:
	$(AR) $(ARFLAGS) $(LIBG2C) $(OBJS)

Makefile: Makefile.in config.status
	$(SHELL) config.status

config.status: configure
	rm -f config.cache
	CONFIG_SITE=no-such-file CC='$(CC)' AR='$(AR)' CFLAGS='$(CFLAGS)' \
	  CPPFLAGS='$(CPPFLAGS)' $(SHELL) config.status --recheck

${srcdir}/configure: configure.in
	cd ${srcdir} && autoconf

${srcdir}/config.hin: stamp-h.in
${srcdir}/stamp-h.in: configure.in acconfig.h
	cd ${srcdir} && autoheader
	echo timestamp > ${srcdir}/stamp-h.in

config.h: stamp-h
stamp-h: config.hin config.status
	$(SHELL) config.status
	echo timestamp > stamp-h

VersionU.o: Version.c
	$(CC) -c $(ALL_CFLAGS) -o $@ $(srcdir)/Version.c

$(OBJS): $(F2C_H_DIR)/f2c.h $(G2C_H_DIR)/g2c.h config.h
access_.o: access_.c
ctime_.o: ctime_.c
dtime_.o: dtime_.c
etime_.o: etime_.c
fnum_.o: fnum_.c $(F2C_H_DIR)/libI77/fio.h
fstat_.o: fstat_.c
gerror_.o: gerror_.c
getcwd_.o: getcwd_.c
getgid_.o: getgid_.c
getlog_.o: getlog_.c
getpid_.o: getpid_.c
getuid_.o: getuid_.c
idate_.o: idate_.c
ierrno_.o: ierrno_.c
irand_.o: irand_.c
isatty_.o: isatty_.c $(F2C_H_DIR)/libI77/fio.h
itime_.o: itime_.c
kill_.o: kill_.c
link_.o: link_.c
loc_.o: loc_.c
lstat_.o: lstat_.c
ltime_.o: ltime_.c
perror_.o: perror_.c
qsort.o: qsort.c
qsort_.o: qsort_.c
rand_.o: rand_.c
rename_.o: rename_.c
second_.o: second_.c
sleep_.o: sleep_.c
srand_.o: srand_.c
stat_.o: stat_.c
symlnk_.o: symlnk_.c
time_.o: time_.c
ttynam_.o: ttynam_.c
unlink_.o: unlink_.c
wait_.o: wait_.c
vxttime_.o: vxttime_.c
vtxidate_.o: vxtidate_.c
fdate_.o: fdate_.c
gmtime_.o: gmtime_.c
secnds_.o: secnds_.c
bes.o: bes.c
dbes.o: dbes.c
lnblnk_.o: lnblnk_.c
chmod_.o: chmod_.c
chdir_.o: chdir_.c
hostnm_.o: hostnm_.c
rename_.o: rename_.c
fputc_.o: fputc_.c
fgetc_.o: fgetc_.c
sys_clock_.o: sys_clock_.c
umask_.o: umask_.c
flush1_.o: flush1_.c
mclock_.o: mclock_.c
alarm_.o: alarm_.c
datetime_.o: datetime_.c

check:
	-$(G77DIR)g77 -B$(G77DIR) -L.. -g $(srcdir)/u77-test.f -lg2c $(LIBS) -lm && ./a.out
	rm -f a.out

install uninstall install-strip dist installcheck installdirs:

mostlyclean:
	rm -f *.o a.out

clean: mostlyclean
	rm -f config.log

distclean: clean
	rm -f config.cache config.status Makefile config.h stamp.h \
	  ../s-libu77 configure

maintainer-clean:

.PHONY: mostlyclean clean distclean maintainer-clean all check uninstall \
        install-strip dist installcheck installdirs archive
