Index: build/premake/extern_libs4.lua =================================================================== --- build/premake/extern_libs4.lua +++ build/premake/extern_libs4.lua @@ -308,32 +308,21 @@ compile_settings = function() if os.is("windows") then add_default_include_paths("gloox") - elseif os.is("macosx") then - -- Support GLOOX_CONFIG for overriding the default PATH-based gloox-config - gloox_config_path = os.getenv("GLOOX_CONFIG") - if not gloox_config_path then - gloox_config_path = "gloox-config" - end - pkgconfig_cflags(nil, gloox_config_path.." --cflags") + elseif not _OPTIONS["android"] then + -- Support GLOOX_CONFIG for overriding the default (pkg-config --cflags gloox) + -- i.e. on OSX where it gets set in update-workspaces.sh + pkgconfig_cflags("gloox", os.getenv("GLOOX_CONFIG") and " --cflags") end end, link_settings = function() if os.is("windows") then add_default_lib_paths("gloox") - end - if os.is("macosx") then - gloox_config_path = os.getenv("GLOOX_CONFIG") - if not gloox_config_path then - gloox_config_path = "gloox-config" - end - pkgconfig_libs(nil, gloox_config_path.." --libs") - else - -- TODO: consider using pkg-config on non-Windows (for compile_settings too) add_default_links({ win_names = { "gloox-1.0" }, - unix_names = { "gloox" }, no_delayload = 1, }) + elseif not _OPTIONS["android"] then + pkgconfig_libs("gloox", os.getenv("GLOOX_CONFIG") and " --libs") end end, }, @@ -377,32 +366,22 @@ compile_settings = function() if os.is("windows") then add_default_include_paths("icu") - elseif os.is("macosx") then - -- Support ICU_CONFIG for overriding the default PATH-based icu-config - icu_config_path = os.getenv("ICU_CONFIG") - if not icu_config_path then - icu_config_path = "icu-config" - end - pkgconfig_cflags(nil, icu_config_path.." --cppflags") + elseif not _OPTIONS["android"] then + -- Support ICU_CONFIG for overriding the default (pkg-config --cflags icu-i18n) + -- i.e. on OSX where it gets set in update-workspaces.sh + pkgconfig_cflags("icu-i18n", os.getenv("ICU_CONFIG") and " --cppflags") end end, link_settings = function() if os.is("windows") then add_default_lib_paths("icu") - end - if os.is("macosx") then - icu_config_path = os.getenv("ICU_CONFIG") - if not icu_config_path then - icu_config_path = "gloox-config" - end - pkgconfig_libs(nil, icu_config_path.." --ldflags-searchpath --ldflags-libsonly --ldflags-system") - else add_default_links({ win_names = { "icuuc", "icuin" }, - unix_names = { "icui18n", "icuuc" }, dbg_suffix = "", no_delayload = 1, }) + elseif not _OPTIONS["android"] then + pkgconfig_libs("icu-i18n", os.getenv("ICU_CONFIG") and " --ldflags-searchpath --ldflags-libsonly --ldflags-system") end end, }, @@ -464,20 +443,15 @@ compile_settings = function() if os.is("windows") then add_default_include_paths("libxml2") - elseif os.is("macosx") then - -- Support XML2_CONFIG for overriding for the default PATH-based xml2-config - xml2_config_path = os.getenv("XML2_CONFIG") - if not xml2_config_path then - xml2_config_path = "xml2-config" - end - - -- use xml2-config instead of pkg-config on OS X - pkgconfig_cflags(nil, xml2_config_path.." --cflags") + elseif not _OPTIONS["android"] then + -- Support XML2_CONFIG for overriding the default (pkg-config --cflags libxml-2.0) + -- i.e. on OSX where it gets set in update-workspaces.sh + pkgconfig_cflags("libxml-2.0", os.getenv("XML2_CONFIG") and " --cflags") + end + if os.is("macosx") then -- libxml2 needs _REENTRANT or __MT__ for thread support; -- OS X doesn't get either set by default, so do it manually defines { "_REENTRANT" } - else - pkgconfig_cflags("libxml-2.0") end end, link_settings = function() @@ -488,14 +462,8 @@ configuration "Release" links { "libxml2" } configuration { } - elseif os.is("macosx") then - xml2_config_path = os.getenv("XML2_CONFIG") - if not xml2_config_path then - xml2_config_path = "xml2-config" - end - pkgconfig_libs(nil, xml2_config_path.." --libs") - else - pkgconfig_libs("libxml-2.0") + elseif not _OPTIONS["android"] then + pkgconfig_libs("libxml-2.0", os.getenv("XML2_CONFIG") and " --libs") end end, }, @@ -586,24 +554,14 @@ elseif not _OPTIONS["android"] then -- Support SDL2_CONFIG for overriding the default (pkg-config sdl2) -- i.e. on OSX where it gets set in update-workspaces.sh - sdl_config_path = os.getenv("SDL2_CONFIG") - if sdl_config_path then - pkgconfig_cflags(nil, sdl_config_path.." --cflags") - else - pkgconfig_cflags("sdl2") - end + pkgconfig_cflags("sdl2", os.getenv("SDL2_CONFIG") and " --cflags") end end, link_settings = function() if os.is("windows") then add_default_lib_paths("sdl2") elseif not _OPTIONS["android"] then - sdl_config_path = os.getenv("SDL2_CONFIG") - if sdl_config_path then - pkgconfig_libs(nil, sdl_config_path.." --libs") - else - pkgconfig_libs("sdl2") - end + pkgconfig_libs("sdl2", os.getenv("SDL2_CONFIG") and " --libs") end end, }, @@ -698,34 +656,31 @@ includedirs { libraries_dir.."wxwidgets/include/msvc" } add_default_include_paths("wxwidgets") else - - -- Support WX_CONFIG for overriding for the default PATH-based wx-config - wx_config_path = os.getenv("WX_CONFIG") - if not wx_config_path then - wx_config_path = "wx-config" - end - - pkgconfig_cflags(nil, wx_config_path.." --unicode=yes --cxxflags") + -- wxwidgets does not come with a definition file for pkg-config, + -- so we have to use wxwidgets' own config tool + wx_config_path = os.getenv("WX_CONFIG") or "wx-config" + pkgconfig_cflags(nil, wx_config_path .. " --unicode=yes --cxxflags") end end, link_settings = function() if os.is("windows") then libdirs { libraries_dir.."wxwidgets/lib/vc_lib" } else - wx_config_path = os.getenv("WX_CONFIG") - if not wx_config_path then - wx_config_path = "wx-config" - end - pkgconfig_libs(nil, wx_config_path.." --unicode=yes --libs std,gl") + wx_config_path = os.getenv("WX_CONFIG") or "wx-config" + pkgconfig_libs(nil, wx_config_path .. " --unicode=yes --libs std,gl") end end, }, x11 = { + compile_settings = function() + if not os.is("windows") and not os.is("macosx") then + pkgconfig_cflags("x11") + end + end, link_settings = function() - add_default_links({ - win_names = { }, - unix_names = { "X11" }, - }) + if not os.is("windows") and not os.is("macosx") then + pkgconfig_libs("x11") + end end, }, xcursor = { Index: build/premake/extern_libs5.lua =================================================================== --- build/premake/extern_libs5.lua +++ build/premake/extern_libs5.lua @@ -262,39 +262,31 @@ compile_settings = function() if os.istarget("windows") then add_default_include_paths("gloox") - elseif os.istarget("macosx") then - -- Support GLOOX_CONFIG for overriding the default PATH-based gloox-config - gloox_config_path = os.getenv("GLOOX_CONFIG") - if not gloox_config_path then - gloox_config_path = "gloox-config" - end - pkgconfig.add_includes(nil, gloox_config_path.." --cflags") + elseif not _OPTIONS["android"] then + -- Support GLOOX_CONFIG for overriding the default (pkg-config --cflags gloox) + -- i.e. on OSX where it gets set in update-workspaces.sh + pkgconfig.add_includes("gloox", os.getenv("GLOOX_CONFIG") and " --cflags") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("gloox") - end - if os.istarget("macosx") then - gloox_config_path = os.getenv("GLOOX_CONFIG") - if not gloox_config_path then - gloox_config_path = "gloox-config" - end - pkgconfig.add_links(nil, gloox_config_path.." --libs") - - -- Manually add gnutls dependencies, those are not present in gloox's pkg-config - add_default_lib_paths("nettle") - add_default_lib_paths("gmp") - add_default_links({ - osx_names = { "nettle", "hogweed", "gmp" }, - }) - else - -- TODO: consider using pkg-config on non-Windows (for compile_settings too) add_default_links({ win_names = { "gloox-1.0" }, - unix_names = { "gloox" }, no_delayload = 1, }) + elseif not _OPTIONS["android"] then + pkgconfig.add_links("gloox", os.getenv("GLOOX_CONFIG") and " --libs") + + if os.istarget("macosx") then + -- Manually add gnutls dependencies, those are not present in gloox's pkg-config + add_default_lib_paths("nettle") + add_default_lib_paths("gmp") + add_default_links({ + osx_names = { "nettle", "hogweed", "gmp" }, + }) + end + end end, }, @@ -338,32 +330,22 @@ compile_settings = function() if os.istarget("windows") then add_default_include_paths("icu") - elseif os.istarget("macosx") then - -- Support ICU_CONFIG for overriding the default PATH-based icu-config - icu_config_path = os.getenv("ICU_CONFIG") - if not icu_config_path then - icu_config_path = "icu-config" - end - pkgconfig.add_includes(nil, icu_config_path.." --cppflags") + elseif not _OPTIONS["android"] then + -- Support ICU_CONFIG for overriding the default (pkg-config --cflags icu-i18n) + -- i.e. on OSX where it gets set in update-workspaces.sh + pkgconfig.add_includes("icu-i18n", os.getenv("ICU_CONFIG") and " --cppflags") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("icu") - end - if os.istarget("macosx") then - icu_config_path = os.getenv("ICU_CONFIG") - if not icu_config_path then - icu_config_path = "gloox-config" - end - pkgconfig.add_links(nil, icu_config_path.." --ldflags-searchpath --ldflags-libsonly --ldflags-system") - else add_default_links({ win_names = { "icuuc", "icuin" }, - unix_names = { "icui18n", "icuuc" }, dbg_suffix = "", no_delayload = 1, }) + elseif not _OPTIONS["android"] then + pkgconfig.add_links("icu-i18n", os.getenv("ICU_CONFIG") and " --ldflags-searchpath --ldflags-libsonly --ldflags-system") end end, }, @@ -427,20 +409,15 @@ compile_settings = function() if os.istarget("windows") then add_default_include_paths("libxml2") - elseif os.istarget("macosx") then - -- Support XML2_CONFIG for overriding for the default PATH-based xml2-config - xml2_config_path = os.getenv("XML2_CONFIG") - if not xml2_config_path then - xml2_config_path = "xml2-config" - end - - -- use xml2-config instead of pkg-config on OS X - pkgconfig.add_includes(nil, xml2_config_path.." --cflags") + elseif not _OPTIONS["android"] then + -- Support XML2_CONFIG for overriding the default (pkg-config --cflags libxml-2.0) + -- i.e. on OSX where it gets set in update-workspaces.sh + pkgconfig.add_includes("libxml-2.0", os.getenv("XML2_CONFIG") and " --cflags") + end + if os.istarget("macosx") then -- libxml2 needs _REENTRANT or __MT__ for thread support; -- OS X doesn't get either set by default, so do it manually defines { "_REENTRANT" } - else - pkgconfig.add_includes("libxml-2.0") end end, link_settings = function() @@ -451,14 +428,8 @@ filter "Release" links { "libxml2" } filter { } - elseif os.istarget("macosx") then - xml2_config_path = os.getenv("XML2_CONFIG") - if not xml2_config_path then - xml2_config_path = "xml2-config" - end - pkgconfig.add_links(nil, xml2_config_path.." --libs") - else - pkgconfig.add_links("libxml-2.0") + elseif not _OPTIONS["android"] then + pkgconfig.add_links("libxml-2.0", os.getenv("XML2_CONFIG") and " --libs") end end, }, @@ -549,24 +520,14 @@ elseif not _OPTIONS["android"] then -- Support SDL2_CONFIG for overriding the default (pkg-config sdl2) -- i.e. on OSX where it gets set in update-workspaces.sh - sdl_config_path = os.getenv("SDL2_CONFIG") - if sdl_config_path then - pkgconfig.add_includes(nil, sdl_config_path.." --cflags") - else - pkgconfig.add_includes("sdl2") - end + pkgconfig.add_includes("sdl2", os.getenv("SDL2_CONFIG") and " --cflags") end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("sdl2") elseif not _OPTIONS["android"] then - sdl_config_path = os.getenv("SDL2_CONFIG") - if sdl_config_path then - pkgconfig.add_links(nil, sdl_config_path.." --libs") - else - pkgconfig.add_links("sdl2") - end + pkgconfig.add_links("sdl2", os.getenv("SDL2_CONFIG") and " --libs") end end, }, @@ -670,34 +631,31 @@ includedirs { libraries_dir.."wxwidgets/include/msvc" } add_default_include_paths("wxwidgets") else - - -- Support WX_CONFIG for overriding for the default PATH-based wx-config - wx_config_path = os.getenv("WX_CONFIG") - if not wx_config_path then - wx_config_path = "wx-config" - end - - pkgconfig.add_includes(nil, wx_config_path.." --unicode=yes --cxxflags") + -- wxwidgets does not come with a definition file for pkg-config, + -- so we have to use wxwidgets' own config tool + wx_config_path = os.getenv("WX_CONFIG") or "wx-config" + pkgconfig.add_includes(nil, wx_config_path .. " --unicode=yes --cxxflags") end end, link_settings = function() if os.istarget("windows") then libdirs { libraries_dir.."wxwidgets/lib/vc_lib" } else - wx_config_path = os.getenv("WX_CONFIG") - if not wx_config_path then - wx_config_path = "wx-config" - end - pkgconfig.add_links(nil, wx_config_path.." --unicode=yes --libs std,gl") + wx_config_path = os.getenv("WX_CONFIG") or "wx-config" + pkgconfig.add_links(nil, wx_config_path .. " --unicode=yes --libs std,gl") end end, }, x11 = { + compile_settings = function() + if not os.istarget("windows") and not os.istarget("macosx") then + pkgconfig.add_includes("x11") + end + end, link_settings = function() - add_default_links({ - win_names = { }, - unix_names = { "X11" }, - }) + if not os.istarget("windows") and not os.istarget("macosx") then + pkgconfig.add_links("x11") + end end, }, xcursor = { Index: build/premake/premake4.lua =================================================================== --- build/premake/premake4.lua +++ build/premake/premake4.lua @@ -379,23 +379,6 @@ end end --- add X11 includes paths after all the others so they don't conflict with --- bundled libs -function project_add_x11_dirs() - if not os.is("windows") and not os.is("macosx") then - -- X11 includes may be installed in one of a gadzillion of five places - -- Famous last words: "You can't include too much! ;-)" - includedirs { - "/usr/X11R6/include/X11", - "/usr/X11R6/include", - "/usr/local/include/X11", - "/usr/local/include", - "/usr/include/X11" - } - libdirs { "/usr/X11R6/lib" } - end -end - -- create a project and set the attributes that are common to all projects. function project_create(project_name, target_type) @@ -528,7 +511,6 @@ project_create(project_name, target_type) project_add_contents(source_root, rel_source_dirs, {}, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() if not extra_params["no_default_link"] then table.insert(static_lib_names, project_name) @@ -551,7 +533,6 @@ project_create(project_name, target_type) project_add_contents(source_root, rel_source_dirs, {}, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() if not extra_params["no_default_link"] then table.insert(static_lib_names, project_name) @@ -949,7 +930,6 @@ } project_add_contents(source_root, {}, {}, extra_params) project_add_extern_libs(used_extern_libs, target_type) - project_add_x11_dirs() -- Platform Specifics if os.is("windows") then @@ -1043,7 +1023,6 @@ project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() -- Platform Specifics if os.is("windows") then @@ -1169,7 +1148,6 @@ local target_type = get_main_project_target_type() project_create(project_name, target_type) - project_add_x11_dirs() local source_root = rootdir.."/source/tools/atlas/AtlasFrontends/" files { source_root..project_name..".cpp" } @@ -1214,7 +1192,6 @@ extra_params["pch_dir"] = source_root project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() -- Platform Specifics if os.is("windows") then @@ -1404,7 +1381,6 @@ project_add_contents(source_root, {}, {}, extra_params) project_add_extern_libs(used_extern_libs, target_type) - project_add_x11_dirs() -- TODO: should fix the duplication between this OS-specific linking -- code, and the similar version in setup_main_exe Index: build/premake/premake5.lua =================================================================== --- build/premake/premake5.lua +++ build/premake/premake5.lua @@ -367,23 +367,6 @@ end end --- add X11 includes paths after all the others so they don't conflict with --- bundled libs -function project_add_x11_dirs() - if not os.istarget("windows") and not os.istarget("macosx") then - -- X11 includes may be installed in one of a gadzillion of five places - -- Famous last words: "You can't include too much! ;-)" - sysincludedirs { - "/usr/X11R6/include/X11", - "/usr/X11R6/include", - "/usr/local/include/X11", - "/usr/local/include", - "/usr/include/X11" - } - libdirs { "/usr/X11R6/lib" } - end -end - -- create a project and set the attributes that are common to all projects. function project_create(project_name, target_type) @@ -528,7 +511,6 @@ project_create(project_name, target_type) project_add_contents(source_root, rel_source_dirs, {}, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() if not extra_params["no_default_link"] then table.insert(static_lib_names, project_name) @@ -551,7 +533,6 @@ project_create(project_name, target_type) project_add_contents(source_root, rel_source_dirs, {}, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() if not extra_params["no_default_link"] then table.insert(static_lib_names, project_name) @@ -961,7 +942,6 @@ } project_add_contents(source_root, {}, {}, extra_params) project_add_extern_libs(used_extern_libs, target_type) - project_add_x11_dirs() dependson { "Collada" } @@ -1057,7 +1037,6 @@ project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() -- Platform Specifics if os.istarget("windows") then @@ -1180,7 +1159,6 @@ local target_type = get_main_project_target_type() project_create(project_name, target_type) - project_add_x11_dirs() local source_root = rootdir.."/source/tools/atlas/AtlasFrontends/" files { source_root..project_name..".cpp" } @@ -1220,7 +1198,6 @@ extra_params["pch_dir"] = source_root project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) project_add_extern_libs(extern_libs, target_type) - project_add_x11_dirs() -- Platform Specifics if os.istarget("windows") then @@ -1364,7 +1341,6 @@ project_add_contents(source_root, {}, {}, extra_params) project_add_extern_libs(used_extern_libs, target_type) - project_add_x11_dirs() dependson { "Collada" } Index: source/lib/sysdep/os/unix/x/x.cpp =================================================================== --- source/lib/sysdep/os/unix/x/x.cpp +++ source/lib/sysdep/os/unix/x/x.cpp @@ -41,10 +41,10 @@ #define Cursor X__Cursor -#include +#include #include -#include -#include +#include +#include #include "SDL.h" #include "SDL_syswm.h"