diff --git a/Makefile b/Makefile index 77b14acb..0291ae2d 100644 --- a/Makefile +++ b/Makefile @@ -133,7 +133,7 @@ build/janet_boot: $(JANET_BOOT_OBJECTS) # Now the reason we bootstrap in the first place build/core_image.c: build/janet_boot - build/janet_boot $@ JANET_PATH $(JANET_PATH) + build/janet_boot $@ JANET_PATH $(JANET_PATH) JANET_HEADERPATH $(INCLUDEDIR)/janet ########################################################## ##### The main interpreter program and shared object ##### @@ -282,8 +282,8 @@ SONAME=libjanet.so.0 install: $(JANET_TARGET) build/version.txt mkdir -p $(BINDIR) cp $(JANET_TARGET) $(BINDIR)/janet - mkdir -p $(INCLUDEDIR) - cp -rf $(JANET_HEADERS) $(INCLUDEDIR) + mkdir -p $(INCLUDEDIR)/janet + cp -rf $(JANET_HEADERS) $(INCLUDEDIR)/janet mkdir -p $(JANET_PATH) cp -rf $(JANET_HEADERS) $(JANET_PATH) mkdir -p $(LIBDIR) diff --git a/meson.build b/meson.build index 29dc3fd4..bbf91cec 100644 --- a/meson.build +++ b/meson.build @@ -22,6 +22,7 @@ project('janet', 'c', default_options : ['c_std=c99']) # Global settings janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') +header_path = join_paths(get_option('prefix'), get_option('includedir'), 'janet') # Link math library on all systems cc = meson.get_compiler('c') @@ -119,7 +120,7 @@ janet_boot = executable('janet-boot', core_src, boot_src, boot_gen, core_image = custom_target('core_image', input : [janet_boot], output : 'core_image.gen.c', - command : [janet_boot, '@OUTPUT@', 'JANET_PATH', janet_path]) + command : [janet_boot, '@OUTPUT@', 'JANET_PATH', janet_path, 'JANET_HEADERPATH', header_path]) libjanet = shared_library('janet', core_src, core_image, include_directories : incdir, @@ -169,10 +170,8 @@ run_target('repl', command : [janet_mainclient]) # Installation install_man('janet.1') -install_headers('src/include/janet.h', 'src/include/janetconf.h') +install_headers('src/include/janet.h', 'src/include/janetconf.h', subdir: 'janet') janet_libs = [ - 'src/include/janet.h', - 'src/include/janetconf.h', 'tools/bars.janet', 'tools/cook.janet', 'tools/highlight.janet' diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 847599b2..dedd914e 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1597,6 +1597,11 @@ on Windows is C:/Janet/Library." (or (process/opts "JANET_PATH") "")) +(var module/*headerpath* + "The path where the janet headers are installed. Useful for building + native modules or compiling code at runtime." + (process/opts "JANET_HEADERPATH")) + # Version of fexists that works even with a reduced OS (if-let [has-stat (_env 'os/stat)] (let [stat (has-stat :value)] diff --git a/tools/cook.janet b/tools/cook.janet index 321a25f4..99175e6d 100644 --- a/tools/cook.janet +++ b/tools/cook.janet @@ -103,7 +103,7 @@ (if is-mac " -undefined dynamic_lookup" "")))) (def CFLAGS (string (if is-win "/I" "-I") - module/*syspath* + module/*headerpath* (if is-win " /O" " -std=c99 -Wall -Wextra -fpic -O") OPTIMIZE))