2013-01-26 04:27:52 +08:00
|
|
|
# This Makefile is part of Mongoose web server project,
|
|
|
|
# https://github.com/valenok/mongoose
|
|
|
|
#
|
2013-08-19 18:39:59 +08:00
|
|
|
# This Makefile is GNU make compatible. You can get GNU Make from
|
|
|
|
# http://gnuwin32.sourceforge.net/packages/make.htm
|
|
|
|
#
|
2013-01-26 04:27:52 +08:00
|
|
|
# Example custom build:
|
2013-09-12 17:02:50 +08:00
|
|
|
# CFLAGS_EXTRA="-g -O0 -DNO_SSL_DL -DUSE_LUA -llua -lcrypto -lssl" make linux
|
2013-01-26 04:27:52 +08:00
|
|
|
#
|
|
|
|
# Flags are:
|
2012-08-19 19:22:28 +08:00
|
|
|
# -DHAVE_MD5 - use system md5 library (-2kb)
|
|
|
|
# -DNDEBUG - strip off all debug code (-5kb)
|
|
|
|
# -DDEBUG - build debug version (very noisy) (+7kb)
|
|
|
|
# -DNO_CGI - disable CGI support (-5kb)
|
|
|
|
# -DNO_SSL - disable SSL functionality (-2kb)
|
2012-09-28 06:58:35 +08:00
|
|
|
# -DNO_SSL_DL - link against system libssl library (-1kb)
|
2012-08-19 19:22:28 +08:00
|
|
|
# -DCONFIG_FILE=\"file\" - use `file' as the default config file
|
|
|
|
# -DSSL_LIB=\"libssl.so.<version>\" - use system versioned SSL shared object
|
2010-11-29 21:46:42 +08:00
|
|
|
# -DCRYPTO_LIB=\"libcrypto.so.<version>\" - use system versioned CRYPTO so
|
2012-09-28 06:58:35 +08:00
|
|
|
# -DUSE_LUA - embed Lua in Mongoose (+100kb)
|
2010-05-04 04:46:42 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
PROG = mongoose
|
|
|
|
EXE_SUFFIX =
|
2013-10-01 22:16:09 +08:00
|
|
|
CFLAGS = -std=c99 -O2 -W -Wall -pedantic -pthread -pipe -I. -I.. $(CFLAGS_EXTRA)
|
2013-09-12 17:02:50 +08:00
|
|
|
VERSION = $(shell perl -lne \
|
|
|
|
'print $$1 if /define\s+MONGOOSE_VERSION\s+"(\S+)"/' ../mongoose.c)
|
2013-10-01 02:51:16 +08:00
|
|
|
|
|
|
|
# The order in which files are listed is important
|
2013-10-04 02:09:35 +08:00
|
|
|
SOURCES = src/internal.h src/util.c src/string.c src/parse_date.c \
|
|
|
|
src/options.c src/crypto.c src/auth.c src/win32.c src/unix.c \
|
2013-11-23 15:48:46 +08:00
|
|
|
src/mg_printf.c src/ssl.c src/http_client.c src/mime.c \
|
2013-11-23 18:47:35 +08:00
|
|
|
src/directory.c src/log.c src/parse_http.c src/io.c src/cgi.c \
|
2013-11-25 01:33:05 +08:00
|
|
|
src/upload.c src/websocket.c src/webdav.c src/mongoose.c src/lua.c
|
2013-09-12 17:02:50 +08:00
|
|
|
|
|
|
|
TINY_SOURCES = ../mongoose.c main.c
|
2013-11-23 21:44:33 +08:00
|
|
|
LUA_SOURCES = $(TINY_SOURCES) lua_5.2.1.c
|
|
|
|
LUA_SQLITE_SOURCES = $(LUA_SOURCES) sqlite3.c lsqlite3.c
|
2013-08-08 19:15:40 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
SQLITE_FLAGS = -DTHREADSAFE=1 -DSQLITE_ENABLE_FTS3 \
|
|
|
|
-DSQLITE_ENABLE_FTS3_PARENTHESIS
|
2013-11-23 21:44:33 +08:00
|
|
|
LUA_FLAGS = -DUSE_LUA
|
|
|
|
LUA_SQLITE_FLAGS = $(SQLITE_FLAGS) $(LUA_FLAGS) -DUSE_LUA_SQLITE3
|
2013-05-18 22:21:52 +08:00
|
|
|
|
|
|
|
# Using Visual Studio 6.0. To build Mongoose:
|
|
|
|
# Set MSVC variable below to where VS 6.0 is installed on your system
|
|
|
|
# Run "PATH_TO_VC6\bin\nmake windows"
|
2013-08-19 06:02:43 +08:00
|
|
|
MSVC = ../../vc6
|
2013-05-18 22:21:52 +08:00
|
|
|
#DBG = /Zi /Od
|
|
|
|
DBG = /DNDEBUG /O1
|
2013-11-23 21:58:01 +08:00
|
|
|
CL = $(MSVC)/bin/cl /MD /TC /nologo $(DBG) /W3 /I$(MSVC)/include /I.. /I.
|
2013-09-08 01:47:38 +08:00
|
|
|
LINK_FLAGS = /incremental:no /libpath:$(MSVC)/lib /machine:IX86 \
|
|
|
|
user32.lib shell32.lib comdlg32.lib ws2_32.lib advapi32.lib
|
|
|
|
LINK = $(MSVC)/bin/link $(LINK_FLAGS)
|
2013-05-18 22:21:52 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
EXE_SUFFIX = .exe
|
|
|
|
else
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S), Linux)
|
|
|
|
CFLAGS += -ldl -lm
|
|
|
|
endif
|
|
|
|
endif
|
2013-05-18 22:21:52 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
all:
|
|
|
|
@echo "make (unix|windows|macos)"
|
2013-07-11 21:24:24 +08:00
|
|
|
|
2013-10-01 22:16:09 +08:00
|
|
|
../mongoose.c: ../mongoose.h Makefile $(SOURCES)
|
2013-09-30 20:09:16 +08:00
|
|
|
cat $(SOURCES) | sed '/#include "internal.h"/d' > $@
|
2013-02-12 20:33:44 +08:00
|
|
|
|
2013-09-26 05:58:36 +08:00
|
|
|
unix_unit_test: $(LUA_SOURCES) Makefile ../test/unit_test.c
|
2013-09-28 07:15:24 +08:00
|
|
|
$(CC) ../test/unit_test.c lua_5.2.1.c $(CFLAGS) -g -O0 -o t && ./t
|
2013-08-08 19:15:40 +08:00
|
|
|
|
2010-12-01 17:25:12 +08:00
|
|
|
# Make sure that the compiler flags come last in the compilation string.
|
|
|
|
# If not so, this can break some on some Linux distros which use
|
|
|
|
# "-Wl,--as-needed" turned on by default in cc command.
|
|
|
|
# Also, this is turned in many other distros in static linkage builds.
|
2013-10-16 04:11:47 +08:00
|
|
|
$(PROG): $(TINY_SOURCES)
|
2013-09-12 17:02:50 +08:00
|
|
|
$(CC) $(TINY_SOURCES) -o $@ $(CFLAGS)
|
2010-05-04 04:46:42 +08:00
|
|
|
|
2013-10-16 04:11:47 +08:00
|
|
|
$(PROG)-lua: $(LUA_SOURCES)
|
2013-11-23 21:44:33 +08:00
|
|
|
$(CC) $(LUA_SOURCES) -o $@ $(LUA_FLAGS) $(CFLAGS)
|
|
|
|
|
|
|
|
$(PROG)-lua-sqlite: $(LUA_SQLITE_SOURCES)
|
|
|
|
$(CC) $(LUA_SQLITE_SOURCES) -o $@ $(LUA_SQLITE_FLAGS) $(CFLAGS)
|
2010-05-04 04:46:42 +08:00
|
|
|
|
2013-09-26 01:37:17 +08:00
|
|
|
unix: $(PROG) $(PROG)-lua
|
2013-09-12 17:02:50 +08:00
|
|
|
|
|
|
|
# Windows build
|
2013-11-23 21:58:01 +08:00
|
|
|
$(PROG).exe: $(LUA_SQLITE_SOURCES)
|
2013-09-12 17:02:50 +08:00
|
|
|
$(MSVC)/bin/rc res.rc
|
2013-11-23 21:58:01 +08:00
|
|
|
$(CL) $(LUA_SQLITE_SOURCES) $(LUA_SQLITE_FLAGS) /link $(LINK_FLAGS) res.res /out:$@
|
2013-01-26 04:27:52 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
$(PROG)-tiny.exe: $(TINY_SOURCES)
|
|
|
|
$(MSVC)/bin/rc res.rc
|
|
|
|
$(CL) $(TINY_SOURCES) /link $(LINK_FLAGS) res.res /out:$@
|
2013-01-17 07:43:06 +08:00
|
|
|
|
2013-09-26 16:34:36 +08:00
|
|
|
$(PROG).dll: $(TINY_SOURCES) Makefile
|
2013-09-26 19:49:41 +08:00
|
|
|
$(CL) ../mongoose.c /Gz /link $(LINK_FLAGS) /DLL /DEF:dll.def /out:$@
|
2013-09-26 16:34:36 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
# This is broken now due to SSL exclusion
|
|
|
|
windows_unit_test.exe: $(LUA_SOURCES) Makefile
|
|
|
|
$(CL) ../test/unit_test.c lua_5.2.1.c -DLUA_COMPAT_ALL \
|
|
|
|
/link /libpath:$(MSVC)/lib advapi32.lib /out:$@
|
|
|
|
./$@
|
2013-05-19 08:25:10 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
windows: $(PROG).exe $(PROG)-tiny.exe
|
2013-05-19 08:25:10 +08:00
|
|
|
|
2013-09-12 17:02:50 +08:00
|
|
|
# MacOS build with Cocoa GUI
|
2013-02-06 01:59:16 +08:00
|
|
|
# For codesign to work in non-interactive mode, unlock login keychain:
|
|
|
|
# security unlock ~/Library/Keychains/login.keychain
|
|
|
|
# See e.g. http://lists.apple.com/archives/apple-cdsa/2008/Jan/msg00027.html
|
2013-09-12 17:02:50 +08:00
|
|
|
macos: $(LUA_SOURCES)
|
|
|
|
DIR=dmg/Mongoose.app
|
|
|
|
rm -rf dmg
|
|
|
|
mkdir -p dmg/Mongoose.app/Contents/{MacOS,Resources}
|
2013-09-18 15:06:48 +08:00
|
|
|
install -m 644 *.icns *.png dmg/Mongoose.app/Contents/Resources/
|
2013-09-12 17:02:50 +08:00
|
|
|
install -m 644 Info.plist dmg/Mongoose.app/Contents/
|
|
|
|
$(CC) $(LUA_SOURCES) \
|
|
|
|
-DUSE_COCOA $(CFLAGS) $(LUA_SQLITE_FLAGS) -mmacosx-version-min=10.4 \
|
|
|
|
-framework Cocoa -ObjC -arch i386 -arch x86_64 \
|
2013-09-17 05:42:18 +08:00
|
|
|
-o dmg/Mongoose.app/Contents/MacOS/Mongoose
|
2013-09-12 17:02:50 +08:00
|
|
|
ln -fs /Applications dmg/
|
|
|
|
hdiutil create Mongoose-$(VERSION).dmg -volname "Mongoose $(VERSION)" \
|
|
|
|
-srcfolder dmg -ov
|
|
|
|
#rm -rf dmg
|
2010-05-04 04:46:42 +08:00
|
|
|
|
2012-08-19 19:22:28 +08:00
|
|
|
tests:
|
2013-08-20 02:10:41 +08:00
|
|
|
perl ../test/test.pl $(TEST)
|
2010-05-04 04:46:42 +08:00
|
|
|
|
2013-02-03 00:42:01 +08:00
|
|
|
tarball: clean
|
2013-09-12 17:02:50 +08:00
|
|
|
rm -rf mongoose-$(VERSION)
|
|
|
|
mkdir mongoose-$(VERSION)
|
|
|
|
install -m 644 ../{LICENSE,*.[ch]} mongoose-$(VERSION)
|
|
|
|
tar -czf mongoose-$(VERSION).tgz mongoose-$(VERSION)
|
|
|
|
|
|
|
|
release: tarball macos
|
|
|
|
wine make windows
|
|
|
|
upx mongoose.exe
|
|
|
|
upx mongoose-tiny.exe
|
|
|
|
cp mongoose.exe mongoose-$(VERSION).exe
|
|
|
|
cp mongoose-tiny.exe mongoose-tiny-$(VERSION).exe
|
|
|
|
cp mongoose.exe mongoose_php_bundle/
|
|
|
|
zip -r mongoose-php-$(VERSION).zip mongoose_php_bundle/
|
2013-02-03 00:42:01 +08:00
|
|
|
|
2010-05-04 04:46:42 +08:00
|
|
|
clean:
|
2013-08-19 06:02:43 +08:00
|
|
|
cd ../examples && $(MAKE) clean
|
2013-01-18 18:43:52 +08:00
|
|
|
rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz \
|
2013-08-19 06:02:43 +08:00
|
|
|
$(PROG).exe *.dll *.lib res.o res.RES *.dSYM *.zip *.pdb \
|
2013-09-12 17:02:50 +08:00
|
|
|
*.exe *dmg* $(PROG)-* unix_unit_test
|