summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-06-19 21:58:42 +0200
committerDavid Robillard <d@drobilla.net>2020-06-19 21:58:42 +0200
commit81babb758e614ae622b39849c0c65cf38505a912 (patch)
tree1422e73a702484fe0565d9d1791a57f3e281cae1
parent1032bc5b7e875d67fe47d51e78e9e75c0eec8e3c (diff)
downloadlilv-81babb758e614ae622b39849c0c65cf38505a912.tar.gz
lilv-81babb758e614ae622b39849c0c65cf38505a912.tar.bz2
lilv-81babb758e614ae622b39849c0c65cf38505a912.zip
Check for CreateSymbolicLink at configure time
This uses the system CreateSymbolicLink if it is available at compile time, and if not, just acts as if the link failed (which is extremely likely anyway). This removes the ugly wrapper code that has been a constant source of compatibility headaches with weird toolchains.
-rw-r--r--src/util.c20
-rw-r--r--wscript8
2 files changed, 10 insertions, 18 deletions
diff --git a/src/util.c b/src/util.c
index 448b66d..7930d70 100644
--- a/src/util.c
+++ b/src/util.c
@@ -29,29 +29,11 @@
#include "serd/serd.h"
#ifdef _WIN32
-#ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0600 /* for CreateSymbolicLink */
-#endif
# include <windows.h>
# include <direct.h>
# include <io.h>
# define F_OK 0
# define mkdir(path, flags) _mkdir(path)
-# if (defined(_MSC_VER) && _MSC_VER <= 1400) || defined(__MINGW64__) || defined(__MINGW32__)
-/** Implement 'CreateSymbolicLink()' for MSVC 8 or earlier */
-#ifdef __cplusplus
-extern "C"
-#endif
-static BOOLEAN WINAPI
-CreateSymbolicLink(LPCTSTR linkpath, LPCTSTR targetpath, DWORD flags)
-{
- typedef BOOLEAN (WINAPI* PFUNC)(LPCTSTR, LPCTSTR, DWORD);
-
- PFUNC pfn = (PFUNC)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
- "CreateSymbolicLinkA");
- return pfn ? pfn(linkpath, targetpath, flags) : 0;
-}
-# endif
#else
# include <dirent.h>
# include <unistd.h>
@@ -494,7 +476,9 @@ lilv_symlink(const char* oldpath, const char* newpath)
int ret = 0;
if (strcmp(oldpath, newpath)) {
#ifdef _WIN32
+#ifdef HAVE_CREATESYMBOLICLINK
ret = !CreateSymbolicLink(newpath, oldpath, 0);
+#endif
if (ret) {
ret = !CreateHardLink(newpath, oldpath, 0);
}
diff --git a/wscript b/wscript
index 00bedf1..1aeb9dd 100644
--- a/wscript
+++ b/wscript
@@ -140,6 +140,14 @@ def configure(conf):
lib = 'dl',
mandatory = False)
+ if conf.env.DEST_OS == 'win32':
+ conf.check_function('c', 'CreateSymbolicLink',
+ header_name = ['windows.h'],
+ define_name = 'HAVE_CREATESYMBOLICLINK',
+ return_type = 'BOOLEAN',
+ arg_types = 'LPCSTR, LPCSTR, DWORD',
+ mandatory = False)
+
if Options.options.dyn_manifest:
conf.define('LILV_DYN_MANIFEST', 1)