用于屏幕输出中空行的linux Makefile语法

时间:2015-12-18 05:54:46

标签: linux makefile screen

我有这个makefile:

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>

我要做的是在“提示>制作”和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...

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

您应该在'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}"