# HG changeset patch # User cslag # Date 1459004150 -3600 # Node ID 079718588eb6849375b4ec0c37fc3347cc02542e # Parent 8070dae592279e40f8af831eb78083555b12ab53 made erlang binding work with system *installed* dyncall: - made build use static libraries (used .o files directly) - removed custom flags for include path and relying on CFLAGS now - change cc to $(CC) - readme update with build instructions, etc. diff -r 8070dae59227 -r 079718588eb6 erlang/erldc/Makefile --- a/erlang/erldc/Makefile Sat Mar 26 15:47:53 2016 +0100 +++ b/erlang/erldc/Makefile Sat Mar 26 15:55:50 2016 +0100 @@ -1,34 +1,29 @@ -# ERLANG_INC is used for -I, below, so add paths where it might be on linux, freebsd, etc. -ERLANG_INC=-I /usr/lib64/erlang/usr/include -I /usr/local/lib/erlang/usr/include -DYNCALL_SRC_PATH=../../../dyncall - # Be sure to 'make clean' after changing the version -VERSION=0.1 +VERSION=0.9 OUTPUTS = priv/erldc.so ebin/dyncall.beam ebin/erldc.app -# Used by install target. Default empty DESTDIR is for a real install to root filesystem (/). -# Override DESTDIR for testing or for a staged install -DESTDIR= +# Used by install target. Default empty PREFIX is for a real install to root filesystem (/). +# Override PREFIX for testing or for a staged install +PREFIX= ERLANG_INST_DIR=/usr/lib64/erlang all: $(OUTPUTS) priv/erldc.so: c_src/dyncallnif.c [ -d priv ] || mkdir priv - cc -o $@ -fPIC -shared \ - $(ERLANG_INC) -I $(DYNCALL_SRC_PATH) \ - $(DYNCALL_SRC_PATH)/dyncall/*.o \ - c_src/dyncallnif.c + $(CC) -o $@ -shared -fPIC $(CFLAGS) -ldyncall_s c_src/dyncallnif.c priv/erldc_testtargets.so: c_src/erldctesttargets.c [ -d priv ] || mkdir priv - cc -o $@ -shared -fPIC c_src/erldctesttargets.c + $(CC) -o $@ -shared -fPIC c_src/erldctesttargets.c ebin/dyncall.beam: src/dyncall.erl + [ -d ebin ] || mkdir ebin erlc +debug_info -o ebin src/dyncall.erl ebin/erldc.app: src/erldc.app.src + [ -d ebin ] || mkdir ebin sed -e 's/---VERSION---/$(VERSION)/' src/erldc.app.src >$@ # Dialyzer, credit to erlang.mk @@ -53,11 +48,11 @@ rm -f test/*.beam clean: - rm -rf priv ebin/* test/*.beam log + rm -rf priv ebin test/*.beam log # Convention appears to be install binaries and source, but not tests or build-related things install: $(OUTPUTS) - appdir=$(DESTDIR)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \ + appdir=$(PREFIX)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \ install -d $$appdir $$appdir/ebin $$appdir/priv $$appdir/src $$appdir/c_src $$appdir/include; \ install README.txt $$appdir; \ install src/*.erl $$appdir/src; \ @@ -67,7 +62,8 @@ install priv/erldc.so $$appdir/priv uninstall: - appdir=$(DESTDIR)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \ + appdir=$(PREFIX)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \ rm -rf $$appdir .PHONY: clean all tests build-plt dialyze install uninstall + diff -r 8070dae59227 -r 079718588eb6 erlang/erldc/README.txt --- a/erlang/erldc/README.txt Sat Mar 26 15:47:53 2016 +0100 +++ b/erlang/erldc/README.txt Sat Mar 26 15:55:50 2016 +0100 @@ -1,16 +1,25 @@ -BUILDING -======== +BUILD/INSTALLATION +================== -To build erldc: +1) make sure dyncall is built and libraries/headers are in include paths or + CFLAGS points to them, etc.. Same goes for erlang headers/libs. + +2) Build this erlang NIF: - make DYNCALL_SRC_PATH=../dyncall ERLANG_INST_DIR=/erlang/in/this/dir all - sudo make ERLANG_INST_DIR=/erlang/in/this/dir install + make -Erlang doesn't use pkg-config, so you must specify ERLANG_INC (and -ERLANG_INST_DIR at install-time). +3) To install, pick correct install paths by defining PREFIX (if needed, e.g. + for stage dir) and ERLANG_INST_DIR (e.g. /usr/lib64/erlang, + /usr/local/lib/erlang, ...): + + make ERLANG_INST_DIR=/erlang/in/this/dir install + +Erlang doesn't use pkg-config, so it's up to you to point to set the flags to +point to correct paths at build and install-time. The makefile is meant to be portable, at least across *nix. + RUNNING TESTS ============= @@ -23,13 +32,16 @@ make build-plt make dialyze + USING ===== + Examine the test suites for several examples. Dyncall is built as an OTP library application, so there's nothing to start or stop. + TODO ==== @@ -37,3 +49,4 @@ AUTHORS ======= Erik Mackdanz +