0

I want to run this command inside my makefile: export PATH=${PATH}:.

When I run it in the normal command prompt it works, but if I run it inside my makefile it does not.

Here's my makefile:

CC=gcc
CFLAGS=-C

all: P0 
    export PATH=${PATH}:.
P0 : main.o 
    $(CC) -0 P0 main.o

main.o: main.c
    $(CC) $(CFLAGS) main.c

Pretty much I want to use the export command to run the executable P0 without the ./

Is there any other way to do this?

Sarah
  • 25
  • 2
  • 5
  • The problem isn't that it isn't *running*; the problem is that it only affects the single instance of the shell that invokes it; it **doesn't**, and **can't**, affect any other shell started by make (which starts a separate, independent, distinct shell for every shell command it's asked to run), or the parent-process shell that invokes `make` to start with. (That's true everywhere: `sh -c 'export PATH=$PATH:.'` sets an updated PATH, but that updated PATH is discarded when that `sh` copy exits, returning you to your parent shell). – Charles Duffy Feb 22 '17 at 15:23
  • Anyhow, you can set environment variables with make syntax directly. – Charles Duffy Feb 22 '17 at 15:23

0 Answers0