So, I have a makefile that works great. In it I set a variable LD_LIBRARY_PATH_VAL
to contain all the paths to all the libraries that the executable needs.
Now, for convenience I want a rule that sets the LD_LIBRARY_PATH
environment variable by doing: make set_ld_lib_path
, such that I get the following output:
> echo $LD_LIBRARY_PATH
> (empty)
> make set_ld_lib_path
> echo $LD_LIBRARY_PATH
> path/to/lib1:path/to/lib2
Here is my rule as it is at the moment:
# Set the LD_LIBRARY_PATH needed to find all dependant libs - for convinience
LD_LIBRARY_PATH_VAL := test123
.PHONY: set_ld_lib_path
set_ld_lib_path: export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH_VAL)
set_ld_lib_path:
@$(ECHO) "$(COLOUR_ACT)LD_LIBRARY_PATH:$(COLOUR_RST) $$LD_LIBRARY_PATH"
Note: I put the line LD_LIBRARY_PATH_VAL := test123
just to make this a complete example - so I would want to get the output for LD_LIBRARY_PATH to be test123, but in my real makefile this would print a long list of lib paths.
So I have read lots of ways to set / export variables, but I have not found a way to do what I want here. I think it may not be possible because I can't update the variable of the calling shell... but in case it is possible I am asking the question :)
Info update I have gnu make version:
GNU Make 4.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2014 Free Software Foundation, Inc. Licence GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.