2013-10-24 27 views
3

我相信我的Makefile(編譯Fortran代碼)使用的cpp預處理器存在問題。我最近更改了操作系統,現在編譯不起作用,並且我對Makefiles或預處理器無法修復它(Makefile是在很多年前給了我的)。cpp預處理器爲Fortran編譯器添加不需要的文本

我最近從Fedora 10更新到Fedora 19(是的,應該早點這麼做)。在將我的代碼複製到新系統並運行gmake之後,我發現我遇到了編譯問題。從我所瞭解的情況來看,應該發生的事情是我的.F文件被預處理並寫爲.f文件。顯然,cpp預處理器現在增加了一些GNU免責聲明(「/ * Copyright(C)1991-2012 Free Software Foundation,Inc.此文件是GNU C Library的一部分....」),編譯器f77)不喜歡。原則上,我可以從每個生成的.f文件中清除此文本,但是嚴重的是,這需要太多時間。

我真的不知道問題的原因是什麼。我想告訴cpp不輸出這個文本,或者f77忽略它,但是還沒有找到管理它的任何標誌。考慮重新編寫Makefile(例如使用更現代的編譯器),但目前我對此有點無望。希望有人能幫助我。我正在複製下面的Makefile以及輸出。

在此先感謝。


的Makefile


# Make sure the SHELL is right 
SHELL = /bin/sh 
MAKE = gmake 

# Define several root directories  
LEP_ROOT := /home/stilgar/SUSY/NeutrinoModel2 
CERN_ROOT := /usr/lib64/cernlib/2006 
INCLUDES := $(LEP_ROOT)/include 
INCLUDES := $(strip $(INCLUDES)) 
incpath  := $(subst $(space),:,$(INCLUDES)) 

vpath %.inc $(incpath) 

# Define tree  
BIN_DIR := $(LEP_ROOT)/bin 

# Define source directory 
SRCDIR := $(LEP_ROOT)/src 

# Libraries 
libs := $(CERN_ROOT)/lib 
libs := $(addprefix -L, $(libs)) 
libs += `cernlib packlib,mathlib,packlib,kernlib` 

#Source files 
#Main Program 
src_files += $(wildcard $(SRCDIR)/main_lfv.F) 
#SM Parameters 
src_files += $(wildcard $(SRCDIR)/param_basic.F) 
src_files += $(wildcard $(SRCDIR)/numajmass.F) 
#SUSY Spectrum 
src_files += $(wildcard $(SRCDIR)/texture2.F) 
src_files += $(wildcard $(SRCDIR)/minserts.F) 
#SUSY Flavour 
src_files += $(wildcard $(SRCDIR)/gmin2.F) 
src_files += $(wildcard $(SRCDIR)/lfv.F) 
#Bounds 
src_files += $(wildcard $(SRCDIR)/experiment.F) 
src_files += $(wildcard $(SRCDIR)/directsearch.F) 
#Loop Functions 
src_files += $(wildcard $(SRCDIR)/fedm.F) 
src_files += $(wildcard $(SRCDIR)/gedm.F) 
#Mathematical Tools 
src_files += $(wildcard $(SRCDIR)/biunitary3.F) 

main_obj_files += $(src_files:%.F=%.o) 
main_ofiles += $(notdir $(main_obj_files)) 
main_files  += $(src_files:%.F=%.f) 
depend   += $(main_obj_files:.o=.d) 

# Name of the executable to be created 
exectry := $(BIN_DIR)/RunStuff 

# Define flags 
FC = f77 
#FC = gfortran 
#FC = g95 
FFLAGS += -c 
FFLAGS += $(addprefix -I, $(INCLUDES)) 

# Define cpp options 
CPP = cpp 
CPPFLAGS += -C -P -E 
CPPFLAGS += $(addprefix -I, $(INCLUDES)) 

.PHONY : all clean cleanall help 
.PHONY : sclean 

all: $(exectry) 

$(exectry): $(main_obj_files) $(main_files) 
@echo '===================================================' 
@echo ' Building executable ' $(exectry) 
@echo ' ' 
@-rm -f [email protected] 
$(FC) -o [email protected] $(main_obj_files) $(LFLAGS) $(libs) 
@echo ' Done ' 
@echo '===================================================' 

clean : sclean 
@echo 
@echo Cleaning up *.o *~ core 
@echo 
@-rm -f *.o core 
@echo done. 
sclean : 
@find . -name "*.bak" -exec rm -f '{}' ';' 
@find . -name "*~" -exec rm -f '{}' ';' 
@find . -name "#*#"    -exec rm -f '{}' ';' 

cleanall : 
@echo '**********************************************************' 
@echo ' Clean all : ' 
@find . -name "*.bak" -exec rm -f '{}' ';' 
@find . -name "*~" -exec rm -f '{}' ';' 
@find . -name "*.log"   -exec rm -f '{}' ';' 
@find . -name "*.out"   -exec rm -f '{}' ';' 
@find . -name "core"   -exec rm -f '{}' ';' 
@find . -name "#*#"    -exec rm -f '{}' ';' 
@-rm -f *.o *.d 
@echo done. 
@echo '**********************************************************' 
help: 
@echo 
@echo ' The possible options are :' 
@echo ' ======================== ' 
@echo 
@echo ' gmake   -- build batch executable' 
@echo ' gmake sclean -- simple clean up '  
@echo ' gmake clean -- clean up a bit more ' 
@echo ' gmake cleanall -- clean everything' 
@echo 

%.f:%.F 
@echo Preprocessing ... $< 
@$(CPP) $(CPPFLAGS) $< > [email protected] 

%.o:%.f 
@echo Compiling ... $< 
@$(FC) $(FFLAGS) -o [email protected] $< 

%.d:%.F 
@touch [email protected] 
@echo Updating ... [email protected]   
@makedepend -- $(CPPFLAGS) -- $< -f [email protected] 
@-rm [email protected] 

輸出


Preprocessing ... /home/stilgar/SUSY/NeutrinoModel2/src/main_lfv.F 
Compiling ... /home/stilgar/SUSY/NeutrinoModel2/src/main_lfv.f 
/home/stilgar/SUSY/NeutrinoModel2/src/main_lfv.f:2: 
     This file is part of the GNU C Library. 
    ^
Non-numeric character at (^) in label field [info -f g77 M LEX] 
/home/stilgar/SUSY/NeutrinoModel2/src/main_lfv.f:4: 
     The GNU C Library is free software; you can redistribute it and/or 
    ^
Non-numeric character at (^) in label field [info -f g77 M LEX] 
/home/stilgar/SUSY/NeutrinoModel2/src/main_lfv.f:5: 
     modify it under the terms of the GNU Lesser General Public 
    ^
Non-numeric character at (^) in label field [info -f g77 M LEX] 

(...) 

gmake: *** [/home/stilgar/SUSY/NeutrinoModel2/src/main_lfv.o] Error 1 

回答

3

我認爲這個問題是-C OPTI在CPPFLAGS變量。 cpp的手冊頁說這會導致預處理器不放棄註釋。我不認爲你想要那樣。刪除該標誌。

另一個nit:你從來沒有想要在你的makefile中設置MAKE變量。

+0

哦,其實是。我嘗試刪除之前,但這次我繼續前刪除所有的.f文件。不過,我仍然有錯誤,請讓我在一秒鐘內回覆您。 – Stilgar

+0

是的,錯誤現在與其他東西相關聯,所以我猜這個問題已經得到解答。還從Makefile中刪除MAKE,非常感謝! – Stilgar