Add C++ support to the build system, from Scott A. Colcord.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3747 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2012-01-15 20:01:20 +00:00
parent e8cfeed54b
commit fc18eebd15
10 changed files with 149 additions and 43 deletions
+52 -38
View File
@@ -10,6 +10,7 @@ uqm_requirements()
{
# Some requirements:
have_build_tools_language C || exit 1
have_build_tools_language CXX || exit 1
have_build_tool LINK || exit 1
case "$HOST_SYSTEM" in
MINGW32*|cegcc)
@@ -108,16 +109,16 @@ uqm_prepare_config()
nodebug_action() {
case "$HOST_SYSTEM" in
WINSCW)
CFLAGS="$CFLAGS -O2 -d NDEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -O2 -d NDEBUG"
;;
ARMV5)
CFLAGS="$CFLAGS -O3 -Otime -DNDEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -O3 -Otime -DNDEBUG"
;;
GCCE)
CFLAGS="$CFLAGS -O3 -DNDEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -O3 -DNDEBUG"
;;
*)
CFLAGS="$CFLAGS -O3 -DNDEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -O3 -DNDEBUG"
;;
esac
DEBUG=0
@@ -127,13 +128,13 @@ uqm_prepare_config()
debug_action() {
case "$HOST_SYSTEM" in
WINSCW)
CFLAGS="$CFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
;;
ARMV5|GCCE)
CFLAGS="$CFLAGS -g -O0 -DDEBUG -D_DEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -DDEBUG -D_DEBUG"
;;
*)
CFLAGS="$CFLAGS -g -O0 -W -Wall -DDEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -W -Wall -DDEBUG"
LDFLAGS="$LDFLAGS -O0"
;;
esac
@@ -144,43 +145,46 @@ uqm_prepare_config()
strictdebug_action() {
case "$HOST_SYSTEM" in
WINSCW)
CFLAGS="$CFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -W all -d DEBUG -d _DEBUG"
;;
ARMV5|GCCE)
CFLAGS="$CFLAGS -g -O0 -DDEBUG -D_DEBUG"
CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -DDEBUG -D_DEBUG"
;;
*)
CFLAGS="$CFLAGS -g -O0 -DDEBUG -W -Wall"
# CFLAGS="$CFLAGS -O1"
CCOMMONFLAGS="$CCOMMONFLAGS -g -O0 -DDEBUG -W -Wall"
# CCOMMONFLAGS="$CCOMMONFLAGS -O1"
# This is needed for -Wunitialized with gcc 3.4
CFLAGS="$CFLAGS -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \
-Wstrict-prototypes -Wmissing-declarations \
CCOMMONFLAGS="$CCOMMONFLAGS -Wcast-qual -Wmissing-declarations \
-Wwrite-strings -Wimplicit -Wreturn-type -Wformat \
-Wswitch -Wcomment -Wchar-subscripts \
-Wparentheses -Wcast-align \
-Wuninitialized"
-Wparentheses -Wcast-align -Wuninitialized"
CFLAGS="$CFLAGS -Wbad-function-cast -Wmissing-prototypes \
-Wstrict-prototypes"
# CFLAGS is for flags not valid in C++.
CFLAGS="$CFLAGS -Wdeclaration-after-statement"
# Until we abandon MSVC 6
# CFLAGS="$CFLAGS -Waggregate-return"
# CCOMMONFLAGS="$CCOMMONFLAGS -Waggregate-return"
# It's not unreasonable to return structs at times.
# CFLAGS="$CFLAGS "-Wpointer-arith"
# CCOMMONFLAGS="$CCOMMONFLAGS "-Wpointer-arith"
# Some standard header won't even compile with this on
# CFLAGS="$CFLAGS -Wshadow"
# CCOMMONFLAGS="$CCOMMONFLAGS -Wshadow"
# This gives absurd conflicts with standard files,
# like from 'y0 and y1'
# CFLAGS="$CFLAGS -Werror"
# CCOMMONFLAGS="$CCOMMONFLAGS -Werror"
# We shouldn't do this until we actually nail them
# all in the original code. Then we can enforce them
# on ourselves.
# CFLAGS="$CFLAGS -pedantic-errors -ansi -trigraphs" # ANSI
# CFLAGS="$CFLAGS -Wnested-externs"
# CCOMMONFLAGS="$CCOMMONFLAGS -pedantic-errors -ansi -trigraphs" # ANSI
# CCOMMONFLAGS="$CCOMMONFLAGS -Wnested-externs"
# We know they're in the code, and though we'd like to
# get rid of them, they're not bugs.
# CFLAGS="$CFLAGS -Winline"
# CCOMMONFLAGS="$CCOMMONFLAGS -Winline"
# This gives too many warnings which we can do nothing
# about, obscuring legitimate warnings.
CFLAGS=`echo $CFLAGS`
# Remove all the unnecessary spaces from $CFLAGS,
CXXFLAGS=`echo $CXXFLAGS`
CCOMMONFLAGS=`echo $CCOMMONFLAGS`
# Remove all the unnecessary spaces from the flags vars
# for more readable messages.
LDFLAGS="$LDFLAGS -O0"
;;
@@ -202,7 +206,7 @@ uqm_prepare_config()
CHOICE_graphics_OPTION_pure_TITLE="Don't include OpenGL graphics support"
CHOICE_graphics_OPTION_pure_ACTION='graphics_pure_action'
graphics_pure_action() {
CFLAGS="$CFLAGS -DGFXMODULE_SDL"
CCOMMONFLAGS="$CCOMMONFLAGS -DGFXMODULE_SDL"
GFXMODULE=sdl
HAVE_OPENGL=0
}
@@ -210,7 +214,7 @@ uqm_prepare_config()
CHOICE_graphics_OPTION_opengl_ACTION='graphics_opengl_action'
CHOICE_graphics_OPTION_opengl_PRECOND="have_library opengl"
graphics_opengl_action() {
CFLAGS="$CFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL"
CCOMMONFLAGS="$CCOMMONFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL"
GFXMODULE=sdl
HAVE_OPENGL=1
use_library opengl
@@ -228,7 +232,7 @@ uqm_prepare_config()
CHOICE_sound_OPTION_openal_PRECOND="have_library openal"
CHOICE_sound_OPTION_openal_ACTION=sound_openal_action
sound_openal_action() {
CFLAGS="$CFLAGS -DHAVE_OPENAL"
CCOMMONFLAGS="$CCOMMONFLAGS -DHAVE_OPENAL"
SOUNDMODULE=openal
use_library openal
}
@@ -249,14 +253,14 @@ uqm_prepare_config()
CHOICE_ovcodec_OPTION_tremor_PRECOND="have_library tremor"
CHOICE_ovcodec_OPTION_tremor_ACTION=ovcodec_tremor_action
ovcodec_tremor_action() {
CFLAGS="$CFLAGS -DOVCODEC_TREMOR"
CCOMMONFLAGS="$CCOMMONFLAGS -DOVCODEC_TREMOR"
OGGVORBIS=tremor
use_library tremor
}
CHOICE_ovcodec_OPTION_none_TITLE="No Ogg Vorbis support"
CHOICE_ovcodec_OPTION_none_ACTION=ovcodec_none_action
ovcodec_none_action() {
CFLAGS="$CFLAGS -DOVCODEC_NONE"
CCOMMONFLAGS="$CCOMMONFLAGS -DOVCODEC_NONE"
OGGVORBIS=none
}
CHOICE_ovcodec_DEFAULT=standard
@@ -266,7 +270,7 @@ uqm_prepare_config()
CHOICE_mikmod_OPTION_internal_TITLE="Included libmikmod"
CHOICE_mikmod_OPTION_internal_ACTION=mikmod_internal_action
mikmod_internal_action() {
CFLAGS="$CFLAGS -DUSE_INTERNAL_MIKMOD"
CCOMMONFLAGS="$CCOMMONFLAGS -DUSE_INTERNAL_MIKMOD"
USE_INTERNAL_MIKMOD=1
}
CHOICE_mikmod_OPTION_external_TITLE="System libmikmod"
@@ -285,7 +289,7 @@ uqm_prepare_config()
# TODO: Check whether SDL has joystick support.
CHOICE_joystick_OPTION_enabled_ACTION=joystick_enabled_action
joystick_enabled_action() {
CFLAGS="$CFLAGS -DHAVE_JOYSTICK"
CCOMMONFLAGS="$CCOMMONFLAGS -DHAVE_JOYSTICK"
}
CHOICE_joystick_OPTION_disabled_TITLE="disabled"
case "$HOST_SYSTEM" in
@@ -309,7 +313,7 @@ uqm_prepare_config()
CHOICE_netplay_OPTION_full_PRECOND="have_library netlibs"
CHOICE_netplay_OPTION_full_ACTION=netplay_full_action
netplay_full_action() {
CFLAGS="$CFLAGS -DNETPLAY=NETPLAY_FULL"
CCOMMONFLAGS="$CCOMMONFLAGS -DNETPLAY=NETPLAY_FULL"
if [ -n "$MACRO_WIN32" ]; then
LDFLAGS="$LDFLAGS -lws2_32"
fi
@@ -320,7 +324,7 @@ uqm_prepare_config()
CHOICE_netplay_OPTION_ipv4_PRECOND="have_library netlibs"
CHOICE_netplay_OPTION_ipv4_ACTION=netplay_ipv4_action
netplay_ipv4_action() {
CFLAGS="$CFLAGS -DNETPLAY=NETPLAY_IPV4"
CCOMMONFLAGS="$CCOMMONFLAGS -DNETPLAY=NETPLAY_IPV4"
NETPLAY="IPV4"
use_library netlibs
}
@@ -333,7 +337,7 @@ uqm_prepare_config()
CHOICE_ioformat_OPTION_stdio_zip_PRECOND="have_library zlib"
CHOICE_ioformat_OPTION_stdio_zip_ACTION="ioformat_stdio_zip_action"
ioformat_stdio_zip_action() {
CFLAGS="$CFLAGS -DHAVE_ZIP=1"
CCOMMONFLAGS="$CCOMMONFLAGS -DHAVE_ZIP=1"
USE_ZIP_IO=1
use_library zlib
}
@@ -344,7 +348,7 @@ uqm_prepare_config()
CHOICE_accel_OPTION_asm_TITLE="Platform acceleration (asm, etc.)"
CHOICE_accel_OPTION_asm_ACTION="accel_asm_action"
accel_asm_action() {
CFLAGS="$CFLAGS -DUSE_PLATFORM_ACCEL"
CCOMMONFLAGS="$CCOMMONFLAGS -DUSE_PLATFORM_ACCEL"
USE_PLATFORM_ACCEL=1
}
CHOICE_accel_OPTION_plainc_TITLE="Only plain C code"
@@ -359,14 +363,14 @@ uqm_prepare_config()
CHOICE_threadlib_OPTION_sdl_TITLE="SDL-controlled thread library"
CHOICE_threadlib_OPTION_sdl_ACTION="threadlib_sdl_action"
threadlib_sdl_action() {
CFLAGS="$CFLAGS -DTHREADLIB_SDL"
CCOMMONFLAGS="$CCOMMONFLAGS -DTHREADLIB_SDL"
THREADLIB="SDL"
}
CHOICE_threadlib_OPTION_pthread_TITLE="Pthread thread library"
CHOICE_threadlib_OPTION_pthread_PRECOND="have_library pthread"
CHOICE_threadlib_OPTION_pthread_ACTION="threadlib_pthread_action"
threadlib_pthread_action() {
CFLAGS="$CFLAGS -DTHREADLIB_PTHREAD"
CCOMMONFLAGS="$CCOMMONFLAGS -DTHREADLIB_PTHREAD"
THREADLIB="PTHREAD"
use_library pthread
}
@@ -419,7 +423,16 @@ uqm_process_config() {
# Set the content dir
CONTENTDIR="${INSTALL_SHAREDIR}uqm/content"
CFLAGS="$CFLAGS -I\"$BUILD_WORK\""
CCOMMONFLAGS="$CCOMMONFLAGS -I\"$BUILD_WORK\""
# Set C++ only flags
# These allow use of C++ without the standard library
CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions -nostdinc++"
# At this point, all the compiler flags must be set.
CFLAGS="$CFLAGS $CCOMMONFLAGS"
CXXFLAGS="$CXXFLAGS $CCOMMONFLAGS"
CCOMMONFLAGS=""
# Export the HAVE_ symbols to config_unix.h, using config_unix.h.in
# as template (or config_win.h/config_win.h.in).
@@ -435,8 +448,9 @@ uqm_process_config() {
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES src "$BUILD_WORK"
# Make build.vars from build.vars.in, substituting variables.
SUBSTITUTE_VARS="BUILD_SYSTEM HOST_SYSTEM CFLAGS LDFLAGS LINK \
SUBSTITUTE_VARS="BUILD_SYSTEM HOST_SYSTEM CFLAGS CXXFLAGS LDFLAGS LINK \
PREPROC_C MKDEP_C COMPILE_C \
PREPROC_CXX MKDEP_CXX COMPILE_CXX \
PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC \
MAKE ECHON SED DEBUG JOYSTICK NETPLAY \
OGGVORBIS SOUNDMODULE USE_INTERNAL_MIKMOD \