Skip to content

Commit

Permalink
ifort shared build
Browse files Browse the repository at this point in the history
  • Loading branch information
urbanjost committed Nov 19, 2022
1 parent e4258d2 commit c24c333
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 24 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand All @@ -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 #
Expand All @@ -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
Expand Down

0 comments on commit c24c333

Please sign in to comment.