bruvio
bruvio

Reputation: 1093

make: *** No rule to make target - gfortran

I am trying to compile a code - this code uses a few libraries and for starters I am trying to create a makefile to get one library I am having difficulties. this is the makefile

HOME        = $(shell pwd)
LIBNA       = libbv.a
LIBZP       = $(HOME)/$(LIBNA)

# FFLAGC      = -Mextend -Msave -g -C -Mchkfpstk -Mchkptr -fpic -Ktrap=fp


FC = gfortran
 ifeq ($(OSTYPE),linux)
        FC = pgf95 -Msave -fpic
 endif

# per il gfortran
 FFLAGC      = -g -Wall-ffixed-line-length-0 -Mextend -Msave -g -C -Mchkfpstk -Mchkptr -fpic -Ktrap=fp

# FC = gfortran
#

SOURCE = \
filename1.f\
filename2.f\
...
filenamen.f


.SUFFIXES: .f




OBJ = $(SRCS:.f=.o)

.f.o:
    $(FC) $(FFLAG)   -c   $< $@


$(LIBZP): $(LIBZP)($(OBJ))
    ar -r $(LIBZP) $?
    rm -f $?

this is the makefile I am using. I get the error

make: *** No rule to make target absolutepath/libbv.a()', needed by absolute_path/libbv.a'. Stop.

I was wondering if any of you can help

Upvotes: 2

Views: 2034

Answers (1)

MadScientist
MadScientist

Reputation: 100836

Well, your error message shows this:

absolutepath/libbv.a()

with nothing inside the parentheses. But your makefile has this:

$(LIBZP): $(LIBZP)($(OBJ))

with $(OBJ) in the parentheses. So clearly, $(OBJ) is expanding to the empty string. Why is that?

Well, OBJ is set here:

OBJ = $(SRCS:.f=.o)

based on SRCS. Well, what does that variable contain?

Aha. Nothing, because it's never set. You set this though:

SOURCE = \
    ...

SOURCE != SRCS, so you're modifying an empty variable and OBJ is the empty string.

I'm not sure why you're prefixing the target with the current directory... that's where it will go by default if you don't specify any directory. In any event, you can use $(CURDIR) rather than running $(shell pwd).

If you're going to use GNU make anyway, I recommend you use pattern rules rather than suffix rules: they're much simpler to read/understand:

%.o : %.f
        $(FC) $(FFLAG) -c $< $@

Also don't you need a -o here before $@? I don't use Fortran compilers but I would imagine they work more or less the same as C/C++ compilers.

Upvotes: 3

Related Questions