aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/c_src.mk
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/c_src.mk')
-rw-r--r--plugins/c_src.mk11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/c_src.mk b/plugins/c_src.mk
index bd46613..92711ce 100644
--- a/plugins/c_src.mk
+++ b/plugins/c_src.mk
@@ -103,7 +103,7 @@ $(C_SRC_OUTPUT_FILE): $(OBJECTS)
$(LDFLAGS) $(if $(filter $(C_SRC_TYPE),shared),-shared) $(LDLIBS) \
-o $(C_SRC_OUTPUT_FILE)
-$(OBJECTS): $(MAKEFILE_LIST)
+$(OBJECTS): $(MAKEFILE_LIST) $(C_SRC_ENV)
%.o: %.c
$(COMPILE_C) $(OUTPUT_OPTION) $<
@@ -125,13 +125,16 @@ clean-c_src:
endif
ifneq ($(wildcard $(C_SRC_DIR)),)
+ERL_ERTS_DIR = $(shell $(ERL) -eval 'io:format("~s~n", [code:lib_dir(erts)]), halt().')
+
$(C_SRC_ENV):
$(verbose) $(ERL) -eval "file:write_file(\"$(call core_native_path,$(C_SRC_ENV))\", \
io_lib:format( \
\"# Generated by Erlang.mk. Edit at your own risk!~n~n\" \
\"ERTS_INCLUDE_DIR ?= ~s/erts-~s/include/~n\" \
\"ERL_INTERFACE_INCLUDE_DIR ?= ~s~n\" \
- \"ERL_INTERFACE_LIB_DIR ?= ~s~n\", \
+ \"ERL_INTERFACE_LIB_DIR ?= ~s~n\" \
+ \"ERTS_DIR ?= $(ERL_ERTS_DIR)~n\", \
[code:root_dir(), erlang:system_info(version), \
code:lib_dir(erl_interface, include), \
code:lib_dir(erl_interface, lib)])), \
@@ -143,6 +146,10 @@ distclean-c_src-env:
$(gen_verbose) rm -f $(C_SRC_ENV)
-include $(C_SRC_ENV)
+
+ifneq ($(ERL_ERTS_DIR),$(ERTS_DIR))
+$(shell rm -f $(C_SRC_ENV))
+endif
endif
# Templates.