+ -
当前位置:首页 → 问答吧 → 如何把unix下的makefile改写为linux下的makefile?

如何把unix下的makefile改写为linux下的makefile?

时间:2007-05-15

来源:互联网

我有一程序,原来是在unix下运行的,现在我想在fedora 6下运行它,可是两个系统的makefile的编写规则不一样。这个程序是用fortran编写的,我现在使用f77编译。请高手帮我修改一下,万分感谢。
第一个程序的:
# Makefile for raysum inversion using neighbourhood algorithm.
# Using Sun compilers:
FPP = fpp
F77 = f77
LD = f77
FFLAGS = -fast
LDFLAGS = -fast

# Change this if the raysum code is elsewhere:
RAYSUM_DIR = ../src

RAYSUMFILES = $(RAYSUM_DIR)/readwrite.o $(RAYSUM_DIR)/buildmodel.o \
              $(RAYSUM_DIR)/phaselist.o $(RAYSUM_DIR)/raysum.o \
              $(RAYSUM_DIR)/eigenvec.o $(RAYSUM_DIR)/eispack-cg.o \
              $(RAYSUM_DIR)/matrixops.o $(RAYSUM_DIR)/trace.o \
              $(RAYSUM_DIR)/misfit.o

.f.o: $(RAYSUM_DIR)/params.h na_param.inc
    $(F77) $(FFLAGS) -c $<

default: all

all: na.o raysum_na

raysum_na.f: raysum_na.F
    $(FPP) -DPARAMFILE=\'$(RAYSUM_DIR)/params.h\' raysum_na.F raysum_na.f

raysum_na: $(RAYSUMFILES) na.o raysum_na.o
    $(LD) $(LDFLAGS) -o raysum_na raysum_na.o na.o $(RAYSUMFILES)
    cp raysum_na ../bin

clean:
    /bin/rm -f *.o core raysum_na
-------------
第二个程序的makefile:
# Makefile for raysum programs.
# Using f77 on Sun -- use -C -g when debugging, and -fast otherwise
# -autopar -parallel makes parallel code
F77 = f77
#FFLAGS = -C -g -ftrap=%all,no%inexact
#LDFLAGS = -C -g
FFLAGS = -fast
LDFLAGS = -fast
# Using g77 on Sun or FreeBSD: (add -g for debugging)
# use -O -funroll-loops -m486
#F77 = g77
#FFLAGS = -Wall -O -funroll-loops -m486
#LDFLAGS =
# Using f2c on FreeBSD
#F77 = f77
#FFLAGS = -O -funroll-loops
#LDFLAGS =

EIG = eigenvec.o matrixops.o eispack-cg.o
RAYSUM = raysum.o $(EIG)
IO = readwrite.o
TRACE = phaselist.o buildmodel.o trace.o
MISFIT = misfit.o

# implicit rule for Fortran compilation. Changing the parameter header
# file recompiles everything.
.f.o: params.h
    $(F77) $(FFLAGS) -c $<
        
default: all

all: seis-spread seis-misfit

seis-spread: seis-spread.o $(RAYSUM) $(IO) $(TRACE)
    $(F77) $(LDFLAGS) -o seis-spread seis-spread.o $(RAYSUM) \
                             $(IO) $(TRACE)
    cp seis-spread ../bin
        
seis-misfit: seis-misfit.o $(MISFIT) $(IO)
    $(F77) $(LDFLAGS) -o seis-misfit seis-misfit.o $(MISFIT) $(IO)
    cp seis-misfit ../bin
clean:
    /bin/rm -f *.o *.core seis-spread seis-misfit      

作者: flh81   发布时间: 2007-05-15