Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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)"
  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. # -DCONFIG_FILE=\"file\" - use `file' as the default config file
  13. # -DHAVE_STRTOUI64 - use system strtoui64() function for strtoull()
  14. # -DSSL_LIB=\"libssl.so.<version>\" - use system versioned SSL shared object
  15. # -DCRYPTO_LIB=\"libcrypto.so.<version>\" - use system versioned CRYPTO so
  16. ##########################################################################
  17. ### UNIX build: linux, bsd, mac, rtems
  18. ##########################################################################
  19. # Add $(LUA_FLAGS) to CFLAGS below if you want to build with Lua
  20. LUA = lua-5.2.1/src
  21. LUA_FLAGS = -DUSE_LUA -I$(LUA) -L$(LUA) -llua -lm
  22. GCC_WARNS = -W -Wall -pedantic
  23. CFLAGS = -std=c99 -O2 $(GCC_WARNS) $(COPT)
  24. MAC_SHARED = -flat_namespace -bundle -undefined suppress
  25. LINFLAGS = -ldl -pthread $(CFLAGS)
  26. LIB = lib$(PROG).so$(MONGOOSE_LIB_SUFFIX)
  27. # Make sure that the compiler flags come last in the compilation string.
  28. # If not so, this can break some on some Linux distros which use
  29. # "-Wl,--as-needed" turned on by default in cc command.
  30. # Also, this is turned in many other distros in static linkage builds.
  31. linux:
  32. $(CC) mongoose.c -shared -fPIC -fpic -o $(LIB) -Wl,-soname,$(LIB) $(LINFLAGS)
  33. $(CC) mongoose.c main.c -o $(PROG) $(LINFLAGS)
  34. bsd:
  35. $(CC) mongoose.c -shared -pthread -fpic -fPIC -o $(LIB) $(CFLAGS)
  36. $(CC) mongoose.c main.c -pthread -o $(PROG) $(CFLAGS)
  37. mac:
  38. $(CC) mongoose.c -pthread -o $(LIB) $(MAC_SHARED) $(CFLAGS)
  39. $(CC) mongoose.c main.c -pthread -o $(PROG) $(CFLAGS)
  40. solaris:
  41. $(CC) mongoose.c -pthread -lnsl \
  42. -lsocket -fpic -fPIC -shared -o $(LIB) $(CFLAGS)
  43. $(CC) mongoose.c main.c -pthread -lnsl -lsocket -o $(PROG) $(CFLAGS)
  44. ##########################################################################
  45. ### WINDOWS build: Using Visual Studio or Mingw
  46. ##########################################################################
  47. # Using Visual Studio 6.0. To build Mongoose:
  48. # o Set MSVC variable below to where VS 6.0 is installed on your system
  49. # o Run "PATH_TO_VC6\bin\nmake windows"
  50. MSVC = e:/vc6
  51. CYA = e:/cyassl-2.0.0rc2
  52. #DBG = /Zi /DDEBUG /Od
  53. DBG = /DNDEBUG /O1
  54. CL = $(MSVC)/bin/cl /MD /TC /nologo $(DBG) /Gz /W3 /DNO_SSL_DL \
  55. /I$(MSVC)/include /DUSE_LUA /I$(LUA)
  56. GUILIB= user32.lib shell32.lib
  57. LINK = /link /incremental:no /libpath:$(MSVC)/lib /machine:IX86 \
  58. /subsystem:windows ws2_32.lib advapi32.lib cyassl.lib lua.lib
  59. CYAFL = /c /I $(CYA)/include -I $(CYA)/include/openssl /I$(MSVC)/INCLUDE \
  60. /I $(CYA)/ctaocrypt/include /D _LIB /D OPENSSL_EXTRA
  61. LUA_SOURCES = $(LUA)/lapi.c $(LUA)/lcode.c $(LUA)/lctype.c \
  62. $(LUA)/ldebug.c $(LUA)/ldo.c $(LUA)/ldump.c \
  63. $(LUA)/lfunc.c $(LUA)/lgc.c $(LUA)/llex.c \
  64. $(LUA)/lmem.c $(LUA)/lobject.c $(LUA)/lopcodes.c \
  65. $(LUA)/lparser.c $(LUA)/lstate.c $(LUA)/lstring.c \
  66. $(LUA)/ltable.c $(LUA)/ltm.c $(LUA)/lundump.c \
  67. $(LUA)/lvm.c $(LUA)/lzio.c $(LUA)/lauxlib.c \
  68. $(LUA)/lbaselib.c $(LUA)/lbitlib.c $(LUA)/lcorolib.c \
  69. $(LUA)/ldblib.c $(LUA)/liolib.c $(LUA)/lmathlib.c \
  70. $(LUA)/loslib.c $(LUA)/lstrlib.c $(LUA)/ltablib.c \
  71. $(LUA)/loadlib.c $(LUA)/linit.c
  72. CYA_SOURCES = \
  73. $(CYA)/src/cyassl_int.c \
  74. $(CYA)/src/cyassl_io.c \
  75. $(CYA)/src/keys.c \
  76. $(CYA)/src/tls.c \
  77. $(CYA)/src/ssl.c \
  78. $(CYA)/ctaocrypt/src/aes.c \
  79. $(CYA)/ctaocrypt/src/arc4.c \
  80. $(CYA)/ctaocrypt/src/asn.c \
  81. $(CYA)/ctaocrypt/src/coding.c \
  82. $(CYA)/ctaocrypt/src/ctc_asm.c \
  83. $(CYA)/ctaocrypt/src/ctc_misc.c \
  84. $(CYA)/ctaocrypt/src/cyassl_memory.c \
  85. $(CYA)/ctaocrypt/src/des3.c \
  86. $(CYA)/ctaocrypt/src/dh.c \
  87. $(CYA)/ctaocrypt/src/dsa.c \
  88. $(CYA)/ctaocrypt/src/ecc.c \
  89. $(CYA)/ctaocrypt/src/hc128.c \
  90. $(CYA)/ctaocrypt/src/hmac.c \
  91. $(CYA)/ctaocrypt/src/integer.c \
  92. $(CYA)/ctaocrypt/src/md4.c \
  93. $(CYA)/ctaocrypt/src/md5.c \
  94. $(CYA)/ctaocrypt/src/pwdbased.c \
  95. $(CYA)/ctaocrypt/src/rabbit.c \
  96. $(CYA)/ctaocrypt/src/random.c \
  97. $(CYA)/ctaocrypt/src/ripemd.c \
  98. $(CYA)/ctaocrypt/src/rsa.c \
  99. $(CYA)/ctaocrypt/src/sha.c \
  100. $(CYA)/ctaocrypt/src/sha256.c \
  101. $(CYA)/ctaocrypt/src/sha512.c \
  102. $(CYA)/ctaocrypt/src/tfm.c
  103. cyassl.lib:
  104. $(CL) /Fo$(CYA)/ $(CYA_SOURCES) $(CYAFL) $(DEF)
  105. $(MSVC)/bin/lib $(CYA)/*.obj /out:$@
  106. lua.lib:
  107. $(CL) /c /Fo$(LUA)/ $(LUA_SOURCES)
  108. $(MSVC)/bin/lib $(LUA_SOURCES:%.c=%.obj) /out:$@
  109. windows: cyassl.lib lua.lib
  110. $(MSVC)/bin/rc win32\res.rc
  111. $(CL) /I win32 main.c mongoose.c /GA $(LINK) win32\res.res \
  112. $(GUILIB) /out:$(PROG).exe
  113. $(CL) mongoose.c /GD $(LINK) /DLL /DEF:win32\dll.def /out:$(PROG).dll
  114. # Build for Windows under MinGW
  115. #MINGWDBG= -DDEBUG -O0 -ggdb
  116. MINGWDBG= -DNDEBUG -Os
  117. MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
  118. #MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,windows $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
  119. mingw:
  120. windres win32\res.rc win32\res.o
  121. $(CC) $(MINGWOPT) mongoose.c -lws2_32 \
  122. -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
  123. $(CC) $(MINGWOPT) -Iwin32 mongoose.c main.c win32\res.o -lws2_32 -ladvapi32 \
  124. -o $(PROG).exe
  125. ##########################################################################
  126. ### Manuals, cleanup, test, release
  127. ##########################################################################
  128. man:
  129. groff -man -T ascii mongoose.1 | col -b > mongoose.txt
  130. groff -man -T ascii mongoose.1 | less
  131. # "TEST=unit make test" - perform unit test only
  132. # "TEST=embedded" - test embedded API by building and testing test/embed.c
  133. # "TEST=basic_tests" - perform basic tests only (no CGI, SSI..)
  134. tests:
  135. perl test/test.pl $(TEST)
  136. release: clean
  137. F=mongoose-`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' mongoose.c`.tgz ; cd .. && tar -czf x mongoose/{LICENSE,Makefile,bindings,examples,test,win32,mongoose.c,mongoose.h,mongoose.1,main.c} && mv x mongoose/$$F
  138. clean:
  139. rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz $(PROG).exe *.dll *.lib