Leandro Lucarella wrote:
Walter Bright, el 21 de marzo a las 20:07 me escribiste:
Andrei Alexandrescu wrote:
.o on Linux, .obj on Windows.
OBJSUFFIX_win32 = .obj
OBJSUFFIX_linux = .o
...
OS = linux
...
... file$(OBJSUFFIX_$(OS)) ...
I hadn't thought of using macros to generate macros. It's a good idea.

I think it's easier and cleaner to use conditionals:

OS = linux

ifeq ($(OS),linux)
OBJSUFFIX = .o
else ifeq ($(OS),win32)
OBJSUFFIX = .obj
endif

... file$(OBJSUFFIX) ...

Yah, yet it turns out it's easier and cleaner the other way around when you generate entries with define and eval:

################################################################################
define GENERATE
# $1 is OS, $2 is the build
...
endef

$(eval $(foreach B,debug release, $(foreach S,posix win32, $(call
        GENERATE,$S,$B))))

This way in one shot you generate debug and release versions for win32 and posix. (Note that I compile for win32 on linux thwough wine).


Andrei

Reply via email to