From 3aa4abcba9e629d5877a137c99bc06ae71d6e0f0 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 12 Sep 2015 17:08:49 +0200 Subject: [PATCH] add Fortran demo --- hermit/Makefile | 4 ++++ hermit/usr/examples/Makefile | 17 ++++++++++++++--- hermit/usr/examples/hellof.f90 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 hermit/usr/examples/hellof.f90 diff --git a/hermit/Makefile b/hermit/Makefile index b89472707..6f4e57393 100644 --- a/hermit/Makefile +++ b/hermit/Makefile @@ -14,6 +14,7 @@ QEMU = qemu-kvm -cpu host CROSSCOMPREFIX = x86_64-hermit- STACKPROT = -fno-stack-protector +FC_FOR_TARGET = $(CROSSCOMPREFIX)gfortran CC_FOR_TARGET = $(CROSSCOMPREFIX)gcc CXX_FOR_TARGET = $(CROSSCOMPREFIX)g++ GCC_FOR_TARGET = $(CROSSCOMPREFIX)gcc @@ -58,6 +59,7 @@ KEEP_DEBUG = --only-keep-debug OUTPUT_FORMAT = -O elf32-i386 CFLAGS_FOR_NEWLIB = -m64 -mtls-direct-seg-refs -ftls-model=initial-exec -O3 #-mavx2 -mfma -mtune=intel #$(STACKPROT) +FFLAGS_FOR_NEWLIB = -O3 CXXFLAGS_FOR_NEWLIB = LDFLAGS_FOR_NEWLIB = NASMFLAGS_FOR_NEWLIB = -felf64 @@ -80,9 +82,11 @@ toolchain: $Q$(MAKE) ARCH=$(ARCH) \ LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_NEWLIB)" \ CFLAGS_FOR_TARGET="$(CFLAGS_FOR_NEWLIB)" \ + FFLAGS_FOR_TARGET="$(FFLAGS_FOR_NEWLIB)" \ CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_NEWLIB)" \ NASMFLAGS="$(NASMFLAGS_FOR_NEWLIB)" \ CC_FOR_TARGET=$(CC_FOR_TARGET) \ + FC_FOR_TARGET=$(FC_FOR_TARGET) \ CXX_FOR_TARGET=$(CXX_FOR_TARGET) \ GCC_FOR_TARGET=$(GCC_FOR_TARGET) \ AR_FOR_TARGET=$(AR_FOR_TARGET) \ diff --git a/hermit/usr/examples/Makefile b/hermit/usr/examples/Makefile index f06cf84b6..3f8c93cc4 100644 --- a/hermit/usr/examples/Makefile +++ b/hermit/usr/examples/Makefile @@ -37,9 +37,13 @@ endif @echo [CXX] $@ $Q$(CXX_FOR_TARGET) -c $(CXXFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< +%.o: %.f90 + @echo [F90] $@ + $Q$(FC_FOR_TARGET) -c $(FFLAGS_FOR_TARGET) -o $@ $< + default: all -all: hello hello++ jacobi stream thr_hello +all: hello hello++ hellof jacobi stream thr_hello stream.o: stream.c @echo [CC] $@ @@ -66,6 +70,13 @@ hello: hello.o $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ $Qchmod a-x $@.sym +hellof: hellof.o + @echo [LD] $@ + $Q$(FC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(FFLAGS_FOR_TARGET) -o $@ $< + $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym + $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qchmod a-x $@.sym + jacobi: jacobi.o @echo [LD] $@ $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -lm @@ -86,11 +97,11 @@ thr_hello: thr_hello.o clean: @echo Cleaning examples - $Q$(RM) hello hello++ jacobi stream thr_hello *.sym *.o *~ + $Q$(RM) hello hello++ hellof jacobi stream thr_hello *.sym *.o *~ veryclean: @echo Propper cleaning examples - $Q$(RM) hello hello++ jacobi stream thr_hello *.sym *.o *~ + $Q$(RM) hello hello++ hellof jacobi stream thr_hello *.sym *.o *~ depend: $Q$(CC_FOR_TARGET) -MM $(CFLAGS_FOR_TARGET) *.c > Makefile.dep diff --git a/hermit/usr/examples/hellof.f90 b/hermit/usr/examples/hellof.f90 new file mode 100644 index 000000000..0fa6ed8ac --- /dev/null +++ b/hermit/usr/examples/hellof.f90 @@ -0,0 +1,30 @@ +! +! Copyright (c) 2015, Stefan Lankes, RWTH Aachen University +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions are met: +! * Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! * Neither the name of the University nor the names of its contributors +! may be used to endorse or promote products derived from this +! software without specific prior written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +! DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! + +program hellof + print *, "HelloWorld from gfortran!" +end program hellof