Hello,

I try to do a makefile for a program with several sources. It's
working if all sources are in the same folder with the makefile
SRC -> file with all f90 and the makefile
OBJ -> objects directory
MOD -> modules directory

the list of objects is generated as follow
OBJDIR = ../obj
SRCS= \
  ./TYP_DateJJSecPico_mod.f90 \
  main.f90

OBJS= $(SRCS:%.f90=$(OBJDIR)/%.o)

Now, I would like to access sources from different directories as
follows
SRC2 -> directory with the new source file toto.f90
SRC -> same as before
OBJ -> same as before
MOD -> same as before

object list is generated as follows
OBJDIR = ../obj
SRCS= \
  ./TYP_DateJJSecPico_mod.f90 \
  ../SRC2/toto.f90 \                        <=========modif
  main.f90

OBJS= $(SRCS:%.f90=$(OBJDIR)/%.o)
This formulation returns OBJS as follows :
../obj/./TYP_DateJJSecPico_mod.f90
../obj/../SRC2/toto.o

WRONG !! but playing whith $(addprefix $(OBJDIR)/,$(notdir $(OBJS)))
I obtain
../obj/TYP_DateJJSecPico_mod.f90
../obj/toto.o

GOOD but SRCS has been modified and cut the directory path from each
file so my inferences $(OBJDIR)/%.o: %.f90 do not work.

Help please,

Brownie

Reply via email to