1SRCS=		string.c shttpd.c log.c auth.c md5.c cgi.c io_ssi.c \
2		io_file.c io_socket.c io_ssl.c io_emb.c io_dir.c io_cgi.c
3HDRS=		defs.h llist.h shttpd.h std_includes.h io.h md5.h ssl.h \
4		compat_unix.h compat_win32.h compat_rtems.h config.h
5OBJS=		$(SRCS:%.c=%.o) compat_unix.c
6PROG=		shttpd
7CL_FLAGS=	/MD /TC /nologo /DNDEBUG /Os 	# MSVC compiler flags
8
9# Possible flags: (in brackets are rough numbers for 'gcc -O2' on i386)
10# -DHAVE_MD5		- use system md5 library (-2kb)
11# -DNDEBUG		- strip off all debug code (-5kb)
12# -D_DEBUG		- build debug version (very noisy) (+6kb)
13# -DNO_CGI		- disable CGI support (-5kb)
14# -DNO_SSL		- disable SSL functionality (-2kb)
15# -DNO_AUTH		- disable authorization support (-4kb)
16# -DCONFIG=\"file\"	- use `file' as the default config file
17# -DNO_SSI		- disable SSI support (-4kb)
18# -DNO_THREADS		- disable threads support (?)
19
20# XXX Note for the windows users. In order to build shttpd, MSVS6 is needed.
21# Follow these steps:
22# 1. Add c:\path_to_msvs6\bin to the system Path environment variable.
23# 2. Add two new system environment variables:
24#    LIB=c:\path_to_msvs6\lib
25#    INCLUDE=c:\path_to_msvs6\include
26# 3. start console, go to shttpd-VERSION\src\ directory
27# 4. type "nmake msvc"
28# 5. go to shttpd-VERSION\examples , type "nmake msvc"
29
30
31all:
32	@echo "make (unix|msvc|mingw|rtems)"
33	@echo 'Linux: "LIBS=-ldl make unix"'
34	@echo 'BSD: "LIBS=-lpthread make unix"'
35	@echo 'Solaris: "LIBS="-lpthread -lnsl -lsocket" make unix"'
36
37.c.o:
38	$(CC) -c $(CFLAGS) $< -o $@
39
40lib$(PROG).a: $(OBJS) compat_unix.o
41	$(AR) -r lib$(PROG).a $(OBJS) compat_unix.o 2>&1
42	ranlib lib$(PROG).a 2>&1
43
44unix: lib$(PROG).a
45	$(CC) $(CFLAGS) standalone.c -o $(PROG) $(LIBS) -L. -l$(PROG)
46#$(CC) $(CFLAGS) -fpic $(SRCS) compat_unix.c -shared -o lib$(PROG).so
47
48rtems:
49	$(CC) -c $(CFLAGS) $(SRCS) compat_rtems.c
50	$(AR) -r lib$(PROG).a *.o && ranlib lib$(PROG).a
51
52$(PROG).lib: $(SRCS) $(HDRS) compat_win32.c
53	del *.obj
54	cl /c $(CL_FLAGS) compat_win32.c $(SRCS)
55	lib /nologo *.obj /out:$@
56
57msvc:	$(PROG).lib
58	cl $(CL_FLAGS) standalone.c /link /out:$(PROG).exe \
59	ws2_32.lib user32.lib advapi32.lib shell32.lib $(PROG).lib
60
61mingw:
62	$(CC) -c $(CFLAGS) $(SRCS) compat_win32.c
63	$(AR) -r lib$(PROG).a *.o && ranlib lib$(PROG).a
64	$(CC) $(CFLAGS) $(SRCS) compat_win32.c standalone.c \
65		-o $(PROG) $(LIBS) -lws2_32 -lcomdlg32 -lcomctl32
66
67man:
68	cat shttpd.1 | tbl | groff -man -Tascii | col -b > shttpd.1.txt
69	cat shttpd.1 | tbl | groff -man -Tascii | less
70
71clean:
72	rm -rf *.o *.core $(PROG) lib$(PROG).a *.lib *.obj
73