Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # This file is part of Mongoose project, http://code.google.com/p/mongoose
  2. # $Id: Makefile 473 2009-09-02 11:20:06Z valenok $
  3. PROG= mongoose
  4. all:
  5. @echo "make (linux|bsd|solaris|mac|windows|mingw|cygwin)"
  6. # Possible COPT values: (in brackets are rough numbers for 'gcc -O2' on i386)
  7. # -DHAVE_MD5 - use system md5 library (-2kb)
  8. # -DNDEBUG - strip off all debug code (-5kb)
  9. # -DDEBUG - build debug version (very noisy) (+7kb)
  10. # -DNO_CGI - disable CGI support (-5kb)
  11. # -DNO_SSL - disable SSL functionality (-2kb)
  12. # -DNO_SSL_DL - link against system libssl library (-1kb)
  13. # -DCONFIG_FILE=\"file\" - use `file' as the default config file
  14. # -DSSL_LIB=\"libssl.so.<version>\" - use system versioned SSL shared object
  15. # -DCRYPTO_LIB=\"libcrypto.so.<version>\" - use system versioned CRYPTO so
  16. # -DUSE_LUA - embed Lua in Mongoose (+100kb)
  17. ##########################################################################
  18. ### UNIX build: linux, bsd, mac, rtems
  19. ##########################################################################
  20. # To build with Lua, download and unzip Lua 5.2.1 source code into the
  21. # mongoose directory, and then add $(LUA_FLAGS) to CFLAGS below
  22. LUA = lua-5.2.1/src
  23. LUA_FLAGS = -DUSE_LUA -I$(LUA) -L$(LUA) -llua -lm
  24. CFLAGS = -std=c99 -O2 -W -Wall -pedantic $(COPT)
  25. LIB = lib$(PROG).so$(MONGOOSE_LIB_SUFFIX)
  26. # Make sure that the compiler flags come last in the compilation string.
  27. # If not so, this can break some on some Linux distros which use
  28. # "-Wl,--as-needed" turned on by default in cc command.
  29. # Also, this is turned in many other distros in static linkage builds.
  30. linux:
  31. $(CC) mongoose.c main.c -o $(PROG) -ldl -pthread $(CFLAGS)
  32. bsd:
  33. $(CC) mongoose.c main.c -pthread -o $(PROG) $(CFLAGS)
  34. mac:
  35. $(CC) mongoose.c main.c -pthread $(CFLAGS) -o $(PROG)
  36. cocoa:
  37. $(CC) mongoose.c main.c -DUSE_COCOA -pthread $(CFLAGS) -framework Cocoa -ObjC -arch i386 -arch x86_64 -o Mongoose
  38. 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
  39. solaris:
  40. $(CC) mongoose.c main.c -pthread -lnsl -lsocket -o $(PROG) $(CFLAGS)
  41. ##########################################################################
  42. ### WINDOWS build: Using Visual Studio or Mingw
  43. ##########################################################################
  44. # Using Visual Studio 6.0. To build Mongoose:
  45. # o Set MSVC variable below to where VS 6.0 is installed on your system
  46. # o Run "PATH_TO_VC6\bin\nmake windows"
  47. MSVC = e:/vc6
  48. CYA = e:/cyassl-2.0.0rc2
  49. #DBG = /Zi /DDEBUG /Od
  50. DBG = /DNDEBUG /O1
  51. CL = $(MSVC)/bin/cl /MD /TC /nologo $(DBG) /Gz /W3 /DNO_SSL_DL \
  52. /I$(MSVC)/include /DUSE_LUA /I$(LUA)
  53. GUILIB= user32.lib shell32.lib comdlg32.lib
  54. LINK = /link /incremental:no /libpath:$(MSVC)/lib /machine:IX86 \
  55. /subsystem:windows ws2_32.lib advapi32.lib cyassl.lib lua.lib
  56. CYAFL = /c /I $(CYA)/include -I $(CYA)/include/openssl /I$(MSVC)/INCLUDE \
  57. /I $(CYA)/ctaocrypt/include /D _LIB /D OPENSSL_EXTRA
  58. LUA_SOURCES = $(LUA)/lapi.c $(LUA)/lcode.c $(LUA)/lctype.c \
  59. $(LUA)/ldebug.c $(LUA)/ldo.c $(LUA)/ldump.c \
  60. $(LUA)/lfunc.c $(LUA)/lgc.c $(LUA)/llex.c \
  61. $(LUA)/lmem.c $(LUA)/lobject.c $(LUA)/lopcodes.c \
  62. $(LUA)/lparser.c $(LUA)/lstate.c $(LUA)/lstring.c \
  63. $(LUA)/ltable.c $(LUA)/ltm.c $(LUA)/lundump.c \
  64. $(LUA)/lvm.c $(LUA)/lzio.c $(LUA)/lauxlib.c \
  65. $(LUA)/lbaselib.c $(LUA)/lbitlib.c $(LUA)/lcorolib.c \
  66. $(LUA)/ldblib.c $(LUA)/liolib.c $(LUA)/lmathlib.c \
  67. $(LUA)/loslib.c $(LUA)/lstrlib.c $(LUA)/ltablib.c \
  68. $(LUA)/loadlib.c $(LUA)/linit.c
  69. LUA_OBJECTS = $(LUA_SOURCES:%.c=%.o)
  70. CYA_SOURCES = $(CYA)/src/cyassl_int.c $(CYA)/src/cyassl_io.c \
  71. $(CYA)/src/keys.c $(CYA)/src/tls.c $(CYA)/src/ssl.c \
  72. $(CYA)/ctaocrypt/src/aes.c $(CYA)/ctaocrypt/src/arc4.c \
  73. $(CYA)/ctaocrypt/src/asn.c $(CYA)/ctaocrypt/src/coding.c \
  74. $(CYA)/ctaocrypt/src/ctc_asm.c $(CYA)/ctaocrypt/src/ctc_misc.c \
  75. $(CYA)/ctaocrypt/src/cyassl_memory.c $(CYA)/ctaocrypt/src/des3.c \
  76. $(CYA)/ctaocrypt/src/dh.c $(CYA)/ctaocrypt/src/dsa.c \
  77. $(CYA)/ctaocrypt/src/ecc.c $(CYA)/ctaocrypt/src/hc128.c \
  78. $(CYA)/ctaocrypt/src/hmac.c $(CYA)/ctaocrypt/src/integer.c \
  79. $(CYA)/ctaocrypt/src/md4.c $(CYA)/ctaocrypt/src/md5.c \
  80. $(CYA)/ctaocrypt/src/pwdbased.c $(CYA)/ctaocrypt/src/rabbit.c \
  81. $(CYA)/ctaocrypt/src/random.c $(CYA)/ctaocrypt/src/ripemd.c \
  82. $(CYA)/ctaocrypt/src/rsa.c $(CYA)/ctaocrypt/src/sha.c \
  83. $(CYA)/ctaocrypt/src/sha256.c $(CYA)/ctaocrypt/src/sha512.c \
  84. $(CYA)/ctaocrypt/src/tfm.c
  85. cyassl.lib:
  86. $(CL) /Fo$(CYA)/ $(CYA_SOURCES) $(CYAFL) $(DEF)
  87. $(MSVC)/bin/lib $(CYA)/*.obj /out:$@
  88. lua.lib:
  89. $(CL) /c /Fo$(LUA)/ $(LUA_SOURCES)
  90. $(MSVC)/bin/lib $(LUA_SOURCES:%.c=%.obj) /out:$@
  91. windows: cyassl.lib lua.lib
  92. $(MSVC)/bin/rc build\res.rc
  93. $(CL) /Ibuild main.c mongoose.c /GA $(LINK) build\res.res \
  94. $(GUILIB) /out:$(PROG).exe
  95. # $(CL) mongoose.c /GD $(LINK) /DLL /DEF:build\dll.def /out:$(PROG).dll
  96. # Build for Windows under MinGW
  97. #MINGWDBG= -DDEBUG -O0 -ggdb
  98. MINGWDBG= -DNDEBUG -Os
  99. MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
  100. #MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,windows $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
  101. mingw:
  102. windres build\res.rc build\res.o
  103. $(CC) $(MINGWOPT) mongoose.c -lws2_32 \
  104. -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
  105. $(CC) $(MINGWOPT) -build mongoose.c main.c build\res.o \
  106. -lws2_32 -ladvapi32 -o $(PROG).exe
  107. # Build for Windows under Cygwin
  108. #CYGWINDBG= -DDEBUG -O0 -ggdb
  109. CYGWINDBG= -DNDEBUG -Os
  110. CYGWINOPT= -W -Wall -mthreads -Wl,--subsystem,console $(CYGWINDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
  111. cygwin:
  112. windres ./build/res.rc ./build/res.o
  113. $(CC) $(CYGWINOPT) mongoose.c -lws2_32 \
  114. -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
  115. $(CC) $(CYGWINOPT) -Ibuild mongoose.c main.c ./build/res.o \
  116. -lws2_32 -ladvapi32 -o $(PROG).exe
  117. ##########################################################################
  118. ### Manuals, cleanup, test, release
  119. ##########################################################################
  120. man:
  121. groff -man -T ascii mongoose.1 | col -b > mongoose.txt
  122. groff -man -T ascii mongoose.1 | less
  123. # "TEST=unit make test" - perform unit test only
  124. # "TEST=embedded" - test embedded API by building and testing test/embed.c
  125. # "TEST=basic_tests" - perform basic tests only (no CGI, SSI..)
  126. tests:
  127. perl test/test.pl $(TEST)
  128. release: clean
  129. 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
  130. clean:
  131. rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz $(PROG).exe *.dll *.lib build/res.o build/res.RES