Page 1 of 1

changing $(PATH) in Makefile has no effect (OS X)

Posted: Thu Jun 10, 2010 1:46 pm
by ischeriad
Hello, I am new to this forum.

I am trying to get the devkitARM to work on OS X 10.6 for GBA development. I have hardly any experience with makefiles and I stumble on what seems a trivial thing. Searching the forums has not helped me. I have installed current Apple Developer Tools, make is GNU Make 3.81.

I have downloaded devkitARM, libgba and gba-expamples and extracted them to /opt/devkitpro/... according to this Getting Started page.

Also I have added these lines to my ~/.profile:

Code: Select all

export DEVKITPRO=/opt/devkitpro
export DEVKITARM=$DEVKITPRO/devkitARM
Now, I have a Makefile which includes the following lines (one example of the Tonc tutorial):

Code: Select all

PATH := $(DEVKITARM)/bin:$(PATH)
PREFIX := arm-eabi-
CC := $(PREFIX)gcc
When executing make, I get the following error:

Code: Select all

make: arm-eabi-gcc: No such file or directory
This is strange, because when I echo the PATH from within the Makefile, it has prepended /opt/devkitpro/devkitARM/bin as desired.

What works is when I prepend the PATH before calling make like this:
$ export PATH=$DEVKITARM/bin:$PATH
$ make
or if I set the PATH in my ~/.profile. But this is only a workaround as I understand it.

The examples of devkitpro (I put them here /opt/devkitpro/examples/gba) compile fine, but I see no reason why the above method does not work.

Thanks.

Re: changing $(PATH) in Makefile has no effect (OS X)

Posted: Thu Jun 10, 2010 7:50 pm
by vuurrobin
I don't know much about how make works with environment variables, but have you tried putting "export PATH := $(DEVKITARM)/bin:$(PATH)" in your makefile?

also, wouldn't it be easier to just take the makefile from the examples?

Re: changing $(PATH) in Makefile has no effect (OS X)

Posted: Thu Jun 10, 2010 11:36 pm
by ischeriad
Yes, I have tried that, it doesn't work.

I would like to understand the difference between the Makefiles, I'm here to learn after all ;).

Re: changing $(PATH) in Makefile has no effect (OS X)

Posted: Sat Jun 12, 2010 1:22 pm
by WinterMute
It's probably best if you show us the whole Makefile you're trying to use, I can't get this to fail on 10.5.

Code: Select all

export PATH	:=	$(DEVKITARM)/bin:$(PATH)

PREFIX	:=	arm-eabi-
CC	:=	$(PREFIX)gcc

all:	gcc_version
	@echo $(PATH)

gcc_version:
	@$(CC) -v

Re: changing $(PATH) in Makefile has no effect (OS X)

Posted: Sat Jun 12, 2010 6:40 pm
by ischeriad
Thank you for your short example, WinterMute. I still don't know why, but it fails with the following error:
$ make
make: arm-eabi-gcc: No such file or directory
make: *** [gcc_version] Error 1
If I modify your example to echo the $(PATH) before executing the compiler, and even show me which compiler it is going to use, I get the following:

Code: Select all

PATH   :=   $(DEVKITARM)/bin:$(PATH)
export PATH

PREFIX   :=   arm-eabi-
CC   :=   $(PREFIX)gcc

all:   gcc_version

gcc_version:
       @echo $(PATH)
       which $(CC)
       @$(CC) -v
$ make
/opt/devkitpro/devkitARM/bin:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin
which arm-eabi-gcc
/opt/devkitpro/devkitARM/bin/arm-eabi-gcc
make: arm-eabi-gcc: No such file or directory
make: *** [gcc_version] Error 1
Of course, /opt/devkitpro/devkitARM/bin/arm-eabi-gcc does exist. This makes absolutely no sense to me.

Re: changing $(PATH) in Makefile has no effect (OS X)

Posted: Fri Jun 18, 2010 3:35 pm
by WinterMute
That's really quite odd, I'm at a bit of a loss to explain this one. It seems like the error may be coming from arm-eabi-gcc rather than make.

How did you extract the devkitARM archive? I've seen some odd issues caused by gui archive tools in the past, it might be worth extracting again using the command line.

Re: changing $(PATH) in Makefile has no effect (OS X)

Posted: Tue Nov 18, 2014 10:15 am
by Parasyte
I just want to bump a really old thread here, and let you know that I have this issue as well (on OS X Yosemite)

Using the minimal example Makefile (above) fails. I have changed the executable name to arm-none-eabi-gcc for recent devkitARM releases.

It works if I set the PATH variable in the command directly:

Code: Select all

export PATH   :=   $(DEVKITARM)/bin:$(PATH)

PREFIX   :=   arm-none-eabi-
CC   :=   $(PREFIX)gcc

all:   gcc_version
    @echo $(PATH)

gcc_version:
    @PATH=$(PATH) $(CC) -v
It also works if I change the shell to /bin/bash (default is /bin/sh)

Code: Select all

export PATH   :=   $(DEVKITARM)/bin:$(PATH)

SHELL := /bin/bash

PREFIX   :=   arm-none-eabi-
CC   :=   $(PREFIX)gcc

all:   gcc_version
    @echo $(PATH)

gcc_version:
    @$(CC) -v
On that note, there is a rule in devkitARM/base_tools that sets the shell variable to /bin/bash for an older version of OSX only: http://sourceforge.net/p/devkitpro/buil ... base_tools

Code: Select all

#---------------------------------------------------------------------------------
# change shell on Snow Leopard
#---------------------------------------------------------------------------------
UNAME_S	:=	$(shell uname -s)
UNAME_R	:=	$(shell uname -r)

ifneq (,$(findstring Darwin,$(UNAME_S)))
	ifneq (,$(findstring 10.8.0,$(UNAME_R)))
		export SHELL=/bin/bash
	endif
endif
I patched my base_tools file locally and now the Makefiles all work as expected:

Code: Select all

#---------------------------------------------------------------------------------
# change shell on Mac OS X
#---------------------------------------------------------------------------------
UNAME_S	:=	$(shell uname -s)

ifneq (,$(findstring Darwin,$(UNAME_S)))
	export SHELL=/bin/bash
endif
WinterMute: Please push this fix upstream? :D