summaryrefslogtreecommitdiffstatshomepage
path: root/makefile
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-02-28 22:10:06 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-02-28 22:10:06 +0000
commite2757c60d2fa5e74909eff1e7a48ce5841ad47e5 (patch)
treeb30bddf750ef14f54e147b8d214d693af27f5d33 /makefile
parent42004cf3baf9c0307775c43096df36c1d5884bf4 (diff)
Modified the makefile to support experimental optional C++
compilation: - new option CPP_COMPILE to trigger this (off by default) - split CFLAGS into common, C-only, and C++-only flags - when enabled, CPP_COMPILE causes 'pp' to be appended to the target name NOTE THAT THE SYSTEM CANNOT ACTUALLY BE COMPILED THIS WAY YET. IT IS JUST AN EXPERIMENT. Modified lib.mak to always build zlib/expat as C regardless of CPP_COMPILE. Modified windows.mak to fix warnings with MAXOPT=1, and to leverage the new CFLAGs definitions. Modified vconv.c to do appropriate conversions for new C++ options. Updated sources so that libutil, libocore (Windows), and libosd (Windows) can be cleanly compiled as C or C++. This was mostly adding some casts against void *. Fixed a few more general obvious problems at random locations in the source: - device->class is now device->devclass - TYPES_COMPATIBLE uses typeid() when compiled for C++ - some functions with reserved names ('xor' in particular) were renamed - nested enums and structs were pulled out into separate definitions (under C++ these would need to be scoped to be referenced) - TOKEN_VALUE cannot use .field=x initialization in C++ :(
Diffstat (limited to 'makefile')
-rw-r--r--makefile93
1 files changed, 61 insertions, 32 deletions
diff --git a/makefile b/makefile
index 19db1882f97..2777a0e3983 100644
--- a/makefile
+++ b/makefile
@@ -143,6 +143,9 @@ BUILD_ZLIB = 1
# (default is OPTIMIZE = 3 normally, or OPTIMIZE = 0 with symbols)
# OPTIMIZE = 3
+# experimental: uncomment to compile everything as C++ for stricter type checking
+# CPP_COMPILE = 1
+
###########################################################################
################## END USER-CONFIGURABLE OPTIONS ######################
@@ -207,6 +210,11 @@ ifdef DEBUG
DEBUGSUFFIX = d
endif
+# cpp builds get a 'pp' suffix
+ifdef CPP_COMPILE
+CPPSUFFIX = pp
+endif
+
# the name is just 'target' if no subtarget; otherwise it is
# the concatenation of the two (e.g., mametiny)
ifeq ($(TARGET),$(SUBTARGET))
@@ -216,7 +224,7 @@ NAME = $(TARGET)$(SUBTARGET)
endif
# fullname is prefix+name+suffix+debugsuffix
-FULLNAME = $(PREFIX)$(NAME)$(SUFFIX)$(DEBUGSUFFIX)
+FULLNAME = $(PREFIX)$(NAME)$(CPPSUFFIX)$(SUFFIX)$(DEBUGSUFFIX)
# add an EXE suffix to get the final emulator name
EMULATOR = $(FULLNAME)$(EXE)
@@ -278,57 +286,74 @@ endif
#-------------------------------------------------
# compile flags
+# CCOMFLAGS are common flags
+# CONLYFLAGS are flags only used when compiling for C
+# CPPONLYFLAGS are flags only used when compiling for C++
#-------------------------------------------------
-# we compile to C89 standard with GNU extensions
-CFLAGS = -std=gnu89
+# start with empties for everything
+CCOMFLAGS =
+CONLYFLAGS =
+CPPONLYFLAGS =
+
+# CFLAGS is defined based on C or C++ targets
+# (remember, expansion only happens when used, so doing it here is ok)
+ifdef CPP_COMPILE
+CFLAGS = $(CCOMFLAGS) $(CPPONLYFLAGS)
+else
+CFLAGS = $(CCOMFLAGS) $(CONLYFLAGS)
+endif
+
+# we compile C-only to C89 standard with GNU extensions
+# we compile C++ code to C++98 standard with GNU extensions
+CONLYFLAGS += -std=gnu89
+CPPONLYFLAGS += -x c++ -std=gnu++98
# this speeds it up a bit by piping between the preprocessor/compiler/assembler
-CFLAGS += -pipe
+CCOMFLAGS += -pipe
-# add -g if we need symbols
+# add -g if we need symbols, and ensure we have frame pointers
ifdef SYMBOLS
-CFLAGS += -g
+CCOMFLAGS += -g -fno-omit-frame-pointer
endif
# add -v if we need verbose build information
ifdef VERBOSE
-CFLAGS += -v
+CCOMFLAGS += -v
endif
-# add a basic set of warnings
-CFLAGS += \
- -Wall \
- -Wpointer-arith \
- -Wbad-function-cast \
- -Wcast-align \
- -Wstrict-prototypes \
- -Wundef \
- -Wformat-security \
- -Wwrite-strings \
-
# add profiling information for the compiler
ifdef PROFILE
-CFLAGS += -pg
-endif
-
-# this warning is not supported on the os2 compilers
-ifneq ($(TARGETOS),os2)
-CFLAGS += -Wdeclaration-after-statement
+CCOMFLAGS += -pg
endif
# add the optimization flag
-CFLAGS += -O$(OPTIMIZE)
+CCOMFLAGS += -O$(OPTIMIZE)
# if we are optimizing, include optimization options
# and make all errors into warnings
ifneq ($(OPTIMIZE),0)
-CFLAGS += -Werror $(ARCHOPTS) -fno-strict-aliasing
+CCOMFLAGS += -Werror -fno-strict-aliasing $(ARCHOPTS)
endif
-# if symbols are on, make sure we have frame pointers
-ifdef SYMBOLS
-CFLAGS += -fno-omit-frame-pointer
+# add a basic set of warnings
+CCOMFLAGS += \
+ -Wall \
+ -Wcast-align \
+ -Wundef \
+ -Wformat-security \
+ -Wwrite-strings \
+ -Wno-sign-compare
+
+# warnings only applicable to C compiles
+CONLYFLAGS += \
+ -Wpointer-arith \
+ -Wbad-function-cast \
+ -Wstrict-prototypes
+
+# this warning is not supported on the os2 compilers
+ifneq ($(TARGETOS),os2)
+CONLYFLAGS += -Wdeclaration-after-statement
endif
@@ -338,7 +363,7 @@ endif
#-------------------------------------------------
# add core include paths
-CFLAGS += \
+CCOMFLAGS += \
-I$(SRC)/$(TARGET) \
-I$(SRC)/$(TARGET)/includes \
-I$(OBJ)/$(TARGET)/layout \
@@ -419,7 +444,7 @@ LIBS =
# add expat XML library
ifdef BUILD_EXPAT
-CFLAGS += -I$(SRC)/lib/expat
+CCOMFLAGS += -I$(SRC)/lib/expat
EXPAT = $(OBJ)/libexpat.a
else
LIBS += -lexpat
@@ -428,7 +453,7 @@ endif
# add ZLIB compression library
ifdef BUILD_ZLIB
-CFLAGS += -I$(SRC)/lib/zlib
+CCOMFLAGS += -I$(SRC)/lib/zlib
ZLIB = $(OBJ)/libz.a
else
LIBS += -lz
@@ -444,6 +469,8 @@ endif
all: maketree buildtools emulator tools
+
+
#-------------------------------------------------
# defines needed by multiple make files
#-------------------------------------------------
@@ -452,6 +479,8 @@ BUILDSRC = $(SRC)/build
BUILDOBJ = $(OBJ)/build
BUILDOUT = $(BUILDOBJ)
+
+
#-------------------------------------------------
# include the various .mak files
#-------------------------------------------------