cvs -d :ext:anoncvs@savannah.gnu.org:/cvsroot/gcc -z 9 co -P \
-rgcc_4_0_1_release gcc
cd gcc
mkdir g95
cd g95
full-path-to-configure/configure --enable-languages=c
./configure --prefix=<installation directory> \
--with-gcc-dir=<path of your GCC directory>
Compile g95 with CFLAGS=-no-cpp-precomp. This prevents the special preprocessor from kicking in and messing things up.
mkdir -p /include/sys /src/G95/gcc/g95
echo "c:/mingw/include/sys /include/sys">>/etc/fstab
echo "PATH=$PATH:/c/GnuWin32/bin">>/etc/profile
exit
# download GCC via CVS
cd /src/G95
CVS_RSH=ssh
export CVS_RSH
cvs -d :ext:anoncvs@savannah.gnu.org:/cvsroot/gcc -z 9 co -P \
-rgcc_4_0_1_release gcc
# configure GCC for G95
cd /src/G95/gcc/g95
/src/G95/gcc/configure --with-gcc \
--with-gnu-ld \
--with-gnu-as \
--host=mingw32 \
--target=mingw32 \
--prefix=/mingw \
--enable-threads \
--disable-nls \
--enable-languages=c \
--disable-win32-registry \
--disable-shared \
--without-x
# build GCC for G95
make
build/gengtype.exe
/src/G95/gcc/gcc/input.h: No such file or directory
make[1]: *** [s-gtype] Error 1
make[1]: Leaving directory `/src/G95/gcc/g95/gcc'
make: *** [all-gcc] Error 2
cp gcc/gtyp-gen.h gcc/gtyp-gen.h.orig
sed -e "s/^\"\/src/\"c:\/msys\/1.0\/src/g" \
gcc/gtyp-gen.h.orig>gcc/gtyp-gen.h
make
cd /src/G95/g95-0.50
./configure --prefix=/usr/local --with-gcc-dir=/src/G95/gcc
mkdir -p /src/G95/gcc/g95
# download GCC via CVS
cd /src/G95
CVS_RSH=ssh
export CVS_RSH
cvs -d :ext:anoncvs@savannah.gnu.org:/cvsroot/gcc -z 9 co -P \
-rgcc_4_0_1_release gcc
# configure GCC for G95
cd /src/G95/gcc/g95
/src/G95/gcc/configure --enable-languages=c \
--disable-nls
# build GCC for G95
make
cd /src/G95/g95-0.50
./configure --prefix=/usr/local --with-gcc-dir=/src/G95/gcc
cd /src/G95/g95-0.50/libf95.a-0.50
./configure --prefix=/usr/local --with-gcc-dir=/src/G95/gcc --with-mingw
rm *.o *.a
make
mkdir /usr/local/lib/gcc-lib/i686-pc-mingw32/4.0.1/
ranlib libf95.a
cp libf95.a /usr/local/lib/gcc-lib/i686-pc-mingw32/4.0.1/
cd /usr/local/lib/gcc-lib/i686-pc-cygwin/4.0.1/
g95 -dumpspecs > specs.0
sed -e '/*startfile:/ {
n
s/%{mno-cygwin:dllcrt2%O%s/%{mno-cygwin:\/usr\/lib\/mingw\/dllcrt2%O%s -L\/usr\/local\/lib\/gcc-lib\/i686-pc-mingw32\/4.0.1 -L\/usr\/lib\/mingw/
s/%{mno-cygwin:crt2%O%s/%{mno-cygwin:\/usr\/lib\/mingw\/crt2%O%s -L\/usr\/local\/lib\/gcc-lib\/i686-pc-mingw32\/4.0.1 -L\/usr\/lib\/mingw/
}' specs.0 > specs
rm specs.0
dmiles@STACK02 /tmp
$ uname
CYGWIN_NT-5.1
dmiles@STACK02 /tmp
$ cat hello.f
program hello
print *,'hello'
end
dmiles@STACK02 /tmp
$ g95 -o hello_cygwin.exe hello.f
dmiles@STACK02 /tmp
$ ./hello_cygwin
hello
dmiles@STACK02 /tmp
$ objdump -x hello_cygwin.exe | grep "DLL Name"
DLL Name: cygwin1.dll
DLL Name: cygwin1.dll
DLL Name: KERNEL32.dll
dmiles@STACK02 /tmp
$ g95 -mno-cygwin -o hello_mingw.exe hello.f
dmiles@STACK02 /tmp
$ ./hello_mingw
hello
dmiles@STACK02 /tmp
$ objdump -x hello_mingw.exe | grep "DLL Name"
DLL Name: msvcrt.dll
DLL Name: msvcrt.dll
DLL Name: KERNEL32.dl
A script to download and unpack the g95 source, and build a version of g95 that uses dlls, has been contributed by Dave Miles.
#!/bin/sh
{
cd /src/G95
rm -fR g95-0.50
wget -O - http://www.g95.org/g95_source.tgz | tar xvfz -
cd g95-0.50
./configure --prefix=/usr/local --with-gcc-dir=/src/G95/gcc
make
tar -zxf libf95.a-0.50.tar.gz &&\
cd libf95.a-0.50 &&\
./configure --prefix=/usr/local --with-gcc-dir=/src/G95/gcc &&\
make
if [ $? != 0 ]
then
exit
fi
make install
mv main.o main.g95
gcc -mdll -o g95.dll \
-Wl,--output-def \
-Wl,g95.def \
-Wl,--out-implib \
-Wl,libf95.dll.a \
-Wl,--export-all-symbols *.o -lws2_32
if [ -f libf95.dll.a ]
then
cp libf95.dll.a /usr/local/lib/gcc-lib/i686-pc-cygwin/4.0.1/
fi
if [ -f g95.dll ]
then
cp g95.dll /bin
fi
cp main.g95 /lib/g95main.o
cd ..
make install
cd ..
} 2>&1 | tee -a bld-g95.log
chmod +x bld-g95.sh
./bld-g95.sh