Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. ##########################################################################
  15. ### UNIX build: linux, bsd, mac, rtems
  16. ##########################################################################
  17. CFLAGS= -W -Wall -std=c99 -pedantic -Os -fomit-frame-pointer $(COPT)
  18. MAC_SHARED= -flat_namespace -bundle -undefined suppress
  19. SSLFLAGS= -lssl -lcrypto
  20. LINFLAGS= -ldl -pthread $(SSLFLAGS) $(CFLAGS)
  21. LIB= _$(PROG).so
  22. linux:
  23. $(CC) $(LINFLAGS) mongoose.c -shared -fPIC -fpic -o $(LIB)
  24. $(CC) $(LINFLAGS) mongoose.c main.c -o $(PROG)
  25. bsd:
  26. $(CC) $(CFLAGS) mongoose.c -shared -pthread -fpic -fPIC -o $(LIB)
  27. $(CC) $(CFLAGS) mongoose.c main.c -pthread $(SSLFLAGS) -o $(PROG)
  28. mac:
  29. $(CC) $(CFLAGS) $(MAC_SHARED) mongoose.c -pthread $(SSLFLAGS) -o $(LIB)
  30. $(CC) $(CFLAGS) mongoose.c main.c -pthread $(SSLFLAGS) -o $(PROG)
  31. solaris:
  32. gcc $(CFLAGS) mongoose.c -pthread -lnsl \
  33. -lsocket $(SSLFLAGS) -fpic -fPIC -shared -o $(LIB)
  34. gcc $(CFLAGS) mongoose.c main.c -pthread -lnsl -lsocket $(SSLFLAGS) \
  35. -o $(PROG)
  36. ##########################################################################
  37. ### WINDOWS build: Using Visual Studio or Mingw
  38. ##########################################################################
  39. # Using Visual Studio 6.0
  40. # Assuming that studio is installed in d:\vc6, change VC variable below to
  41. # the correct path on your system. Run "d:\vc6\bin\nmake windows"
  42. VC= q:\vc6
  43. OUT= c:\out
  44. #WINDBG= /Zi /DDEBUG /Od /DDEBUG
  45. WINDBG= /DNDEBUG #/Os
  46. CLFLAGS= /MD /TC /nologo /W4 /c $(WINDBG) /I $(VC)/include
  47. LINKFLAGS= /incremental:no /libpath:$(VC)\lib ws2_32.lib
  48. windows:
  49. $(VC)\bin\cl main.c $(CLFLAGS) /Fo$(OUT)\main.obj
  50. $(VC)\bin\cl mongoose.c $(CLFLAGS) /Fo$(OUT)\mongoose.obj
  51. $(VC)\bin\link $(OUT)\mongoose.obj $(LINKFLAGS) \
  52. /DLL /DEF:win32\dll.def /out:$(OUT)\_$(PROG).dll
  53. $(VC)\bin\link $(OUT)\main.obj $(OUT)\mongoose.obj $(LINKFLAGS) \
  54. /out:$(OUT)\$(PROG).exe
  55. # Build for Windows under MinGW
  56. #MINGWDBG= -DDEBUG -O0
  57. MINGWDBG= -DNDEBUG -Os
  58. MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT
  59. mingw:
  60. gcc $(MINGWOPT) mongoose.c -lws2_32 \
  61. -shared -Wl,--out-implib=$(PROG).lib -o _$(PROG).dll
  62. gcc $(MINGWOPT) mongoose.c main.c -lws2_32 -ladvapi32 -o $(PROG).exe
  63. ##########################################################################
  64. ### Manuals, cleanup, test, release
  65. ##########################################################################
  66. man:
  67. cat mongoose.1 | tbl | groff -man -Tascii | col -b > mongoose.1.txt
  68. cat mongoose.1 | tbl | groff -man -Tascii | less
  69. # "TEST=unit make test" - perform unit test only
  70. # "TEST=embedded" - test embedded API by building and testing test/embed.c
  71. # "TEST=basic_tests" - perform basic tests only (no CGI, SSI..)
  72. test: do_test
  73. do_test:
  74. perl test/test.pl $(TEST)
  75. release: clean
  76. 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
  77. clean:
  78. rm -rf *.o *.core $(PROG) *.obj $(PROG).1.txt *.dSYM *.tgz