aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/libx11
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/libx11
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/libx11')
-rw-r--r--vcpkg/ports/libx11/add_dl_pc.patch36
-rw-r--r--vcpkg/ports/libx11/cl.build.patch147
-rw-r--r--vcpkg/ports/libx11/dllimport.patch44
-rw-r--r--vcpkg/ports/libx11/io_include.patch12
-rw-r--r--vcpkg/ports/libx11/optimize-configure.patch13
-rw-r--r--vcpkg/ports/libx11/portfile.cmake108
-rw-r--r--vcpkg/ports/libx11/vcpkg-cmake-wrapper.cmake20
-rw-r--r--vcpkg/ports/libx11/vcpkg.json22
-rw-r--r--vcpkg/ports/libx11/vcxserver.patch138
9 files changed, 540 insertions, 0 deletions
diff --git a/vcpkg/ports/libx11/add_dl_pc.patch b/vcpkg/ports/libx11/add_dl_pc.patch
new file mode 100644
index 0000000..35069b1
--- /dev/null
+++ b/vcpkg/ports/libx11/add_dl_pc.patch
@@ -0,0 +1,36 @@
+diff --git a/configure.ac b/configure.ac
+index 92b740b88..083e37ee5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -106,8 +106,12 @@ if test "x$ac_cv_search_dlopen" = xno; then
+ AC_DEFINE(HAVE_SHL_LOAD,1,
+ [Use shl_load to load shared libraries])
+ AC_CHECK_HEADERS([dl.h])
++ XLDLIB="$ac_cv_search_shl_load"
+ fi
+ else
++ if test "x$ac_cv_search_dlopen" != 'xnone required'; then
++ XLDLIB="$ac_cv_search_dlopen"
++ fi
+ AC_DEFINE(HAVE_DLOPEN,1,[Use dlopen to load shared libraries])
+ AC_CHECK_HEADERS([dlfcn.h])
+ fi
+@@ -116,6 +120,7 @@ if test "x$ac_cv_header_dlfcn_h" = xyes -o "x$ac_cv_header_dl_h" = xyes; then
+ else
+ HAVE_LOADABLE_MODULES=no
+ fi
++AC_SUBST(XLDLIB)
+ AC_MSG_RESULT($HAVE_LOADABLE_MODULES)
+
+ AC_MSG_CHECKING([if loadable i18n module support should be enabled])
+diff --git a/x11.pc.in b/x11.pc.in
+index 25c7e7cd0..4ecf23e8d 100644
+--- a/x11.pc.in
++++ b/x11.pc.in
+@@ -11,5 +11,5 @@ Version: @PACKAGE_VERSION@
+ Requires: xproto @XKBPROTO_REQUIRES@
+ Requires.private: @X11_EXTRA_DEPS@
+ Cflags: -I${includedir} @XTHREAD_CFLAGS@
+-Libs: -L${libdir} -lX11
++Libs: -L${libdir} -lX11 @XLDLIB@
+ Libs.private: @XTHREADLIB@
diff --git a/vcpkg/ports/libx11/cl.build.patch b/vcpkg/ports/libx11/cl.build.patch
new file mode 100644
index 0000000..2845f1d
--- /dev/null
+++ b/vcpkg/ports/libx11/cl.build.patch
@@ -0,0 +1,147 @@
+diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
+index 844571688..e46c4ec5d 100644
+--- a/include/X11/Xlibint.h
++++ b/include/X11/Xlibint.h
+@@ -1351,11 +1351,14 @@ extern int _XOpenFile(
+ int /* flags */
+ );
+
++#if defined(_MSC_VER) && !defined(mode_t)
++typedef int mode_t;
++#endif
+ extern int _XOpenFileMode(
+ _Xconst char* /* path */,
+ int /* flags */,
+ mode_t /* mode */
+ );
+
+ extern void* _XFopenFile(
+ _Xconst char* /* path */,
+diff --git a/modules/im/ximcp/imLcLkup.c b/modules/im/ximcp/imLcLkup.c
+index 56dba9673..d10de825e 100644
+--- a/modules/im/ximcp/imLcLkup.c
++++ b/modules/im/ximcp/imLcLkup.c
+@@ -61,27 +61,37 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
+ ||(ic->private.local.brl_committed != 0))) {
+ if (ic->private.local.brl_committed != 0) { /* Braille Event */
+ unsigned char pattern = ic->private.local.brl_committed;
++#ifndef _MSC_VER
+ char mb2[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)];
++#else
++ char *mb2 = (char*)malloc(XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)*sizeof(char));
++#endif
+ ret = _Xlcwctomb(ic->core.im->core.lcd, mb2, BRL_UC_ROW | pattern);
+ if(ret > bytes) {
+ if(status) *status = XBufferOverflow;
++#ifdef _MSC_VER
++ free(mb2);
++#endif
+ return(ret);
+ }
+ if(keysym) *keysym = XK_braille_blank | pattern;
+ if(ret > 0) {
+ if (keysym) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ memcpy(buffer, mb2, ret);
+ } else {
+ if(keysym) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
++#ifdef _MSC_VER
++ free(mb2);
++#endif
+ } else { /* Composed Event */
+ ret = strlen(&mb[b[ic->private.local.composed].mb]);
+ if(ret > bytes) {
+diff --git a/src/XlibInt.c b/src/XlibInt.c
+index e4fb4e5f2..4cfa1aeab 100644
+--- a/src/XlibInt.c
++++ b/src/XlibInt.c
+@@ -60,6 +60,8 @@ from The Open Group.
+ /* Needed for ioctl() on Solaris */
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
++#else
++ #define F_OK 0
+ #endif
+
+ #ifdef XTHREADS
+@@ -985,7 +987,7 @@ _XWireToEvent(
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+- ev->window = None;
++ ev->window = 0;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+@@ -1919,7 +1925,11 @@ int _XOpenFileMode(path, flags, mode)
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
++#ifndef _MSC_VER
+ ret = open (bufp, flags, mode);
++#else
++ ret = _open (bufp, flags, mode);
++#endif
+
+ (void) SetErrorMode (olderror);
+
+diff --git a/src/xlibi18n/XDefaultOMIF.c b/src/xlibi18n/XDefaultOMIF.c
+index 9345547c3..77d914fe1 100644
+--- a/src/xlibi18n/XDefaultOMIF.c
++++ b/src/xlibi18n/XDefaultOMIF.c
+@@ -70,6 +70,14 @@ Sun Microsystems, Inc. or its licensors is granted.
+ #include <X11/Xatom.h>
+ #include <stdio.h>
+
++#if !defined(ssize_t)
++ #ifdef _WIN64
++ #define ssize_t long long
++ #else
++ #define ssize_t long
++ #endif
++#endif
++
+ #define MAXFONTS 100
+
+ #define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
+diff --git a/src/xlibi18n/lcDB.c b/src/xlibi18n/lcDB.c
+index e04a5d89f..fa46f8ecc 100644
+--- a/src/xlibi18n/lcDB.c
++++ b/src/xlibi18n/lcDB.c
+@@ -65,6 +65,14 @@
+
+ #include <stdio.h>
+
++#if !defined(ssize_t)
++ #ifdef _WIN64
++ #define ssize_t long long
++ #else
++ #define ssize_t long
++ #endif
++#endif
++
+ typedef struct _DatabaseRec {
+ char *category;
+ char *name;
+diff --git a/src/xlibi18n/lcFile.c b/src/xlibi18n/lcFile.c
+index e43ac2c0e..d9f49b725 100644
+--- a/src/xlibi18n/lcFile.c
++++ b/src/xlibi18n/lcFile.c
+@@ -32,7 +32,9 @@
+ #include "Xlibint.h"
+ #include "XlcPubI.h"
+ #include <X11/Xos.h>
++#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
++#endif
+
+ /************************************************************************/
+
diff --git a/vcpkg/ports/libx11/dllimport.patch b/vcpkg/ports/libx11/dllimport.patch
new file mode 100644
index 0000000..a06adc0
--- /dev/null
+++ b/vcpkg/ports/libx11/dllimport.patch
@@ -0,0 +1,44 @@
+diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
+index 603d05669..8596cb434 100644
+--- a/include/X11/Xlibint.h
++++ b/include/X11/Xlibint.h
+@@ -389,23 +389,26 @@ struct _XLockPtrs {
+ #define _XLockMutex_fn (*_XLockMutex_fn_p)
+ #define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
+ #define _Xglobal_lock (*_Xglobal_lock_p)
++#define X_LOCK_EXTERN __declspec(dllimport) extern
++#else
++#define X_LOCK_EXTERN extern
+ #endif
+
+ /* in XlibInt.c */
+-extern void (*_XCreateMutex_fn)(
++X_LOCK_EXTERN void (*_XCreateMutex_fn)(
+ LockInfoPtr /* lock */
+ );
+-extern void (*_XFreeMutex_fn)(
++X_LOCK_EXTERN void (*_XFreeMutex_fn)(
+ LockInfoPtr /* lock */
+ );
+-extern void (*_XLockMutex_fn)(
++X_LOCK_EXTERN void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+ #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+ #endif
+ );
+-extern void (*_XUnlockMutex_fn)(
++X_LOCK_EXTERN void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+ #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+@@ -413,7 +416,7 @@ extern void (*_XUnlockMutex_fn)(
+ #endif
+ );
+
+-extern LockInfoPtr _Xglobal_lock;
++X_LOCK_EXTERN LockInfoPtr _Xglobal_lock;
+
+ #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ #define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
diff --git a/vcpkg/ports/libx11/io_include.patch b/vcpkg/ports/libx11/io_include.patch
new file mode 100644
index 0000000..184b8d5
--- /dev/null
+++ b/vcpkg/ports/libx11/io_include.patch
@@ -0,0 +1,12 @@
+diff --git a/src/XlibInt.c b/src/XlibInt.c
+index bab39bc00..31b6511cb 100644
+--- a/src/XlibInt.c
++++ b/src/XlibInt.c
+@@ -45,6 +45,7 @@ from The Open Group.
+ #include <stdio.h>
+ #ifdef WIN32
+ #include <direct.h>
++#include <io.h>
+ #endif
+
+ /* Needed for FIONREAD on Solaris */
diff --git a/vcpkg/ports/libx11/optimize-configure.patch b/vcpkg/ports/libx11/optimize-configure.patch
new file mode 100644
index 0000000..d964c2b
--- /dev/null
+++ b/vcpkg/ports/libx11/optimize-configure.patch
@@ -0,0 +1,13 @@
+diff --git a/Makefile.am b/Makefile.am
+index b14f9d78..2df82fe3 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -4,7 +4,7 @@ else
+ ORDER=modules src
+ endif
+ # Order: nls before specs
+-SUBDIRS=include $(ORDER) nls man specs
++SUBDIRS=include $(ORDER) nls
+
+ ACLOCAL_AMFLAGS = -I m4
+
diff --git a/vcpkg/ports/libx11/portfile.cmake b/vcpkg/ports/libx11/portfile.cmake
new file mode 100644
index 0000000..d5cd2a4
--- /dev/null
+++ b/vcpkg/ports/libx11/portfile.cmake
@@ -0,0 +1,108 @@
+if(NOT X_VCPKG_FORCE_VCPKG_X_LIBRARIES AND NOT VCPKG_TARGET_IS_WINDOWS)
+ message(STATUS "Utils and libraries provided by '${PORT}' should be provided by your system! Install the required packages or force vcpkg libraries by setting X_VCPKG_FORCE_VCPKG_X_LIBRARIES in your triplet")
+ set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
+else()
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
+ set(PATCHES dllimport.patch)
+endif()
+
+vcpkg_from_gitlab(
+ GITLAB_URL https://gitlab.freedesktop.org/xorg
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO lib/libx11
+ REF 3a30ada60c5217ada37b143b541c8e6f6284c7fa
+ SHA512 441f86ff8293d27459feaa93f85bcd4d02c6bd64fdb4d95199e5ee8a75340c2ce9b0fccd0b05840ce0de30ff3af3d21e6f37c81840e82b37dbddf082911b585d
+ HEAD_REF master
+ PATCHES
+ optimize-configure.patch
+ cl.build.patch
+ io_include.patch
+ ${PATCHES}
+ vcxserver.patch
+ add_dl_pc.patch
+)
+
+set(ENV{ACLOCAL} "aclocal -I \"${CURRENT_INSTALLED_DIR}/share/xorg/aclocal/\"")
+
+set(OPTIONS "")
+if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
+ set(ENV{CPP} "cl_cpp_wrapper")
+ list(APPEND OPTIONS
+ --enable-loadable-i18n=no #Pointer conversion errors
+ --enable-unix-transport=no
+ --disable-thread-safety-constructor
+ ac_cv_search_dlopen=no
+ )
+endif()
+if(VCPKG_TARGET_IS_WINDOWS)
+ list(APPEND OPTIONS
+ --enable-malloc0returnsnull=yes #Configure fails to run the test for some reason
+ --enable-ipv6
+ --enable-hyperv
+ --enable-tcp-transport
+ --with-launchd=no
+ --with-lint=no
+ --disable-selective-werror
+ )
+endif()
+if(VCPKG_CROSSCOMPILING)
+ list(APPEND OPTIONS
+ --enable-malloc0returnsnull=yes
+ )
+endif()
+if(NOT XLSTPROC)
+ find_program(XLSTPROC NAMES "xsltproc${VCPKG_HOST_EXECUTABLE_SUFFIX}" PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/libxslt" PATH_SUFFIXES "bin")
+endif()
+if(NOT XLSTPROC)
+ message(FATAL_ERROR "${PORT} requires xlstproc for the host system. Please install libxslt within vcpkg or your system package manager!")
+endif()
+get_filename_component(XLSTPROC_DIR "${XLSTPROC}" DIRECTORY)
+file(TO_NATIVE_PATH "${XLSTPROC_DIR}" XLSTPROC_DIR_NATIVE)
+vcpkg_add_to_path("${XLSTPROC_DIR}")
+set(ENV{XLSTPROC} "${XLSTPROC}")
+
+if(VCPKG_TARGET_IS_OSX)
+ set(ENV{LC_ALL} C)
+endif()
+vcpkg_find_acquire_program(PERL)
+vcpkg_configure_make(
+ SOURCE_PATH "${SOURCE_PATH}"
+ AUTOCONFIG
+ OPTIONS
+ ${OPTIONS}
+)
+
+if(VCPKG_CROSSCOMPILING)
+ file(GLOB FOR_BUILD_FILES "${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}/*")
+ file(COPY ${FOR_BUILD_FILES} DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/src/util")
+ if(NOT VCPKG_BUILD_TYPE)
+ file(COPY ${FOR_BUILD_FILES} DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/src/util")
+ endif()
+endif()
+vcpkg_install_make()
+vcpkg_fixup_pkgconfig()
+
+if(EXISTS "${CURRENT_INSTALLED_DIR}/include/X11/extensions/XKBgeom.h")
+ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/X11/extensions/") #XKBgeom.h should be the only file in there
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
+
+# Handle copyright
+file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
+
+if(NOT VCPKG_CROSSCOMPILING)
+ file(READ "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/config.log" config_contents)
+ string(REGEX MATCH "ac_cv_objext=[^\n]+" objsuffix "${config_contents}")
+ string(REPLACE "ac_cv_objext=" "." objsuffix "${objsuffix}")
+ file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/src/util/makekeys${VCPKG_TARGET_EXECUTABLE_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
+ file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/src/util/makekeys${objsuffix}" DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}")
+endif()
+
+endif()
+
+configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake"
+ "${CURRENT_PACKAGES_DIR}/share/x11/vcpkg-cmake-wrapper.cmake" @ONLY)
+
diff --git a/vcpkg/ports/libx11/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/libx11/vcpkg-cmake-wrapper.cmake
new file mode 100644
index 0000000..4085a39
--- /dev/null
+++ b/vcpkg/ports/libx11/vcpkg-cmake-wrapper.cmake
@@ -0,0 +1,20 @@
+set(Z_VCPKG_FIRST_X11_SEARCH OFF)
+if(NOT X11_FOUND)
+ set(Z_VCPKG_FIRST_X11_SEARCH ON)
+endif()
+_find_package(${ARGS})
+if(TARGET X11::X11 AND Z_VCPKG_FIRST_X11_SEARCH)
+ target_link_libraries(X11::X11 INTERFACE ${CMAKE_DL_LIBS})
+ if(TARGET X11::xcb)
+ target_link_libraries(X11::X11 INTERFACE X11::xcb)
+ endif()
+endif()
+if(TARGET X11::xcb AND Z_VCPKG_FIRST_X11_SEARCH)
+ if(TARGET X11::Xdmcp)
+ set_property(TARGET X11::xcb APPEND PROPERTY INTERFACE_LINK_LIBRARIES X11::Xdmcp)
+ endif()
+ if(TARGET X11::Xau)
+ set_property(TARGET X11::xcb APPEND PROPERTY INTERFACE_LINK_LIBRARIES X11::Xau)
+ endif()
+endif()
+unset(Z_VCPKG_FIRST_X11_SEARCH) \ No newline at end of file
diff --git a/vcpkg/ports/libx11/vcpkg.json b/vcpkg/ports/libx11/vcpkg.json
new file mode 100644
index 0000000..44c4128
--- /dev/null
+++ b/vcpkg/ports/libx11/vcpkg.json
@@ -0,0 +1,22 @@
+{
+ "name": "libx11",
+ "version": "1.8.1",
+ "port-version": 4,
+ "description": "The X Window System is a network-transparent window system that was designed at MIT.",
+ "homepage": "https://www.x.org/wiki/",
+ "license": "MIT",
+ "dependencies": [
+ "bzip2",
+ {
+ "name": "libx11",
+ "host": true
+ },
+ {
+ "name": "libxslt",
+ "host": true
+ },
+ "xcb",
+ "xproto",
+ "xtrans"
+ ]
+}
diff --git a/vcpkg/ports/libx11/vcxserver.patch b/vcpkg/ports/libx11/vcxserver.patch
new file mode 100644
index 0000000..10a6312
--- /dev/null
+++ b/vcpkg/ports/libx11/vcxserver.patch
@@ -0,0 +1,138 @@
+diff --git a/include/X11/Xlib.h b/include/X11/Xlib.h
+index 5faf83b..c6c63a3 100644
+--- a/include/X11/Xlib.h
++++ b/include/X11/Xlib.h
+@@ -79,7 +79,7 @@ _Xmblen(
+
+ typedef char *XPointer;
+
+-#define Bool int
+-#define Status int
++typedef int Bool;
++typedef int Status;
+ #define True 1
+ #define False 0
+diff --git a/src/CrGlCur.c b/src/CrGlCur.c
+index 460660f..510ff5d 100644
+--- a/src/CrGlCur.c
++++ b/src/CrGlCur.c
+@@ -51,8 +51,14 @@ in this Software without prior written authorization from The Open Group.
+ #if defined(hpux)
+ typedef shl_t XModuleType;
+ #else
++#ifdef _MSC_VER
++#include <X11/XWindows.h>
++typedef HANDLE XModuleType;
++#define dlsym GetProcAddress
++#else
+ typedef void *XModuleType;
+ #endif
++#endif
+
+ #ifndef LIBXCURSOR
+ #define LIBXCURSOR "libXcursor.so.1"
+@@ -70,8 +76,12 @@ open_library (void)
+ {
+ #if defined(hpux)
+ module = shl_load(library, BIND_DEFERRED, 0L);
++#else
++#ifdef _MSC_VER
++ module = LoadLibrary(library);
+ #else
+ module = dlopen(library, RTLD_LAZY);
++#endif
+ #endif
+ if (module)
+ return module;
+diff --git a/src/GetDflt.c b/src/GetDflt.c
+index c9222a2..c6e1b25 100644
+--- a/src/GetDflt.c
++++ b/src/GetDflt.c
+@@ -137,9 +138,13 @@ InitDefaults(
+ * ~/.Xdefaults. Next, if there is an XENVIRONMENT environment variable,
+ * then load that file.
+ */
+-
++
+ if (dpy->xdefaults == NULL) {
++ #ifdef _MSC_VER
++ const char *slashDotXdefaults = ".Xdefaults";
++ #else
+ const char *slashDotXdefaults = "/.Xdefaults";
++ #endif
+
+ (void) GetHomeDir (fname, (int) (PATH_MAX - strlen (slashDotXdefaults) - 1));
+ (void) strcat (fname, slashDotXdefaults);
+@@ -149,7 +154,11 @@ InitDefaults(
+ }
+
+ if (!(xenv = getenv ("XENVIRONMENT"))) {
++ #ifdef _MSC_VER
++ const char *slashDotXdefaultsDash = ".Xdefaults-";
++ #else
+ const char *slashDotXdefaultsDash = "/.Xdefaults-";
++ #endif
+ int len;
+
+ (void) GetHomeDir (fname, (int) (PATH_MAX - strlen (slashDotXdefaultsDash) - 1));
+ diff --git a/src/SetLocale.c b/src/SetLocale.c
+index 81f4a7c..cb52f11 100644
+--- a/src/SetLocale.c
++++ b/src/SetLocale.c
+@@ -63,11 +63,11 @@ from The Open Group.
+ #include <X11/Xlocale.h>
+ #include <X11/Xos.h>
+ #include "XlcPubI.h"
+
+ #define MAXLOCALE 64 /* buffer size of locale name */
+
+
+-#if defined(__APPLE__) || defined(__CYGWIN__)
++#if defined(__APPLE__) || defined(__CYGWIN__) || defined(_MSC_VER)
+ char *
+ _Xsetlocale(
+ int category,
+diff --git a/src/StrKeysym.c b/src/StrKeysym.c
+index be77a93..6967bcc 100644
+--- a/src/StrKeysym.c
++++ b/src/StrKeysym.c
+@@ -39,12 +39,12 @@ in this Software without prior written authorization from The Open Group.
+
+ #ifndef KEYSYMDB
+ #ifndef XKEYSYMDB
+-#define KEYSYMDB "/usr/lib/X11/XKeysymDB"
++#define KEYSYMDB "XKeysymDB"
+ #else
+ #define KEYSYMDB XKEYSYMDB
+ #endif
+ #endif
+
+ static Bool initialized;
+ static XrmDatabase keysymdb;
+ static XrmQuark Qkeysym[2];
+diff --git a/src/xlibi18n/lcDynamic.c b/src/xlibi18n/lcDynamic.c
+index 3821bff..a50aa70 100644
+--- a/src/xlibi18n/lcDynamic.c
++++ b/src/xlibi18n/lcDynamic.c
+@@ -51,7 +51,7 @@ from The Open Group.
+ #include "Xlcint.h"
+
+ #ifndef XLOCALEDIR
+-#define XLOCALEDIR "/usr/lib/X11/locale"
++#define XLOCALEDIR "locale"
+ #endif
+
+ #define LCLIBNAME "xi18n.so"
+diff --git a/src/xlibi18n/lcFile.c b/src/xlibi18n/lcFile.c
+index 25cabd5..819ac89 100644
+--- a/src/xlibi18n/lcFile.c
++++ b/src/xlibi18n/lcFile.c
+@@ -195,7 +192,7 @@ _XlcParsePath(
+ }
+
+ #ifndef XLOCALEDIR
+-#define XLOCALEDIR "/usr/lib/X11/locale"
++#define XLOCALEDIR "locale"
+ #endif
+
+ void