# Makefiles, Bash, and the CC variable with Clang++



## wolfspider (Jul 15, 2018)

I have a Makefile, a bash script, and wondering why the $CC variable will not carry over into the bash script when it's defined in the Makefile by default. I'm using the typical thumb drive install of FreeBSD 11 and when running gmake it seems that I have to redefine it in each file. I don't have a global CC variable set up to specify clang++ so what would be a good standard way to set this up that most people would agree upon? Is there a place in the FreeBSD system where this is usually defined for everyone or am I missing something? Sure, there are many ways to accomplish this but I just am interested to know what would be a good way to go about it and make sure its pretty consistent on everybody's system who is running a FreeBSD server.


----------



## SirDice (Jul 16, 2018)

For Bourne shells (that includes Bash) variables need to be exported for 'child' processes to pick them up.


----------



## wolfspider (Jul 16, 2018)

Ok, that sounds fine to me and seemed like the obvious answer. So this issue really comes down to the formatting of the Makefile which is not really compatible with Makefiles for BSD. I've had to run gmake for this and GRPC examples in order to get them to build without writing a separate Makefile for it. Recently made the decision though trying to make everyone happy all at once is not as high a priority. Alright I'll go with that and make it a requisite for building from source- what I'm thinking is "check and see if it's defined and if not define it". Fortunately it's already somewhat written that way. Thanks!


----------

