How to set child process' environment variable in Makefile

bodokaiser

I would like to change this Makefile:

SHELL := /bin/bash
PATH  := node_modules/.bin:$(PATH)

boot:
    @supervisor         \
      --harmony         \
      --watch etc,lib       \
      --extensions js,json      \
      --no-restart-on error     \
        lib

test:
    NODE_ENV=test mocha         \
      --harmony             \
      --reporter spec       \
        test

clean:
    @rm -rf node_modules

.PHONY: test clean

to:

SHELL := /bin/bash
PATH  := node_modules/.bin:$(PATH)

boot:
    @supervisor         \
      --harmony         \
      --watch etc,lib       \
      --extensions js,json      \
      --no-restart-on error     \
        lib

test: NODE_ENV=test
test:
    mocha                   \
      --harmony             \
      --reporter spec       \
        test

clean:
    @rm -rf node_modules

.PHONY: test clean

Unfortunately the second one does not work (the node process still runs with the default NODE_ENV.

What did I miss?

MadScientist

Make variables are not exported into the environment of processes make invokes... by default. However you can use make's export to force them to do so. Change:

test: NODE_ENV = test

to this:

test: export NODE_ENV = test

(assuming you have a sufficiently modern version of GNU make >= 3.77 ).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to set environment variables in makefile?

From Dev

Is it possible to set environment variable through a makefile?

From Java

How to get a shell environment variable in a makefile?

From Java

How to set GOPRIVATE environment variable

From Dev

How to set an integer as a environment variable?

From Dev

How to set environment variable in java

From Dev

How to set the environment variable in tox?

From Dev

How to permanently set an environment variable

From Dev

How to set environment variable permanently?

From Dev

Defaulting an environment variable in a makefile

From Dev

How to set DISPLAY variable for a process?

From Dev

How to conditionally set Makefile variable to something if it is empty?

From Dev

How to conditionally set Makefile variable to something if it is empty?

From Dev

Makefile: How to export environment variable to shell before target?

From Dev

Makefile set variable in target

From Dev

Linux MAKEFILE access environment variable

From Dev

Start process with environment variable

From Dev

Start process with environment variable

From Dev

How to set the environment variable of zerobrane studio

From Dev

appveyor - how to set environment variable using %HOMEPATH%

From Dev

How do I set an environment variable?

From Dev

How to set environment variable for gulp-jasmine

From Dev

How to set environment variable using Chef?

From Dev

How to set system environment variable in C#?

From Dev

How set environment variable on capistrano deploy?

From Dev

How to set an environment variable in maven depending on the OS

From Dev

How to set the PATH environment variable for JVM

From Dev

How to set Jenkins environment variable from script

From Dev

How to set and retrieve environment variable in Python

Related Related

  1. 1

    How to set environment variables in makefile?

  2. 2

    Is it possible to set environment variable through a makefile?

  3. 3

    How to get a shell environment variable in a makefile?

  4. 4

    How to set GOPRIVATE environment variable

  5. 5

    How to set an integer as a environment variable?

  6. 6

    How to set environment variable in java

  7. 7

    How to set the environment variable in tox?

  8. 8

    How to permanently set an environment variable

  9. 9

    How to set environment variable permanently?

  10. 10

    Defaulting an environment variable in a makefile

  11. 11

    How to set DISPLAY variable for a process?

  12. 12

    How to conditionally set Makefile variable to something if it is empty?

  13. 13

    How to conditionally set Makefile variable to something if it is empty?

  14. 14

    Makefile: How to export environment variable to shell before target?

  15. 15

    Makefile set variable in target

  16. 16

    Linux MAKEFILE access environment variable

  17. 17

    Start process with environment variable

  18. 18

    Start process with environment variable

  19. 19

    How to set the environment variable of zerobrane studio

  20. 20

    appveyor - how to set environment variable using %HOMEPATH%

  21. 21

    How do I set an environment variable?

  22. 22

    How to set environment variable for gulp-jasmine

  23. 23

    How to set environment variable using Chef?

  24. 24

    How to set system environment variable in C#?

  25. 25

    How set environment variable on capistrano deploy?

  26. 26

    How to set an environment variable in maven depending on the OS

  27. 27

    How to set the PATH environment variable for JVM

  28. 28

    How to set Jenkins environment variable from script

  29. 29

    How to set and retrieve environment variable in Python

HotTag

Archive