Mail Archives: djgpp/1996/12/16/10:10:48
I have compiled f2c with djgpp. This is what I have:
djgpp v2.01 = gcc-2.7.2.1
make-3.75
bison 1.24
fileutils-3.13
textutils-1.19
sed (some old version)
f2c version 19950201
You can get all these packages from the standard djgpp distribution.
f2c is in v1apps/f2c95201.zip !
Install all packages. The f2c source gets into
djgpp/contrib/f2c95201/src/
The f2c program is compiled for djgpp v1. It doesn't work on djgpp
v2. Thus you should recompile the package.
Now I had to change a few things in the makefile in the
f2c95201/src/src directory. This is the diff:
36c36
< sed <tokdefs.h "s/#define/%%token/" > gram
---
> sed <tokdefs.h "s/#define/%token/" > gram
43c43
< sed 's/^# line.*/\/* & *\//' gram_tab.c >gram.c
---
> sed "s/^# line.*/\/* & *\//" gram_tab.c >gram.c
Thus, replace the %%token with %token and the single quotes with
double quotes on the appropriate lines.
Now you can go to f2c95201\src and run mk.bat
This compiles everything.
Then install the package using
install d:\djgpp
Then try the package with a test.f fortran file:
f2c test.f
gcc -o test test.c -lf2c -lm
You can also use a makefile to compile fortran files automatically:
I have two examples included how to use this makefile. simple.f is a
simple fortran program. complex.f is a program that calls sub.f.
If you have further questions, please contact me.
----begin makefile-------
# This set of implicit rules makes it possible to transparantly
# use f2c. You can use, e.g.,
# make test.c
# make test.o
# make test
# make test.exe
# Remove old fortran implicit rules
%.o : %.f
%.o : %.F
% : %.f
% : %.F
# Original link rule has highest priority
% : %.o
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
# Implicit rule to compile & link fortran source (create .exe)
%.exe : %.f
f2c $(F2CFLAGS) $<
$(CC) $*.c $(LOADLIBES) -o $@
rm $*.c
# Implicit rule to compile & link fortran source
% : %.f
f2c $(F2CFLAGS) $<
$(CC) $*.c $(LOADLIBES) -o $@
rm $*.c
# Implicit rule to compile fortran source
%.o : %.f
f2c $(F2CFLAGS) $<
$(CC) -c $(CFLAGS) -o $@ $*.c
rm $*.c
# Implicit rule to generate c from fortran
%.c : %.f
f2c $(F2CFLAGS) $<
# F2C Options
# long input lines
F2CFLAGS = -f
# ANSI C
F2CFLAGS += -A
# Needed libraries for f2c
LOADLIBES += -lf2c -lm
# here starts the normal makefile
all: simple complex
clean:
rm -f *.c *.o *.exe simple complex
complex: complex.o sub.o
----end of makefile-------
----
Koen Van Herck
Electronic Design Engineer
E-mail: Koen DOT VanHerck AT barco DOT com
BBBB AAA RRRR CCC OOO B A R C O V I S U A L S Y S T E M S
B B A A R R C O O A division of Barco Projection Systems
B BB A AAA R RR C OO O OO
B B A A R R C O O Noordlaan 5 Tel +32 (0)56 36 85 71
BBBB A A R R CCC OOO B-8520 Kuurne Fax +32 (0)56 36 83 55
- Raw text -