cmake.backbone/templates/library_constructor.c.in

49 lines
1.2 KiB
C

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
@LC_WIN32_INCLUDES@
#elif defined(linux) || defined(UNIX) || defined(__unix__)
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
@LC_UNIX_INCLUDES@
#endif
@LC_COMMON_INCLUDES@
#include "gettext-config.h"
char SO_PATH[FILENAME_MAX];
@LC_GLOB_VARS@
#if defined(_WIN32) || defined(_WIN64)
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
#elif defined(linux) || defined(UNIX) || defined(__unix__)
void __attribute__ ((constructor)) load_library (void)
#endif
{
gchar *soDir, *localePath;
@LC_VARS@
#if defined(_WIN32) || defined(_WIN64)
GetModuleFileName (hInstance, SO_PATH, FILENAME_MAX);
@LC_WIN32_CODE@
#elif defined(linux) || defined(UNIX) || defined(__unix__)
Dl_info dl_info;
dladdr(load_library, &dl_info);
strcpy (SO_PATH, dl_info.dli_fname);
@LC_UNIX_CODE@
#endif
soDir = g_path_get_dirname (SO_PATH);
localePath = g_build_filename (soDir, "@LC_RELATIVE_PREFIX@/share/locale", NULL);
g_free (soDir);
bindtextdomain (GETTEXT_PACKAGE, localePath);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
g_free (localePath);
@LC_COMMON_CODE@
}