tags:

views:

25

answers:

1

Hello,

I've got a Makefile which has a couple of targets (all, install, uninstall). I'm trying to use the $JAVA_HOME environment variable, which works perfect in the all target, but when the install target is executed, the $JAVA_HOME variable seems to be empty (although it is not - I have checked in the terminal). Does anyone have any ideas?

all:
        # This works good
        @echo ${JAVA_HOME}


ifeq ($(UNAME), Linux)
install:
        # This prints a blank line.
        @echo ${JAVA_HOME}
        # Doing stuff here

uninstall:
        # Doing stuff here
endif


Thanks,
Chris

A: 

I don't see a problem with what you have posted, but the way you set up JAVA_HOME before calling make may be the contributing factor. Are you using export to create the environment variable? If not, the make process might not be inheriting that part of the environment.

Yep, I'm using the following line, by putting it in the /etc/profile file:export JAVA_HOME=/usr/lib/jvm/jdk1.5.0_22
Chrisc
Ok, I think my problem is arising because I am running the "install" target as "sudo" and the all target as a normal user.
Chrisc