From ab4b5d4fed894a8ea469252d393005eec1221d3e Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 26 Sep 2016 12:14:53 -0400 Subject: [PATCH] more mods to support windows, but for gnu compilation this time under cygwin. --- nucleus/library/crypto/ssl_init.h | 2 +- nucleus/library/filesystem/filename.cpp | 2 +- nucleus/library/security/win32_security.cpp | 2 +- .../tests_nodes/test_packable_tree.cpp | 3 -- nucleus/library/versions/version_checker.cpp | 36 ++++++++++++------- .../tools/simple_utilities/create_guid.cpp | 6 ++-- nucleus/tools/simple_utilities/makefile | 2 +- nucleus/tools/simple_utilities/playsound.cpp | 4 +-- scripts/clam/cpp/rules.def | 19 +++++----- scripts/clam/cpp/variables.def | 17 +++++++-- 10 files changed, 57 insertions(+), 36 deletions(-) diff --git a/nucleus/library/crypto/ssl_init.h b/nucleus/library/crypto/ssl_init.h index ece041c5..fc1d8af2 100644 --- a/nucleus/library/crypto/ssl_init.h +++ b/nucleus/library/crypto/ssl_init.h @@ -29,7 +29,7 @@ namespace crypto { */ //we define NEWER_OPENSSL for those places where we're using openssl 1.1.1. -#ifdef _MSC_VER +#if defined(_MSC_VER) #define NEWER_OPENSSL #else // #define OLDER_OPENSSL diff --git a/nucleus/library/filesystem/filename.cpp b/nucleus/library/filesystem/filename.cpp index 152cfc04..ed7b914a 100644 --- a/nucleus/library/filesystem/filename.cpp +++ b/nucleus/library/filesystem/filename.cpp @@ -24,7 +24,7 @@ #include #include #include -#if defined(__UNIX__) +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) #include #else #include diff --git a/nucleus/library/security/win32_security.cpp b/nucleus/library/security/win32_security.cpp index e62a65c5..ab8226d1 100644 --- a/nucleus/library/security/win32_security.cpp +++ b/nucleus/library/security/win32_security.cpp @@ -16,7 +16,7 @@ * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ -#ifdef __WIN32__ +#ifdef _MSC_VER #include "win32_security.h" diff --git a/nucleus/library/tests_nodes/test_packable_tree.cpp b/nucleus/library/tests_nodes/test_packable_tree.cpp index 3d971dda..1793fd20 100644 --- a/nucleus/library/tests_nodes/test_packable_tree.cpp +++ b/nucleus/library/tests_nodes/test_packable_tree.cpp @@ -34,9 +34,6 @@ #include #include -#ifdef __WIN32__ - #include -#endif #include #include #include diff --git a/nucleus/library/versions/version_checker.cpp b/nucleus/library/versions/version_checker.cpp index 88788517..d3c2a235 100644 --- a/nucleus/library/versions/version_checker.cpp +++ b/nucleus/library/versions/version_checker.cpp @@ -44,7 +44,8 @@ using namespace structures; #include #endif -#ifdef __WIN32__ +#if defined(_MSC_VER) +//#ifdef __WIN32__ // ensures that we handle the data properly regardless of unicode settings. #ifdef UNICODE #define render_ptr(ptr) from_unicode_temp( (UTF16 *) ptr) @@ -97,7 +98,8 @@ bool version_checker::good_version() const bool version_checker::loaded(const astring &library_file_name) { -#ifdef __WIN32__ +//#ifdef __WIN32__ +#if defined(_MSC_VER) return bool(get_handle(library_file_name) != 0); #else //temp code. @@ -107,7 +109,8 @@ bool version_checker::loaded(const astring &library_file_name) void *version_checker::get_handle(const astring &library_file_name) { -#ifdef __WIN32__ +//#ifdef __WIN32__ +#if defined(_MSC_VER) return GetModuleHandle(to_unicode_temp(library_file_name)); #else if (library_file_name.t()) return NIL; else return NIL; @@ -116,10 +119,11 @@ void *version_checker::get_handle(const astring &library_file_name) astring version_checker::module_name(const void *module_handle) { -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) if (module_handle) {} return application_configuration::application_name(); -#elif defined(__WIN32__) +#elif defined(_MSC_VER) +//#elif defined(__WIN32__) flexichar low_buff[MAX_ABS_PATH + 1]; GetModuleFileName((HMODULE)module_handle, low_buff, MAX_ABS_PATH - 1); astring buff = from_unicode_temp(low_buff); @@ -141,7 +145,8 @@ bool version_checker::retrieve_version_info(const astring &filename, // determine the required size of the version info buffer. int required_size; -#ifdef __WIN32__ +#if defined(_MSC_VER) +//#ifdef __WIN32__ un_long module_handle; // filled with the dll or exe handle. required_size = GetFileVersionInfoSize(to_unicode_temp(filename), &module_handle); #else @@ -152,7 +157,8 @@ bool version_checker::retrieve_version_info(const astring &filename, // read the version info into our buffer. bool success = false; -#ifdef __WIN32__ +#if defined(_MSC_VER) +//#ifdef __WIN32__ success = GetFileVersionInfo(to_unicode_temp(filename), module_handle, required_size, to_fill.access()); #else @@ -166,7 +172,8 @@ bool version_checker::get_language(byte_array &version_chunk, { high = 0; low = 0; -#ifdef __WIN32__ +#if defined(_MSC_VER) +//#ifdef __WIN32__ // determine the language that the version's written in. basis::un_int data_size; void *pointer_to_language_structure; @@ -188,7 +195,8 @@ bool version_checker::get_language(byte_array &version_chunk, version version_checker::retrieve_version(const astring &filename) { -#ifdef UNIX +//#ifdef UNIX +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // totally bogus stand-in; this just returns the version we were built with // rather than the version that's actually tagged on the file. @@ -213,7 +221,7 @@ version version_checker::retrieve_version(const astring &filename) astring file_version_key(root_key + astring("\\FileVersion")); astring version_string; -#ifdef __WIN32__ +#ifdef _MSC_VER abyte *file_version_pointer; basis::un_int data_size; if (!VerQueryValue(version_info_found.access(), @@ -256,7 +264,8 @@ bool version_checker::get_record(const astring &filename, // the various version pieces are retrieved... -#ifdef __WIN32__ +//#ifdef __WIN32__ +#ifdef _MSC_VER basis::un_int data_size; void *data_pointer; @@ -348,9 +357,10 @@ void version_checker::complain_wrong_version(const astring &library_file_name, to_show += astring("]. "); to_show += *_version_complaint; -#ifdef __UNIX__ +//#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) continuable_error("version checking", "failure", to_show.s()); -#elif defined(__WIN32__) +#elif defined(_MSC_VER) MessageBox(0, to_unicode_temp(to_show), to_unicode_temp("version_checking::failure"), MB_OK); #endif diff --git a/nucleus/tools/simple_utilities/create_guid.cpp b/nucleus/tools/simple_utilities/create_guid.cpp index e359804e..942925de 100644 --- a/nucleus/tools/simple_utilities/create_guid.cpp +++ b/nucleus/tools/simple_utilities/create_guid.cpp @@ -27,7 +27,7 @@ #include #include -#ifdef __WIN32__ +#ifdef _MSC_VER #include #endif @@ -59,7 +59,7 @@ int create_guid::execute() { FUNCDEF("execute"); SETUP_CONSOLE_LOGGER; -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // this is completely bogus for the time being. it just produces a random // number rather than a guid. @@ -77,7 +77,7 @@ int create_guid::execute() for (int i = 0; i < 8; i++) add_random; faux_guid += "}"; BASE_LOG(faux_guid.lower()); -#elif defined (__WIN32__) +#elif defined (_MSC_VER) GUID guid; CoCreateGuid(&guid); const int BUFFER_SIZE = 1024; diff --git a/nucleus/tools/simple_utilities/makefile b/nucleus/tools/simple_utilities/makefile index 0fe5e849..5983fae5 100644 --- a/nucleus/tools/simple_utilities/makefile +++ b/nucleus/tools/simple_utilities/makefile @@ -12,7 +12,7 @@ ifeq "$(OMIT_VERSIONS)" "" endif DEFINITIONS += __BUILD_STATIC_APPLICATION__ UNDEFINITIONS += ENABLE_MEMORY_HOOK ENABLE_CALLSTACK_TRACKING -ifeq "$(OP_SYSTEM)" "WIN32" +ifeq "$(COMPILER)" "VISUAL_CPP" # static C runtime support... #hmmm: resurrect this as a particular build type, so makefiles don't need to know this... COMPILER_FLAGS += -MT diff --git a/nucleus/tools/simple_utilities/playsound.cpp b/nucleus/tools/simple_utilities/playsound.cpp index d5fa793e..4f94ad96 100644 --- a/nucleus/tools/simple_utilities/playsound.cpp +++ b/nucleus/tools/simple_utilities/playsound.cpp @@ -26,7 +26,7 @@ #include #include -#ifdef __WIN32__ +#ifdef _MSC_VER #include #endif @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) } for (int i = 1; i < argc; i++) { // out.log(astring(astring::SPRINTF, "soundfile %d: %s", i, argv[i])); -#ifdef __WIN32__ +#ifdef _MSC_VER if (!PlaySound(to_unicode_temp(argv[i]), NIL, SND_FILENAME)) out.log(astring("failed to play ") + argv[i], ALWAYS_PRINT); #else diff --git a/scripts/clam/cpp/rules.def b/scripts/clam/cpp/rules.def index 0b9c3599..b9db8446 100644 --- a/scripts/clam/cpp/rules.def +++ b/scripts/clam/cpp/rules.def @@ -163,8 +163,8 @@ ifneq "$(OP_SYSTEM)" "WIN32" endif # win32 compiler additions. -ifeq "$(OP_SYSTEM)" "WIN32" -#ifeq "$(COMPILER)" "VISUAL_CPP" +#ifeq "$(OP_SYSTEM)" "WIN32" +ifeq "$(COMPILER)" "VISUAL_CPP" # processes the def file for linkage, if one has been specified. ifneq "$(DEF_FILE)" "" LOAD_FLAG_PREFIX += -def:$(DEF_FILE) @@ -207,7 +207,7 @@ ifeq "$(OP_SYSTEM)" "WIN32" endif ifneq "$(USE_CURL)" "" - # curl wants this win32 flag? +# # curl wants this win32 flag? # DEFINITIONS += _WIN32 LOCAL_HEADERS += $(THIRD_PARTY_DIR)/curl/include LIBRARY_SEARCH_PATH += $(THIRD_PARTY_DIR)/curl/lib @@ -244,13 +244,13 @@ ifeq "$(OP_SYSTEM)" "WIN32" LOCAL_HEADERS += $(THIRD_PARTY_DIR)/openssl/include LIBRARY_SEARCH_PATH += $(THIRD_PARTY_DIR)/openssl/lib LIBS_USED += libcrypto.lib libssl.lib -# LIBS_USED += libeay32.lib $(shell cp $(THIRD_PARTY_DIR)/openssl/lib/*dll $(EXECUTABLE_DIR) ) endif endif -ifeq "$(OP_SYSTEM)" "WIN32" +#ifeq "$(OP_SYSTEM)" "WIN32" +ifeq "$(COMPILER)" "VISUAL_CPP" # prep the actual source variable so that certain file names are translated. ACTUAL_RESX = $(RESX:%.resx=$(OBJECT_DIR)/%.resources) ACTUAL_RESX_FLAGS = $(ACTUAL_RESX:%=-ASSEMBLYLINKRESOURCE:%) @@ -266,7 +266,7 @@ ACTUAL_LOCAL_LIBS = $(TEMP_LOC1) # Create the list of objects from the list of source files. TEMP_OBJ1 = $(SOURCE:%.cpp=%.obj) TEMP_OBJ2 = $(TEMP_OBJ1:%.c=%.obj) -ifeq "$(OP_SYSTEM)" "WIN32" +ifeq "$(COMPILER)" "VISUAL_CPP" ifneq "$(OMIT_VERSIONS)" "" # remove version rc files if we're not dealing with versions. TEMP_OBJ3a = $(TEMP_OBJ2:%_version.rc=) @@ -333,7 +333,8 @@ MULTI_BUILD_CMD = $(CC) $(COMPILER_FLAGS) -c `cat $(BUILD_LIST_FILE)` $(OBJECT_N # support for allocations; if regular new and DEBUG_NEW get mixed together, # crashes used to result. supposedly these are gone now at least. ifneq "$(USE_MFC)" "" - ifeq "$(OP_SYSTEM)" "WIN32" +# ifeq "$(OP_SYSTEM)" "WIN32" + ifeq "$(COMPILER)" "VISUAL_CPP" # set the flag that says we are doing mfc extension dlls. DEFINITIONS += _AFXDLL DEPENDENCY_DEFINITIONS += _MT _DLL @@ -462,7 +463,7 @@ endif # resource compiler for win32. -ifeq "$(OP_SYSTEM)" "WIN32" +ifeq "$(COMPILER)" "VISUAL_CPP" $(OBJECT_DIR)/%.res: %.rc $(PARAMETER_FILE) ifeq "$(NO_COMPILE)" "" @echo Resource [$@] @@ -476,7 +477,7 @@ $(OBJECT_DIR)/%.resources: %.resx $(PARAMETER_FILE) $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi' $(VCS_ROOT)/../SDK/v1.1/bin/resgen $< $@ endif -else #non-win32 +else #non-visual studio # this platform probably does not use rc files. $(OBJECT_DIR)/%.res: %.rc ifeq "$(NO_COMPILE)" "" diff --git a/scripts/clam/cpp/variables.def b/scripts/clam/cpp/variables.def index 1581e075..fc161193 100644 --- a/scripts/clam/cpp/variables.def +++ b/scripts/clam/cpp/variables.def @@ -72,8 +72,8 @@ ifeq "$(COMPILER)" "" endif endif ifeq "$(OP_SYSTEM)" "WIN32" -# COMPILER := GNU_WINDOWS - COMPILER := VISUAL_CPP + COMPILER := GNU_WINDOWS +# COMPILER := VISUAL_CPP endif ifeq "$(COMPILER)" "" # if we get into this case, we have no idea how to set the default @@ -456,6 +456,10 @@ ifneq "$(OMIT_VERSIONS)" "" DEFINITIONS += NO_VERSION endif +############################################################################ +# compiler specific section below. +############################################################################ + ifeq "$(COMPILER)" "GNU_LINUX" # Unix GNU compiler... CC = g++ @@ -538,6 +542,8 @@ ifeq "$(COMPILER)" "GNU_LINUX" endif +############################################################################ + ifeq "$(COMPILER)" "GNU_ARM_LINUX" # ARM-linux GNU compiler... COMPILER_ROOT_DIR = /usr/local/arm-linux @@ -582,6 +588,8 @@ ifeq "$(COMPILER)" "GNU_ARM_LINUX" endif +############################################################################ + ifeq "$(COMPILER)" "GNU_WINDOWS" # GNU compiler for MS Windoze... CC = g++ @@ -606,6 +614,7 @@ ifeq "$(COMPILER)" "GNU_WINDOWS" LIBRARY_TOOL = ar LIBRARY_PATH_FLAG = -L LIB_PREFIX = lib + LIB_ENDING = .a # LOAD_FLAG_PREFIX += -lpthread LOAD_FLAG_PREFIX += -mwindows CREATE_LIBRARY_FLAG += -r @@ -619,6 +628,8 @@ ifeq "$(COMPILER)" "GNU_WINDOWS" endif +############################################################################ + ifeq "$(COMPILER)" "VISUAL_CPP" # microsoft visual c++ 4.x, 5.x or 6.x. @@ -898,6 +909,8 @@ ifeq "$(COMPILER)" "VISUAL_CPP" endif +############################################################################ + ifeq "$(COMPILER)" "GNU_DARWIN" # Darwin kernel GNU compiler... CC = g++ -- 2.34.1