Commit 1eed7702 authored by Sergey Lyubka's avatar Sergey Lyubka

Moved Makefile and main.c to build/

parent 511ef413
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
# -DUSE_LUA - embed Lua in Mongoose (+100kb) # -DUSE_LUA - embed Lua in Mongoose (+100kb)
PROG = mongoose PROG = mongoose
CFLAGS = -std=c99 -O2 -W -Wall -pedantic -pthread -pipe $(COPT) CFLAGS = -std=c99 -O2 -W -Wall -pedantic -pthread -pipe -I.. $(COPT)
# To build with Lua, download and unzip Lua 5.2.1 source code into the # To build with Lua, download and unzip Lua 5.2.1 source code into the
# mongoose directory, and then add $(LUA_SOURCES) to CFLAGS # mongoose directory, and then add $(LUA_SOURCES) to CFLAGS
LUA = lua-5.2.1/src LUA = ../lua-5.2.1/src
LUA_FLAGS = -I$(LUA) -DLUA_COMPAT_ALL LUA_FLAGS = -I$(LUA) -DLUA_COMPAT_ALL
LUA_SOURCES = $(LUA)/lapi.c $(LUA)/lcode.c $(LUA)/lctype.c \ LUA_SOURCES = $(LUA)/lapi.c $(LUA)/lcode.c $(LUA)/lctype.c \
$(LUA)/ldebug.c $(LUA)/ldo.c $(LUA)/ldump.c \ $(LUA)/ldebug.c $(LUA)/ldo.c $(LUA)/ldump.c \
...@@ -41,7 +41,7 @@ ifneq ($(OS), Windows_NT) ...@@ -41,7 +41,7 @@ ifneq ($(OS), Windows_NT)
endif endif
# Stock windows binary builds with Lua and YASSL library. # Stock windows binary builds with Lua and YASSL library.
YASSL = ../cyassl-2.4.6 YASSL = ../../cyassl-2.4.6
YASSL_FLAGS = -I $(YASSL) -I $(YASSL)/cyassl \ YASSL_FLAGS = -I $(YASSL) -I $(YASSL)/cyassl \
-D _LIB -D OPENSSL_EXTRA -D HAVE_ERRNO_H \ -D _LIB -D OPENSSL_EXTRA -D HAVE_ERRNO_H \
-D HAVE_GETHOSTBYNAME -D HAVE_INET_NTOA -D HAVE_LIMITS_H \ -D HAVE_GETHOSTBYNAME -D HAVE_INET_NTOA -D HAVE_LIMITS_H \
...@@ -65,20 +65,20 @@ YASSL_SOURCES = \ ...@@ -65,20 +65,20 @@ YASSL_SOURCES = \
$(YASSL)/ctaocrypt/src/ecc.c $(YASSL)/src/ocsp.c $(YASSL)/src/crl.c \ $(YASSL)/ctaocrypt/src/ecc.c $(YASSL)/src/ocsp.c $(YASSL)/src/crl.c \
$(YASSL)/ctaocrypt/src/hc128.c $(YASSL)/ctaocrypt/src/memory.c $(YASSL)/ctaocrypt/src/hc128.c $(YASSL)/ctaocrypt/src/memory.c
ALL_SOURCES = main.c mongoose.c build/sqlite3.c build/lsqlite3.c \ ALL_SOURCES = ../mongoose.c main.c sqlite3.c lsqlite3.c \
$(LUA_SOURCES) $(YASSL_SOURCES) $(LUA_SOURCES) $(YASSL_SOURCES)
ALL_OBJECTS = $(ALL_SOURCES:%.c=%.o) ALL_OBJECTS = $(ALL_SOURCES:%.c=%.o)
ALL_WINOBJS = $(ALL_SOURCES:%.c=%.obj) ALL_WINOBJS = $(ALL_SOURCES:%.c=%.obj)
SQLITE_FLAGS = -DTHREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_FLAGS = -DTHREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS
MONGOOSE_FLAGS = -DNO_SSL_DL -DUSE_LUA -DUSE_LUA_SQLITE3 $(COPT) MONGOOSE_FLAGS = -DNO_SSL_DL -DUSE_LUA -DUSE_LUA_SQLITE3 -I.. $(COPT)
FLAGS = $(MONGOOSE_FLAGS) $(SQLITE_FLAGS) $(YASSL_FLAGS) $(LUA_FLAGS) FLAGS = $(MONGOOSE_FLAGS) $(SQLITE_FLAGS) $(YASSL_FLAGS) $(LUA_FLAGS)
# Using Visual Studio 6.0. To build Mongoose: # Using Visual Studio 6.0. To build Mongoose:
# Set MSVC variable below to where VS 6.0 is installed on your system # Set MSVC variable below to where VS 6.0 is installed on your system
# Run "PATH_TO_VC6\bin\nmake windows" # Run "PATH_TO_VC6\bin\nmake windows"
MSVC = ../vc6 MSVC = ../../vc6
#DBG = /Zi /Od #DBG = /Zi /Od
DBG = /DNDEBUG /O1 DBG = /DNDEBUG /O1
CL = $(MSVC)/bin/cl /MD /TC /nologo $(DBG) /W3 /GA /I$(MSVC)/include CL = $(MSVC)/bin/cl /MD /TC /nologo $(DBG) /W3 /GA /I$(MSVC)/include
...@@ -109,17 +109,17 @@ mongoose.o: mod_lua.c ...@@ -109,17 +109,17 @@ mongoose.o: mod_lua.c
# "-Wl,--as-needed" turned on by default in cc command. # "-Wl,--as-needed" turned on by default in cc command.
# Also, this is turned in many other distros in static linkage builds. # Also, this is turned in many other distros in static linkage builds.
linux: linux:
$(CC) mongoose.c main.c -o $(PROG) -ldl $(CFLAGS) $(CC) ../mongoose.c main.c -o $(PROG) -ldl $(CFLAGS)
mac: bsd mac: bsd
bsd: bsd:
$(CC) mongoose.c main.c -o $(PROG) $(CFLAGS) $(CC) ../mongoose.c main.c -o $(PROG) $(CFLAGS)
bsd_lua: $(ALL_OBJECTS) bsd_lua: $(ALL_OBJECTS)
$(CC) $(ALL_OBJECTS) -o $@ $(CC) $(ALL_OBJECTS) -o $@
solaris: solaris:
$(CC) mongoose.c main.c -lnsl -lsocket -o $(PROG) $(CFLAGS) $(CC) ../mongoose.c main.c -lnsl -lsocket -o $(PROG) $(CFLAGS)
lib$(PROG).a: $(ALL_OBJECTS) lib$(PROG).a: $(ALL_OBJECTS)
ar cr $@ $(ALL_OBJECTS) ar cr $@ $(ALL_OBJECTS)
...@@ -130,14 +130,13 @@ $(PROG).lib: $(ALL_WINOBJS) ...@@ -130,14 +130,13 @@ $(PROG).lib: $(ALL_WINOBJS)
# For codesign to work in non-interactive mode, unlock login keychain: # For codesign to work in non-interactive mode, unlock login keychain:
# security unlock ~/Library/Keychains/login.keychain # security unlock ~/Library/Keychains/login.keychain
# See e.g. http://lists.apple.com/archives/apple-cdsa/2008/Jan/msg00027.html # See e.g. http://lists.apple.com/archives/apple-cdsa/2008/Jan/msg00027.html
Mongoose: mongoose.c main.c Mongoose: ../mongoose.c main.c
$(CC) mongoose.c main.c build/lsqlite3.c build/sqlite3.c \ $(CC) $(ALL_SOURCES) \
-DUSE_COCOA $(CFLAGS) $(FLAGS) -mmacosx-version-min=10.4 \ -DUSE_COCOA $(CFLAGS) $(FLAGS) -mmacosx-version-min=10.4 \
$(YASSL_SOURCES) $(LUA_SOURCES) \
-framework Cocoa -ObjC -arch i386 -arch x86_64 -o Mongoose -framework Cocoa -ObjC -arch i386 -arch x86_64 -o Mongoose
cocoa: Mongoose cocoa: Mongoose
V=`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' mongoose.c`; DIR=dmg/Mongoose.app && rm -rf $$DIR && mkdir -p $$DIR/Contents/{MacOS,Resources} && install -m 644 build/mongoose_*.png $$DIR/Contents/Resources/ && install -m 644 build/Info.plist $$DIR/Contents/ && install -m 755 Mongoose $$DIR/Contents/MacOS/ && ln -fs /Applications dmg/ ; hdiutil create Mongoose_$$V.dmg -volname "Mongoose $$V" -srcfolder dmg -ov #; rm -rf dmg V=`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' ../mongoose.c`; DIR=dmg/Mongoose.app && rm -rf $$DIR && mkdir -p $$DIR/Contents/{MacOS,Resources} && install -m 644 mongoose_*.png $$DIR/Contents/Resources/ && install -m 644 Info.plist $$DIR/Contents/ && install -m 755 Mongoose $$DIR/Contents/MacOS/ && ln -fs /Applications dmg/ ; hdiutil create Mongoose_$$V.dmg -volname "Mongoose $$V" -srcfolder dmg -ov #; rm -rf dmg
un: un:
$(CC) test/unit_test.c -o unit_test -I. -I$(LUA) $(LUA_SOURCES) \ $(CC) test/unit_test.c -o unit_test -I. -I$(LUA) $(LUA_SOURCES) \
...@@ -151,18 +150,18 @@ wi: ...@@ -151,18 +150,18 @@ wi:
./unit_test.exe ./unit_test.exe
windows: $(ALL_WINOBJS) windows: $(ALL_WINOBJS)
$(MSVC)/bin/rc build/res.rc $(MSVC)/bin/rc res.rc
$(LINK) /nologo $(ALL_WINOBJS) build/res.res /out:$(PROG).exe $(LINK) /nologo $(ALL_WINOBJS) res.res /out:$(PROG).exe
# Build for Windows under MinGW # Build for Windows under MinGW
#MINGWDBG= -DDEBUG -O0 -ggdb #MINGWDBG= -DDEBUG -O0 -ggdb
MINGWDBG= -DNDEBUG -Os MINGWDBG= -DNDEBUG -Os
MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT) MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
mingw: mingw:
windres build\res.rc build\res.o windres res.rc res.o
$(CC) $(MINGWOPT) mongoose.c -lws2_32 \ $(CC) $(MINGWOPT) ../mongoose.c -lws2_32 \
-shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
$(CC) $(MINGWOPT) mongoose.c main.c build\res.o \ $(CC) $(MINGWOPT) ../mongoose.c main.c res.o \
-lws2_32 -ladvapi32 -lcomdlg32 -o $(PROG).exe -lws2_32 -ladvapi32 -lcomdlg32 -o $(PROG).exe
# Build for Windows under Cygwin # Build for Windows under Cygwin
...@@ -170,24 +169,24 @@ mingw: ...@@ -170,24 +169,24 @@ mingw:
CYGWINDBG= -DNDEBUG -Os CYGWINDBG= -DNDEBUG -Os
CYGWINOPT= -W -Wall -mthreads -Wl,--subsystem,console $(CYGWINDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT) CYGWINOPT= -W -Wall -mthreads -Wl,--subsystem,console $(CYGWINDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
cygwin: cygwin:
windres ./build/res.rc ./build/res.o windres res.rc res.o
$(CC) $(CYGWINOPT) mongoose.c -lws2_32 \ $(CC) $(CYGWINOPT) ../mongoose.c -lws2_32 \
-shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
$(CC) $(CYGWINOPT) -Ibuild mongoose.c main.c ./build/res.o \ $(CC) $(CYGWINOPT) -I.. ../mongoose.c main.c res.o \
-lws2_32 -ladvapi32 -o $(PROG).exe -lws2_32 -ladvapi32 -o $(PROG).exe
tests: tests:
perl test/test.pl $(TEST) perl test/test.pl $(TEST)
tarball: clean tarball: clean
F=mongoose-`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' mongoose.c`.tgz ; cd .. && tar -czf x mongoose/{LICENSE,Makefile,examples,test,build,*.[ch],*.md} && mv x mongoose/$$F F=mongoose-`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' ../mongoose.c`.tgz ; cd ../.. && tar -czf x mongoose/{LICENSE,examples,test,build,*.[ch],*.md} && mv x mongoose/$$F
release: tarball cocoa release: tarball cocoa
wine make windows wine make windows
V=`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' mongoose.c`; upx mongoose.exe; cp mongoose.exe mongoose-$$V.exe; cp mongoose.exe mongoose_php_bundle/; zip -r mongoose_php_bundle_$$V.zip mongoose_php_bundle/ V=`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' ../mongoose.c`; upx mongoose.exe; cp mongoose.exe mongoose-$$V.exe; cp mongoose.exe mongoose_php_bundle/; zip -r mongoose_php_bundle_$$V.zip mongoose_php_bundle/
clean: clean:
cd examples && $(MAKE) clean cd ../examples && $(MAKE) clean
rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz \ rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz \
$(PROG).exe *.dll *.lib build/res.o build/res.RES *.dSYM *.zip *.pdb \ $(PROG).exe *.dll *.lib res.o res.RES *.dSYM *.zip *.pdb \
*.exe *dmg* $(ALL_OBJECTS) $(ALL_WINOBJS) *.exe *dmg* $(ALL_OBJECTS) $(ALL_WINOBJS)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment