-
Notifications
You must be signed in to change notification settings - Fork 14
/
mako.mk
119 lines (94 loc) · 2.93 KB
/
mako.mk
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Makefile for compiling the Mako Server for Linux
# Example: make -f mako.mk EPOLL=true
# The above compiles mako using the 'epoll' socket dispatcher. The
# default is to use the 'select' socket dispatcher.
# The makefile is designed for the "Embedded Linux Web Based Device
# Management" tutorial and will auto include the generated Lua
# bindings if found. The makefile will also auto include SQLite, Lua
# Protobuf, and LPeg if found. LPeg can be installed as follows:
# wget http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.2.tar.gz
# cd src
# tar xvzf ../lpeg-1.0.2.tar.gz
# mv lpeg-1.0.2 lpeg
ifdef CROSS_COMPILE
CC = $(CROSS_COMPILE)gcc
endif
#Required
ifeq (,$(wildcard ../BAS-Resources/build/mako.sh))
$(error ../BAS-Resources not found. Repository https://github.com/RealTimeLogic/BAS-Resources required!)
endif
#Optional
export LPEGDIR=../LPeg
export PROTOBUFDIR=../lua-protobuf
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
XLIB=-framework IOKit -framework CoreFoundation;
CFLAGS += =-D_OSX_ -DLUA_USE_MACOSX
endif
CFLAGS += -fmerge-all-constants -O3 -Os -Wall
# Add required macros and enable large-file support
CFLAGS += -DMAKO -DUSE_EMBEDDED_ZIP=0 -DLUA_USE_LINUX -DBA_FILESIZE64
# Add features
CFLAGS += -DUSE_LUAINTF=1
CFLAGS += -DUSE_DBGMON=1
CFLAGS += -DUSE_OPCUA=1
CFLAGS += -Iinc -Iinc/arch/Posix
ifdef EPOLL
SODISP = epoll
CFLAGS += -Iinc/arch/NET/epoll
else
SODISP = generic
CFLAGS += -Iinc/arch/NET/Posix
endif
VPATH = src:src/arch/Posix:src/arch/NET/$(SODISP):src/DiskIo/posix:examples/MakoServer/src
# Implicit rules for making .o files from .c files
%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<
SOURCE = BAS.c ThreadLib.c SoDisp.c BaFile.c MakoMain.c
#Do we have SQLite?
ifneq (,$(wildcard src/sqlite3.c))
$(info Including SQLite)
SOURCE += ls_sqlite3.c luasql.c sqlite3.c
else
$(info Excluding SQLite)
CFLAGS += -DUSE_SQL=0
endif
#Do we have LPEG?
#git clone https://github.com/roberto-ieru/LPeg.git
ifneq (,$(wildcard $(LPEGDIR)/lpcode.c))
$(info Including LPEG)
CFLAGS += -DUSE_LPEG=1
SOURCE += $(notdir $(wildcard $(LPEGDIR)/*.c))
VPATH := $(VPATH):$(LPEGDIR)
else
$(info Excluding LPEG)
endif
#Do we have Lua Protobuf?
#https://github.com/starwing/lua-protobuf
ifneq (,$(wildcard $(PROTOBUFDIR)/pb.c))
$(info Including Lua Protobuf)
CFLAGS += -DUSE_PROTOBUF=1
SOURCE += pb.c
VPATH := $(VPATH):$(PROTOBUFDIR)
else
$(info Excluding Lua Protobuf)
endif
ifneq (,$(wildcard MyCustomBindings.c))
$(info including the Lua MyCustomBindings example)
VPATH += .
SOURCE += MyCustomBindings.c MyCustomBindings_wrap.c
CFLAGS += -DmyCustomBindings=luaopen_cpu
else
$(info Excluding Lua MyCustomBindings example)
endif
OBJS = $(SOURCE:%.c=%.o)
mako: $(OBJS) mako.zip
$(CC) -o mako $(OBJS) -lpthread -lm -ldl $(XLIB)
# Must be in the same directory as the mako executable
mako.zip:
cd ../BAS-Resources/build&&./mako.sh
cp ../BAS-Resources/build/mako.zip .
MyCustomBindings_wrap.c : MyCustomBindings.i
swig -lua MyCustomBindings.i
clean:
rm -f mako *.o