我相信我的Makefile(编译Fortran代码)所使用的cpp预处理器有问题。我最近更改了操作系统,现在编译无法正常工作,而且我对Makefiles或预处理器的了解不足以解决该问题(Makefile是很多年前提供给我的)。
我最近从Fedora 10更新到Fedora 19(是的,应该早些做)。将代码复制到新系统并运行gmake后,我发现编译存在问题。据我了解,应该发生的事情是我的.F文件已经过预处理并写为.f文件。显然,cpp预处理器现在正在添加某种GNU免责声明(“ / *版权所有(C)1991-2012自由软件基金会,该文件是GNU C库的一部分。”。),编译器( f77)不喜欢。原则上,我可以从每个生成的.f文件中删除此文本,但是严重的是,这花费了太多时间。
我真的不知道是什么原因造成的。我想告诉cpp不要输出此文本,或者f77忽略它,但是还没有找到管理此文本的任何标志。考虑重新编写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 $@
$(FC) -o $@ $(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) $< > $@
%.o:%.f
@echo Compiling ... $<
@$(FC) $(FFLAGS) -o $@ $<
%.d:%.F
@touch $@
@echo Updating ... $@
@makedepend -- $(CPPFLAGS) -- $< -f $@
@-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
我认为问题出-C
在CPPFLAGS
变量中。的手册页cpp
指出,这会使预处理器不放弃注释。我不想要你 删除该标志。
另一个要点:您永远不想MAKE
在makefile中设置变量。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句