-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
55 lines (40 loc) · 1.48 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
.PHONY: %.eap dockerbuild 3rd-party-clean clean very-clean
PROG = modbusacap
SRCS = $(wildcard *.c)
OBJS = $(SRCS:.c=.o)
STRIP ?= strip
PKGS = gio-2.0 glib-2.0 axevent axparameter
CFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags $(PKGS))
LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs $(PKGS))
# libmodbus
LIBMODBUS_VERSION = 3.1.7
LIBMODBUS_DIR = $(CURDIR)/libmodbus-$(LIBMODBUS_VERSION)
LIBMODBUS = $(LIBMODBUS_DIR)/lib/libmodbus.a
CFLAGS += -I $(LIBMODBUS_DIR)/include/modbus
LDLIBS += $(LIBMODBUS)
CFLAGS += -Wformat=2 -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wdisabled-optimization -Wall -Werror
# main targets
all: $(PROG)
$(STRIP) $(PROG)
$(OBJS): $(LIBMODBUS)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(LDLIBS) -o $@
# libmodbus targets
$(LIBMODBUS_DIR):
curl -L https://libmodbus.org/releases/libmodbus-$(LIBMODBUS_VERSION).tar.gz | tar xz
$(LIBMODBUS_DIR)/Makefile: | $(LIBMODBUS_DIR)
cd $(LIBMODBUS_DIR) && \
./configure --host=$(ARCH) --prefix=$(LIBMODBUS_DIR)
$(LIBMODBUS): $(LIBMODBUS_DIR)/Makefile
make -C $(LIBMODBUS_DIR) -j install
# docker build container targets
%.eap:
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=$(basename $@) -o type=local,dest=. "$(CURDIR)"
dockerbuild: armv7hf.eap aarch64.eap
# clean targets
3rd-party-clean:
make -C $(LIBMODBUS_DIR) clean
clean:
rm -f $(PROG) *.o *.eap *LICENSE.txt pa*conf*
very-clean: clean 3rd-party-clean
rm -rf *.eap *.eap.old eap $(LIBMODBUS_DIR)