我有这个生成文件:
SHELL=/bin/bash
COMPILER_VERSION = "Intel 64 Compiler 16.0.0.109 Build 20150815"
SOURCES = \
ron1.f \
ron2.f \
ron3.f \
ron4.f
OBJECTS = $(SOURCES:.f=.o)
TARGET = mylib.a
FC = gfortran
FFLAGS = -O3
linux: $(TARGET)
@echo
@echo " " \
ar r $(TARGET) $(OBJECTS)
@echo
@echo " " \
ranlib $(TARGET)
@echo
$(TARGET): $(OBJECTS)
$(OBJECTS):$(SOURCES)
cleanall:
@echo
rm -f $(OBJECTS) $(TARGET)
@echo
clean:
@echo
rm -f $(OBJECTS)
@echo
.f.o:
@echo " " \
$(FC) -c $(FFLAGS) $*.f
结果如下:
prompt> make cleanall
rm -f ron1.o ron2.o ron3.o ron4.o mylib.a
prompt> make
gfortran -c -O3 ron1.f
gfortran -c -O3 ron2.f
gfortran -c -O3 ron3.f
gfortran -c -O3 ron4.f
ar r mylib.a ron1.o ron2.o ron3.o ron4.o
ranlib mylib.a
prompt>
我想要做的是在“prompt> make”和 gfortran
的第一次发生之间创建一个空间。
理想情况下,我希望屏幕上的输出在第一个 gfortran
发生之前首先打印出我的 COMPILER_VERSION 变量的内容,这样输出看起来像
prompt> make
makefile written for: Intel 64 Compiler 16.0.0.109 Build 20150815
gfortran -c -O3 ron1.f
gfortran -c -O3 ron2.f
gfortran -c -O3 ron3.f
and so on...
非常感谢任何帮助。
最佳答案
您应该向“linux”目标添加一些先决条件,例如此处的“ECHO”:
linux: ECHO $(TARGET)
ar r $(TARGET) $(OBJECTS)
@echo
@echo " " \
ranlib $(TARGET)
@echo
ECHO:
@echo "\n\n\n\n Makefile written for the compiler version ${COMPILER_VERSION}"
关于屏幕输出中空行的linux Makefile语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34349299/