From: Chris Koeritz Date: Thu, 22 Sep 2016 21:47:27 +0000 (-0400) Subject: lots of mods getting windows to build under cygwin without visual studio. X-Git-Tag: 2.140.90~430 X-Git-Url: https://feistymeow.org/gitweb/?p=feisty_meow.git;a=commitdiff_plain;h=24b2947ed9364f3e83fa1bb544ff6b1fdbf0428f lots of mods getting windows to build under cygwin without visual studio. not quite there yet, but have made it to filesystem tests. --- diff --git a/nucleus/library/application/command_line.cpp b/nucleus/library/application/command_line.cpp index de6d6110..f132867f 100644 --- a/nucleus/library/application/command_line.cpp +++ b/nucleus/library/application/command_line.cpp @@ -74,7 +74,7 @@ command_parameter &command_parameter::operator = // the default is a dash (-), while for DOS most programs use forward-slash // (/). Adding more characters is trivial; just add a character to the list // before the sentinel of '\0'. -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WIN32__) static char option_prefixes[] = { '-', '/', '\0' }; #elif defined(__UNIX__) static char option_prefixes[] = { '-', '\0' }; @@ -244,7 +244,7 @@ string_array command_line::get_command_line() // the temporary string below can be given a flat formatting of the commands // and it will be popped out into a list of arguments. astring temporary; -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) if (!_global_argc || !_global_argv) { // our global parameters have not been set, so we must calculate them. temporary = application_configuration::get_cmdline_from_proc(); @@ -257,7 +257,7 @@ string_array command_line::get_command_line() // we don't need a long string to be parsed; the list is ready. return listo_cmds; } -#elif defined(__WIN32__) +#elif defined(_MSC_VER) // we have easy access to the original list of commands. for (int i = 0; i < _global_argc; i++) { // add a string entry for each argument. diff --git a/nucleus/library/application/hoople_main.h b/nucleus/library/application/hoople_main.h index aac5a74e..51875c2c 100644 --- a/nucleus/library/application/hoople_main.h +++ b/nucleus/library/application/hoople_main.h @@ -56,7 +56,7 @@ namespace application { ////////////// -#elif defined(__UNIX__) +#elif defined(__UNIX__) || defined(__GNU_WINDOWS__) //! options that should work for most unix and linux apps. #define HOOPLE_MAIN(obj_name, obj_args) \ HOOPLE_STARTUP_CODE; \ @@ -69,7 +69,7 @@ namespace application { ////////////// -#elif defined(__WIN32__) +#elif defined(_MSC_VER) // for win32 we need to support four different environments--console mode, // borland compilation, MFC programs and regular windows programs. #ifdef _CONSOLE diff --git a/nucleus/library/application/hoople_service.cpp b/nucleus/library/application/hoople_service.cpp index 969a2c27..317ada24 100644 --- a/nucleus/library/application/hoople_service.cpp +++ b/nucleus/library/application/hoople_service.cpp @@ -113,10 +113,9 @@ bool hoople_service::close_application(const astring &app_name) // zap all of them using our signal. for (int i = 0; i < pids.length(); i++) { //would linux be better served with sigterm also? -#ifdef __UNIX__ +#ifndef _MSC_VER kill(pids[i], SIGHUP); -#endif -#ifdef __WIN32__ +#else //lame--goes to whole program. raise(SIGTERM); #endif @@ -151,13 +150,13 @@ bool hoople_service::setup(const astring &app_name, int timer_period) // setup signal handler for HUP signal. this is the one used to tell us // to leave. -#ifdef __UNIX__ +#ifndef _MSC_VER signal(SIGHUP, handle_OS_signal); #endif // setup a handler for interrupt (e.g. ctrl-C) also. signal(SIGINT, handle_OS_signal); -#ifdef __WIN32__ +#ifdef _MSC_VER signal(SIGBREAK, handle_OS_signal); #endif diff --git a/nucleus/library/application/registry_config.cpp b/nucleus/library/application/registry_config.cpp index 96f9fc92..0fcbb01b 100644 --- a/nucleus/library/application/registry_config.cpp +++ b/nucleus/library/application/registry_config.cpp @@ -23,7 +23,7 @@ using namespace basis; using namespace filesystem; using namespace structures; -#ifdef __WIN32__ +#ifdef _MSC_VER // this implementation only works on windows currently. //hmmm: i suppose we could fake it with an ini file. @@ -106,7 +106,7 @@ bool registry_configurator::put(const astring §ion_in, const astring &entry, if (!to_store.length()) return delete_entry(section, entry); else if (!section.length()) return false; -#ifdef __WIN32__ +#ifdef _MSC_VER HKEY key; long ret = RegOpenKeyEx((HKEY)translate_hive(_hive), to_unicode_temp(section), 0, KEY_WRITE, &key); @@ -145,7 +145,7 @@ bool registry_configurator::get(const astring §ion_in, const astring &entry, if (!section_in) return false; if (!entry) {} // not a problem. astring section = fix_section(section_in); -#ifdef __WIN32__ +#ifdef _MSC_VER HKEY key; long ret = RegOpenKeyEx((HKEY)translate_hive(_hive), to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key); @@ -190,7 +190,7 @@ bool registry_configurator::get_section(const astring §ion_in, info.reset(); if (!section_in.length()) return false; astring section = fix_section(section_in); -#ifdef __WIN32__ +#ifdef _MSC_VER HKEY key; long ret = RegOpenKeyEx((HKEY)translate_hive(_hive), to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key); @@ -233,7 +233,7 @@ bool registry_configurator::section_exists(const astring §ion_in) FUNCDEF("section_exists"); if (!section_in.length()) return false; astring section = fix_section(section_in); -#ifdef __WIN32__ +#ifdef _MSC_VER HKEY key; long ret = RegOpenKeyEx((HKEY)translate_hive(_hive), to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key); @@ -254,7 +254,7 @@ bool registry_configurator::delete_section(const astring §ion_in) if (!section_in.length()) return false; astring section = fix_section(section_in); //if the key doesn't exist, should that be a failure? -#ifdef __WIN32__ +#ifdef _MSC_VER long ret = SHDeleteKey((HKEY)translate_hive(_hive), to_unicode_temp(section)); if (ret != ERROR_SUCCESS) { @@ -275,7 +275,7 @@ bool registry_configurator::delete_entry(const astring §ion_in, astring section = fix_section(section_in); if (!entry) {} // no problem. -#ifdef __WIN32__ +#ifdef _MSC_VER HKEY key; long ret = RegOpenKeyEx((HKEY)translate_hive(_hive), to_unicode_temp(section), 0, KEY_SET_VALUE, &key); diff --git a/nucleus/library/application/windoze_helper.h b/nucleus/library/application/windoze_helper.h index a02b2965..3da87453 100644 --- a/nucleus/library/application/windoze_helper.h +++ b/nucleus/library/application/windoze_helper.h @@ -23,8 +23,11 @@ // gnarly headers that are needed for certain types of compilation... //unix headers not needed in here for new purpose of file. -#ifdef __UNIX__ +#ifndef _MSC_VER #include + #ifdef __GNU_WINDOWS__ + #include + #endif #endif #ifndef NO_XWINDOWS #ifdef __XWINDOWS__ @@ -38,6 +41,11 @@ #ifndef STRICT #define STRICT #endif + // winsock support... + #undef FD_SETSIZE + #define FD_SETSIZE 1000 + // if you don't set this, you can only select on a default of 64 sockets. + #include // windows headers... #define _WINSOCKAPI_ // make windows.h happy about winsock. #ifndef _AFXDLL @@ -48,11 +56,6 @@ #include #include #endif - // winsock support... - #undef FD_SETSIZE - #define FD_SETSIZE 1000 - // if you don't set this, you can only select on a default of 64 sockets. - #include #endif // forward. diff --git a/nucleus/library/basis/astring.cpp b/nucleus/library/basis/astring.cpp index 55b9daf8..3c09fce8 100644 --- a/nucleus/library/basis/astring.cpp +++ b/nucleus/library/basis/astring.cpp @@ -19,12 +19,12 @@ #include #include -#ifdef __WIN32__ - #undef strcasecmp - #undef strncasecmp - #define strcasecmp strcmpi - #define strncasecmp strnicmp -#endif +//#ifdef __WIN32__ +// #undef strcasecmp +// #undef strncasecmp +// #define strcasecmp strcmpi +// #define strncasecmp strnicmp +//#endif //#define DEBUG_STRING // uncomment for debugging version. diff --git a/nucleus/library/basis/environment.cpp b/nucleus/library/basis/environment.cpp index 520b7791..6ce8b06c 100644 --- a/nucleus/library/basis/environment.cpp +++ b/nucleus/library/basis/environment.cpp @@ -17,12 +17,17 @@ #include #include -#ifdef __UNIX__ +#ifndef _MSC_VER #include #include #endif -#ifdef __WIN32__ +#ifdef _MSC_VER #define _WINSOCKAPI_ // make windows.h happy about winsock. + // winsock support... + #undef FD_SETSIZE + #define FD_SETSIZE 1000 + // if you don't set this, you can only select on a default of 64 sockets. + #include #include #include #endif @@ -49,7 +54,7 @@ astring environment::TMP() astring environment::get(const astring &variable_name) { -#ifdef __WIN32__ +#ifdef _MSC_VER char *value = getenv(variable_name.upper().observe()); // dos & os/2 require upper case for the name, so we just do it that way. #else @@ -65,7 +70,7 @@ astring environment::get(const astring &variable_name) bool environment::set(const astring &variable_name, const astring &value) { int ret = 0; -#ifdef __WIN32__ +#ifdef _MSC_VER astring assignment = variable_name + "=" + value; ret = _putenv(assignment.s()); #else @@ -76,7 +81,7 @@ bool environment::set(const astring &variable_name, const astring &value) basis::un_int environment::system_uptime() { -#ifdef __WIN32__ +#ifdef _MSC_VER return timeGetTime(); #else static clock_t __ctps = sysconf(_SC_CLK_TCK); // clock ticks per second. diff --git a/nucleus/library/basis/mutex.cpp b/nucleus/library/basis/mutex.cpp index 6a9af775..1857e106 100644 --- a/nucleus/library/basis/mutex.cpp +++ b/nucleus/library/basis/mutex.cpp @@ -26,6 +26,11 @@ #endif #ifdef __WIN32__ #define _WINSOCKAPI_ // make windows.h happy about winsock. + // winsock support... + #undef FD_SETSIZE + #define FD_SETSIZE 1000 + // if you don't set this, you can only select on a default of 64 sockets. + #include #include #endif diff --git a/nucleus/library/configuration/application_configuration.cpp b/nucleus/library/configuration/application_configuration.cpp index 9f01391f..af502e78 100644 --- a/nucleus/library/configuration/application_configuration.cpp +++ b/nucleus/library/configuration/application_configuration.cpp @@ -29,13 +29,11 @@ #include #include #endif -#ifdef __WIN32__ +#ifdef _MSC_VER #include #include #else #include -#endif -#ifdef __UNIX__ #include #include #endif @@ -58,7 +56,7 @@ namespace configuration { const int MAXIMUM_COMMAND_LINE = 32 * KILOBYTE; // maximum command line that we'll deal with here. -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) astring application_configuration::get_cmdline_from_proc() { FUNCDEF("get_cmdline_from_proc"); @@ -205,9 +203,9 @@ astring application_configuration::application_name() uint32_t buffsize = MAX_ABS_PATH - 1; _NSGetExecutablePath(buffer, &buffsize); to_return = (char *)buffer; -#elif __UNIX__ +#elif defined(__UNIX__) || defined(__GNU_WINDOWS__) to_return = get_cmdline_from_proc(); -#elif defined(__WIN32__) +#elif defined(_MSC_VER) flexichar low_buff[MAX_ABS_PATH + 1]; GetModuleFileName(NIL, low_buff, MAX_ABS_PATH - 1); astring buff = from_unicode_temp(low_buff); @@ -220,7 +218,7 @@ astring application_configuration::application_name() return to_return; } -#if defined(__UNIX__) || defined(__WIN32__) +#if defined(__UNIX__) || defined(_MSC_VER) || defined(__GNU_WINDOWS__) basis::un_int application_configuration::process_id() { return getpid(); } #else #pragma error("hmmm: need process id implementation for this OS!") @@ -234,7 +232,7 @@ astring application_configuration::current_directory() char buff[MAX_ABS_PATH]; getcwd(buff, MAX_ABS_PATH - 1); to_return = buff; -#elif defined(__WIN32__) +#elif defined(_MSC_VER) flexichar low_buff[MAX_ABS_PATH + 1]; GetCurrentDirectory(MAX_ABS_PATH, low_buff); to_return = from_unicode_temp(low_buff); @@ -265,7 +263,7 @@ structures::version application_configuration::get_OS_version() utsname kernel_parms; uname(&kernel_parms); to_return = version(kernel_parms.release); -#elif defined(__WIN32__) +#elif defined(_MSC_VER) OSVERSIONINFO info; info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ::GetVersionEx(&info); diff --git a/nucleus/library/configuration/application_configuration.h b/nucleus/library/configuration/application_configuration.h index 52ddb864..bb829304 100644 --- a/nucleus/library/configuration/application_configuration.h +++ b/nucleus/library/configuration/application_configuration.h @@ -113,7 +113,7 @@ public: need a filename. an empty string is returned on failure to create the directory. */ -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) #ifdef __APPLE__ static basis::astring get_cmdline_for_apple(); #endif diff --git a/nucleus/library/configuration/ini_configurator.cpp b/nucleus/library/configuration/ini_configurator.cpp index 8f66f01a..67436f83 100644 --- a/nucleus/library/configuration/ini_configurator.cpp +++ b/nucleus/library/configuration/ini_configurator.cpp @@ -51,7 +51,7 @@ ini_configurator::ini_configurator(const astring &ini_filename, treatment_of_defaults behavior, file_location_default where) : configurator(behavior), _ini_name(new filename), -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) _parser(new ini_parser("", behavior)), #endif _where(where), @@ -63,7 +63,7 @@ ini_configurator::ini_configurator(const astring &ini_filename, ini_configurator::~ini_configurator() { WHACK(_ini_name); -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) WHACK(_parser); #endif } @@ -72,7 +72,7 @@ astring ini_configurator::name() const { return _ini_name->raw(); } void ini_configurator::refresh() { -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) write_ini_file(); WHACK(_parser); _parser = new ini_parser("", behavior()); @@ -88,7 +88,7 @@ void ini_configurator::name(const astring &name) // that don't include a directory name. if (_where == OS_DIRECTORY) use_appdir = false; if (_where == ALL_USERS_DIRECTORY) use_appdir = false; -#ifndef __WIN32__ +#ifdef _MSC_VER use_appdir = true; #endif // we must create the filename if they specified no directory at all. @@ -108,7 +108,7 @@ void ini_configurator::name(const astring &name) _ini_name->basename()); } } -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // read in the file's contents. read_ini_file(); #endif @@ -139,7 +139,7 @@ void ini_configurator::sections(string_array &list) //hmmm: refactor section_exists to use the sections call, if it's faser? bool ini_configurator::section_exists(const astring §ion) { -#ifdef __WIN32__ +#ifdef _MSC_VER string_table infos; // heavy-weight call here... return get_section(section, infos); @@ -148,7 +148,7 @@ bool ini_configurator::section_exists(const astring §ion) #endif } -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) void ini_configurator::read_ini_file() { #ifdef DEBUG_INI_CONFIGURATOR @@ -200,7 +200,7 @@ void ini_configurator::write_ini_file() bool ini_configurator::delete_section(const astring §ion) { -#ifdef __WIN32__ +#ifdef _MSC_VER return put_profile_string(section, "", ""); #else // zap the section. @@ -213,7 +213,7 @@ bool ini_configurator::delete_section(const astring §ion) bool ini_configurator::delete_entry(const astring §ion, const astring &ent) { -#ifdef __WIN32__ +#ifdef _MSC_VER return put_profile_string(section, ent, ""); #else // zap the entry. @@ -231,7 +231,7 @@ bool ini_configurator::put(const astring §ion, const astring &entry, if (!to_store.length()) return delete_entry(section, entry); else if (!entry.length()) return delete_section(section); else if (!section.length()) return false; -#ifdef __WIN32__ +#ifdef _MSC_VER return put_profile_string(section, entry, to_store); #else // write the entry. @@ -245,7 +245,7 @@ bool ini_configurator::put(const astring §ion, const astring &entry, bool ini_configurator::get(const astring §ion, const astring &entry, astring &found) { -#ifndef __WIN32__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) return _parser->get(section, entry, found); #else flexichar temp_buffer[MAXIMUM_LINE_INI_CONFIG]; @@ -260,7 +260,7 @@ bool ini_configurator::get(const astring §ion, const astring &entry, bool ini_configurator::get_section(const astring §ion, string_table &info) { FUNCDEF("get_section"); -#ifndef __WIN32__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) return _parser->get_section(section, info); #else info.reset(); @@ -302,7 +302,7 @@ bool ini_configurator::get_section(const astring §ion, string_table &info) bool ini_configurator::put_section(const astring §ion, const string_table &info) { -#ifdef __WIN32__ +#ifdef _MSC_VER variable_tokenizer parser("\1", "="); parser.table() = info; astring flat = parser.text_form(); @@ -330,7 +330,7 @@ bool ini_configurator::put_section(const astring §ion, #endif } -#ifdef __WIN32__ +#ifdef _MSC_VER bool ini_configurator::put_profile_string(const astring §ion, const astring &entry, const astring &to_store) { diff --git a/nucleus/library/configuration/ini_configurator.h b/nucleus/library/configuration/ini_configurator.h index ad99906d..cb58ccdb 100644 --- a/nucleus/library/configuration/ini_configurator.h +++ b/nucleus/library/configuration/ini_configurator.h @@ -16,7 +16,7 @@ \*****************************************************************************/ #include "configurator.h" -#ifndef __WIN32__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) #include "ini_parser.h" #include #endif @@ -110,13 +110,13 @@ public: private: filesystem::filename *_ini_name; //!< the file we're manipulating. -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) ini_parser *_parser; //!< used for real storage and parsing. #endif file_location_default _where; //!< where to find and store the file. bool _add_spaces; //!< tracks whether we're adding spaces around equals. -#ifdef __WIN32__ +#ifdef _MSC_VER bool put_profile_string(const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store); //!< encapsulates windows' ini storage method. @@ -124,8 +124,7 @@ private: const basis::astring &default_value, basis::flexichar *return_buffer, int buffer_size); //!< encapsulates windows' ini retrieval method. -#endif -#ifdef __UNIX__ +#else void read_ini_file(); //!< reads the INI file's contents into memory. void write_ini_file(); diff --git a/nucleus/library/filesystem/directory.cpp b/nucleus/library/filesystem/directory.cpp index 052c10bf..c9ce8e99 100644 --- a/nucleus/library/filesystem/directory.cpp +++ b/nucleus/library/filesystem/directory.cpp @@ -27,13 +27,13 @@ #include #include #include -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) #include #include #include #include #endif -#ifdef __WIN32__ +#ifdef _MSC_VER #include #endif @@ -101,7 +101,7 @@ astring directory::absolute_path(const astring &rel_path) { char abs_path[MAX_ABS_PATH + 1]; abs_path[0] = '\0'; -#ifdef __WIN32__ +#ifdef _MSC_VER if (!_fullpath(abs_path, rel_path.s(), MAX_ABS_PATH)) return ""; return abs_path; #else @@ -113,7 +113,7 @@ astring directory::absolute_path(const astring &rel_path) astring directory::current() { astring to_return("."); // failure result. -#ifdef __WIN32__ +#ifdef _MSC_VER flexichar buffer[MAX_ABS_PATH + 1] = { '\0' }; GetCurrentDirectory(MAX_ABS_PATH, buffer); to_return = from_unicode_temp(buffer); @@ -151,7 +151,7 @@ bool directory::rescan() _folders->reset(); astring cur_dir = "."; astring par_dir = ".."; -#ifdef __WIN32__ +#ifdef _MSC_VER // start reading the directory. WIN32_FIND_DATA wfd; astring real_path_spec = *_path + "/" + *_pattern; @@ -194,8 +194,7 @@ bool directory::rescan() } } while (FindNextFile(search_handle, &wfd)); FindClose(search_handle); -#endif -#ifdef __UNIX__ +#else DIR *dir = opendir(_path->s()); //hmmm: could check errno to determine what caused the problem. if (!dir) return false; @@ -234,10 +233,9 @@ bool directory::rescan() bool directory::make_directory(const astring &path) { -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) int mk_ret = mkdir(path.s(), 0777); -#endif -#ifdef __WIN32__ +#else int mk_ret = mkdir(path.s()); #endif return !mk_ret; @@ -245,10 +243,9 @@ bool directory::make_directory(const astring &path) bool directory::remove_directory(const astring &path) { -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) int rm_ret = rmdir(path.s()); -#endif -#ifdef __WIN32__ +#else int rm_ret = rmdir(path.s()); #endif return !rm_ret; @@ -283,3 +280,4 @@ bool directory::recursive_create(const astring &directory_name) } } // namespace. + diff --git a/nucleus/library/filesystem/filename.cpp b/nucleus/library/filesystem/filename.cpp index 664a9970..5ce3886e 100644 --- a/nucleus/library/filesystem/filename.cpp +++ b/nucleus/library/filesystem/filename.cpp @@ -24,10 +24,9 @@ #include #include #include -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) #include -#endif -#ifdef __WIN32__ +#else #include #endif diff --git a/nucleus/library/filesystem/filename.h b/nucleus/library/filesystem/filename.h index c1710c13..d1f2fb42 100644 --- a/nucleus/library/filesystem/filename.h +++ b/nucleus/library/filesystem/filename.h @@ -27,6 +27,11 @@ class status_info; // define useful constant for filesystem path length. #ifndef MAX_ABS_PATH #ifdef __WIN32__ + // winsock support... + #undef FD_SETSIZE + #define FD_SETSIZE 1000 + // if you don't set this, you can only select on a default of 64 sockets. + #include #include #define MAX_ABS_PATH MAX_PATH #else diff --git a/nucleus/library/loggers/file_logger.cpp b/nucleus/library/loggers/file_logger.cpp index a18caa14..bd8c22a6 100644 --- a/nucleus/library/loggers/file_logger.cpp +++ b/nucleus/library/loggers/file_logger.cpp @@ -27,13 +27,12 @@ #include #include -#ifdef __WIN32__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) + #include +#else #include #endif #include -#ifdef __UNIX__ - #include -#endif using namespace basis; using namespace configuration; diff --git a/nucleus/library/processes/ethread.cpp b/nucleus/library/processes/ethread.cpp index 84e15498..15b39564 100644 --- a/nucleus/library/processes/ethread.cpp +++ b/nucleus/library/processes/ethread.cpp @@ -23,9 +23,9 @@ #include #include -#ifdef __WIN32__ +#ifdef _MSC_VER #include -#elif defined(__UNIX__) +#elif defined(__UNIX__) || defined(__GNU_WINDOWS__) #include #else #error unknown OS for thread support. @@ -89,10 +89,10 @@ ethread::ethread() _thread_active(false), _stop_thread(false), _data(NIL), -#ifdef __UNIX__ - _handle(new pthread_t), -#elif defined(__WIN32__) +#ifdef _MSC_VER _handle(0), +#else + _handle(new pthread_t), #endif _sleep_time(0), _periodic(false), @@ -107,10 +107,10 @@ ethread::ethread(int sleep_timer, timed_thread_types how) _thread_active(false), _stop_thread(false), _data(NIL), -#ifdef __UNIX__ - _handle(new pthread_t), -#elif defined(__WIN32__) +#ifdef _MSC_VER _handle(0), +#else + _handle(new pthread_t), #endif _sleep_time(sleep_timer), _periodic(true), @@ -127,7 +127,7 @@ ethread::~ethread() { stop(); WHACK(_next_activation); -#ifdef __UNIX__ +#ifndef _MSC_VER WHACK(_handle); #endif } @@ -155,7 +155,7 @@ bool ethread::start(void *thread_data) int error = 0; int attempts = 0; while (attempts++ < MAXIMUM_CREATE_ATTEMPTS) { -#ifdef __UNIX__ +#ifndef _MSC_VER pthread_attr_t attribs; // special flags for creation of thread. int aret = pthread_attr_init(&attribs); if (aret) LOG("failed to init attribs."); @@ -170,7 +170,7 @@ bool ethread::start(void *thread_data) (void *)this); if (!ret) success = true; else error = ret; -#elif defined(__WIN32__) +#else if (_periodic) _handle = _beginthread(periodic_thread_driver, 0, (void *)this); else @@ -197,7 +197,7 @@ void ethread::stop() cancel(); // tell thread to leave. if (!thread_started()) return; // not running. while (!thread_finished()) { -#ifdef __WIN32__ +#ifdef _MSC_VER int result = 0; if (!GetExitCodeThread((HANDLE)_handle, (LPDWORD)&result) || (result != STILL_ACTIVE)) { @@ -213,14 +213,14 @@ void ethread::exempt_stop() { _thread_active = false; _thread_ready = false; -#ifdef __WIN32__ +#ifdef _MSC_VER _handle = 0; #endif } -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) void *ethread::one_shot_thread_driver(void *hidden_pointer) -#elif defined(__WIN32__) +#elif defined(_MSC_VER) void ethread::one_shot_thread_driver(void *hidden_pointer) #else #error unknown thread signature. @@ -228,7 +228,7 @@ void ethread::one_shot_thread_driver(void *hidden_pointer) { FUNCDEF("one_shot_thread_driver"); ethread *manager = (ethread *)hidden_pointer; -#ifdef __UNIX__ +#ifndef _MSC_VER if (!manager) return NIL; #else if (!manager) return; @@ -244,7 +244,7 @@ void ethread::one_shot_thread_driver(void *hidden_pointer) #ifdef COUNT_THREADS _current_threads().decrement(); #endif -#ifdef __UNIX__ +#ifndef _MSC_VER pthread_exit(NIL); return NIL; #else @@ -252,9 +252,9 @@ void ethread::one_shot_thread_driver(void *hidden_pointer) #endif } -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) void *ethread::periodic_thread_driver(void *hidden_pointer) -#elif defined(__WIN32__) +#elif defined(_MSC_VER) void ethread::periodic_thread_driver(void *hidden_pointer) #else #error unknown thread signature. @@ -262,9 +262,9 @@ void ethread::periodic_thread_driver(void *hidden_pointer) { FUNCDEF("periodic_thread_driver"); ethread *manager = (ethread *)hidden_pointer; -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) if (!manager) return NIL; -#elif defined(__WIN32__) +#elif defined(_MSC_VER) if (!manager) return; #endif #ifdef COUNT_THREADS @@ -316,10 +316,10 @@ void ethread::periodic_thread_driver(void *hidden_pointer) #ifdef COUNT_THREADS _current_threads().decrement(); #endif -#ifdef __UNIX__ +#ifndef _MSC_VER pthread_exit(NIL); return NIL; -#elif defined(__WIN32__) +#else _endthread(); #endif } diff --git a/nucleus/library/processes/ethread.h b/nucleus/library/processes/ethread.h index 9adab465..ddc11f84 100644 --- a/nucleus/library/processes/ethread.h +++ b/nucleus/library/processes/ethread.h @@ -20,12 +20,6 @@ #include -#ifndef __APPLE__ -#ifdef __UNIX__ -// typedef long unsigned int pthread_t; -#endif -#endif - namespace processes { //! Provides a platform-independent object for adding threads to a program. @@ -154,9 +148,9 @@ private: bool _thread_active; //!< is the thread currently performing? bool _stop_thread; //!< true if the thread should stop now. void *_data; //!< holds the thread's link back to whatever. -#ifdef __UNIX__ +#ifndef _MSC_VER pthread_t *_handle; //!< thread structure for our thread. -#elif defined(__WIN32__) +#else uintptr_t _handle; //!< thread handle for the active thread, or zero. #endif int _sleep_time; //!< threads perform at roughly this interval. @@ -165,10 +159,10 @@ private: timed_thread_types _how; //!< how is the period evaluated? // the OS level thread functions. -#ifdef __UNIX__ +#ifndef _MSC_VER static void *periodic_thread_driver(void *hidden_pointer); static void *one_shot_thread_driver(void *hidden_pointer); -#elif defined(__WIN32__) +#else static void periodic_thread_driver(void *hidden_pointer); static void one_shot_thread_driver(void *hidden_pointer); #endif diff --git a/nucleus/library/processes/launch_process.cpp b/nucleus/library/processes/launch_process.cpp index bb8d7ada..20e10fda 100644 --- a/nucleus/library/processes/launch_process.cpp +++ b/nucleus/library/processes/launch_process.cpp @@ -22,13 +22,12 @@ #include #include -#ifdef __UNIX__ +#ifndef _MSC_VER #include #include #include #include -#endif -#ifdef __WIN32__ +#else #include #include #include @@ -60,7 +59,7 @@ int_set __our_kids() { return __hidden_kids; } -#ifdef __WIN32__ +#ifdef _MSC_VER bool launch_process::event_poll(MSG &message) { message.hwnd = 0; @@ -87,7 +86,7 @@ bool launch_process::event_poll(MSG &message) //const int MAXIMUM_COMMAND_LINE = 32 * KILOBYTE; // maximum command line that we'll deal with here. -#ifdef __UNIX__ +#ifndef _MSC_VER void launch_process::exiting_child_signal_handler(int sig_num) { FUNCDEF("exiting_child_signal_handler"); @@ -172,7 +171,7 @@ basis::un_int launch_process::run(const astring &app_name_in, const astring &com app_name.insert(0, "\""); if (app_name[app_name.end()] != '"') app_name += "\""; -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // unix / linux implementation. if (flag & RETURN_IMMEDIATELY) { // they want to get back right away. @@ -230,7 +229,7 @@ basis::un_int launch_process::run(const astring &app_name_in, const astring &com // assume they want to wait. return system((app_name + " " + command_line).s()); } -#elif defined(__WIN32__) +#elif defined(_MSC_VER) //checking on whether we have admin rights for the launch. //if (IsUserAnAdmin()) { diff --git a/nucleus/library/processes/launch_process.h b/nucleus/library/processes/launch_process.h index a988c4c5..44ce4857 100644 --- a/nucleus/library/processes/launch_process.h +++ b/nucleus/library/processes/launch_process.h @@ -81,11 +81,10 @@ public: function. */ private: -#ifdef __UNIX__ +#ifndef _MSC_VER static void exiting_child_signal_handler(int sig_num); //!< awaits the child processes rather than leaving process handles willy nilly. -#endif -#ifdef __WIN32__ +#else static bool event_poll(tagMSG &message); //!< tries to process one win32 event and retrieve the "message" from it. /*!< this is a very general poll and will retrieve any message that's diff --git a/nucleus/library/processes/process_control.cpp b/nucleus/library/processes/process_control.cpp index c4025bda..bfc49cca 100644 --- a/nucleus/library/processes/process_control.cpp +++ b/nucleus/library/processes/process_control.cpp @@ -41,7 +41,7 @@ #include #include -#ifdef __UNIX__ +#ifndef _MSC_VER #include #endif @@ -54,15 +54,14 @@ using namespace structures; namespace processes { -#ifdef __WIN32__ +#ifdef _MSC_VER #include const astring NTVDM_NAME = "ntvdm.exe"; // the umbrella process that hangs onto 16 bit tasks for NT. - #ifdef _MSCVER - #include - #endif -#endif -#ifdef __UNIX__ +// #ifdef _MSCVER +// #include +// #endif +#else #include #include #endif @@ -78,16 +77,16 @@ namespace processes { class process_implementation_hider { public: -#ifdef __WIN32__ +#ifdef _MSC_VER // psapi members: application_instance psapi_dll; application_instance vdm_dll; BOOL (WINAPI *enumerate_processes)(basis::un_int *, basis::un_int cb, basis::un_int *); BOOL (WINAPI *enumerate_modules)(HANDLE, HMODULE *, basis::un_int, basis::un_int *); basis::un_int (WINAPI *get_module_name)(HANDLE, HMODULE, LPTSTR, basis::un_int); -#ifdef _MSCVER - INT (WINAPI *tasker_16bit)(basis::un_int, TASKENUMPROCEX fp, LPARAM); -#endif +//#ifdef _MSCVER +// INT (WINAPI *tasker_16bit)(basis::un_int, TASKENUMPROCEX fp, LPARAM); +//#endif // toolhelp members: application_instance kernel32_dll; @@ -101,9 +100,9 @@ public: process_implementation_hider() : psapi_dll(NIL), vdm_dll(NIL), enumerate_processes(NIL), enumerate_modules(NIL), get_module_name(NIL), -#ifdef _MSCVER - tasker_16bit(NIL), -#endif +//#ifdef _MSCVER +// tasker_16bit(NIL), +//#endif kernel32_dll(NIL), create_snapshot(NIL), first_process(NIL), next_process(NIL) {} @@ -136,10 +135,9 @@ public: process_control::process_control() : _ptrs(new process_implementation_hider), -#ifdef __WIN32__ +#ifdef _MSC_VER _use_psapi(true), -#endif -#ifdef __UNIX__ +#else _rando(new chaos), #endif _healthy(false) @@ -147,7 +145,7 @@ process_control::process_control() // Check to see if were running under Windows95 or Windows NT. version osver = application_configuration::get_OS_version(); -#ifdef __WIN32__ +#ifdef _MSC_VER if (osver.v_revision() == VER_PLATFORM_WIN32_WINDOWS) { // we're on Windows 95, so use the toolhelp API for the processes. _use_psapi = false; @@ -159,8 +157,7 @@ process_control::process_control() _healthy = initialize_psapi_support(); else _healthy = initialize_toolhelp_support(); -#endif -#ifdef __UNIX__ +#else _healthy = true; #endif } @@ -168,7 +165,7 @@ process_control::process_control() process_control::~process_control() { WHACK(_ptrs); -#ifdef __UNIX__ +#ifndef _MSC_VER WHACK(_rando); #endif } @@ -198,7 +195,7 @@ void process_control::sort_by_pid(process_entry_array &v) bool process_control::query_processes(process_entry_array &to_fill) { if (!_healthy) return false; -#ifdef __WIN32__ +#ifdef _MSC_VER if (!_use_psapi) { // we're on Windows 95 or something, so use the toolhelp API for the // processes. @@ -207,13 +204,12 @@ bool process_control::query_processes(process_entry_array &to_fill) // we're on Windows NT and so on; use the process API (PSAPI) to get info. return get_processes_with_psapi(to_fill); } -#endif -#ifdef __UNIX__ +#else return get_processes_with_ps(to_fill); #endif } -#ifdef __WIN32__ +#ifdef _MSC_VER bool process_control::initialize_psapi_support() { // create an instance of the PSAPI dll for querying 32-bit processes and @@ -233,15 +229,15 @@ bool process_control::initialize_psapi_support() _ptrs->get_module_name = (basis::un_int (WINAPI *)(HANDLE, HMODULE, LPTSTR, basis::un_int)) GetProcAddress(_ptrs->psapi_dll, "GetModuleFileNameExA"); -#ifdef _MSCVER - _ptrs->tasker_16bit = (INT(WINAPI *)(basis::un_int, TASKENUMPROCEX, LPARAM)) - GetProcAddress(_ptrs->vdm_dll, "VDMEnumTaskWOWEx"); -#endif +//#ifdef _MSCVER +// _ptrs->tasker_16bit = (INT(WINAPI *)(basis::un_int, TASKENUMPROCEX, LPARAM)) +// GetProcAddress(_ptrs->vdm_dll, "VDMEnumTaskWOWEx"); +//#endif if (!_ptrs->enumerate_processes || !_ptrs->enumerate_modules || !_ptrs->get_module_name -#ifdef _MSCVER - || !_ptrs->tasker_16bit -#endif +//#ifdef _MSCVER +// || !_ptrs->tasker_16bit +//#endif ) return false; return true; @@ -273,12 +269,11 @@ bool process_control::zap_process(basis::un_int to_zap) FUNCDEF("zap_process"); #endif if (!_healthy) return false; -#ifdef __UNIX__ +#ifndef _MSC_VER int ret = kill(to_zap, 9); // send the serious take-down signal to the process. return !ret; -#endif -#ifdef __WIN32__ +#else HANDLE h = OpenProcess(PROCESS_TERMINATE, false, to_zap); if (!h) { #ifdef DEBUG_PROCESS_CONTROL @@ -310,10 +305,9 @@ process_entry process_control::query_process(basis::un_int to_query) } //hmmm: implement more specifically. -#ifdef __UNIX__ +#ifndef _MSC_VER //put in the single process grabber deal. -#endif -#ifdef __WIN32__ +#else //grab the entry from the list. #endif @@ -358,7 +352,7 @@ bool process_control::find_process_in_list(const process_entry_array &processes, ////////////// -#ifdef __WIN32__ +#ifdef _MSC_VER // this section is the PSAPI version of the query. // called back on each 16 bit task. @@ -450,15 +444,15 @@ bool process_control::get_processes_with_psapi(process_entry_array &to_fill) (new_entry.path().end() - NTVDM_NAME.length() + 1, new_entry.path().end()); temp.to_lower(); -#ifdef _MSCVER -//hmmm: pull this back in for mingw when it seems to be supported, if ever. - if (temp == NTVDM_NAME) { - // set up a callback stampede on the 16 bit processes. - process_info_clump info(pid_list[i], to_fill); - _ptrs->tasker_16bit(pid_list[i], (TASKENUMPROCEX)process_16bit, - (LPARAM)&info); - } -#endif +//#ifdef _MSCVER +////hmmm: pull this back in for mingw when it seems to be supported, if ever. +// if (temp == NTVDM_NAME) { +// // set up a callback stampede on the 16 bit processes. +// process_info_clump info(pid_list[i], to_fill); +// _ptrs->tasker_16bit(pid_list[i], (TASKENUMPROCEX)process_16bit, +// (LPARAM)&info); +// } +//#endif } } @@ -505,7 +499,7 @@ bool process_control::get_processes_with_toolhelp(process_entry_array &to_fill) } #endif // __WIN32__ -#ifdef __UNIX__ +#ifndef _MSC_VER #define CLOSE_TEMPORARY_FILE { \ /* continuable_error("process_control", "get_processes_with_ps", error); */ \ diff --git a/nucleus/library/processes/process_control.h b/nucleus/library/processes/process_control.h index c6d25861..350da8c6 100644 --- a/nucleus/library/processes/process_control.h +++ b/nucleus/library/processes/process_control.h @@ -74,19 +74,17 @@ public: private: process_implementation_hider *_ptrs; //!< our OS baggage. -#ifdef __UNIX__ +#ifndef _MSC_VER mathematics::chaos *_rando; //!< used for process list. -#endif -#ifdef __WIN32__ +#else bool _use_psapi; //!< true if we should be using the PSAPI on NT and family. #endif bool _healthy; //!< true if construction succeeded. -#ifdef __UNIX__ +#ifndef _MSC_VER bool get_processes_with_ps(process_entry_array &to_fill); //!< asks the ps program what processes exist. -#endif -#ifdef __WIN32__ +#else // fill in our function pointers to access the kernel functions appropriate // for either NT (psapi) or 9x (toolhelp). bool initialize_psapi_support(); diff --git a/nucleus/library/tests_basis/test_string.cpp b/nucleus/library/tests_basis/test_string.cpp index a4263ba4..a8eb15e5 100644 --- a/nucleus/library/tests_basis/test_string.cpp +++ b/nucleus/library/tests_basis/test_string.cpp @@ -33,7 +33,7 @@ #include #include -#ifdef __WIN32__ +#ifdef _MSC_VER #include #endif #include @@ -775,6 +775,7 @@ void test_string::run_test_23() void test_string::run_test_24() { FUNCDEF("run_test_24"); +#ifndef __GNU_WINDOWS__ #ifdef __WIN32__ // 24th test group tests _bstr_t conversions. _bstr_t beast("abcdefgh"); @@ -793,6 +794,7 @@ void test_string::run_test_24() _bstr_t pork = string_convert::to_bstr_t(jethro); ASSERT_FALSE(strcmp(pork.operator char *(), jethro.s()), "second test failed comparison"); #endif +#endif } void test_string::run_test_25() diff --git a/nucleus/library/textual/string_convert.h b/nucleus/library/textual/string_convert.h index 697439e7..a0544728 100644 --- a/nucleus/library/textual/string_convert.h +++ b/nucleus/library/textual/string_convert.h @@ -20,11 +20,16 @@ #ifdef __WIN32__ #ifndef _MANAGED - #ifndef __MINGW32__ #define _WINSOCKAPI_ // the dance of the windows headers. - #include - #include - #endif + // winsock support... + #undef FD_SETSIZE + #define FD_SETSIZE 1000 + // if you don't set this, you can only select on a default of 64 sockets. + #include + #include + #ifndef __GNU_WINDOWS__ + #include + #endif #endif #endif @@ -48,7 +53,7 @@ namespace string_convert #ifdef WIN32 #ifndef _MANAGED - #ifndef __MINGW32__ + #ifndef __GNU_WINDOWS__ //! conversion from ATL's _bstr_t object to astring. inline basis::astring to_astring(const _bstr_t &original) { return basis::astring(basis::astring::UNTERMINATED, (const char *)original, @@ -58,7 +63,7 @@ namespace string_convert //! conversion from astring to the ATL _bstr_t object. inline _bstr_t to_bstr_t(const basis::astring &original) { return _bstr_t(original.s()); } - #endif + #endif #endif #endif diff --git a/nucleus/library/timely/timer_driver.cpp b/nucleus/library/timely/timer_driver.cpp index 9be8aba0..c8186c72 100644 --- a/nucleus/library/timely/timer_driver.cpp +++ b/nucleus/library/timely/timer_driver.cpp @@ -62,7 +62,7 @@ SAFE_STATIC(timer_driver, timer_driver::global_timer_driver, ) ////////////// -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) const int OUR_SIGNAL = SIGUSR2; class signalling_thread : public ethread @@ -78,7 +78,7 @@ private: }; #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) void timer_driver_private_handler(int signal_seen) #elif defined(__WIN32__) void __stdcall timer_driver_private_handler(window_handle hwnd, basis::un_int msg, @@ -92,7 +92,7 @@ void __stdcall timer_driver_private_handler(window_handle hwnd, basis::un_int ms #define static_class_name() "timer_driver" FUNCDEF("timer_driver_private_handler"); #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) int seen = signal_seen; if (seen != OUR_SIGNAL) { #elif defined(__WIN32__) @@ -147,10 +147,9 @@ public: timer_driver::timer_driver() : _timers(new driven_objects_list), _lock(new mutex), -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) _prompter(new signalling_thread(INITIAL_TIMER_GRANULARITY)), -#endif -#ifdef __WIN32__ +#else _real_timer_id(NIL), #endif _in_timer(false) @@ -215,7 +214,7 @@ timer_driver::~timer_driver() #endif } -#ifdef __WIN32__ +#ifdef _MSC_VER basis::un_int *timer_driver::real_timer_id() { return _real_timer_id; } #endif @@ -405,10 +404,10 @@ void timer_driver::hookup_OS_timer(int duration) #ifdef DEBUG_TIMER_DRIVER LOG(a_sprintf("hooking next OS timer in %d ms.", duration)); #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // just make our thread hit after the duration specified. _prompter->reschedule(duration); -#elif defined(__WIN32__) +#elif defined(_MSC_VER) int max_tries_left = 100; while (max_tries_left-- >= 0) { _real_timer_id = (basis::un_int *)SetTimer(NIL, 0, duration, @@ -429,10 +428,10 @@ void timer_driver::unhook_OS_timer() #ifdef DEBUG_TIMER_DRIVER FUNCDEF("unhook_OS_timer"); #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // postpone the thread for quite a while so we can take care of business. _prompter->reschedule(LONG_TIME); -#elif defined(__WIN32__) +#elif defined(_MSC_VER) if (_real_timer_id) KillTimer(NIL, (UINT_PTR)_real_timer_id); #endif #ifdef DEBUG_TIMER_DRIVER diff --git a/nucleus/library/timely/timer_driver.h b/nucleus/library/timely/timer_driver.h index ae2b9735..1cf2932f 100644 --- a/nucleus/library/timely/timer_driver.h +++ b/nucleus/library/timely/timer_driver.h @@ -69,7 +69,7 @@ public: // internal methods. -#ifdef __WIN32__ +#if defined(_MSC_VER) basis::un_int *real_timer_id(); //!< provides the timer id for comparison on windows platforms. #endif @@ -83,10 +83,9 @@ public: private: driven_objects_list *_timers; //!< timer hooked objects. basis::mutex *_lock; //!< protects list of timers. -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) signalling_thread *_prompter; //!< drives our timers. -#endif -#ifdef __WIN32__ +#else basis::un_int *_real_timer_id; //!< used for storing window timer handle. #endif bool _in_timer; //!< true if we're handling the timer right now. diff --git a/scripts/clam/cpp/rules.def b/scripts/clam/cpp/rules.def index 65b9c389..9183ab87 100644 --- a/scripts/clam/cpp/rules.def +++ b/scripts/clam/cpp/rules.def @@ -27,16 +27,47 @@ endif # implement special bits for gnu on unix. ifeq "$(COMPILER)" "GNU_LINUX" ifneq "$(USE_XWIN)" "" - ifneq "$(OP_SYSTEM)" "WIN32" - DEFINITIONS += __XWINDOWS__ __X__ - LIBS_USED += Xm Xt X11 Xft Xp + DEFINITIONS += __XWINDOWS__ __X__ + LIBS_USED += Xm Xt X11 Xft Xp #need to separate out with a USE_MOTIF kind of thing. LIBS_USED += Xmu - HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include /usr/include/g++ - LIBRARY_SEARCH_PATH += /usr/X11R6/lib + HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include /usr/include/g++ + LIBRARY_SEARCH_PATH += /usr/X11R6/lib + endif + + ifneq "$(USE_SSL)" "" + LIBS_USED += ssl crypto + endif + + ifneq "$(USE_WXWIDGETS)" "" + DEFINITIONS += __WXWIDGETS__ + use_unicode = + ifneq "$(findstring UNICODE, $(DEFINITIONS))" "" + use_unicode = true + endif + + # decide whether to turn on the unicode flag or not. + ifneq "$(use_unicode)" "" + DEFINITIONS += wxUSE_UNICODE + UNICODE_FLAG_ADD = --unicode=yes + else + UNICODE_FLAG_ADD = --unicode=no endif + # could add for debugging: --debug=yes + COMPILER_FLAGS += $(shell wx-config --cxxflags $(UNICODE_FLAG_ADD) ) + + LOAD_FLAG_PREFIX += $(shell wx-config --libs $(UNICODE_FLAG_ADD) ) endif + ifneq "$(USE_CURL)" "" + COMPILER_FLAGS += `curl-config --cflags` + LOAD_FLAG_SUFFIX += `curl-config --libs` + endif +endif + +# some special code for gnu compiler on windows. +ifeq "$(COMPILER)" "GNU_WINDOWS" + ifneq "$(USE_SSL)" "" LIBS_USED += ssl crypto endif @@ -45,9 +76,7 @@ LIBS_USED += Xmu DEFINITIONS += __WXWIDGETS__ use_unicode = ifneq "$(findstring UNICODE, $(DEFINITIONS))" "" -# ifeq "$(OP_SYSTEM)" "WIN32" - use_unicode = true -# endif + use_unicode = true endif # decide whether to turn on the unicode flag or not. @@ -91,9 +120,7 @@ ifeq "$(COMPILER)" "GNU_DARWIN" DEFINITIONS += __WXWIDGETS__ use_unicode = ifneq "$(findstring UNICODE, $(DEFINITIONS))" "" -# ifeq "$(OP_SYSTEM)" "WIN32" use_unicode = true -# endif endif # decide whether to turn on the unicode flag or not. @@ -137,6 +164,7 @@ endif # win32 compiler additions. 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) @@ -328,12 +356,12 @@ ACTUAL_FIRST_TARGETS = check_requirements $(EXTRA_FIRST_TARGETS) $(VERSION_TARGE # Adds the primary targets to the list of products to create. ifeq "$(NO_COMPILE)" "" - ifeq "$(OP_SYSTEM)" "UNIX" + ifneq "$(COMPILER)" "VISUAL_CPP" ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%) else ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%.exe) endif - ifeq "$(OP_SYSTEM)" "UNIX" + ifneq "$(COMPILER)" "VISUAL_CPP" ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=%.so) ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=$(DYNAMIC_LIBRARY_DIR)/%$(TRIPART_VERSION).so) else @@ -532,7 +560,7 @@ endif #no_compile # creates "exe" executables using all of the appropriate objects. -ifeq "$(OP_SYSTEM)" "WIN32" +ifeq "$(COMPILER)" "VISUAL_CPP" ifneq "$(NO_COMPILE)" "" $(EXECUTABLE_DIR)/%.exe: endif @@ -556,9 +584,9 @@ $(EXECUTABLE_DIR)/%.exe: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)" endif endif #no_compile -endif #win32 +endif #visual studio -ifeq "$(OP_SYSTEM)" "UNIX" +ifneq "$(COMPILER)" "VISUAL_CPP" ifneq "$(NO_COMPILE)" "" $(EXECUTABLE_DIR)/%: endif diff --git a/scripts/clam/cpp/variables.def b/scripts/clam/cpp/variables.def index 03f2ab65..8dda9172 100644 --- a/scripts/clam/cpp/variables.def +++ b/scripts/clam/cpp/variables.def @@ -60,7 +60,7 @@ endif # code. It is mainly used within CLAM itself for determining the proper # compiler flags. export COMPILER -#COMPILER := GNU_LINUX | GNU_ARM_LINUX | GNU_DARWIN | GNU_WIN32 | VISUAL_CPP +#COMPILER := GNU_LINUX | GNU_ARM_LINUX | GNU_DARWIN | GNU_WINDOWS | VISUAL_CPP # choose a default compiler if none was specified. ifeq "$(COMPILER)" "" @@ -72,8 +72,8 @@ ifeq "$(COMPILER)" "" endif endif ifeq "$(OP_SYSTEM)" "WIN32" -# COMPILER := GNU_WIN32 - 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 @@ -421,8 +421,13 @@ ifeq "$(OP_SYSTEM)" "UNIX" DYNLIB_ENDING = .so endif ifeq "$(OP_SYSTEM)" "WIN32" - LIB_ENDING = .lib - DYNLIB_ENDING = .dll + ifeq "$(COMPILER)" "VISUAL_CPP" + LIB_ENDING = .lib + DYNLIB_ENDING = .dll + else + LIB_ENDING = .a + DYNLIB_ENDING = .so + endif endif ############################################################################### @@ -577,11 +582,11 @@ ifeq "$(COMPILER)" "GNU_ARM_LINUX" endif -ifeq "$(COMPILER)" "GNU_WIN32" +ifeq "$(COMPILER)" "GNU_WINDOWS" # GNU compiler for MS Windoze... CC = g++ ifeq "$(COMPILER_ROOT_DIR)" "" - COMPILER_ROOT_DIR = c:/system/mingw + COMPILER_ROOT_DIR = $(CYGROOT) endif export COMPILER_VERSION = $(shell $(SHELL) $(CLAM_DIR)/cpp/get_version.sh $(COMPILER) $(COMPILER_ROOT_DIR) ) @@ -589,14 +594,17 @@ ifeq "$(COMPILER)" "GNU_WIN32" RC := $(COMPILER_ROOT_DIR)/bin/windres PLATFORM_ADD_IN = w32_ - COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/include/c++/3.4.2 $(COMPILER_ROOT_DIR)/lib/gcc/mingw32/3.4.2/include + COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/include/c++/3.4.2 +#$(COMPILER_ROOT_DIR)/lib/gcc/mingw32/3.4.2/include ###$(COMPILER_ROOT_DIR)/usr/include/mingw $(COMPILER_ROOT_DIR)/usr/include $(COMPILER_ROOT_DIR)/usr/include/w32api $(COMPILER_ROOT_DIR)/usr/include/extras COMPILER_LIBRARY_DIR = $(COMPILER_ROOT_DIR)/lib - DEFINITIONS += _Windows _WINDOWS WIN32 __WIN32__ __FLAT__ VC_EXTRALEAN WIN32_LEAN_AND_MEAN ATL_NO_LEAN_AND_MEAN _WIN32 __cplusplus + DEFINITIONS += __GNU_WINDOWS__ _Windows _WINDOWS WIN32 __WIN32__ __FLAT__ VC_EXTRALEAN WIN32_LEAN_AND_MEAN ATL_NO_LEAN_AND_MEAN _WIN32 __cplusplus __USE_W32_SOCKETS #__USE_GNU LIBRARY_TOOL = ar + LIBRARY_PATH_FLAG = -L + LIB_PREFIX = lib # LOAD_FLAG_PREFIX += -lpthread LOAD_FLAG_PREFIX += -mwindows CREATE_LIBRARY_FLAG += -r