6285eab9ac5a4f1735b87b151a37bb2ec71c1524
[openwrt-10.03/.git] / package / uhttpd / Makefile
1 #
2 # Copyright (C) 2010-2011 Jo-Philipp Wich <xm@subsignal.org>
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=uhttpd
11 PKG_RELEASE:=28
12
13 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
14 PKG_CONFIG_DEPENDS := \
15         CONFIG_PACKAGE_uhttpd-mod-lua \
16         CONFIG_PACKAGE_uhttpd-mod-tls \
17         CONFIG_PACKAGE_uhttpd-mod-tls_cyassl \
18         CONFIG_PACKAGE_uhttpd-mod-tls_openssl
19
20 include $(INCLUDE_DIR)/package.mk
21
22 define Package/uhttpd/default
23   SECTION:=net
24   CATEGORY:=Network
25   SUBMENU:=Web Servers/Proxies
26   TITLE:=uHTTPd - tiny, single threaded HTTP server
27   MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
28 endef
29
30 define Package/uhttpd
31   $(Package/uhttpd/default)
32   MENU:=1
33 endef
34
35 define Package/uhttpd/description
36  uHTTPd is a tiny single threaded HTTP server with TLS, CGI and Lua
37  support. It is intended as a drop-in replacement for the Busybox
38  HTTP daemon.
39 endef
40
41
42 define Package/uhttpd-mod-tls
43   $(Package/uhttpd/default)
44   TITLE+= (TLS plugin)
45   DEPENDS:=uhttpd +PACKAGE_uhttpd-mod-tls_cyassl:libcyassl +PACKAGE_uhttpd-mod-tls_openssl:libopenssl
46 endef
47
48 define Package/uhttpd-mod-tls/description
49  The TLS plugin adds HTTPS support to uHTTPd.
50 endef
51
52 define Package/uhttpd-mod-tls/config
53         choice
54                 depends on PACKAGE_uhttpd-mod-tls
55                 prompt "TLS Provider"
56                 default PACKAGE_uhttpd-mod-tls_cyassl
57
58                 config PACKAGE_uhttpd-mod-tls_cyassl
59                         bool "CyaSSL"
60
61                 config PACKAGE_uhttpd-mod-tls_openssl
62                         bool "OpenSSL"
63         endchoice
64 endef
65
66 UHTTPD_TLS:=
67 TLS_CFLAGS:=
68 TLS_LDFLAGS:=
69
70 ifneq ($(CONFIG_PACKAGE_uhttpd-mod-tls_cyassl),)
71   UHTTPD_TLS:=cyassl
72   TLS_CFLAGS:=-I$(STAGING_DIR)/usr/include/cyassl -DTLS_IS_CYASSL
73   TLS_LDFLAGS:=-lcyassl -lm
74 endif
75
76 ifneq ($(CONFIG_PACKAGE_uhttpd-mod-tls_openssl),)
77   UHTTPD_TLS:=openssl
78   TLS_CFLAGS:=-DTLS_IS_OPENSSL
79   TLS_LDFLAGS:=-lssl
80 endif
81
82
83 define Package/uhttpd-mod-lua
84   $(Package/uhttpd/default)
85   TITLE+= (Lua plugin)
86   DEPENDS:=uhttpd +liblua
87 endef
88
89 define Package/uhttpd-mod-lua/description
90  The Lua plugin adds a CGI-like Lua runtime interface to uHTTPd.
91 endef
92
93
94 TARGET_CFLAGS += $(TLS_CFLAGS)
95 TARGET_LDFLAGS += $(TLS_LDFLAGS) -Wl,-rpath-link=$(STAGING_DIR)/usr/lib
96 MAKE_VARS += \
97         FPIC="$(FPIC)" \
98         LUA_SUPPORT="$(if $(CONFIG_PACKAGE_uhttpd-mod-lua),1)" \
99         TLS_SUPPORT="$(if $(CONFIG_PACKAGE_uhttpd-mod-tls),1)" \
100         UHTTPD_TLS="$(UHTTPD_TLS)" \
101         TLS_CFLAGS="$(TLS_CFLAGS)" \
102         TLS_LDFLAGS="$(TLS_LDFLAGS)"
103
104 define Build/Prepare
105         mkdir -p $(PKG_BUILD_DIR)
106         $(CP) ./src/* $(PKG_BUILD_DIR)/
107 endef
108
109 define Package/uhttpd/conffiles
110 /etc/config/uhttpd
111 /etc/uhttpd.crt
112 /etc/uhttpd.key
113 endef
114
115 define Package/uhttpd/install
116         $(INSTALL_DIR) $(1)/etc/init.d
117         $(INSTALL_BIN) ./files/uhttpd.init $(1)/etc/init.d/uhttpd
118         $(INSTALL_DIR) $(1)/etc/config
119         $(INSTALL_CONF) ./files/uhttpd.config $(1)/etc/config/uhttpd
120         $(INSTALL_DIR) $(1)/usr/sbin
121         $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd $(1)/usr/sbin/uhttpd
122 endef
123
124 define Package/uhttpd-mod-tls/install
125         $(INSTALL_DIR) $(1)/usr/lib
126         $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_tls.so $(1)/usr/lib/
127 endef
128
129 define Package/uhttpd-mod-lua/install
130         $(INSTALL_DIR) $(1)/usr/lib
131         $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_lua.so $(1)/usr/lib/
132 endef
133
134
135 $(eval $(call BuildPackage,uhttpd))
136 $(eval $(call BuildPackage,uhttpd-mod-tls))
137 $(eval $(call BuildPackage,uhttpd-mod-lua))