Sqlite3 is not conditional anymore, support amalgamation on UNIX.

This commit is contained in:
Christian Speckner 2020-12-14 00:10:11 +01:00
parent 0999396853
commit 771b5b44e3
7 changed files with 244058 additions and 244027 deletions

View File

@ -21,7 +21,7 @@
srcdir ?= . srcdir ?= .
DEFINES := -DSDL_SUPPORT -D_GLIBCXX_USE_CXX11_ABI=1 DEFINES := -DSDL_SUPPORT -D_GLIBCXX_USE_CXX11_ABI=1 -DSQLITE_SUPPORT
LDFLAGS := -pthread LDFLAGS := -pthread
INCLUDES := INCLUDES :=
LIBS := LIBS :=
@ -40,48 +40,61 @@ include config.mak
# CXXFLAGS+= -Werror # CXXFLAGS+= -Werror
ifdef CXXFLAGS ifdef CXXFLAGS
CFLAGS:= $(CXXFLAGS)
CXXFLAGS:= $(CXXFLAGS) -x c++ CXXFLAGS:= $(CXXFLAGS) -x c++
else else
CXXFLAGS:= -O2 -x c++ CXXFLAGS:= -O2 -x c++
CFLAGS:= -O2
endif endif
CXXFLAGS+= -Wall -Wextra -Wno-unused-parameter CXXFLAGS+= -Wall -Wextra -Wno-unused-parameter
CXLAGS+= -Wall -Wextra -Wno-unused-parameter
ifdef HAVE_GCC ifdef HAVE_GCC
CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++17 CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++17
CFLAGS+= -Wno-multichar -Wunused
endif endif
ifdef HAVE_CLANG ifdef HAVE_CLANG
CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++17 CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++17
CFLAGS+= -Wno-multichar -Wunused
endif endif
ifdef CLANG_WARNINGS ifdef CLANG_WARNINGS
CXXFLAGS+= -Weverything -Wno-c++17-extensions -Wno-c++98-compat-pedantic \ EXTRA_WARN=-Weverything -Wno-c++17-extensions -Wno-c++98-compat-pedantic \
-Wno-switch-enum -Wno-conversion -Wno-covered-switch-default \ -Wno-switch-enum -Wno-conversion -Wno-covered-switch-default \
-Wno-inconsistent-missing-destructor-override -Wno-float-equal \ -Wno-inconsistent-missing-destructor-override -Wno-float-equal \
-Wno-exit-time-destructors -Wno-global-constructors -Wno-weak-vtables \ -Wno-exit-time-destructors -Wno-global-constructors -Wno-weak-vtables \
-Wno-four-char-constants -Wno-padded -Wno-four-char-constants -Wno-padded
CXXFLAGS+= $(EXTRA_WARN)
CFLAGS+= $(EXTRA_WARN)
endif endif
ifdef PROFILE ifdef PROFILE
PROF:= -pg -fprofile-arcs -ftest-coverage PROF:= -pg -fprofile-arcs -ftest-coverage
CXXFLAGS+= $(PROF) CXXFLAGS+= $(PROF)
CFLAGS+= $(PROF)
endif endif
ifdef DEBUG ifdef DEBUG
CXXFLAGS += -g CXXFLAGS += -g
CFLAGS += -g
else else
ifdef HAVE_GCC ifdef HAVE_GCC
CXXFLAGS+= -fomit-frame-pointer CXXFLAGS+= -fomit-frame-pointer
CFLAGS+= -fomit-frame-pointer
endif endif
ifdef HAVE_CLANG ifdef HAVE_CLANG
CXXFLAGS+= -fomit-frame-pointer CXXFLAGS+= -fomit-frame-pointer
CFLAGS+= -fomit-frame-pointer
endif endif
endif endif
ifdef RELEASE ifdef RELEASE
CXXFLAGS += -flto -fno-rtti CXXFLAGS += -flto -fno-rtti
CFLAGS += -flto
LDFLAGS += -flto -fno-rtti LDFLAGS += -flto -fno-rtti
endif endif
@ -107,6 +120,8 @@ PROFILE_STAMP = profile.stamp
CXXFLAGS_PROFILE_GENERATE = $(CXXFLAGS) CXXFLAGS_PROFILE_GENERATE = $(CXXFLAGS)
CXXFLAGS_PROFILE_USE = $(CXXFLAGS) CXXFLAGS_PROFILE_USE = $(CXXFLAGS)
CFLAGS_PROFILE_GENERATE = $(CFLAGS)
CFLAGS_PROFILE_USE = $(CFLAGS)
LDFLAGS_PROFILE_GENERATE = $(LDFLAGS) LDFLAGS_PROFILE_GENERATE = $(LDFLAGS)
STELLA_PROFILE_GENERATE = $(BINARY_LOADER) ./$(EXECUTABLE_PROFILE_GENERATE) -profile \ STELLA_PROFILE_GENERATE = $(BINARY_LOADER) ./$(EXECUTABLE_PROFILE_GENERATE) -profile \
$(PROFILE_DIR)/128.bin:10 \ $(PROFILE_DIR)/128.bin:10 \
@ -115,6 +130,8 @@ STELLA_PROFILE_GENERATE = $(BINARY_LOADER) ./$(EXECUTABLE_PROFILE_GENERATE) -pro
ifdef HAVE_CLANG ifdef HAVE_CLANG
CXXFLAGS_PROFILE_GENERATE += -fprofile-generate=$(PROFILE_OUT) CXXFLAGS_PROFILE_GENERATE += -fprofile-generate=$(PROFILE_OUT)
CXXFLAGS_PROFILE_USE += -fprofile-use=$(PROFILE_OUT) CXXFLAGS_PROFILE_USE += -fprofile-use=$(PROFILE_OUT)
CFLAGS_PROFILE_GENERATE += -fprofile-generate=$(PROFILE_OUT)
CFLAGS_PROFILE_USE += -fprofile-use=$(PROFILE_OUT)
LDFLAGS_PROFILE_GENERATE += -fprofile-generate LDFLAGS_PROFILE_GENERATE += -fprofile-generate
STELLA_PROFILE_GENERATE := \ STELLA_PROFILE_GENERATE := \
LLVM_PROFILE_FILE="$(PROFILE_OUT)/default.profraw" $(STELLA_PROFILE_GENERATE) && \ LLVM_PROFILE_FILE="$(PROFILE_OUT)/default.profraw" $(STELLA_PROFILE_GENERATE) && \
@ -124,6 +141,8 @@ endif
ifdef HAVE_GCC ifdef HAVE_GCC
CXXFLAGS_PROFILE_GENERATE += -fprofile-generate -fprofile-dir=$(PROFILE_OUT) CXXFLAGS_PROFILE_GENERATE += -fprofile-generate -fprofile-dir=$(PROFILE_OUT)
CXXFLAGS_PROFILE_USE += -fprofile-use -fprofile-dir=$(PROFILE_OUT) CXXFLAGS_PROFILE_USE += -fprofile-use -fprofile-dir=$(PROFILE_OUT)
CFLAGS_PROFILE_GENERATE += -fprofile-generate -fprofile-dir=$(PROFILE_OUT)
CFLAGS_PROFILE_USE += -fprofile-use -fprofile-dir=$(PROFILE_OUT)
LDFLAGS_PROFILE_GENERATE += -fprofile-generate LDFLAGS_PROFILE_GENERATE += -fprofile-generate
STELLA_PROFILE_GENERATE := $(STELLA_PROFILE_GENERATE) && \ STELLA_PROFILE_GENERATE := $(STELLA_PROFILE_GENERATE) && \
rm -fr $(PROFILE_OUT)/$(OBJECT_ROOT_PROFILE_USE) && \ rm -fr $(PROFILE_OUT)/$(OBJECT_ROOT_PROFILE_USE) && \
@ -155,7 +174,8 @@ MODULES += \
src/common/tv_filters \ src/common/tv_filters \
src/emucore \ src/emucore \
src/emucore/tia \ src/emucore/tia \
src/emucore/tia/frame-manager src/emucore/tia/frame-manager \
src/common/repository/sqlite
###################################################################### ######################################################################
# The build rules follow - normally you should have no need to # The build rules follow - normally you should have no need to
@ -223,7 +243,7 @@ $(OBJECT_ROOT)/%.o: %.cxx
$(OBJECT_ROOT)/%.o: %.c $(OBJECT_ROOT)/%.o: %.c
$(create_dir) $(create_dir)
$(CC) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $@ $(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS) $(CPPFLAGS) -c $(<) -o $@
$(merge_dep) $(merge_dep)
$(OBJECT_ROOT_PROFILE_GENERERATE)/%.pgen.o: %.cxx $(OBJECT_ROOT_PROFILE_GENERERATE)/%.pgen.o: %.cxx
@ -231,9 +251,9 @@ $(OBJECT_ROOT_PROFILE_GENERERATE)/%.pgen.o: %.cxx
$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_GENERATE) $(CPPFLAGS) -c $(<) -o $@ $(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_GENERATE) $(CPPFLAGS) -c $(<) -o $@
$(merge_dep) $(merge_dep)
$(OBJECT_ROOT_PROFILE_GENERERATE)/%.pgen.o: %.cxx $(OBJECT_ROOT_PROFILE_GENERERATE)/%.pgen.o: %.c
$(create_dir) $(create_dir)
$(CC) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_GENERATE) $(CPPFLAGS) -c $(<) -o $@ $(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS_PROFILE_GENERATE) $(CPPFLAGS) -c $(<) -o $@
$(merge_dep) $(merge_dep)
$(OBJECT_ROOT_PROFILE_USE)/%.pgo.o: %.cxx $(PROFILE_STAMP) $(OBJECT_ROOT_PROFILE_USE)/%.pgo.o: %.cxx $(PROFILE_STAMP)
@ -241,9 +261,9 @@ $(OBJECT_ROOT_PROFILE_USE)/%.pgo.o: %.cxx $(PROFILE_STAMP)
$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_USE) $(CPPFLAGS) -c $(<) -o $@ $(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_USE) $(CPPFLAGS) -c $(<) -o $@
$(merge_dep) $(merge_dep)
$(OBJECT_ROOT_PROFILE_USE)/%.pgo.o: %.cxx $(PROFILE_STAMP) $(OBJECT_ROOT_PROFILE_USE)/%.pgo.o: %.c $(PROFILE_STAMP)
$(create_dir) $(create_dir)
$(CC) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_USE) $(CPPFLAGS) -c $(<) -o $@ $(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS_PROFILE_USE) $(CPPFLAGS) -c $(<) -o $@
$(merge_dep) $(merge_dep)
else else
@ -257,7 +277,7 @@ $(OBJECT_ROOT)/%.o: %.cxx
$(OBJECT_ROOT)/%.o: %.c $(OBJECT_ROOT)/%.o: %.c
$(create_dir) $(create_dir)
$(CC) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $@ $(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS) $(CPPFLAGS) -c $(<) -o $@
$(OBJECT_ROOT_PROFILE_GENERERATE)/%.o: %.cxx $(OBJECT_ROOT_PROFILE_GENERERATE)/%.o: %.cxx
$(create_dir) $(create_dir)
@ -265,7 +285,7 @@ $(OBJECT_ROOT_PROFILE_GENERERATE)/%.o: %.cxx
$(OBJECT_ROOT_PROFILE_GENERERATE)/%.o: %.c $(OBJECT_ROOT_PROFILE_GENERERATE)/%.o: %.c
$(create_dir) $(create_dir)
$(CC) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_GENERATE) $(CPPFLAGS) -c $(<) -o $@ $(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS_PROFILE_GENERATE) $(CPPFLAGS) -c $(<) -o $@
$(OBJECT_ROOT_PROFILE_USE)/%.o: %.cxx $(PROFILE_STAMP) $(OBJECT_ROOT_PROFILE_USE)/%.o: %.cxx $(PROFILE_STAMP)
$(create_dir) $(create_dir)
@ -273,7 +293,7 @@ $(OBJECT_ROOT_PROFILE_USE)/%.o: %.cxx $(PROFILE_STAMP)
$(OBJECT_ROOT_PROFILE_USE)/%.o: %.c $(PROFILE_STAMP) $(OBJECT_ROOT_PROFILE_USE)/%.o: %.c $(PROFILE_STAMP)
$(create_dir) $(create_dir)
$(CC) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS_PROFILE_USE) $(CPPFLAGS) -c $(<) -o $@ $(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS_PROFILE_USE) $(CPPFLAGS) -c $(<) -o $@
endif endif

47
configure vendored
View File

@ -206,8 +206,7 @@ Optional Features:
--disable-png --disable-png
--enable-zip enable/disable ZIP file support [enabled] --enable-zip enable/disable ZIP file support [enabled]
--disable-zip --disable-zip
--enable-sqlite enable SQLite for storing settings and preferences [disabled] --sqlite-builtin always use builtin version of sqlite
--disable-sqlite
--enable-windowed enable/disable windowed rendering modes [enabled] --enable-windowed enable/disable windowed rendering modes [enabled]
--disable-windowed --disable-windowed
--enable-shared build shared binary [enabled] --enable-shared build shared binary [enabled]
@ -253,8 +252,7 @@ for ac_option in $@; do
--disable-png) _build_png=no ;; --disable-png) _build_png=no ;;
--enable-zip) _build_zip=yes ;; --enable-zip) _build_zip=yes ;;
--disable-zip) _build_zip=no ;; --disable-zip) _build_zip=no ;;
--enable-sqlite) _build_sqlite=yes ;; --sqlite-builtin) _sqlite_builtin=yes ;;
--disable-sqlite) _build_sqlite=no ;;
--enable-windowed) _build_windowed=yes ;; --enable-windowed) _build_windowed=yes ;;
--disable-windowed) _build_windowed=no ;; --disable-windowed) _build_windowed=no ;;
--enable-shared) _build_static=no ;; --enable-shared) _build_static=no ;;
@ -670,24 +668,19 @@ fi
# Check for SQLite # Check for SQLite
# #
echocheck "SQLite" echocheck "SQLite"
if test "$_build_sqlite" = yes ; then _sqlite=no
_sqlite=no if test $_sqlite_builtin != yes ; then
cat > $TMPC << EOF cat > $TMPC << EOF
#include <stdio.h> #include <stdio.h>
#include <sqlite3.h> #include <sqlite3.h>
int main(void) { printf("%s\n", SQLITE_VERSION); } int main(void) { printf("%s\n", SQLITE_VERSION); }
EOF EOF
cc_check $LDFLAGS $CXXFLAGS $SQLITE_CFLAGS $SQLITE_LIBS -lsqlite3 && _sqlite=yes cc_check $LDFLAGS $CXXFLAGS $SQLITE_CFLAGS $SQLITE_LIBS -lsqlite3 && _sqlite=yes
fi
if test "$_sqlite" = yes ; then if test "$_sqlite" = yes ; then
echo "$_sqlite" echo "$_sqlite"
else
echo "disabled"
_build_sqlite=no
fi
else else
echo "disabled" echo "builtin"
_build_sqlite=no
fi fi
# #
@ -759,14 +752,6 @@ else
echo echo
fi fi
if test "$_build_sqlite" = yes ; then
echo_n " SQLite enabled"
echo
else
echo_n " SQLite disabled"
echo
fi
if test "$_build_windowed" = "yes" ; then if test "$_build_windowed" = "yes" ; then
echo_n " Windowed rendering modes enabled" echo_n " Windowed rendering modes enabled"
echo echo
@ -820,10 +805,11 @@ YACC="$SRC/yacc"
CHEAT="$SRC/cheat" CHEAT="$SRC/cheat"
LIBPNG="$SRC/libpng" LIBPNG="$SRC/libpng"
ZLIB="$SRC/zlib" ZLIB="$SRC/zlib"
SQLITE="$SRC/common/repository/sqlite" SQLITE_REPO="$SRC/common/repository/sqlite"
SQLITE_LIB="$SRC/sqlite"
JSON="$SRC/json" JSON="$SRC/json"
INCLUDES="-I$CORE -I$COMMON -I$TV -I$TIA -I$TIA_FRAME_MANAGER -I$JSON" INCLUDES="-I$CORE -I$COMMON -I$TV -I$TIA -I$TIA_FRAME_MANAGER -I$JSON -I$SQLITE_REPO"
INCLUDES="$INCLUDES `$_sdlconfig --cflags`" INCLUDES="$INCLUDES `$_sdlconfig --cflags`"
if test "$_build_static" = yes ; then if test "$_build_static" = yes ; then
@ -846,6 +832,9 @@ case $_host_os in
DEFINES="$DEFINES -DBSPF_UNIX -DMACOS_KEYS" DEFINES="$DEFINES -DBSPF_UNIX -DMACOS_KEYS"
MODULES="$MODULES $SRC/unix" MODULES="$MODULES $SRC/unix"
INCLUDES="$INCLUDES -I$SRC/unix" INCLUDES="$INCLUDES -I$SRC/unix"
if test "$have_clang" == yes; then
CXXFLAGS="$CXXFLAGS -Wno-poison-system-directories"
fi
;; ;;
retron77) retron77)
DEFINES="$DEFINES -DBSPF_UNIX -DRETRON77" DEFINES="$DEFINES -DBSPF_UNIX -DRETRON77"
@ -904,11 +893,11 @@ if test "$_build_png" = yes ; then
fi fi
fi fi
if test "$_build_sqlite" = yes; then if test "$_sqlite" = yes; then
DEFINES="$DEFINES -DSQLITE_SUPPORT"
MODULES="$MODULES $SQLITE"
INCLUDES="$INCLUDES -I$SQLITE"
LIBS="$LIBS -lsqlite3" LIBS="$LIBS -lsqlite3"
else
MODULES="$MODULES $SQLITE_LIB"
INCLUDES="$INCLUDES -I$SQLITE_LIB"
fi fi
if test "$_build_zip" = yes ; then if test "$_build_zip" = yes ; then

10
src/sqlite/module.mk Normal file
View File

@ -0,0 +1,10 @@
MODULE := src/sqlite
MODULE_OBJS := \
src/sqlite/sqlite3.o
MODULE_DIRS += \
src/sqlite
# Include common rules
include $(srcdir)/common.rules

231754
src/sqlite/source/sqlite3.c Normal file

File diff suppressed because it is too large Load Diff

12237
src/sqlite/source/sqlite3.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff