当前位置: 首页 > 工具软件 > SHTTPD > 使用案例 >

build shttpd Makefile

汝臻
2023-12-01

# build shttpd static lib and so
#
# revised by:  350137278@qq.com
# last update: 2020-06-05
###############################################################
PREFIX=.

# Default build config for Linux
LIBS?=   -ldl -lpthread

SRCS= string.c shttpd.c log.c auth.c md5.c cgi.c io_ssi.c \
		io_file.c io_socket.c io_ssl.c io_emb.c io_dir.c io_cgi.c

HDRS= defs.h llist.h shttpd.h std_includes.h io.h md5.h ssl.h \
		compat_unix.h compat_win32.h compat_rtems.h config.h

OBJS=		$(SRCS:%.c=%.o) compat_unix.c
PROG=		shttpd

# MSVC compiler flags
CL_FLAGS=	/MD /TC /nologo /DNDEBUG /Os

# default build config for Linux
#LIBS?=   -ldl -lpthread
#CFLAGS?= -DNO_SSL

# Possible CFLAGS: (in brackets are rough numbers for 'gcc -O2' on i386)
# -DHAVE_MD5	- use system md5 library (-2kb)
# -DNDEBUG		- strip off all debug code (-5kb)
# -D_DEBUG		- build debug version (very noisy) (+6kb)
# -DNO_CGI		- disable CGI support (-5kb)
# -DNO_SSL		- disable SSL functionality (-2kb)
# -DNO_AUTH		- disable authorization support (-4kb)
# -DCONFIG=\"file\"	- use `file' as the default config file
# -DNO_SSI		- disable SSI support (-4kb)
# -DNO_THREADS	- disable threads support (?)

# XXX Note for the windows users. In order to build shttpd, MSVS6 is needed.
# Follow these steps:
# 1. Add c:\path_to_msvs6\bin to the system Path environment variable.
# 2. Add two new system environment variables:
#    LIB=c:\path_to_msvs6\lib
#    INCLUDE=c:\path_to_msvs6\include
# 3. start console, go to shttpd-VERSION\src\ directory
# 4. type "nmake msvc"
# 5. go to shttpd-VERSION\examples , type "nmake msvc"


all:
	@echo "-- Build $(PROG) usage:"
	@echo "   # make (linux|msvc|mingw|rtems)"
	@echo '   Linux:   # LIBS="-ldl -lpthread" CFLAGS="-DNO_SSL" make linux'
	@echo '            # LIBS="-ldl -lpthread" make linux'
	@echo '            # LIBS="-ldl -lpthread" make linuxso'
	@echo '   BSD:     # LIBS="-ldl -lpthread" make linux'
	@echo '   Solaris: # LIBS="-lpthread -lnsl -lsocket" make linux'

.c.o:
	$(CC) -c $(CFLAGS) $< -o $@

lib$(PROG).a: $(OBJS) compat_unix.o
	$(AR) -r lib$(PROG).a $(OBJS) compat_unix.o 2>&1
	ranlib lib$(PROG).a 2>&1

linux: lib$(PROG).a
	$(CC) $(CFLAGS) standalone.c -o $(PROG) $(LIBS) -L. -l$(PROG)

linuxso:
	$(CC) $(CFLAGS) -fpic $(SRCS) compat_unix.c -shared -o lib$(PROG).so

rtems:
	$(CC) -c $(CFLAGS) $(SRCS) compat_rtems.c
	$(AR) -r lib$(PROG).a *.o && ranlib lib$(PROG).a 

$(PROG).lib: $(SRCS) $(HDRS) compat_win32.c
	del *.obj
	cl /c $(CL_FLAGS) compat_win32.c $(SRCS)
	lib /nologo *.obj /out:$@

msvc: $(PROG).lib
	cl $(CL_FLAGS) standalone.c /link /out:$(PROG).exe \
	ws2_32.lib user32.lib advapi32.lib shell32.lib $(PROG).lib

mingw:
	$(CC) -c $(CFLAGS) $(SRCS) compat_win32.c
	$(AR) -r lib$(PROG).a *.o && ranlib lib$(PROG).a 
	$(CC) $(CFLAGS) $(SRCS) compat_win32.c standalone.c \
		-o $(PROG) $(LIBS) -lws2_32 -lcomdlg32 -lcomctl32

man:
	cat shttpd.1 | tbl | groff -man -Tascii | col -b > shttpd.1.txt
	cat shttpd.1 | tbl | groff -man -Tascii | less

clean:
	rm -rf *.o *.core $(PROG) lib$(PROG).a lib$(PROG).so *.lib *.obj
 类似资料:

相关阅读

相关文章

相关问答