comparison erlang/erldc/Makefile @ 12:079718588eb6

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.
author cslag
date Sat, 26 Mar 2016 15:55:50 +0100
parents 0cfcc391201f
children 7752fcb107e7
comparison
equal deleted inserted replaced
11:8070dae59227 12:079718588eb6
1 # ERLANG_INC is used for -I, below, so add paths where it might be on linux, freebsd, etc.
2 ERLANG_INC=-I /usr/lib64/erlang/usr/include -I /usr/local/lib/erlang/usr/include
3 DYNCALL_SRC_PATH=../../../dyncall
4
5 # Be sure to 'make clean' after changing the version 1 # Be sure to 'make clean' after changing the version
6 VERSION=0.1 2 VERSION=0.9
7 3
8 OUTPUTS = priv/erldc.so ebin/dyncall.beam ebin/erldc.app 4 OUTPUTS = priv/erldc.so ebin/dyncall.beam ebin/erldc.app
9 5
10 # Used by install target. Default empty DESTDIR is for a real install to root filesystem (/). 6 # Used by install target. Default empty PREFIX is for a real install to root filesystem (/).
11 # Override DESTDIR for testing or for a staged install 7 # Override PREFIX for testing or for a staged install
12 DESTDIR= 8 PREFIX=
13 ERLANG_INST_DIR=/usr/lib64/erlang 9 ERLANG_INST_DIR=/usr/lib64/erlang
14 10
15 all: $(OUTPUTS) 11 all: $(OUTPUTS)
16 12
17 priv/erldc.so: c_src/dyncallnif.c 13 priv/erldc.so: c_src/dyncallnif.c
18 [ -d priv ] || mkdir priv 14 [ -d priv ] || mkdir priv
19 cc -o $@ -fPIC -shared \ 15 $(CC) -o $@ -shared -fPIC $(CFLAGS) -ldyncall_s c_src/dyncallnif.c
20 $(ERLANG_INC) -I $(DYNCALL_SRC_PATH) \
21 $(DYNCALL_SRC_PATH)/dyncall/*.o \
22 c_src/dyncallnif.c
23 16
24 priv/erldc_testtargets.so: c_src/erldctesttargets.c 17 priv/erldc_testtargets.so: c_src/erldctesttargets.c
25 [ -d priv ] || mkdir priv 18 [ -d priv ] || mkdir priv
26 cc -o $@ -shared -fPIC c_src/erldctesttargets.c 19 $(CC) -o $@ -shared -fPIC c_src/erldctesttargets.c
27 20
28 ebin/dyncall.beam: src/dyncall.erl 21 ebin/dyncall.beam: src/dyncall.erl
22 [ -d ebin ] || mkdir ebin
29 erlc +debug_info -o ebin src/dyncall.erl 23 erlc +debug_info -o ebin src/dyncall.erl
30 24
31 ebin/erldc.app: src/erldc.app.src 25 ebin/erldc.app: src/erldc.app.src
26 [ -d ebin ] || mkdir ebin
32 sed -e 's/---VERSION---/$(VERSION)/' src/erldc.app.src >$@ 27 sed -e 's/---VERSION---/$(VERSION)/' src/erldc.app.src >$@
33 28
34 # Dialyzer, credit to erlang.mk 29 # Dialyzer, credit to erlang.mk
35 DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \ 30 DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \
36 -Wunmatched_returns # -Wunderspecs 31 -Wunmatched_returns # -Wunderspecs
51 -suite linkload_SUITE call_SUITE \ 46 -suite linkload_SUITE call_SUITE \
52 misc_SUITE callf_SUITE 47 misc_SUITE callf_SUITE
53 rm -f test/*.beam 48 rm -f test/*.beam
54 49
55 clean: 50 clean:
56 rm -rf priv ebin/* test/*.beam log 51 rm -rf priv ebin test/*.beam log
57 52
58 # Convention appears to be install binaries and source, but not tests or build-related things 53 # Convention appears to be install binaries and source, but not tests or build-related things
59 install: $(OUTPUTS) 54 install: $(OUTPUTS)
60 appdir=$(DESTDIR)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \ 55 appdir=$(PREFIX)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \
61 install -d $$appdir $$appdir/ebin $$appdir/priv $$appdir/src $$appdir/c_src $$appdir/include; \ 56 install -d $$appdir $$appdir/ebin $$appdir/priv $$appdir/src $$appdir/c_src $$appdir/include; \
62 install README.txt $$appdir; \ 57 install README.txt $$appdir; \
63 install src/*.erl $$appdir/src; \ 58 install src/*.erl $$appdir/src; \
64 install include/*.hrl $$appdir/include; \ 59 install include/*.hrl $$appdir/include; \
65 install c_src/*.c $$appdir/c_src; \ 60 install c_src/*.c $$appdir/c_src; \
66 install ebin/* $$appdir/ebin; \ 61 install ebin/* $$appdir/ebin; \
67 install priv/erldc.so $$appdir/priv 62 install priv/erldc.so $$appdir/priv
68 63
69 uninstall: 64 uninstall:
70 appdir=$(DESTDIR)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \ 65 appdir=$(PREFIX)$(ERLANG_INST_DIR)/lib/erldc-$(VERSION); \
71 rm -rf $$appdir 66 rm -rf $$appdir
72 67
73 .PHONY: clean all tests build-plt dialyze install uninstall 68 .PHONY: clean all tests build-plt dialyze install uninstall
69