Skip to content

Commit

Permalink
[build] Use GNUInstallDirs for NGS_PATH
Browse files Browse the repository at this point in the history
Source: #669
  • Loading branch information
ilyash-b committed Jul 11, 2024
1 parent 7c1fa0c commit acdbb5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include(GNUInstallDirs)
# -D_XOPEN_SOURCE - strptime on Linux
# -D_DEFAULT_SOURCE - MAP_ANONYMOUS on Linux
# -D__BSD_VISIBLE - AF_UNIX on FreeBSD
add_definitions(-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE=1 -D_DEFAULT_SOURCE=1 -D_BSD_SOURCE -D__BSD_VISIBLE)
add_definitions(-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE=1 -D_DEFAULT_SOURCE=1 -D_BSD_SOURCE -D__BSD_VISIBLE -DINSTALL_LIBDIR=${CMAKE_INSTALL_FULL_LIBDIR})

# This is workaround for boehm GC library bug or NGS usage of it
# which cases sporadic SIGSEGV and other issues after fork() in child process.
Expand Down
4 changes: 1 addition & 3 deletions lib/stdlib.ngs
Original file line number Diff line number Diff line change
Expand Up @@ -8587,10 +8587,8 @@ section "Loading code" {
%[
${ try ENV.HOME / '.ngs' }
/usr/local/etc/ngs
/usr/local/lib/ngs
/usr/local/lib64/ngs
/etc/ngs
/usr/lib/ngs
${C_INSTALL_LIBDIR}
].filter()
}

Expand Down
7 changes: 7 additions & 0 deletions vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3757,6 +3757,13 @@ void vm_init(VM *vm, int argc, char **argv) {
set_global(vm, "PCRE_NEWLINE", MAKE_INT(d));
}

// INSTALL_LIBDIR - https://stackoverflow.com/questions/47346133/how-to-use-a-define-inside-a-format-string
#define NGS_STR_TMP(X) #X
#define NGS_STR_TMP2(X) NGS_STR_TMP(X)
set_global(vm, "C_INSTALL_LIBDIR", make_string(NGS_STR_TMP2(INSTALL_LIBDIR)));
#undef NGS_STR_TMP2
#undef NGS_STR_TMP

#define FFI_TYPE(name) \
vm->c_ ## name = make_ffi_type(&(name)); \
set_global(vm, "c_" #name, vm->c_ ## name)
Expand Down

0 comments on commit acdbb5c

Please sign in to comment.