* Added support for compiling Haiku with GCC 4. The main difference is that

we use the libstdc++ (including it's headers) that comes with the
  compiler.
* Apparently option "-I-" has been deprecated, which is why we now treat the
  include stuff a bit differently.
* Removed avcodec from the Haiku image, since the library wouldn't build with
  gcc 4, and I'm not in the mood to fix that (declaration of an array of an
  incomplete type).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14876 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2005-11-12 22:58:54 +00:00
parent 01eda82dbf
commit 8b5934c975
7 changed files with 222 additions and 55 deletions

View File

@ -101,25 +101,10 @@ for level in $(HAIKU_DEBUG_LEVELS[2-]) {
}
# analyze GCC version
if ! $(HAIKU_GCC_RAW_VERSION) {
ECHO "Variable HAIKU_GCC_RAW_VERSION not set. Please run ./configure or" ;
EXIT "specify it manually." ;
}
HAIKU_GCC_VERSION = ;
{
# split the raw version string at `.' and `-' characters
local version = $(HAIKU_GCC_RAW_VERSION) ;
while $(version) {
local split = [ Match "([^.-]*)[.-](.*)" : $(version) ] ;
if $(split) {
HAIKU_GCC_VERSION += $(split[1]) ;
version = $(split[2]) ;
} else {
HAIKU_GCC_VERSION += $(version) ;
version = ;
}
}
}
HAIKU_GCC_VERSION = [ FAnalyzeGCCVersion HAIKU_GCC_RAW_VERSION ] ;
# set variables for gcc header options
SetIncludePropertiesVariables HAIKU ;
# assembler flags
HAIKU_ASFLAGS = ;
@ -150,11 +135,11 @@ if $(DEBUG_PRINTF) {
# warning flags
HAIKU_WARNING_CCFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wcast-align
-Wsign-compare ;
HAIKU_WARNING_C++FLAGS = -Wall -Wmissing-prototypes -Wno-ctor-dtor-privacy
HAIKU_WARNING_C++FLAGS = -Wall -Wno-ctor-dtor-privacy
-Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ;
HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wmissing-prototypes ;
HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wmissing-prototypes ;
HAIKU_KERNEL_WARNING_C++FLAGS = -Wall ;
# debug flags
HAIKU_DEBUG_FLAGS ?= -ggdb ;
@ -175,6 +160,11 @@ for level in $(HAIKU_DEBUG_LEVELS[2-]) {
HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ;
}
# gcc version dependent defines
# if $(HAIKU_GCC_VERSION[1]) >= 3 {
# HAIKU_DEFINES += __FUNCTION__=__func__ ;
# }
# private kernel headers do be used when compiling kernel code
HAIKU_PRIVATE_KERNEL_HEADERS =
[ PrivateHeaders $(DOT) kernel libroot
@ -186,7 +176,20 @@ HAIKU_PRIVATE_KERNEL_HEADERS =
HAIKU_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS:G=libgcc) ;
# the C++ library
HAIKU_LIBSTDC++ = libstdc++.r4.so ;
if $(HAIKU_SHARED_LIBSTDC++) {
HAIKU_LIBSTDC++ = $(HAIKU_SHARED_LIBSTDC++) ;
} else if $(HAIKU_STATIC_LIBSTDC++) {
HAIKU_LIBSTDC++ = $(HAIKU_STATIC_LIBSTDC++) ;
} else {
HAIKU_LIBSTDC++ = libstdc++.r4.so ;
}
# the C++ support library
if $(HAIKU_GCC_VERSION[1]) < 3 {
HAIKU_LIBSUPC++ = ;
} else {
HAIKU_LIBSUPC++ = supc++ ;
}
# library and executable glue code
local commonGlueCode =
@ -234,6 +237,7 @@ HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ;
textencoding tracker translation {
HAIKU_LIBRARY_NAME_MAP_$(i) = lib$(i).so ;
}
HAIKU_LIBRARY_NAME_MAP_libstdc++ = $(HAIKU_LIBSTDC++) ;
}
@ -292,6 +296,12 @@ for level in $(HAIKU_DEBUG_LEVELS[2-]) {
= [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ;
}
# analyze GCC version
HOST_GCC_VERSION = [ FAnalyzeGCCVersion HOST_GCC_RAW_VERSION ] ;
# set variables for gcc header options
SetIncludePropertiesVariables HOST ;
# assembler flags
HOST_ASFLAGS = ;
@ -307,11 +317,11 @@ HOST_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions
# warning flags
HOST_WARNING_CCFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wcast-align
-Wsign-compare ;
HOST_WARNING_C++FLAGS = -Wall -Wmissing-prototypes -Wno-ctor-dtor-privacy
HOST_WARNING_C++FLAGS = -Wall -Wno-ctor-dtor-privacy
-Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ;
HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wmissing-prototypes ;
HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wmissing-prototypes ;
HOST_KERNEL_WARNING_C++FLAGS = -Wall ;
# debug flags
switch $(HOST_PLATFORM) {
@ -370,6 +380,13 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
= "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ;
# the C++ support library
if $(HOST_GCC_VERSION[1]) < 3 {
HOST_LIBSUPC++ = ;
} else {
HOST_LIBSUPC++ = supc++ ;
}
# The BeOS compilers define __INTEL__ respectively __POWERPC__. On the
# build platform we need to make sure, this is also defined.
if $(HOST_CPU) = x86 {
@ -450,10 +467,12 @@ HAIKU_COMPATIBLE = $(TARGET_PLATFORM_HAIKU_COMPATIBLE) ;
# specified TARGET_PLATFORM.
local buildVars =
ARCH CPU
ARCH CPU GCC_VERSION
AR CC C++ LD OBJCOPY RANLIB
INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION
HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES
ARFLAGS UNARFLAGS
@ -471,7 +490,7 @@ local buildVars =
PRIVATE_KERNEL_HEADERS
LIBSTDC++
LIBSTDC++ LIBSUPC++
ARCH_MACRO_DEFINE EXECUTABLE_MIME_TYPE

View File

@ -24,7 +24,7 @@ BEOS_PREFERENCES = Backgrounds DataTranslations FileTypes Fonts Media Menu
Mouse Keyboard Keymap Screen ScrollBar Sounds Time VirtualMemory
Workspaces ScreenSaver
;
BEOS_SYSTEM_LIB = libbe.so libstdc++.r4.so libnet.so libmedia.so libtracker.so
BEOS_SYSTEM_LIB = libbe.so $(HAIKU_LIBSTDC++) libnet.so libmedia.so libtracker.so
libtranslation.so libbind.so libnetapi.so libsocket.so libdebug.so
libtextencoding.so libz.so libfreetype.so libpng.so libappserver.so
libdevice.so libgame.so libscreensaver.so libroot.so
@ -47,10 +47,10 @@ BEOS_ADD_ONS_TRANSLATORS = STXTTranslator RTF-Translator PNGTranslator
BEOS_ADD_ONS_MEDIA = mixer.media_addon legacy.media_addon
multi_audio.media_addon
;
BEOS_ADD_ONS_MEDIA_PLUGINS = aiff_reader avcodec mp3_decoder musepack
BEOS_ADD_ONS_MEDIA_PLUGINS = aiff_reader mp3_decoder musepack
raw_decoder wav_reader mov_reader au_reader avi_reader mp3_reader ogg
speex vorbis
# ac3_decoder theora matroska
# ac3_decoder avcodec theora matroska
;
BEOS_ADD_ONS_INPUT = <input>keyboard <input>mouse canna screen_saver ;
BEOS_ADD_ONS_SCREENSAVERS = Haiku ;

View File

@ -1,16 +1,15 @@
# FIncludes <dirs> ;
#
# Overridden to support a second argument, the option to be used.
#
rule FIncludes { return $(2:E="--bad-include-option ")$(1) ; }
# FSysIncludes <dirs> ;
#
# Counterpart of FIncludes for system include search paths.
#
#if $(OSPLAT) = X86 {
rule FSysIncludes { return -I$(<) ; }
HDRS_INCLUDES_SEPARATOR = -I- ;
# } else {
# rule FSysIncludes { return "-i "$(<) ; }
# HDRS_INCLUDES_SEPARATOR = -i- ;
# }
# mwcc support commented out
rule FSysIncludes { return $(2:E="--bad-include-option ")$(1) ; }
rule SubDirSysHdrs
{
@ -54,8 +53,22 @@ rule ObjectSysHdrs
SYSHDRS on $(file) = $(sysHeaders) ;
# reformat ASHDRS and CCHDRS
local fileHeaders = [ FIncludes $(HDRS) ]
$(HDRS_INCLUDES_SEPARATOR) [ FIncludes $(sysHeaders) ] ;
local fileHeaders ;
if $(PLATFORM) = host {
fileHeaders =
[ FIncludes $(HDRS) : $(HOST_LOCAL_INCLUDES_OPTION) ]
$(HOST_INCLUDES_SEPARATOR)
[ FSysIncludes $(sysHeaders)
: $(HOST_SYSTEM_INCLUDES_OPTION) ] ;
} else {
fileHeaders =
[ FIncludes $(HDRS) : $(TARGET_LOCAL_INCLUDES_OPTION) ]
$(TARGET_INCLUDES_SEPARATOR)
[ FSysIncludes $(sysHeaders)
: $(TARGET_SYSTEM_INCLUDES_OPTION) ] ;
}
ASHDRS on $(file) = $(fileHeaders) ;
CCHDRS on $(file) = $(fileHeaders) ;
}
@ -356,15 +369,21 @@ rule FStandardHeaders
# Use glibc headers
headers += [ FDirName $(HAIKU_TOP) headers glibc ] ;
headers += [ FDirName $(HAIKU_TOP) headers cpp ] ;
# Use public OS header directories
headers += [ PublicHeaders $(osIncludes) ] ;
# Use the root of the private headers -- not so nice, but simplifies things.
headers += [ PrivateHeaders $(DOT) ] ;
# The platform (compiler actually) dependent headers.
# The C++ headers. If specified, we use the compiler headers, otherwise
# the ones that come with our libstdc++.
if $(HAIKU_C++_HEADERS_DIR) {
headers += $(HAIKU_C++_HEADERS_DIR) ;
} else {
headers += [ FDirName $(HAIKU_TOP) headers cpp ] ;
}
# The compiler dependent headers.
headers += $(HAIKU_GCC_HEADERS_DIR) ;
return $(headers) ;

View File

@ -188,6 +188,50 @@ rule SetPlatformCompatibilityFlagVariables
?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ;
}
rule FAnalyzeGCCVersion
{
# FAnalyzeGCCVersion <rawVersionVariable> ;
#
local varName = $(1) ;
local rawVersion = $($(varName)) ;
if ! $(rawVersion) {
ECHO "Variable $(varName) not set. Please run ./configure or" ;
EXIT "specify it manually." ;
}
local version = ;
# split the raw version string at `.' and `-' characters
while $(rawVersion) {
local split = [ Match "([^.-]*)[.-](.*)" : $(rawVersion) ] ;
if $(split) {
version += $(split[1]) ;
rawVersion = $(split[2]) ;
} else {
version += $(rawVersion) ;
rawVersion = ;
}
}
return $(version) ;
}
rule SetIncludePropertiesVariables
{
# SetIncludePropertiesVariables <varPrefix> ;
#
local prefix = $(1) ;
if $($(prefix)_GCC_VERSION[1]) < 4 {
$(prefix)_INCLUDES_SEPARATOR = -I- ;
$(prefix)_LOCAL_INCLUDES_OPTION = -I ;
$(prefix)_SYSTEM_INCLUDES_OPTION = -I ;
} else {
$(prefix)_INCLUDES_SEPARATOR = ;
$(prefix)_LOCAL_INCLUDES_OPTION = "-iquote " ;
$(prefix)_SYSTEM_INCLUDES_OPTION = "-idirafter " ;
}
}
#pragma mark -

View File

@ -42,7 +42,9 @@ rule KernelLd
if $(3) { LINKFLAGS on $(1) += --script=$(3) ; }
# Remove any preset LINKLIBS, but link against libgcc.a
LINKLIBS on $(1) = $(TARGET_GCC_LIBGCC) ;
LINKLIBS on $(1) = -l$(TARGET_LIBSUPC++) $(TARGET_GCC_LIBGCC) ;
# TODO: Linking against TARGET_LIBSUPC++ is OK, but doing it like
# this is not so nice.
# TODO: Do we really want to invoke SetupKernel here? The objects should
# have been compiled with KernelObjects anyway, so we're doing that twice.

View File

@ -150,21 +150,33 @@ rule Object
rule As
{
local flags ;
local includesSeparator ;
local localIncludesOption ;
local systemIncludesOption ;
if [ on $(1) return $(PLATFORM) ] = host {
flags = [ on $(1) return $(HOST_ASFLAGS) $(ASFLAGS) ] ;
CC on $(1) = $(HOST_CC) ;
includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
} else {
flags = [ on $(1) return $(TARGET_ASFLAGS) $(ASFLAGS) ] ;
CC on $(1) = $(TARGET_CC) ;
includesSeparator = $(TARGET_INCLUDES_SEPARATOR) ;
localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(TARGET_SYSTEM_INCLUDES_OPTION) ;
}
Depends $(<) : $(>) ;
ASFLAGS on $(<) += $(flags) $(SUBDIRASFLAGS) ;
ASHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ]
$(HDRS_INCLUDES_SEPARATOR) [ on $(<) FSysIncludes $(SYSHDRS) ] ;
ASHDRS on $(<) = [ on $(<) FIncludes $(HDRS) : $(localIncludesOption) ]
$(includesSeparator)
[ on $(<) FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
ASDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
}
@ -217,6 +229,9 @@ rule Cc
on $(1) {
local flags ;
local includesSeparator ;
local localIncludesOption ;
local systemIncludesOption ;
# optimization flags
if $(DEBUG) = 0 {
@ -241,6 +256,10 @@ rule Cc
CC on $(1) = $(HOST_CC) ;
includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
} else {
# warning flags
if $(WARNINGS) != 0 {
@ -252,11 +271,16 @@ rule Cc
$(SUBDIRCCFLAGS) $(CCFLAGS) ;
CC on $(1) = $(TARGET_CC) ;
includesSeparator = $(TARGET_INCLUDES_SEPARATOR) ;
localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(TARGET_SYSTEM_INCLUDES_OPTION) ;
}
CCFLAGS on $(<) = $(flags) ;
CCHDRS on $(<) = [ FIncludes $(HDRS) ] $(HDRS_INCLUDES_SEPARATOR)
[ FSysIncludes $(SYSHDRS) ] ;
CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
$(includesSeparator)
[ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
}
}
@ -272,6 +296,9 @@ rule C++
on $(1) {
local flags ;
local includesSeparator ;
local localIncludesOption ;
local systemIncludesOption ;
# optimization flags
if $(DEBUG) = 0 {
@ -296,6 +323,10 @@ rule C++
C++ on $(1) = $(HOST_C++) ;
includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
} else {
# warning flags
if $(WARNINGS) != 0 {
@ -307,11 +338,16 @@ rule C++
$(SUBDIRC++FLAGS) $(C++FLAGS) ;
C++ on $(1) = $(TARGET_C++) ;
includesSeparator = $(TARGET_INCLUDES_SEPARATOR) ;
localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ;
systemIncludesOption = $(TARGET_SYSTEM_INCLUDES_OPTION) ;
}
C++FLAGS on $(<) = $(flags) ;
CCHDRS on $(<) = [ FIncludes $(HDRS) ] $(HDRS_INCLUDES_SEPARATOR)
[ FSysIncludes $(SYSHDRS) ] ;
CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
$(includesSeparator)
[ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
}
}
@ -563,13 +599,30 @@ rule ObjectHdrs
local file ;
for file in $(objects) {
HDRS on $(file) = [ on $(file) return $(HDRS) ] $(headers) ;
on $(file) {
local localHeaders = $(HDRS) $(headers) ;
SYSHDRS on $(file) = $(localHeaders) ;
# reformat ASHDRS and CCHDRS
local fileHeaders = [ on $(file) FIncludes $(HDRS) ]
$(HDRS_INCLUDES_SEPARATOR) [ on $(file) FSysIncludes $(SYSHDRS) ] ;
ASHDRS on $(file) = $(fileHeaders) ;
CCHDRS on $(file) = $(fileHeaders) ;
# reformat ASHDRS and CCHDRS
local fileHeaders ;
if $(PLATFORM) = host {
fileHeaders =
[ FIncludes $(localHeaders) : $(HOST_LOCAL_INCLUDES_OPTION) ]
$(HOST_INCLUDES_SEPARATOR)
[ FSysIncludes $(SYSHDRS)
: $(HOST_SYSTEM_INCLUDES_OPTION) ] ;
} else {
fileHeaders =
[ FIncludes $(localHeaders) : $(TARGET_LOCAL_INCLUDES_OPTION) ]
$(TARGET_INCLUDES_SEPARATOR)
[ FSysIncludes $(SYSHDRS)
: $(TARGET_SYSTEM_INCLUDES_OPTION) ] ;
}
ASHDRS on $(file) = $(fileHeaders) ;
CCHDRS on $(file) = $(fileHeaders) ;
}
}
}

30
configure vendored
View File

@ -79,6 +79,26 @@ standard_gcc_settings()
HAIKU_GCC_GLUE_CODE="crtbegin.o crtend.o"
HAIKU_GCC_HEADERS_DIR=${gccdir}/include
HAIKU_GCC_LIBGCC_OBJECTS=`ar t ${HAIKU_GCC_LIBGCC}`
# for gcc 4 we use the libstdc++ that comes with the compiler
case $haikuGCCVersion in
4.*)
haikuStaticLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.a`
haikuSharedLibStdCxx=`$HAIKU_CC -print-file-name=libstdc++.so`
local headers=$gccdir/../../../../include/c++/$haikuGCCVersion
haikuCxxHeadersDir=$headers
for d in $haikuGCCMachine backward ext debug; do
haikuCxxHeadersDir="$haikuCxxHeadersDir $headers/$d"
done
if [ $haikuStaticLibStdCxx = libstdc++.a ]; then
haikuStaticLibStdCxx=
fi
if [ $haikuSharedLibStdCxx = libstdc++.so ]; then
haikuSharedLibStdCxx=
fi
;;
esac
}
# set_default_value
@ -128,6 +148,10 @@ cd $currentDir
#
platform=`uname`
haikuGCCVersion=
haikuStaticLibStdCxx=
haikuSharedLibStdCxx=
haikuCxxHeadersDir=
hostGCCVersion=`cc -dumpversion`
floppy=
bochs_debug=0
include_gpl_addons=0
@ -235,6 +259,10 @@ HAIKU_GCC_LIB_DIR ?= ${HAIKU_GCC_LIB_DIR} ;
HAIKU_GCC_HEADERS_DIR ?= ${HAIKU_GCC_HEADERS_DIR} ;
HAIKU_GCC_LIBGCC ?= ${HAIKU_GCC_LIBGCC} ;
HAIKU_STATIC_LIBSTDC++ ?= ${haikuStaticLibStdCxx} ;
HAIKU_SHARED_LIBSTDC++ ?= ${haikuSharedLibStdCxx} ;
HAIKU_C++_HEADERS_DIR ?= ${haikuCxxHeadersDir} ;
HAIKU_BUILD_ATTRIBUTES_DIR ?= ${buildAttributesDir} ;
HAIKU_AR ?= ${HAIKU_AR} ;
@ -249,6 +277,8 @@ HAIKU_LDFLAGS ?= ${HAIKU_LDFLAGS} ;
HAIKU_ARFLAGS ?= ${HAIKU_ARFLAGS} ;
HAIKU_UNARFLAGS ?= ${HAIKU_UNARFLAGS} ;
HOST_GCC_RAW_VERSION ?= ${hostGCCVersion} ;
EOF
# Libgcc.a objects