From c24c333d394baa15cab10f82669a8c1ea54247d5 Mon Sep 17 00:00:00 2001 From: "John S. Urban" Date: Fri, 18 Nov 2022 23:40:22 -0500 Subject: [PATCH] ifort shared build --- README.md | 3 +++ src/Makefile | 27 ++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2956898a..e0b16b97 100755 --- a/README.md +++ b/README.md @@ -118,6 +118,9 @@ These demo programs provide templates for the most common usage: ``` and everything needed by gfortran will be placed in libgfortran/ that you may add to an appropriate area, such as $HOME/.local/lib/gfortran/. +```bash + make clean ifort ifort_install # same for ifort +``` NOTE: These instructions are very likely to change and to include instructions for other compilers, especially for shared libraries diff --git a/src/Makefile b/src/Makefile index 0e6f0523..c79ffb77 100755 --- a/src/Makefile +++ b/src/Makefile @@ -44,7 +44,7 @@ nvfortran: all @echo built with $(F90) ifort: F90=ifort -ifort: FCFLAGS := -warn all -traceback +ifort: FCFLAGS := -warn all -traceback -fpic ifort: all @echo built with $(F90) @@ -81,7 +81,26 @@ gfortran_install: $(OBJS) # put directory in load path and run using shared version env LD_LIBRARY_PATH=libgfortran/:${LD_LIBRARY_PATH} ./hello_shared # show one is static and other needs shared library - ldd hello_shared hello_static + -env LD_LIBRARY_PATH=libgfortran/:${LD_LIBRARY_PATH} ldd hello_shared hello_static +ifort_install: $(OBJS) + # very Linux/Unix/BSD/.. specific and just for ifort + mkdir -p libifort/ + # static library and modules + $(AR) $(ARFLAGS) libifort/libM_CLI2.a $^ + cp *.mod libifort/ + # shared library + ifort -shared -o libifort/lib$(LIB).so.1 $(OBJS) + cd libifort && ln -sf lib$(LIB).so.1 lib$(LIB).so + @echo example static build + ifort -static sample/hello.f90 -Llibifort -lM_CLI2 -o hello_static + ./hello_static + + @echo example shared build + ifort sample/hello.f90 -Llibifort -lM_CLI2 -o hello_shared + # put directory in load path and run using shared version + env LD_LIBRARY_PATH=libifort/:${LD_LIBRARY_PATH} ./hello_shared + # show one is static and other needs shared library + -env LD_LIBRARY_PATH=libifort/:${LD_LIBRARY_PATH} ldd hello_shared hello_static .SUFFIXES: $(SUFFIXES) .f90 .F90 .f90.o: @@ -96,7 +115,8 @@ help: : # OPTIONS: # : # run -- run manpage demo programs # : # test -- run test programs # - : # gfortran_install -- place static and shared library in ./lib for gfortran # + : # gfortran_install -- place static and shared library in ./libgfortran # + : # ifort_install -- place static and shared library in ./libifort # : ############################################################################### : # man -- show all manpages as text # : # ship -- rebuild archive files of manpages # @@ -110,6 +130,7 @@ help: : # make clean # : # make ifort run # : # make clean gfortran gfortran_install # create libgfortran/ # + : # make clean ifort ifort_install # create libifort/ # : ############################################################################### .PHONY: clean