-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
164 lines (131 loc) · 6.09 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
##############################################
# OpenWrt Makefile for Doodle3D WifiBox firmware
##############################################
include $(TOPDIR)/rules.mk
#NOTE: this hack is required to get files included inside a define block, see this link:
#http://stackoverflow.com/questions/3524726/how-to-make-eval-shell-work-in-gnu-make
#The '¤' character must not appear in included scripts.
define newline
endef
IncludeWithNewlines = $(subst ¤,$(newline),$(shell cat $1 | tr '\n' '¤'))
# Name and release number of this package
PKG_NAME := wifibox
PKG_VERSION := 0.1.1
PKG_RELEASE := 8
# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/wifibox
SECTION:=mods
CATEGORY:=Doodle3D
MENU:=1
# DEFAULT:=y
TITLE:=Doodle3D WifiBox firmware
URL:=http://www.doodle3d.com/wifibox
DEPENDS:=+lua +luafilesystem +libuci-lua +libiwinfo-lua +uhttpd +uhttpd-mod-lua +doodle3d-client +print3d
endef
define Package/wifibox/description
Doodle3D WifiBox firmware
Web interface to draw doodles and print them with ease.
Automatically connects to known network or provide one to connect with.
Intended to be used on TP-Link WR703n or MR3020.
endef
define Package/wifibox/config
source "$(SOURCE)/Config.in"
endef
# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default. The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) -r ./src/* $(PKG_BUILD_DIR)/
$(CP) -r ./ReleaseNotes.md $(PKG_BUILD_DIR)/
endef
define Build/Configure
# no configuration necessary
endef
define Build/Compile directives
# no compilation necessary (although possible with luac?)
endef
# This information is contained within the ipk file and (at least) used by
# sysupgrade to determine which files to keep (see `opkg list-changed-conffiles`).
define Package/wifibox/conffiles
/etc/config/wifibox
/etc/logrotate.d/wifibox.conf
endef
# The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
WIFIBOX_BASE_DIR := $(PKG_BUILD_DIR)
TGT_LUA_DIR_SUFFIX := usr/share/lua/wifibox
define Package/wifibox/install
### create required directories (autowifi)
# $(INSTALL_DIR) $(1)/$(TGT_LUA_DIR_SUFFIX)
$(INSTALL_DIR) $(1)/$(TGT_LUA_DIR_SUFFIX)/network
# $(INSTALL_DIR) $(1)/$(TGT_LUA_DIR_SUFFIX)/rest
$(INSTALL_DIR) $(1)/$(TGT_LUA_DIR_SUFFIX)/rest/api
$(INSTALL_DIR) $(1)/$(TGT_LUA_DIR_SUFFIX)/script
$(INSTALL_DIR) $(1)/$(TGT_LUA_DIR_SUFFIX)/util
$(INSTALL_DIR) $(1)/bin
#$(INSTALL_DIR) $(1)/etc
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/logrotate.d
$(INSTALL_DIR) $(1)/root/
$(INSTALL_DIR) $(1)/root/sketches
#$(INSTALL_DIR) $(1)/www
$(INSTALL_DIR) $(1)/www/cgi-bin
#copy wps button script to procd folder
$(INSTALL_DIR) $(1)/etc/rc.button/
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/wifi-switch-netconfig.sh $(1)/etc/rc.button/wps
### create all files in /usr/share/lua/autowifi (autowifi)
$(CP) $(WIFIBOX_BASE_DIR)/opkg.conf $(1)/$(TGT_LUA_DIR_SUFFIX)/
$(CP) $(WIFIBOX_BASE_DIR)/*.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/
$(CP) $(WIFIBOX_BASE_DIR)/network/*.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/network/
$(CP) $(WIFIBOX_BASE_DIR)/rest/*.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/rest/
$(CP) $(WIFIBOX_BASE_DIR)/rest/api/*.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/rest/api/
$(CP) $(WIFIBOX_BASE_DIR)/util/*.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/util/
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/d3d-updater.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/script
$(LN) -s /$(TGT_LUA_DIR_SUFFIX)/script/d3d-updater.lua $(1)/bin/d3d-updater
$(CP) $(WIFIBOX_BASE_DIR)/script/loglite-filters.lua $(1)/root/
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/loglite.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/script
$(LN) -s /$(TGT_LUA_DIR_SUFFIX)/script/loglite.lua $(1)/bin/loglite
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/wifibox_init $(1)/etc/init.d/wifibox
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/dhcpcheck_init $(1)/etc/init.d/dhcpcheck
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/d3dapi $(1)/$(TGT_LUA_DIR_SUFFIX)/script
$(LN) -s /$(TGT_LUA_DIR_SUFFIX)/script/d3dapi $(1)/bin/d3dapi
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/signin.sh $(1)/$(TGT_LUA_DIR_SUFFIX)/script
$(CP) $(WIFIBOX_BASE_DIR)/script/logrotate-wifibox.conf $(1)/etc/logrotate.d/wifibox.conf
$(INSTALL_BIN) $(WIFIBOX_BASE_DIR)/script/print-fetch.lua $(1)/$(TGT_LUA_DIR_SUFFIX)/script
$(LN) -s /$(TGT_LUA_DIR_SUFFIX)/script/print-fetch.lua $(1)/bin/print-fetch
$(CP) $(WIFIBOX_BASE_DIR)/script/wifibox.uci.config $(1)/etc/config/wifibox # copy base configuration to uci config dir
$(CP) $(WIFIBOX_BASE_DIR)/FIRMWARE-VERSION $(1)/etc/wifibox-version
echo "<html><body><pre><code>" > $(1)/www/ReleaseNotes.html
cat $(WIFIBOX_BASE_DIR)/ReleaseNotes.md >> $(1)/www/ReleaseNotes.html
echo "</code></pre></body></html>" >> $(1)/www/ReleaseNotes.html
ifeq ($(CONFIG_WIFIBOX_DEVEL_PACKAGE),y)
# $(INSTALL_DIR) $(1)/$(TGT_LUA_DIR_SUFFIX)/test
# $(CP) $(WIFIBOX_BASE_DIR)/test/* $(1)/$(TGT_LUA_DIR_SUFFIX)/test/
# $(LN) -s /$(TGT_LUA_DIR_SUFFIX)/test $(1)/www/
endif
### create links elsewhere in the system (autowifi)
$(LN) -s /$(TGT_LUA_DIR_SUFFIX)/script/d3dapi $(1)/www/cgi-bin
$(LN) -s /root/sketches $(1)/www/
endef
define Package/wifibox/postinst
$(call IncludeWithNewlines,post-install.sh)
endef
define Package/wifibox/prerm
$(call IncludeWithNewlines,pre-remove.sh)
endef
define Package/wifibox/postrm
$(call IncludeWithNewlines,post-remove.sh)
endef
$(eval $(call BuildPackage,wifibox))