-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (82 loc) · 2.69 KB
/
Copy pathMakefile
File metadata and controls
108 lines (82 loc) · 2.69 KB
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
ifeq ($(OPENWRT_BUILD),)
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
CFLAGS=-MMD -O2 -march=x86-64-v3 -mtune=cannonlake -Wall -Wextra -I/opt/local/include -g
else
CFLAGS=-MMD -O2 -Wall -Wextra -I/opt/local/include -g
endif
LDFLAGS=-L/opt/local/lib
LDLIBS=-lusb-1.0 -lrt
ifeq ($(firstword $(origin CC)),default)
CC:=clang
endif
HMLAN_OBJS:=hmcfgusb.o hmland.o util.o
HMSNIFF_OBJS:=hmcfgusb.o hmuartlgw.o hmsniff.o
FLASH_HMCFGUSB_OBJS:=hmcfgusb.o firmware.o util.o flash-hmcfgusb.o
FLASH_HMMODUART_OBJS:=hmuartlgw.o firmware.o util.o flash-hmmoduart.o
FLASH_OTA_OBJS:=hmcfgusb.o culfw.o hmuartlgw.o firmware.o util.o flash-ota.o hm.o aes.o
OBJS:=$(HMLAN_OBJS) $(HMSNIFF_OBJS) $(FLASH_HMCFGUSB_OBJS) $(FLASH_HMMODUART_OBJS) $(FLASH_OTA_OBJS)
all: hmland hmsniff flash-hmcfgusb flash-hmmoduart flash-ota
DEPEND:=$(OBJS:.o=.d)
-include $(DEPEND)
hmland: $(HMLAN_OBJS)
hmsniff: $(HMSNIFF_OBJS)
flash-hmcfgusb: $(FLASH_HMCFGUSB_OBJS)
flash-hmmoduart: $(FLASH_HMMODUART_OBJS)
flash-ota: $(FLASH_OTA_OBJS)
test_unit: test_unit.c util.o
$(CC) $(CFLAGS) -o $@ test_unit.c util.o
test: test_unit
./test_unit
clean:
rm -f $(HMLAN_OBJS) $(HMSNIFF_OBJS) $(FLASH_HMCFGUSB_OBJS) $(FLASH_HMMODUART_OBJS) $(FLASH_OTA_OBJS) $(DEPEND) hmland hmsniff flash-hmcfgusb flash-hmmoduart flash-ota test_unit test_unit.d
.PHONY: all clean test
else
#OpenWRT/LEDE
include $(TOPDIR)/rules.mk
PKG_NAME:=hmcfgusb
PKG_VERSION:=$(shell grep 'VERSION' version.h | cut -d'"' -f 2)
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/hmcfgusb
SECTION:=utils
CATEGORY:=Utilities
DEPENDS:=+libusb-1.0
TITLE:=HM-CFG-USB utilities
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./* $(PKG_BUILD_DIR)/
$(SED) 's/OPENWRT_BUILD/DISABLED_CHECK_FOR_OPENWRT_TO_USE_CORRECT_BLOCK_NOW/' $(PKG_BUILD_DIR)/Makefile
endef
define Package/hmcfgusb/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hmland $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hmsniff $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/flash-hmcfgusb $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/flash-ota $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.hmland.OpenWRT $(1)/etc/init.d/hmland
endef
define Package/hmcfgusb/postinst
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Enabling rc.d symlink for hmland"
/etc/init.d/hmland enable
fi
exit 0
endef
define Package/hmcfgusb/prerm
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Removing rc.d symlink for hmland"
/etc/init.d/hmland disable
fi
exit 0
endef
$(eval $(call BuildPackage,hmcfgusb))
endif