[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
findstring & ifeq
From: |
Ken Mankoff |
Subject: |
findstring & ifeq |
Date: |
Wed, 10 May 2006 16:56:34 -0400 (EDT) |
Hi List,
I have a bunch of sources I'm trying to compile... All .f files, but
about 50% use one command and 50% use another...
I'm trying to do conditional compilation using findstring and ifeq
in the makefile, but having errors. Can anyone advise how to best do
this?
The problem I am having is with a simple 'ifeq' command the logic
works (like the example in the manual here) but if I nest a
$(findstring) in the $(ifeq) then no matter what the rule is true...
# this works:
ifeq ("foo","foo")
@echo here
endif
# this works too (nothing printed)
ifeq ("foo","bar")
@echo here
endif
# this works too... If I touch a file in the OBJ list it echos
# the filename if I touch a file NOT in the OBJ list, it echos
# a blank line
%.o: %.f
@echo $(findstring $@,$(OBJ))
# So... why doesn't this work?
%.o: %.f
ifeq ($(findstring $@,$(OBJ)),)
@echo not found
else
@echo found
endif
The Makefile I'm testing is below.
Thanks,
-k.
FC=xlf
FCMP=xlf_r
FFLAGS=-O2 -qmaxmem=-1 -qalias=nostd -qsave -qfloat=strictnmaf -c
FFLAGSMP=-qsmp=omp $(FFLAGS)
# these are single processor source files
SRC = f0.f, f1.f, f2.f, etc...
# these are SMP (distributed)
SRCMP = f0mp.f, f1mp.f, f2mp.f, etc...
# except in reality the filenames are long and complex and I cannot
# just search for the word "mp" in the filename...
OBJ=$(SRC:.f=.o)
OBJMP=$(SRCMP:.f=.o)
SRCS = $(SRC) $(SRCMP) # all sources
OBJS = $(OBJ) $(OBJMP) # all objects
all: foo
foo: $(OBJS)
# ./compile.sh
%.o: %.f
ifeq ($(findstring $@,$(OBJ)),$@)
# search in OBJ (not OBJS or OBJMP) for this file.
@echo single processor
$(FC) $(FFLAGS) $<
else
@echo dual processor
$(FCMP) $(FFLAGSMP) $<
endif
- findstring & ifeq,
Ken Mankoff <=