forked from esl/erlang_ale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
100 lines (71 loc) · 2.71 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
PROJECT=erlang_ale
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
XC_DIR=/usr/local/gcc-4.8.0-for-linux32
ERL_LIB=/usr/local/lib/erlang/lib/erl_interface-3.7.11
CFLAGS=-Wall -I/usr/local/include -I$(ERL_LIB)/include -I$(XC_DIR)/include -Ideps/erlang_portutil -Ideps/pihwm/lib
CC=$(XC_DIR)/bin/i586-pc-linux-gcc
endif
ifeq ($(UNAME), Linux)
ERL_LIB=/usr/lib/erlang/lib/erl_interface-3.7.9
CFLAGS=-Wall -I/usr/local/include -I$(ERL_LIB)/include -Ideps/erlang_portutil -Ideps/pihwm/lib
CC=gcc
endif
#DEPS = edown gen_leader gproc meck pihwm erlang_portutil
DEPS = gproc meck pihwm erlang_portutil
#dep_edown = https://github.com/esl/edown.git master
#dep_gen_leader = https://github.com/abecciu/gen_leader_revival.git master
dep_gproc = https://github.com/lehoff/gproc.git master
#0.2.13.3
dep_meck = https://github.com/eproxus/meck.git 0.7.2
dep_pihwm = https://github.com/omerk/pihwm.git master "./configure"
dep_erlang_portutil = https://github.com/omerk/erlang_portutil master
include erlang.mk
REBAR_DEPS_DIR=${DEPS_DIR}
ERL_LIBS:=./deps:${ERL_LIBS}
LDFLAGS=-L. -L$(ERL_LIB)/lib -Ldeps/pihwm/lib -Lpriv
# PIHWMLIB = pihwm pi_gpio
all: init library
library: gpio_port pwm_nif i2c_lib examples
init:
mkdir -p priv ebin
gpio_port: priv/gpio_port.o deps/erlang_portutil/port_comms.o
$(CC) ${LDFLAGS} deps/erlang_portutil/port_comms.o deps/pihwm/lib/pihwm.o deps/pihwm/lib/pi_gpio.o priv/gpio_port.o -lerl_interface -lei -lpthread -o priv/gpio_port
gpio_test: priv/gpio_test.o
$(CC) $(LDFLAGS) $< pihwm.o pi_gpio.o -lpthread -o $@
# PWM
pwm_nif:
$(CC) $(LDFLAGS) $< -o priv/pwm_nif.so -fpic -shared c_src/pwm_nif.c deps/pihwm/lib/pihwm.c deps/pihwm/lib/pi_pwm.c
pwm: pwm_nif
erlc -o ./ebin src/pwm.erl
# I2C
erl_comm.o: c_src/erl_comm.c
$(CC) -c c_src/erl_comm.c -o priv/erl_comm.o
i2c_ei.o: c_src/i2c_ei.c
$(CC) -c c_src/i2c_ei.c -o priv/i2c_ei.o
i2c_lib: i2c_ei.o erl_comm.o
$(CC) -o priv/i2c_lib -I$(ERL_LIB)/include -lpthread -L$(ERL_LIB)/lib priv/i2c_ei.o priv/erl_comm.o deps/pihwm/lib/pihwm.o deps/pihwm/lib/pi_i2c.o -lerl_interface -lei
rm -rf priv/i2c_ei.o priv/erl_comm.o
port_lib.beam:
erlc -o ./ebin src/port_lib.erl
i2c: i2c_lib port_lib.beam
erlc -o ./ebin src/i2c.erl src/i2c_sup.erl
# EXAMPLE
examples:
erlc -o examples examples/*.erl
shell:
sudo erl -sname e1 -setcookie secretcookie -pz deps/*/ebin -pz ebin -pz examples
test:
ct_run -noshell -pa deps/*/ebin -pa ebin -sname ct -env TEST_DIR test -dir test
run_test:
ct_run -noshell -pa deps/*/ebin -pa ebin -sname ct -env TEST_DIR test -dir test
clean_ct:
rm -rf ct_run*
rm -rf ct_default.css
rm -rf index.html
rm -rf all_runs.html
rm -rf jquery*
rm -rf variables*@*
priv/%.o: c_src/%.c
$(CC) -g $(CFLAGS) -c -o $@ $<
.PHONY: all library init shell