aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlava Yurin <[email protected]>2014-11-18 20:27:13 +0600
committerSlava Yurin <[email protected]>2014-11-19 17:23:55 +0600
commit2ab9c8bfcbe70a8ae521df96444759bdb39f712f (patch)
tree10bd45dd740b5b321a25832fe1fd7a7855313821
parente523171600610df7235053fa929bc6ee0dbb393e (diff)
downloaderlang.mk-2ab9c8bfcbe70a8ae521df96444759bdb39f712f.tar.gz
erlang.mk-2ab9c8bfcbe70a8ae521df96444759bdb39f712f.tar.bz2
erlang.mk-2ab9c8bfcbe70a8ae521df96444759bdb39f712f.zip
Add erl_interface for c_src compile and link
Using LDFLAGS, LDLIBS for link
-rw-r--r--plugins/c_src.mk22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/c_src.mk b/plugins/c_src.mk
index daee44e..de14954 100644
--- a/plugins/c_src.mk
+++ b/plugins/c_src.mk
@@ -25,10 +25,15 @@ else ifeq ($(UNAME_SYS), Linux)
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
endif
+CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
+
+LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei
+LDFLAGS += -shared
+
# Verbosity.
c_src_verbose_0 = @echo " C_SRC " $(?F);
-c_src_verbose = $(appsrc_verbose_$(V))
+c_src_verbose = $(c_src_verbose_$(V))
# Targets.
@@ -36,13 +41,18 @@ ifeq ($(wildcard $(C_SRC_DIR)/Makefile),)
app:: $(C_SRC_ENV)
@mkdir -p priv/
- $(c_src_verbose) $(CC) $(CFLAGS) $(C_SRC_DIR)/*.c -fPIC -shared -o $(C_SRC_OUTPUT) \
- -I $(ERTS_INCLUDE_DIR) $(C_SRC_OPTS)
+ $(c_src_verbose) $(CC) $(CFLAGS) $(C_SRC_DIR)/*.c \
+ $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT) $(C_SRC_OPTS)
$(C_SRC_ENV):
- erl -noshell -noinput -eval "file:write_file(\"$(C_SRC_ENV)\", \
- io_lib:format(\"ERTS_INCLUDE_DIR ?= ~s/erts-~s/include/\", \
- [code:root_dir(), erlang:system_info(version)])), \
+ @erl -noshell -noinput -eval "file:write_file(\"$(C_SRC_ENV)\", \
+ io_lib:format( \
+ \"ERTS_INCLUDE_DIR ?= ~s/erts-~s/include/~n\" \
+ \"ERL_INTERFACE_INCLUDE_DIR ?= ~s~n\" \
+ \"ERL_INTERFACE_LIB_DIR ?= ~s~n\", \
+ [code:root_dir(), erlang:system_info(version), \
+ code:lib_dir(erl_interface, include), \
+ code:lib_dir(erl_interface, lib)])), \
erlang:halt()."
-include $(C_SRC_ENV)