priitj / whitedb

WhiteDB memory database
http://whitedb.org/
GNU General Public License v3.0
608 stars 78 forks source link

Ensure that all compile*.sh scripts use the CC env var #21

Closed necrophcodr closed 10 years ago

necrophcodr commented 10 years ago

These commits fixes issues where the user would have to edit the simple compilation scripts in order to build with their desired compiler. Now, certain issues may still be present, which is why this pull request should be checked and tested first. For the most part though, it should really just work by running the script, and using a different compiler can easily be specified through the use of the CC environment variable.

For instance, to compile using clang:

CC=clang ./compile.sh
priitj commented 10 years ago

Great, this is exactly the idea I had in mind (and didn't get around doing yet).

Now, there's a couple of things though. '[[' is bash syntax, but I'd really like the scripts to be sh compatible. It's just nicer this way. Also see:

https://wiki.ubuntu.com/DashAsBinSh

Using the COMPILER intermediate variable gives us a nice clean error message. However, I think just running $CC directly would work fine too. It will be very obvious if the compiler is missing, so there is no danger that the user will miss it.

In other words,

[ -z "$CC" ] && CC=cc
${CC} -o file file.c file2.c

What do you think? Simple and surely portable to almost any incarnation of sh.

necrophcodr commented 10 years ago

How about that?

priitj commented 10 years ago

Yep, this looks great. Thank you!