make-w32
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extending gmake to make it less dependant on the shell


From: Manu
Subject: Re: Extending gmake to make it less dependant on the shell
Date: Thu, 25 Mar 2004 19:25:13 +0100

Matt Lavoie wrote:


> Hi there,
>
> I was wondering if the community has considered extending gnu make to make
> it less dependent on shells.  I work at NVidia corp and recently moved
major
> portions of our build over to gnu make.  With a few exceptions, things are
> working well.  However, an on going issue is the battle of the shells.
>
> Parts of the code base compile under flavors of unix, windows, macos...
It'd
> be great if we could share major portions of the makefiles.  The trouble
is,
> many of the makefiles contain numerous OS and shell specific references.

I had such troubles using MSYS (bash) vs Windows's shell.

To compile under Windows's shell, I run a bat file:

[...]
set DOS=1
%COMSPEC% /K
[...]

Then in my makefile, I've defined a function to fix paths
and defined $(RM) accordingly:

ifeq ($(DOS), 1)
 define FixPath
  $(subst /,\,$(1))
 endef
 RM=del
else
 define FixPath
  $(subst \,/,$(1))
 endef
 RM=rm -f
endif

Usage examples:
$(OBJDIR)/%.o : %.c
 $(MAKEDEPEND) > $(call FixPath,$(DEPDIR)/$*.Po)
 $(COMPILE.c) -c $< -o $@

clean:
 $(RM) $(call FixPath,$(DEPDIR)/*.Po)
 $(RM) $(call FixPath,$(DEPDIR)/*.Pr)
 $(RM) $(call FixPath,$(target))
 $(RM) $(call FixPath,$(OBJDIR)/*.o)
 $(RM) $(call FixPath,$(OBJDIR)/*.res)

$(target): $(addprefix $(OBJDIR)/, $(OBJECTS))
 $(RM) $(call FixPath,$@)
 $(AR) $(ARFLAGS) $@ $^
 $(RANLIB) $@


It's possible to do the same for "echo" and other simple commands
I suppose.
Manu.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]