scripts/config: fix menuconfig segfault in text inputs when format patterns are enter...
[openwrt.git] / package / network / services / uhttpd / src / Makefile
1 CGI_SUPPORT ?= 1
2 LUA_SUPPORT ?= 1
3 TLS_SUPPORT ?= 1
4 UHTTPD_TLS ?= cyassl
5
6 CFLAGS ?= -I./lua-5.1.4/src $(TLS_CFLAGS) -O0 -ggdb3
7 LDFLAGS ?= -L./lua-5.1.4/src
8
9 CFLAGS += -Wall --std=gnu99
10
11 ifeq ($(UHTTPD_TLS),openssl)
12   TLS_LDFLAGS ?= -L./openssl-0.9.8m -lssl
13   TLS_CFLAGS ?= -I./openssl-0.9.8m/include -DTLS_IS_OPENSSL
14 else
15   TLS_LDFLAGS ?= -L./cyassl-1.4.0/src/.libs -lcyassl
16   TLS_CFLAGS ?= -I./cyassl-1.4.0/include -DTLS_IS_CYASSL
17 endif
18
19 OBJ := uhttpd.o uhttpd-file.o uhttpd-utils.o
20 LIB := -Wl,--export-dynamic -lcrypt -ldl
21
22 TLSLIB :=
23 LUALIB :=
24
25 HAVE_SHADOW=$(shell echo 'int main(void){ return !getspnam("root"); }' | \
26         $(CC) -include shadow.h -xc -o/dev/null - 2>/dev/null && echo yes)
27
28 ifeq ($(HAVE_SHADOW),yes)
29   CFLAGS += -DHAVE_SHADOW
30 endif
31
32 ifeq ($(TLS_SUPPORT),1)
33   CFLAGS += -DHAVE_TLS
34 endif
35
36 ifeq ($(CGI_SUPPORT),1)
37   CFLAGS += -DHAVE_CGI
38 endif
39
40 ifeq ($(LUA_SUPPORT),1)
41   CFLAGS += -DHAVE_LUA
42 endif
43
44 ifeq ($(UBUS_SUPPORT),1)
45   CFLAGS += -DHAVE_UBUS
46 endif
47
48
49 world: compile
50
51 ifeq ($(CGI_SUPPORT),1)
52   OBJ += uhttpd-cgi.o
53 endif
54
55 ifeq ($(LUA_SUPPORT),1)
56   LUALIB := uhttpd_lua.so
57
58   $(LUALIB): uhttpd-lua.c
59                 $(CC) $(CFLAGS) $(LDFLAGS) $(FPIC) \
60                         -shared -lm -llua -ldl \
61                         -o $(LUALIB) uhttpd-lua.c
62 endif
63
64 ifeq ($(TLS_SUPPORT),1)
65   TLSLIB := uhttpd_tls.so
66
67   $(TLSLIB): uhttpd-tls.c
68                 $(CC) $(CFLAGS) $(LDFLAGS) $(FPIC) \
69                         -shared $(TLS_LDFLAGS) \
70                         -o $(TLSLIB) uhttpd-tls.c
71 endif
72
73 ifeq ($(UBUS_SUPPORT),1)
74   UBUSLIB := uhttpd_ubus.so
75
76   $(UBUSLIB): uhttpd-ubus.c
77                 $(CC) $(CFLAGS) $(LDFLAGS) $(FPIC) \
78                         -shared -lubus -ljson -lblobmsg_json \
79                         -o $(UBUSLIB) uhttpd-ubus.c
80 endif
81
82 %.o: %.c
83         $(CC) $(CFLAGS) -c -o $@ $<
84
85 compile: $(OBJ) $(TLSLIB) $(LUALIB) $(UBUSLIB)
86         $(CC) -o uhttpd $(LDFLAGS) $(OBJ) $(LIB)
87
88 clean:
89         rm -f *.o *.so uhttpd