Merge remote-tracking branch 'origin/tomato-shibby-RT-AC' into arrmo-RT-AC
[tomato.git] / release / src / router / www / Makefile
blob824bfba4f78d3ab5524b73de04b17671b6eff186
2 include ../common.mak
4 all:
6 clean:
8 install:
9 rm -rf $(INSTALLDIR)/www
10 mkdir -p $(INSTALLDIR)/www
12 cp *.gif *.png *.ico *.html *.php robots.txt $(INSTALLDIR)/www
14 # squish some of the files by trimming whitespace...
16 for F in $(wildcard *.js *.jsx); do \
17 sed '/^\/\*\s*$$/,/\*\//! { s/^\s\+//; s/\s\+$$//; /^\/\/ --\+\s*/d; /^$$/d }' < $$F > $(INSTALLDIR)/www/$$F; \
18 done
20 for F in $(wildcard *.css); do \
21 sed '/^\/\*\s*$$/,/\*\//! { s/\s\+/ /g; s/^\s\+//; s/\s\+$$//; /^$$/d }' < $$F > $(INSTALLDIR)/www/$$F; \
22 done
24 # remove "debug.js" references, convert color.css, remove comments
25 # in between REMOVE-BEGIN and REMOVE-END, and compress whitespace
27 for F in $(wildcard *.asp *.svg); do \
28 sed -e "/REMOVE-BEGIN/,/REMOVE-END/d" \
29 -e "s,<script[^>]\+debug\.js[^>]\+></script>,," \
30 -e "s,<link[^>]\+href='color\.css'>,<% css(); %>," \
31 -e "s,color\.css,<% nv('web_css'); %>\.css," \
32 -e "s,<!-- / / / -->,," \
33 -e "s,\x0d,," \
34 -e "s,^\s\+,," \
35 -e "/^$$/d" \
36 -e "/^<!--$$/,/^-->$$/! { s,^\s\+, , }" $$F > $(INSTALLDIR)/www/$$F; \
37 done
39 # Only include Linux 2.6 options if building for Linux 2.6.
40 ifneq ($(CONFIG_LINUX26),y)
41 cd $(INSTALLDIR)/www && \
42 for F in $(wildcard *.asp *.js); do \
43 sed -i $$F -e "/LINUX26-BEGIN/,/LINUX26-END/d"; \
44 done
45 # But remove some K24 options if building for Linux 2.6.
46 else
47 cd $(INSTALLDIR)/www && \
48 for F in $(wildcard *.asp *.js); do \
49 sed -i $$F -e "/LINUX24-BEGIN/,/LINUX24-END/d"; \
50 done
51 endif
53 # Add Build Information to about.asp page (placeholders exist)
54 sed -i $(INSTALLDIR)/www/about.asp -e "s/#param-blddate#/`date +"%Y %B %d, %H:%M %P"`/"
55 sed -i $(INSTALLDIR)/www/about.asp -e "s/#param-bldmach#/`uname -m -r -s -n`/"
57 # Only include the CIFS pages if CIFS is configured in.
58 ifneq ($(TCONFIG_CIFS),y)
59 rm -f $(INSTALLDIR)/www/admin-cifs.asp
60 sed -i $(INSTALLDIR)/www/tomato.js -e "/CIFS-BEGIN/,/CIFS-END/d"
61 sed -i $(INSTALLDIR)/www/admin-bwm.asp -e "/CIFS-BEGIN/,/CIFS-END/d"
62 sed -i $(INSTALLDIR)/www/nas-media.asp -e "/CIFS-BEGIN/,/CIFS-END/d"
63 endif
65 # Only include the JFFS pages if JFFS is configured in.
66 ifneq ($(TCONFIG_JFFS2),y)
67 rm -f $(INSTALLDIR)/www/admin-jffs2.asp
68 sed -i $(INSTALLDIR)/www/tomato.js -e "/JFFS2-BEGIN/,/JFFS2-END/d"
69 sed -i $(INSTALLDIR)/www/admin-bwm.asp -e "/JFFS2-BEGIN/,/JFFS2-END/d"
70 sed -i $(INSTALLDIR)/www/admin-upgrade.asp -e "/JFFS2-BEGIN/,/JFFS2-END/d"
71 sed -i $(INSTALLDIR)/www/nas-media.asp -e "/JFFS2-BEGIN/,/JFFS2-END/d"
72 endif
74 # Only include the Zebra options if Zebra is configured in.
75 ifneq ($(TCONFIG_ZEBRA),y)
76 sed -i $(INSTALLDIR)/www/advanced-routing.asp -e "/ZEBRA-BEGIN/,/ZEBRA-END/d"
77 endif
79 # Only include EMF options if EMF is configured in.
80 ifneq ($(TCONFIG_EMF),y)
81 sed -i $(INSTALLDIR)/www/advanced-routing.asp -e "/EMF-BEGIN/,/EMF-END/d"
82 endif
84 # Only include NTFS settings if NTFS support is configured in.
85 ifneq ($(TCONFIG_NTFS),y)
86 sed -i $(INSTALLDIR)/www/nas-usb.asp -e "/NTFS-BEGIN/,/NTFS-END/d"
87 endif
88 # Only include the FTP pages if FTP Server is configured in.
89 ifneq ($(TCONFIG_FTP),y)
90 rm -f $(INSTALLDIR)/www/nas-ftp.asp
91 sed -i $(INSTALLDIR)/www/tomato.js -e "/FTP-BEGIN/,/FTP-END/d"
92 endif
93 # Only include the Samba pages if Samba is configured in.
94 ifneq ($(TCONFIG_SAMBASRV),y)
95 rm -f $(INSTALLDIR)/www/nas-samba.asp
96 sed -i $(INSTALLDIR)/www/tomato.js -e "/SAMBA-BEGIN/,/SAMBA-END/d"
97 endif
98 # Only include the Media Server pages if Media Server is configured in.
99 ifneq ($(TCONFIG_MEDIA_SERVER),y)
100 rm -f $(INSTALLDIR)/www/nas-media.asp
101 sed -i $(INSTALLDIR)/www/tomato.js -e "/MEDIA-SRV-BEGIN/,/MEDIA-SRV-END/d"
102 endif
104 # Victek for RAF verion
105 # Only include Captive Portal menu option and pages when configured.
106 ifneq ($(TCONFIG_NOCAT),y)
107 rm -f $(INSTALLDIR)/www/splashd.asp
108 rm -f $(INSTALLDIR)/www/splash.html
109 rm -f $(INSTALLDIR)/www/style.css
110 sed -i $(INSTALLDIR)/www/tomato.js -e "/NOCAT-BEGIN/,/NOCAT-END/d"
111 sed -i $(INSTALLDIR)/www/about.asp -e "/NOCAT-BEGIN/,/NOCAT-END/d"
112 endif
114 # Clean up NGinX files if not needed
115 ifneq ($(TCONFIG_NGINX),y)
116 rm -f $(INSTALLDIR)/www/nginx.asp
117 rm -f $(INSTALLDIR)/www/index.html
118 rm -f $(INSTALLDIR)/www/index.php
119 sed -i $(INSTALLDIR)/www/tomato.js -e "/NGINX-BEGIN/,/NGINX-END/d"
120 sed -i $(INSTALLDIR)/www/about.asp -e "/NGINX-BEGIN/,/NGINX-END/d"
121 endif
124 # Only include HFS/HFS+ option and pages when configured.
125 ifneq ($(TCONFIG_HFS),y)
126 sed -i $(INSTALLDIR)/www/nas-usb.asp -e "/HFS-BEGIN/,/HFS-END/d"
127 sed -i $(INSTALLDIR)/www/about.asp -e "/HFS-BEGIN/,/HFS-END/d"
128 endif
130 # Only include IPv6 options if IPv6 is configured in.
131 ifneq ($(TCONFIG_IPV6),y)
132 cd $(INSTALLDIR)/www && \
133 for F in $(wildcard *.asp *.js *.jsx); do \
134 [ -f $(INSTALLDIR)/www/$$F ] && sed -i $$F \
135 -e "/IPV6-BEGIN/,/IPV6-END/d" \
136 || true; \
137 done
138 rm -f $(INSTALLDIR)/www/basic-ipv6.asp
139 endif
141 # Only include the Transmission binary path select if Transmission binaries is configured in.
142 ifneq ($(TCONFIG_BBT),y)
143 sed -i $(INSTALLDIR)/www/nas-bittorrent.asp -e "/BBT-BEGIN/,/BBT-END/d"
144 sed -i $(INSTALLDIR)/www/about.asp -e "/BBT-BEGIN/,/BBT-END/d"
145 endif
147 # Only include the Transmission pages if Transmission is configured in.
148 ifneq ($(TCONFIG_BT),y)
149 rm -f $(INSTALLDIR)/www/nas-bittorrent.asp
150 sed -i $(INSTALLDIR)/www/tomato.js -e "/BT-BEGIN/,/BT-END/d"
151 sed -i $(INSTALLDIR)/www/about.asp -e "/BT-BEGIN/,/BT-END/d"
152 endif
154 # Only include the UPS pages if apcupsd is configured in.
155 ifneq ($(TCONFIG_UPS),y)
156 rm -f $(INSTALLDIR)/www/nas-ups.asp
157 sed -i $(INSTALLDIR)/www/tomato.js -e "/UPS-BEGIN/,/UPS-END/d"
158 sed -i $(INSTALLDIR)/www/about.asp -e "/UPS-BEGIN/,/UPS-END/d"
159 endif
161 # Only include the TOR pages if tor project is configured in.
162 ifneq ($(TCONFIG_TOR),y)
163 rm -f $(INSTALLDIR)/www/advanced-tor.asp
164 sed -i $(INSTALLDIR)/www/tomato.js -e "/TOR-BEGIN/,/TOR-END/d"
165 sed -i $(INSTALLDIR)/www/about.asp -e "/TOR-BEGIN/,/TOR-END/d"
166 endif
170 # Only include the USB and NAS pages if USB Support is configured in.
171 ifneq ($(TCONFIG_USB),y)
172 rm -f $(INSTALLDIR)/www/nas-*.*
173 sed -i $(INSTALLDIR)/www/tomato.js -e "/USB-BEGIN/,/USB-END/d"
174 sed -i $(INSTALLDIR)/www/admin-buttons.asp -e "/USB-BEGIN/,/USB-END/d"
175 sed -i $(INSTALLDIR)/www/admin-access.asp -e "/USB-BEGIN/,/USB-END/d"
176 sed -i $(INSTALLDIR)/www/about.asp -e "/USB-BEGIN/,/USB-END/d"
177 endif
179 ## Only include CTF option if CTF module exists
180 # test -d $(SRCBASE)/ctf/linux || sed -i $(INSTALLDIR)/www/advanced-misc.asp -e "/CTF-BEGIN/,/CTF-END/d"
182 # Only include the CTF configuration if CTF is configured in.
183 ifneq ($(TCONFIG_CTF),y)
184 sed -i $(INSTALLDIR)/www/advanced-misc.asp -e "/CTF-BEGIN/,/CTF-END/d"
185 endif
187 ifeq ($(TOMATO_EXPERIMENTAL),1)
188 cd $(INSTALLDIR)/www && \
189 for F in $(wildcard *.asp); do \
190 sed -e "s,<div class='title'>Tomato</div>,<div class='title'>Tomato <small><i>(beta)</i></small></div>," $$F > $$F.tmp; \
191 mv $$F.tmp $$F; \
192 done
193 endif
195 cd $(INSTALLDIR)/www && \
196 for F in $(wildcard *.asp); do \
197 sed -e "s,<div class='version'>Version <% version(); %></div>,<div class='version'>Version <% version(); %> by shibby</div>," $$F > $$F.tmp; \
198 mv $$F.tmp $$F; \
199 done
202 # Only include the vpn pages if OpenVPN is compiled in
203 # Remove AES ciphers from the GUI if openssl doesn't have an AES directory
204 ifeq ($(TCONFIG_OPENVPN),y)
205 test -d ../openssl/crypto/aes || sed -i $(INSTALLDIR)/www/vpn.js -e "/AES-BEGIN/,/AES-END/d"
206 sed -i $(INSTALLDIR)/www/tomato.js -e "/ VPN-BEGIN/d" -e "/ VPN-END/d"
207 sed -i $(INSTALLDIR)/www/admin-access.asp -e "/ VPN-BEGIN/d" -e "/ VPN-END/d"
208 sed -i $(INSTALLDIR)/www/about.asp -e "/ VPN-BEGIN/d" -e "/ VPN-END/d"
209 else
210 rm -f $(INSTALLDIR)/www/vpn-server.asp
211 rm -f $(INSTALLDIR)/www/vpn-client.asp
212 rm -f $(INSTALLDIR)/www/vpn.js
213 sed -i $(INSTALLDIR)/www/tomato.js -e "/ OPENVPN-BEGIN/,/ OPENVPN-END/d"
214 sed -i $(INSTALLDIR)/www/about.asp -e "/ OPENVPN-BEGIN/,/ OPENVPN-END/d"
215 endif
217 # Only include the PPTPD pages if PPTPD is compiled in
218 ifeq ($(TCONFIG_PPTPD),y)
219 sed -i $(INSTALLDIR)/www/tomato.js -e "/ VPN-BEGIN/d" -e "/ VPN-END/d"
220 sed -i $(INSTALLDIR)/www/admin-access.asp -e "/ VPN-BEGIN/d" -e "/ VPN-END/d"
221 sed -i $(INSTALLDIR)/www/about.asp -e "/ VPN-BEGIN/d" -e "/ VPN-END/d"
222 else
223 rm -f $(INSTALLDIR)/www/vpn-pptp-server.asp
224 rm -f $(INSTALLDIR)/www/vpn-pptp-online.asp
225 rm -f $(INSTALLDIR)/www/vpn-pptp.asp
226 sed -i $(INSTALLDIR)/www/tomato.js -e "/ PPTPD-BEGIN/,/ PPTPD-END/d"
227 sed -i $(INSTALLDIR)/www/about.asp -e "/ PPTPD-BEGIN/,/ PPTPD-END/d"
228 endif
230 # Only include the nfs pages if NFS is compiled in
231 ifneq ($(TCONFIG_NFS),y)
232 rm -f $(INSTALLDIR)/www/admin-nfs.asp
233 sed -i $(INSTALLDIR)/www/tomato.js -e "/NFS-BEGIN/,/NFS-END/d"
234 sed -i $(INSTALLDIR)/www/about.asp -e "/NFS-BEGIN/,/NFS-END/d"
235 endif
237 # Only include the snmp pages if SNMP is compiled in
238 ifneq ($(TCONFIG_SNMP),y)
239 rm -f $(INSTALLDIR)/www/admin-snmp.asp
240 sed -i $(INSTALLDIR)/www/tomato.js -e "/SNMP-BEGIN/,/SNMP-END/d"
241 sed -i $(INSTALLDIR)/www/about.asp -e "/SNMP-BEGIN/,/SNMP-END/d"
242 endif
244 # Only include the mmc pages if SDHC is compiled in
245 ifneq ($(TCONFIG_SDHC),y)
246 rm -f $(INSTALLDIR)/www/admin-sdhc.asp
247 sed -i $(INSTALLDIR)/www/tomato.js -e "/SDHC-BEGIN/,/SDHC-END/d"
248 sed -i $(INSTALLDIR)/www/about.asp -e "/SDHC-BEGIN/,/SDHC-END/d"
249 endif
251 # Only include the dnssec option if is compiled in
252 ifneq ($(TCONFIG_DNSSEC),y)
253 sed -i $(INSTALLDIR)/www/basic-network.asp -e "/DNSSEC-BEGIN/,/DNSSEC-END/d"
254 sed -i $(INSTALLDIR)/www/about.asp -e "/DNSSEC-BEGIN/,/DNSSEC-END/d"
255 endif
257 # Only include the dnscrypt option if is compiled in
258 ifeq ($(TCONFIG_DNSCRYPT),y)
259 $(TOP)/www/dnscrypt-helper.sh $(INSTALLDIR)/../rom/rom/etc/dnscrypt-resolvers.csv $(INSTALLDIR)/www/basic-network.asp
260 else
261 sed -i $(INSTALLDIR)/www/basic-network.asp -e "/DNSCRYPT-BEGIN/,/DNSCRYPT-END/d"
262 sed -i $(INSTALLDIR)/www/about.asp -e "/DNSCRYPT-BEGIN/,/DNSCRYPT-END/d"
263 endif
265 # clean up
266 cd $(INSTALLDIR)/www && \
267 for F in $(wildcard *.asp *.js *.jsx *.html); do \
268 [ -f $(INSTALLDIR)/www/$$F ] && sed -i $$F \
269 -e "/LINUX26-BEGIN/d" -e "/LINUX26-END/d" \
270 -e "/LINUX24-BEGIN/d" -e "/LINUX24-END/d" \
271 -e "/USB-BEGIN/d" -e "/USB-END/d" \
272 -e "/NTFS-BEGIN/d" -e "/NTFS-END/d" \
273 -e "/SAMBA-BEGIN/d" -e "/SAMBA-END/d" \
274 -e "/FTP-BEGIN/d" -e "/FTP-END/d" \
275 -e "/MEDIA-SRV-BEGIN/d" -e "/MEDIA-SRV-END/d" \
276 -e "/JFFS2-BEGIN/d" -e "/JFFS2-END/d" \
277 -e "/CIFS-BEGIN/d" -e "/CIFS-END/d" \
278 -e "/ZEBRA-BEGIN/d" -e "/ZEBRA-END/d" \
279 -e "/EMF-BEGIN/d" -e "/EMF-END/d" \
280 -e "/OPENVPN-BEGIN/d" -e "/OPENVPN-END/d" \
281 -e "/AES-BEGIN/d" -e "/AES-END/d" \
282 -e "/PPTPD-BEGIN/d" -e "/PPTPD-END/d"\
283 -e "/VPN-BEGIN/,/VPN-END/d" \
284 -e "/IPV6-BEGIN/d" -e "/IPV6-END/d" \
285 -e "/CTF-BEGIN/d" -e "/CTF-END/d" \
286 -e "/BBT-BEGIN/d" -e "/BBT-END/d" \
287 -e "/BT-BEGIN/d" -e "/BT-END/d" \
288 -e "/NFS-BEGIN/d" -e "/NFS-END/d" \
289 -e "/NOCAT-BEGIN/d" -e "/NOCAT-END/d"\
290 -e "/NGINX-BEGIN/d" -e "/NGINX-END/d"\
291 -e "/SNMP-BEGIN/d" -e "/SNMP-END/d"\
292 -e "/SDHC-BEGIN/d" -e "/SDHC-END/d"\
293 -e "/HFS-BEGIN/d" -e "/HFS-END/d"\
294 -e "/DNSCRYPT-BEGIN/d" -e "/DNSCRYPT-END/d"\
295 -e "/DNSSEC-BEGIN/d" -e "/DNSSEC-END/d"\
296 -e "/TOR-BEGIN/d" -e "/TOR-END/d"\
297 || true; \
298 done
300 # make sure old and debugging crap is gone
301 @rm -f $(INSTALLDIR)/www/debug.js
302 @rm -f $(INSTALLDIR)/www/*-x.*
303 @rm -f $(INSTALLDIR)/www/*-old.*
304 @rm -f $(INSTALLDIR)/www/color.css
306 chmod 0644 $(INSTALLDIR)/www/*
308 # remove C-style comments from java files. All "control" comments have been processed by now.
309 for F in $(wildcard *.js *.jsx); do \
310 [ -f $(INSTALLDIR)/www/$$F ] && $(TOP)/www/remcoms2.sh $(INSTALLDIR)/www/$$F c; \
311 done