Increase compiler-warning level
[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 CC=gcc
25
26 HMLAN_OBJS=hmcfgusb.o hmland.o util.o
27 HMSNIFF_OBJS=hmcfgusb.o hmuartlgw.o hmsniff.o
28 FLASH_HMCFGUSB_OBJS=hmcfgusb.o firmware.o util.o flash-hmcfgusb.o
29 FLASH_HMMODUART_OBJS=hmuartlgw.o firmware.o util.o flash-hmmoduart.o
30 FLASH_OTA_OBJS=hmcfgusb.o culfw.o hmuartlgw.o firmware.o util.o flash-ota.o hm.o aes.o
31
32 OBJS=$(HMLAN_OBJS) $(HMSNIFF_OBJS) $(FLASH_HMCFGUSB_OBJS) $(FLASH_HMMODUART_OBJS) $(FLASH_OTA_OBJS)
33
34 all: hmland hmsniff flash-hmcfgusb flash-hmmoduart flash-ota
35
36 DEPEND=$(OBJS:.o=.d)
37 -include $(DEPEND)
38
39 hmland: $(HMLAN_OBJS)
40
41 hmsniff: $(HMSNIFF_OBJS)
42
43 flash-hmcfgusb: $(FLASH_HMCFGUSB_OBJS)
44
45 flash-hmmoduart: $(FLASH_HMMODUART_OBJS)
46
47 flash-ota: $(FLASH_OTA_OBJS)
48
49 clean:
50 rm -f $(HMLAN_OBJS) $(HMSNIFF_OBJS) $(FLASH_HMCFGUSB_OBJS) $(FLASH_HMMODUART_OBJS) $(FLASH_OTA_OBJS) $(DEPEND) hmland hmsniff flash-hmcfgusb flash-hmmoduart flash-ota
51
52 .PHONY: all clean
53
54 else
55
56 #OpenWRT/LEDE
57 include $(TOPDIR)/rules.mk
58
59 PKG_NAME:=hmcfgusb
60 PKG_VERSION:=$(shell grep 'VERSION' version.h | cut -d'"' -f 2)
61 PKG_RELEASE:=1
62 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
63
64 include $(INCLUDE_DIR)/package.mk
65
66 define Package/hmcfgusb
67 SECTION:=utils
68 CATEGORY:=Utilities
69 DEPENDS:=+libusb-1.0
70 TITLE:=HM-CFG-USB utilities
71 endef
72
73 define Build/Prepare
74 mkdir -p $(PKG_BUILD_DIR)
75 $(CP) ./* $(PKG_BUILD_DIR)/
76 $(SED) 's/OPENWRT_BUILD/DISABLED_CHECK_FOR_OPENWRT_TO_USE_CORRECT_BLOCK_NOW/' $(PKG_BUILD_DIR)/Makefile
77 endef
78
79 define Package/hmcfgusb/install
80 $(INSTALL_DIR) $(1)/usr/sbin/
81 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hmland $(1)/usr/sbin/
82 $(INSTALL_DIR) $(1)/usr/bin/
83 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hmsniff $(1)/usr/bin/
84 $(INSTALL_BIN) $(PKG_BUILD_DIR)/flash-hmcfgusb $(1)/usr/bin/
85 $(INSTALL_BIN) $(PKG_BUILD_DIR)/flash-ota $(1)/usr/bin/
86 $(INSTALL_DIR) $(1)/etc/init.d/
87 $(INSTALL_BIN) $(PKG_BUILD_DIR)/init.hmland.OpenWRT $(1)/etc/init.d/hmland
88 endef
89
90 define Package/hmcfgusb/postinst
91 #!/bin/sh
92 # check if we are on real system
93 if [ -z "$${IPKG_INSTROOT}" ]; then
94 echo "Enabling rc.d symlink for hmland"
95 /etc/init.d/hmland enable
96 fi
97 exit 0
98 endef
99
100 define Package/hmcfgusb/prerm
101 #!/bin/sh
102 # check if we are on real system
103 if [ -z "$${IPKG_INSTROOT}" ]; then
104 echo "Removing rc.d symlink for hmland"
105 /etc/init.d/hmland disable
106 fi
107 exit 0
108 endef
109
110 $(eval $(call BuildPackage,hmcfgusb))
111 endif
Impressum, Datenschutz