UNIX-like Interface

Lab Exercise
Prerequisites Overview Exercise Solution Cleanup

Prerequisites

You should complete the Unix-like Interface module before starting this lab.


Overview

The goal of this lab exercise is to convert a Unix makefile to one that will run under the cygwin interface in Windows 2000.


Exercise

Starting with the Unix makefile, which you should save in your own directory, convert it to so that you would expect it to run under cygwin in Windows 2000. The Unix version and the solution require files that are not present, so the makefiles will not execute as written. Although this is very similar to the presentation in the talk, a hands on approach may prove beneficial.

Hint: The items in boldface type are the ones that need to be changed.

Specifically they are CPP, CPPFLAGS, FC, CC, FFLAGS, LDFLAGS, LIBS, and SUFFIXES.


Solution

# Makefile for the a program on the Velocity Cluster with the
# Windows 2000 operating system.

# Preprocessor variables
CPP = fpp

# Preprocessor flags
CPPFLAGS = /P /DWINNT /DWPRNG

# Fortran compiler, 2 choices
FC = df
FC = f77

# C Compiler
CC = cl

# Fortran compiler options
FFLAGS = /debug:full /optimize:0 -IInclude -IC:\PROGRA~1\MPIPro\include

# Linker/loader variables. Remember the .exe as part of the executable name.
LDFLAGS = /link /out:mypackage.exe 
 
# The IMSL libs listed are set to LINK_F90.  The specific files are
# "IMSL.LIB IMSLMPISTUB.LIB IMSLS_ERR.LIB" 
LIBS = "IMSL.LIB IMSLMPISTUB.LIB IMSLS_ERR.LIB" 

# Suffix rule definitions
# All three of these need to be here. ".F.f" is necessary for working
# with RCS and GNU make, and ".f.o" and ".F.o" are always necessary. 

# change for NT, .f-->.for, .o-->.obj
.SUFFIXES: .obj .for .F

.F.for:
	 ${CPP} ${CPPFLAGS} $*.F >  $*.for

.for.obj:
	${FC} -c ${FFLAGS} $<

.F.obj:
	${CPP} ${CPPFLAGS} $*.F >  $*.for
	${FC} -c ${FFLAGS} $*.for

objects = a.obj           b.obj           c.obj           d.obj 	  prng.obj

# All rules go below here

mypackage.exe: ${objects} 
	${FC} ${LDFLAGS} ${objects} ${LIBS}

clean:
	rm -f *.obj *.obj


Cleanup

Running this tutorial will leave the following files in your folder:

a UNIX makefile
a converted makefile