Skip to content
Advertisement

linux Makefile syntax for blank lines in screen output

i have this 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

It results the below output:

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>

what i am looking to do is create a space between “prompt> make” and the first happening of gfortran.

and ideally i would like the output on the screen to first print out the contents of my COMPILER_VERSION variable before the first gfortran happens, such that the output would look like

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...

any help much appreciated.

Advertisement

Answer

You should add to the ‘linux’ target some prerequisite like ‘ECHO’ here:

linux: ECHO $(TARGET)
     ar r $(TARGET) $(OBJECTS)
     @echo
     @echo "   " 
     ranlib $(TARGET)
     @echo

ECHO:
     @echo "nnnn Makefile written for the compiler version ${COMPILER_VERSION}"
Advertisement