Makefile 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. # -DNO_SSI - disable SSI support (-4kb)
  14. # -DHAVE_STRTOUI64 - use system strtoui64() function for strtoull()
  15. ##########################################################################
  16. ### UNIX build: linux, bsd, mac, rtems
  17. ##########################################################################
  18. CFLAGS= -W -Wall -std=c99 -pedantic -Os -fomit-frame-pointer $(COPT)
  19. MAC_SHARED= -flat_namespace -bundle -undefined suppress
  20. LINFLAGS= -D_POSIX_SOURCE -D_BSD_SOURCE -D_FILE_OFFSET_BITS=64 \
  21. -D_LARGEFILE_SOURCE -ldl -lpthread $(CFLAGS)
  22. LIB= _$(PROG).so
  23. linux:
  24. $(CC) $(LINFLAGS) mongoose.c -shared -fPIC -fpic -s -o $(LIB)
  25. $(CC) $(LINFLAGS) mongoose.c main.c -s -o $(PROG)
  26. bsd:
  27. $(CC) $(CFLAGS) mongoose.c -shared -lpthread -s -fpic -fPIC -o $(LIB)
  28. $(CC) $(CFLAGS) mongoose.c main.c -lpthread -s -o $(PROG)
  29. mac:
  30. $(CC) $(CFLAGS) $(MAC_SHARED) mongoose.c -lpthread -o $(LIB)
  31. $(CC) $(CFLAGS) mongoose.c main.c -lpthread -o $(PROG)
  32. solaris:
  33. gcc $(CFLAGS) mongoose.c -lpthread -lnsl \
  34. -lsocket -s -fpic -fPIC -shared -o $(LIB)
  35. gcc $(CFLAGS) mongoose.c main.c -lpthread -lnsl -lsocket -s -o $(PROG)
  36. ##########################################################################
  37. ### WINDOWS build: Using Visual Studio or Mingw
  38. ##########################################################################
  39. # Using Visual Studio Express
  40. # 1. Download and install Visual Studio Express 2008 to c:\msvc8
  41. # 2. Download and install Windows SDK to c:\sdk
  42. # 3. Go to c:\msvc8\vc\bin and start "VIsual Studio 2008 Command prompt"
  43. # (or Itanium/amd64 command promt to build x64 version)
  44. # 4. In the command prompt, go to mongoose directory and do "nmake windows"
  45. #WINDBG= /Zi /DDEBUG /Od /DDEBUG
  46. WINDBG= /DNDEBUG /Os
  47. WINFLAGS= /MT /TC /nologo /W4 $(WINDBG)
  48. windows:
  49. cl $(WINFLAGS) mongoose.c /link /incremental:no /DLL \
  50. /DEF:win32\dll.def /out:_$(PROG).dll ws2_32.lib
  51. cl $(WINFLAGS) mongoose.c main.c /link /incremental:no \
  52. /out:$(PROG).exe ws2_32.lib
  53. # Build for Windows under MinGW
  54. #MINGWDBG= -DDEBUG -O0
  55. MINGWDBG= -DNDEBUG -Os
  56. MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT
  57. mingw:
  58. gcc $(MINGWOPT) mongoose.c -lws2_32 \
  59. -shared -Wl,--out-implib=$(PROG).lib -o _$(PROG).dll
  60. gcc $(MINGWOPT) mongoose.c main.c -lws2_32 -ladvapi32 -o $(PROG).exe
  61. ##########################################################################
  62. ### Manuals, cleanup, test, release
  63. ##########################################################################
  64. man:
  65. cat mongoose.1 | tbl | groff -man -Tascii | col -b > mongoose.1.txt
  66. cat mongoose.1 | tbl | groff -man -Tascii | less
  67. # "TEST=unit make test" - perform unit test only
  68. # "TEST=embedded" - test embedded API by building and testing test/embed.c
  69. # "TEST=basic_tests" - perform basic tests only (no CGI, SSI..)
  70. test: do_test
  71. do_test:
  72. perl test/test.pl $(TEST)
  73. release: clean
  74. F=mongoose-`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' mongoose.c`.tgz ; cd .. && tar --exclude \*.svn --exclude \*.swp --exclude \*.nfs\* --exclude win32 -czf x mongoose && mv x mongoose/$$F
  75. clean:
  76. rm -rf *.o *.core $(PROG) *.obj $(PROG).1.txt *.dSYM *.tgz