Makefile 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. GCC_WARNS = -W -Wall -pedantic
  20. # -Wno-missing-field-initializers -Wno-unused-parameter -Wno-format-zero-length -Wno-missing-braces
  21. CFLAGS = -std=c99 -O2 $(GCC_WARNS) $(COPT)
  22. MAC_SHARED = -flat_namespace -bundle -undefined suppress
  23. LINFLAGS = -ldl -pthread $(CFLAGS)
  24. LIB = lib$(PROG).so$(MONGOOSE_LIB_SUFFIX)
  25. # Make sure that the compiler flags come last in the compilation string.
  26. # If not so, this can break some on some Linux distros which use
  27. # "-Wl,--as-needed" turned on by default in cc command.
  28. # Also, this is turned in many other distros in static linkage builds.
  29. linux:
  30. $(CC) mongoose.c -shared -fPIC -fpic -o $(LIB) -Wl,-soname,$(LIB) $(LINFLAGS)
  31. $(CC) mongoose.c main.c -o $(PROG) $(LINFLAGS)
  32. bsd:
  33. $(CC) mongoose.c -shared -pthread -fpic -fPIC -o $(LIB) $(CFLAGS)
  34. $(CC) mongoose.c main.c -pthread -o $(PROG) $(CFLAGS)
  35. mac:
  36. $(CC) mongoose.c -pthread -o $(LIB) $(MAC_SHARED) $(CFLAGS)
  37. $(CC) mongoose.c main.c -pthread -o $(PROG) $(CFLAGS)
  38. solaris:
  39. $(CC) mongoose.c -pthread -lnsl \
  40. -lsocket -fpic -fPIC -shared -o $(LIB) $(CFLAGS)
  41. $(CC) mongoose.c main.c -pthread -lnsl -lsocket -o $(PROG) $(CFLAGS)
  42. ##########################################################################
  43. ### WINDOWS build: Using Visual Studio or Mingw
  44. ##########################################################################
  45. # Using Visual Studio 6.0. To build Mongoose:
  46. # o Set MSVC variable below to where VS 6.0 is installed on your system
  47. # o Run "PATH_TO_VC6\bin\nmake windows"
  48. MSVC = e:/vc6
  49. CYA = e:/cyassl-2.0.0rc2
  50. #DBG = /Zi /DDEBUG /Od
  51. DBG = /DNDEBUG /O1
  52. CL = $(MSVC)/bin/cl /MD /TC /nologo $(DBG) /Gz /W3 /DNO_SSL_DL \
  53. /I$(MSVC)/include
  54. GUILIB= user32.lib shell32.lib
  55. LINK = /link /incremental:no /libpath:$(MSVC)/lib /machine:IX86 \
  56. /subsystem:windows ws2_32.lib advapi32.lib cyassl.lib
  57. CYAFL = /c /I $(CYA)/include -I $(CYA)/include/openssl /I$(MSVC)/INCLUDE \
  58. /I $(CYA)/ctaocrypt/include /D _LIB /D OPENSSL_EXTRA
  59. CYASRC= \
  60. $(CYA)/src/cyassl_int.c \
  61. $(CYA)/src/cyassl_io.c \
  62. $(CYA)/src/keys.c \
  63. $(CYA)/src/tls.c \
  64. $(CYA)/src/ssl.c \
  65. $(CYA)/ctaocrypt/src/aes.c \
  66. $(CYA)/ctaocrypt/src/arc4.c \
  67. $(CYA)/ctaocrypt/src/asn.c \
  68. $(CYA)/ctaocrypt/src/coding.c \
  69. $(CYA)/ctaocrypt/src/ctc_asm.c \
  70. $(CYA)/ctaocrypt/src/ctc_misc.c \
  71. $(CYA)/ctaocrypt/src/cyassl_memory.c \
  72. $(CYA)/ctaocrypt/src/des3.c \
  73. $(CYA)/ctaocrypt/src/dh.c \
  74. $(CYA)/ctaocrypt/src/dsa.c \
  75. $(CYA)/ctaocrypt/src/ecc.c \
  76. $(CYA)/ctaocrypt/src/hc128.c \
  77. $(CYA)/ctaocrypt/src/hmac.c \
  78. $(CYA)/ctaocrypt/src/integer.c \
  79. $(CYA)/ctaocrypt/src/md4.c \
  80. $(CYA)/ctaocrypt/src/md5.c \
  81. $(CYA)/ctaocrypt/src/pwdbased.c \
  82. $(CYA)/ctaocrypt/src/rabbit.c \
  83. $(CYA)/ctaocrypt/src/random.c \
  84. $(CYA)/ctaocrypt/src/ripemd.c \
  85. $(CYA)/ctaocrypt/src/rsa.c \
  86. $(CYA)/ctaocrypt/src/sha.c \
  87. $(CYA)/ctaocrypt/src/sha256.c \
  88. $(CYA)/ctaocrypt/src/sha512.c \
  89. $(CYA)/ctaocrypt/src/tfm.c
  90. cyassl.lib:
  91. $(CL) $(CYASRC) $(CYAFL) $(DEF)
  92. $(MSVC)/bin/lib *.obj /out:$@
  93. windows: cyassl.lib
  94. $(MSVC)/bin/rc win32\res.rc
  95. $(CL) /I win32 main.c mongoose.c /GA $(LINK) win32\res.res \
  96. $(GUILIB) /out:$(PROG).exe
  97. $(CL) mongoose.c /GD $(LINK) /DLL /DEF:win32\dll.def /out:$(PROG).dll
  98. # Build for Windows under MinGW
  99. #MINGWDBG= -DDEBUG -O0 -ggdb
  100. MINGWDBG= -DNDEBUG -Os
  101. MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
  102. #MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,windows $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
  103. mingw:
  104. windres win32\res.rc win32\res.o
  105. $(CC) $(MINGWOPT) mongoose.c -lws2_32 \
  106. -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
  107. $(CC) $(MINGWOPT) -Iwin32 mongoose.c main.c win32\res.o -lws2_32 -ladvapi32 \
  108. -o $(PROG).exe
  109. ##########################################################################
  110. ### Manuals, cleanup, test, release
  111. ##########################################################################
  112. man:
  113. groff -man -T ascii mongoose.1 | col -b > mongoose.txt
  114. groff -man -T ascii mongoose.1 | less
  115. # "TEST=unit make test" - perform unit test only
  116. # "TEST=embedded" - test embedded API by building and testing test/embed.c
  117. # "TEST=basic_tests" - perform basic tests only (no CGI, SSI..)
  118. tests:
  119. perl test/test.pl $(TEST)
  120. release: clean
  121. 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
  122. clean:
  123. rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz $(PROG).exe *.dll *.lib