diff 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
line wrap: on
line diff
--- 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
+