3

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.

3 Answers 3

2

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 "\n\n\n\n Makefile written for the compiler version ${COMPILER_VERSION}"
0

thanks a bunch, that worked. your

linux: ECHO $(TARGET)

worked great, only thing i did different than what you typed was this syntax for ECHO: which i placed at the bottom of the makefile. It allowed me to space out the screen output exactly how i wanted it.

ECHO:
    @echo
    @echo "Makefile written for compiler version ${COMPILER_VERSION}"
    @echo
1
  • If he answered your question, you should accept the answer.
    – Ziffusion
    Commented Dec 21, 2015 at 4:14
0

You can use echo with flag -e

@echo -e "\n"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.