Makefile 4.8 KB

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