forked from flukso/lua-mosquitto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
42 lines (32 loc) · 994 Bytes
/
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
PKGC ?= pkg-config
# lua's package config can be under various names
LUAPKGC := $(shell for pc in lua lua5.1 lua5.2 lua5.3; do \
$(PKGC) --exists $$pc && echo $$pc && break; \
done)
LUA_VERSION := $(shell $(PKGC) --variable=V $(LUAPKGC))
LUA_LIBDIR := $(shell $(PKGC) --variable=libdir $(LUAPKGC))
LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
LUA_LDFLAGS := $(shell $(PKGC) --libs-only-L $(LUAPKGC))
CMOD = mosquitto.so
OBJS = lua-mosquitto.o
LIBS = -lmosquitto
CSTD = -std=gnu99
OPT ?= -Os
WARN = -Wall -pedantic
CFLAGS += -fPIC $(CSTD) $(WARN) $(OPT) $(LUA_CFLAGS)
LDFLAGS += -shared $(CSTD) $(LIBS) $(LUA_LDFLAGS)
ifeq ($(OPENWRT_BUILD),1)
LUA_VERSION=
endif
ifeq ($(LUA_MOSQUITTO_COMPAT),yes)
CFLAGS += -DLUA_MOSQUITTO_COMPAT
endif
$(CMOD): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
.c.o:
$(CC) -c $(CFLAGS) -o $@ $<
install:
mkdir -p $(DESTDIR)$(LUA_LIBDIR)/lua/$(LUA_VERSION)
cp $(CMOD) $(DESTDIR)$(LUA_LIBDIR)/lua/$(LUA_VERSION)
clean:
$(RM) $(CMOD) $(OBJS)