# Makefile for GNU F77 compiler runtime, libc interface.
# Copyright (C) 1995-1998, 2001 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@

F2C_H_DIR = @srcdir@/..
G2C_H_DIR = ..
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
@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 .lo

.c.lo:
	@LIBTOOL@ --mode=compile $(CC) -c -DSkip_f2c_Undefs $(ALL_CFLAGS) $<

OBJS =  VersionU.lo gerror_.lo perror_.lo ierrno_.lo itime_.lo time_.lo \
	unlink_.lo fnum_.lo getpid_.lo getuid_.lo getgid_.lo kill_.lo rand_.lo \
	srand_.lo irand_.lo sleep_.lo idate_.lo ctime_.lo etime_.lo \
	dtime_.lo  isatty_.lo ltime_.lo fstat_.lo stat_.lo \
	lstat_.lo access_.lo link_.lo getlog_.lo ttynam_.lo getcwd_.lo symlnk_.lo \
        vxttime_.lo vxtidate_.lo gmtime_.lo fdate_.lo secnds_.lo \
	bes.lo dbes.lo \
	chdir_.lo chmod_.lo lnblnk_.lo hostnm_.lo rename_.lo fgetc_.lo fputc_.lo \
        umask_.lo sys_clock_.lo date_.lo second_.lo flush1_.lo mclock_.lo \
	alarm_.lo datetime_.lo
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)
	-rm -f $@.T $@
	objs='$(OBJS)'; for name in $$objs; do \
	  echo libU77/$${name} >> $@.T; done
	mv $@.T $@

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

config.status: configure
	rm -f config.cache
	CONFIG_SITE=no-such-file CC='$(CC)' 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.lo: Version.c
	@LIBTOOL@ --mode=compile $(CC) -c $(ALL_CFLAGS) $(srcdir)/Version.c -o $@

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

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

install uninstall install-strip dist installcheck installdirs:

mostlyclean:
	rm -f *.o *.lo a.out
	rm -rf .libs

clean: mostlyclean
	rm -f config.log ../s-libu77

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
