Suppress warnings about non-literal format strings
[hmcfgusb] / Makefile
1 ifeq ($(OPENWRT_BUILD),)
2
3 #Normal system
4 CFLAGS=-Wall -Wextra -Wno-unused-parameter -pedantic
5 CFLAGS+= -Wno-unknown-warning-option
6 CFLAGS+= -Wformat=2
7 CFLAGS+= -Wformat-truncation=2
8 CFLAGS+= -Wwrite-strings
9 CFLAGS+= -Wnull-dereference
10 CFLAGS+= -Wuninitialized
11 CFLAGS+= -Wstrict-overflow
12 CFLAGS+= -Wdate-time
13 CFLAGS+= -Wundef
14 CFLAGS+= -Wpacked
15 CFLAGS+= -Wduplicated-branches
16 CFLAGS+= -Wduplicated-cond
17 CFLAGS+= -Wstrict-prototypes
18 CFLAGS+= -Wbad-function-cast
19 CFLAGS+= -Wold-style-definition
20 CFLAGS+= -MMD -O2 -I/opt/local/include -g
21
22 LDFLAGS:=-L/opt/local/lib
23 LDLIBS:=-lusb-1.0 -lrt
24
25 ifeq ($(firstword $(origin CC)),default)
26 CC:=gcc
27 endif
28
29 HMLAN_OBJS:=hmcfgusb.o hmland.o util.o
30 HMSNIFF_OBJS:=hmcfgusb.o hmuartlgw.o hmsniff.o
31 FLASH_HMCFGUSB_OBJS:=hmcfgusb.o firmware.o util.o flash-hmcfgusb.o
32 FLASH_HMMODUART_OBJS:=hmuartlgw.o firmware.o util.o flash-hmmoduart.o
33 FLASH_OTA_OBJS:=hmcfgusb.o culfw.o hmuartlgw.o firmware.o util.o flash-ota.o hm.o aes.o
34
35 OBJS:=$(HMLAN_OBJS) $(HMSNIFF_OBJS) $(FLASH_HMCFGUSB_OBJS) $(FLASH_HMMODUART_OBJS) $(FLASH_OTA_OBJS)
36
37 all: hmland hmsniff flash-hmcfgusb flash-hmmoduart flash-ota
38
39 DEPEND:=$(OBJS:.o=.d)
40 -include $(DEPEND)
41
42 hmland: $(HMLAN_OBJS)
43
44 hmsniff: $(HMSNIFF_OBJS)
45
46 flash-hmcfgusb: $(FLASH_HMCFGUSB_OBJS)
47
48 flash-hmmoduart: $(FLASH_HMMODUART_OBJS)
49
50 flash-ota: $(FLASH_OTA_OBJS)
51
52 clean:
53 rm -f $(HMLAN_OBJS) $(HMSNIFF_OBJS) $(FLASH_HMCFGUSB_OBJS) $(FLASH_HMMODUART_OBJS) $(FLASH_OTA_OBJS) $(DEPEND) hmland hmsniff flash-hmcfgusb flash-hmmoduart flash-ota
54
55 .PHONY: all clean
56
57 else
58
59 #OpenWRT/LEDE
60 include $(TOPDIR)/rules.mk
61
62 PKG_NAME:=hmcfgusb
63 PKG_VERSION:=$(shell grep 'VERSION' version.h | cut -d'"' -f 2)
64 PKG_RELEASE:=1
65 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
66
67 include $(INCLUDE_DIR)/package.mk
68
69 define Package/hmcfgusb
70 SECTION:=utils
71 CATEGORY:=Utilities
72 DEPENDS:=+libusb-1.0
73 TITLE:=HM-CFG-USB utilities
74 endef
75
76 define Build/Prepare
77 mkdir -p $(PKG_BUILD_DIR)
78 $(CP) ./* $(PKG_BUILD_DIR)/
79 $(SED) 's/OPENWRT_BUILD/DISABLED_CHECK_FOR_OPENWRT_TO_USE_CORRECT_BLOCK_NOW/' $(PKG_BUILD_DIR)/Makefile
80 endef
81
82 define Package/hmcfgusb/install
83 $(INSTALL_DIR) $(1)/usr/sbin/
84 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hmland $(1)/usr/sbin/
85 $(INSTALL_DIR) $(1)/usr/bin/
86 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hmsniff $(1)/usr/bin/
87 $(INSTALL_BIN) $(PKG_BUILD_DIR)/flash-hmcfgusb $(1)/usr/bin/
88 $(INSTALL_BIN) $(PKG_BUILD_DIR)/flash-ota $(1)/usr/bin/
89 $(INSTALL_DIR) $(1)/etc/init.d/
90 $(INSTALL_BIN) $(PKG_BUILD_DIR)/init.hmland.OpenWRT $(1)/etc/init.d/hmland
91 endef
92
93 define Package/hmcfgusb/postinst
94 #!/bin/sh
95 # check if we are on real system
96 if [ -z "$${IPKG_INSTROOT}" ]; then
97 echo "Enabling rc.d symlink for hmland"
98 /etc/init.d/hmland enable
99 fi
100 exit 0
101 endef
102
103 define Package/hmcfgusb/prerm
104 #!/bin/sh
105 # check if we are on real system
106 if [ -z "$${IPKG_INSTROOT}" ]; then
107 echo "Removing rc.d symlink for hmland"
108 /etc/init.d/hmland disable
109 fi
110 exit 0
111 endef
112
113 $(eval $(call BuildPackage,hmcfgusb))
114 endif
Impressum, Datenschutz