Pages: [1]
|
|
|
Author
|
Topic: How to use CFLAGS when compiling in OSX 10.9.? (Read 4504 times)
|
superbutcherx
*Many bubbles*
Offline
Posts: 116
|
Hullo.
Compiling on UQM-HD on OSX versions 10.4...10.8 has been pretty straightforward using the "CFLAGS="-I/Library/Frameworks/SDL.framework/Headers" ./build.sh uqm config" command.
However, in OSX 10.9., the gcc command has been changed to point to clang, and this leads to the CFLAGS in front of ./build.sh to not work. SDL cannot be found: <command line>:1:10: fatal error: 'SDL/SDL_version.h' file not found
I downloaded real GCC with brew, but it can't complete the build in 10.9 because there are some clang-specific commands in OSX's headers that UQM uses. Those won't compile with GCC.
One way I found to build the sucker was to initiate the build with GCC. And when the configuration was done, abort the build, switch default compiler to clang and continue the build with it. But this just feels stupid.
Could you guys help a poor programmer out? Is there an easier way to do this, like some way of making those CFLAGS work?
|
|
« Last Edit: August 26, 2014, 06:30:21 am by superbutcherx »
|
Logged
|
|
|
|
superbutcherx
*Many bubbles*
Offline
Posts: 116
|
A little less messy way of doing it: Use the real GCC-4.2 to do the ./build.sh uqm config (with CFLAGS)
and then switch to clang and do the ./build.sh uqm install with it.
Still quite horrible, though.
|
|
|
Logged
|
|
|
|
oldlaptop
*Smell* controller
Offline
Posts: 337
|
The compiler switching at least can be done fairly nicely with a build system patch I've had laying around for a while (I've used this for testing with clang on linux, mainly). There's also someplace inside the build system where CFLAGS can be altered if you're desperate; IIRC it's whichever shell script handles the interactive menus. The really good way to handle this would be to add proper OSX (and FreeBSD) support, making the appropriate versions of them them default to using clang directly (I may have a patch for proper FreeBSD support laying around somewhere as well).
This patch is against current UQM git; it does not apply cleanly to v0.7.0, but adaptation should be trivial. The last part is a minor source code change to make a certain compiler- dependent preprocessor macro default to a sane value when it doesn't recognize the compiler; this allows obscure stuff like tcc to build UQM without errror.
diff --git a/sc2/build/unix/config_proginfo_build b/sc2/build/unix/config_proginfo_build index e265527..c6a1a44 100644 --- a/sc2/build/unix/config_proginfo_build +++ b/sc2/build/unix/config_proginfo_build @@ -75,6 +75,47 @@ useGccBuildTools() { BUILDTOOL_LINK_COMMAND="\$PROG_gcc_FILE $EXTRA_PLATFORM_GCC_FLAGS_LINK" BUILDTOOL_LINK_DEPEND='gcc' } + +# Determine C compiler to use based on $CC - options must be fairly consistent +# with gcc. tcc will work if gcc is used for mkdep (comment out lines 5 and 6 +# of useEnvironmentCC) +useEnvironmentCC() { + # These strings will be evaluated later. + BUILDTOOL_PREPROC_C_COMMAND="\$CC -E $EXTRA_PLATFORM_GCC_FLAGS_PREPROC_C" + BUILDTOOL_PREPROC_C_DEPEND="$CC" + + BUILDTOOL_MKDEP_C_COMMAND="\$CC -MM $EXTRA_PLATFORM_GCC_FLAGS_MKDEP_C" + BUILDTOOL_MKDEP_C_DEPEND="$CC" + + BUILDTOOL_COMPILE_C_COMMAND="\$CC -c $EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C" + BUILDTOOL_COMPILE_C_DEPEND="$CC" + + BUILDTOOL_LINK_COMMAND="\$CC $EXTRA_PLATFORM_GCC_FLAGS_LINK" + BUILDTOOL_LINK_DEPEND="$CC" +} + +useEnvironmentCXX() { + BUILDTOOL_PREPROC_CXX_COMMAND="\$CXX -E $EXTRA_PLATFORM_GCC_FLAGS_PREPROC_CXX" + BUILDTOOL_PREPROC_CXX_DEPEND="$CXX" + + BUILDTOOL_MKDEP_CXX_COMMAND="\$CXX -MM $EXTRA_PLATFORM_GCC_FLAGS_MKDEP_CXX" + BUILDTOOL_MKDEP_CXX_DEPEND="$CXX" + + BUILDTOOL_COMPILE_CXX_COMMAND="\$CXX -c $EXTRA_PLATFORM_GCC_FLAGS_COMPILE_CXX" + BUILDTOOL_COMPILE_CXX_DEPEND="$CXX" +} + +useEnvironmentOBJC() { + BUILDTOOL_PREPROC_OBJC_COMMAND="\$OBJC -E $EXTRA_PLATFORM_GCC_FLAGS_PREPROC_OBJC" + BUILDTOOL_PREPROC_OBJC_DEPEND="$OBJC" + + BUILDTOOL_MKDEP_OBJC_COMMAND="\$OBJC -MM $EXTRA_PLATFORM_GCC_FLAGS_MKDEP_OBJC" + BUILDTOOL_MKDEP_OBJC_DEPEND="$OBJC" + + BUILDTOOL_COMPILE_OBJC_COMMAND="\$OBJC -c $EXTRA_PLATFORM_GCC_FLAGS_COMPILE_OBJC" + BUILDTOOL_COMPILE_OBJC_DEPEND="$OBJC" +} + case "$HOST_SYSTEM" in Darwin) EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C='-mmacosx-version-min=10.4 -arch i386' @@ -221,6 +262,20 @@ case "$HOST_SYSTEM" in ;; *) useGccBuildTools + + # Override useGccBuildTools if envvars say so + if [ $CC ] ; then + useEnvironmentCC + fi + + if [ $CXX ] ; then + useEnvironmentCXX + fi + + if [ $OBJC ] ; then + useEnvironmentOBJC + fi + ;; esac case "$HOST_SYSTEM" in @@ -386,6 +441,19 @@ PROG_mingw_gcc_FILE="i686-pc-mingw32-gcc" PROG_mingw_gcc_ACTION="" PROG_mingw_gcc_VERSION='$(i686-pc-mingw32-gcc --version)' +### clang ### +PROG_clang_NAME="Clang/LLVM C/C++/ObjC compiler" +PROG_clang_FILE="clang" +PROG_clang_ACTION="" +PROG_clang_VERSION='$(clang --version)' + +# NOTE: tcc cannot currently do mkdep! You will need to use gcc for mkdep only +# (see useEnvironmentCC) +### tcc ### +PROG_tcc_NAME="Tiny C Compiler" +PROG_tcc_FILE="tcc" +PROG_tcc_ACTION="" +PROG_tcc_VERSION='$(tcc -v)' ############################################################################## # Describe the libaries (possibly) used: # diff --git a/sc2/src/libs/compiler.h b/sc2/src/libs/compiler.h index 6e795aa..da04b39 100644 --- a/sc2/src/libs/compiler.h +++ b/sc2/src/libs/compiler.h @@ -87,6 +87,10 @@ typedef DWORD (*PDWORDFUNC) (void); # define _PACKED # define _ALIGNED_ANY # define _ALIGNED_ON(bytes) +#else +# define _PACKED +# define _ALIGNED_ANY +# define _ALIGNED_ON(bytes) #endif #if defined(__cplusplus)
|
|
« Last Edit: August 27, 2014, 02:25:09 am by oldlaptop »
|
Logged
|
|
|
|
superbutcherx
*Many bubbles*
Offline
Posts: 116
|
Thanks! I'll try the patch out this evening.
BTW, would you feel like coding some stuff for UQM-HD? There are still some annoyances in the game that are ...annoying.
|
|
|
Logged
|
|
|
|
Pages: [1]
|
|
|
|
|