[Top][All Lists]

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

Re: Running specific part of a Makefile under a specific shell

From: Kaz Kylheku (gmake)
Subject: Re: Running specific part of a Makefile under a specific shell
Date: Thu, 10 Feb 2022 17:01:57 -0800
User-agent: Roundcube Webmail/0.9.2

On 2022-02-10 15:15, peter0x44 wrote:
Hi all,
I have a Makefile that is intended for running under both Windows and
Linux, for the raylib library.

This Makefile, under Windows, for the `make clean` target uses the del
builtin command of cmd.exe to delete files.

        del *.o /s
        del lib$(RAYLIB_LIB_NAME).a /s

That doesn't work unless you have .ONESHELL so that the multiple lines
of a recipe are executed as one script.

You probably want del $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a /s,
without any cd.

        del lib$(RAYLIB_LIB_NAME)dll.a /s
        del $(RAYLIB_LIB_NAME).dll /s

However, that the shell is always cmd.exe is a bad assumption on
Windows, as this won't be true if GNU Make finds sh.exe in the PATH,

Therefore, a different variable is probably needed for this.

Somewhere near the top, conditionally define a DEL macro:

  ifneq ($(CONFIG_CMD_EXE),)
  DEL := del $1 /s
  DEL := rm -f $1

then in the clean recipe just

  $(call DEL,*.o)

this CONFIG_CMD_EXE variable is somewhat independent in that
whereas it will always be false (blank, unset) if you're not
building for Windows, it could be true or false if you are building
under Windows.

Somewhere you need to set this configuration variable in a way
which matches the situation: what sort of make installation is being used.

E.g in a config.make file which is included.

reply via email to

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