2010-05-03 21:46:42 +01:00
# This file is part of Mongoose project, http://code.google.com/p/mongoose
# $Id: Makefile 473 2009-09-02 11:20:06Z valenok $
PROG = mongoose
all :
@echo "make (linux|bsd|solaris|mac|windows|mingw)"
# Possible COPT values: (in brackets are rough numbers for 'gcc -O2' on i386)
2012-08-19 12:22:28 +01:00
# -DHAVE_MD5 - use system md5 library (-2kb)
# -DNDEBUG - strip off all debug code (-5kb)
# -DDEBUG - build debug version (very noisy) (+7kb)
# -DNO_CGI - disable CGI support (-5kb)
# -DNO_SSL - disable SSL functionality (-2kb)
# -DCONFIG_FILE=\"file\" - use `file' as the default config file
# -DHAVE_STRTOUI64 - use system strtoui64() function for strtoull()
# -DSSL_LIB=\"libssl.so.<version>\" - use system versioned SSL shared object
2010-11-29 14:46:42 +01:00
# -DCRYPTO_LIB=\"libcrypto.so.<version>\" - use system versioned CRYPTO so
2010-05-03 21:46:42 +01:00
##########################################################################
### UNIX build: linux, bsd, mac, rtems
##########################################################################
2012-08-25 22:02:51 +01:00
GCC_WARNS = -W -Wall -pedantic
# -Wno-missing-field-initializers -Wno-unused-parameter -Wno-format-zero-length -Wno-missing-braces
2012-09-13 19:39:02 +03:00
CFLAGS = -std= c99 -O2 $( GCC_WARNS) $( COPT)
2012-08-19 12:22:28 +01:00
MAC_SHARED = -flat_namespace -bundle -undefined suppress
LINFLAGS = -ldl -pthread $( CFLAGS)
LIB = _$( PROG) .so
CC = gcc
2010-05-03 21:46:42 +01:00
2010-12-01 09:25:12 +00:00
# Make sure that the compiler flags come last in the compilation string.
# If not so, this can break some on some Linux distros which use
# "-Wl,--as-needed" turned on by default in cc command.
# Also, this is turned in many other distros in static linkage builds.
2010-05-03 21:46:42 +01:00
linux :
2010-12-01 09:25:12 +00:00
$( CC) mongoose.c -shared -fPIC -fpic -o $( LIB) $( LINFLAGS)
$( CC) mongoose.c main.c -o $( PROG) $( LINFLAGS)
2010-05-03 21:46:42 +01:00
bsd :
2010-12-01 09:25:12 +00:00
$( CC) mongoose.c -shared -pthread -fpic -fPIC -o $( LIB) $( CFLAGS)
$( CC) mongoose.c main.c -pthread -o $( PROG) $( CFLAGS)
2010-05-03 21:46:42 +01:00
mac :
2010-12-01 09:25:12 +00:00
$( CC) mongoose.c -pthread -o $( LIB) $( MAC_SHARED) $( CFLAGS)
$( CC) mongoose.c main.c -pthread -o $( PROG) $( CFLAGS)
2010-05-03 21:46:42 +01:00
solaris :
2012-08-19 12:22:28 +01:00
$( CC) mongoose.c -pthread -lnsl \
2010-12-01 09:25:12 +00:00
-lsocket -fpic -fPIC -shared -o $( LIB) $( CFLAGS)
2012-08-19 12:22:28 +01:00
$( CC) mongoose.c main.c -pthread -lnsl -lsocket -o $( PROG) $( CFLAGS)
2010-05-03 21:46:42 +01:00
##########################################################################
### WINDOWS build: Using Visual Studio or Mingw
##########################################################################
2010-08-28 18:05:21 +01:00
# Using Visual Studio 6.0. To build Mongoose:
# o Set VC variable below to where VS 6.0 is installed on your system
# o Run "PATH_TO_VC6\bin\nmake windows"
2010-05-03 21:46:42 +01:00
2012-08-19 12:22:28 +01:00
VC = z:
CYA = y:
#DBG = /Zi /DDEBUG /Od
DBG = /DNDEBUG /O1
CL = cl /MD /TC /nologo $( DBG) /Gz /W3 /DNO_SSL_DL
GUILIB = user32.lib shell32.lib
LINK = /link /incremental:no /libpath:$( VC) \l ib /subsystem:windows \
ws2_32.lib advapi32.lib cyassl.lib
2011-07-21 21:50:18 +01:00
CYAFL = /c /I $( CYA) /include -I $( CYA) /include/openssl \
/I $( CYA) /ctaocrypt/include /D _LIB /D OPENSSL_EXTRA
2010-09-07 21:06:06 +01:00
2011-07-21 22:02:40 +01:00
CYASRC = \
$( CYA) /src/cyassl_int.c \
2010-09-07 21:06:06 +01:00
$( CYA) /src/cyassl_io.c \
$( CYA) /src/keys.c \
$( CYA) /src/tls.c \
2011-07-21 21:50:18 +01:00
$( CYA) /src/ssl.c \
2010-09-07 21:06:06 +01:00
$( CYA) /ctaocrypt/src/aes.c \
$( CYA) /ctaocrypt/src/arc4.c \
$( CYA) /ctaocrypt/src/asn.c \
2011-07-21 21:50:18 +01:00
$( CYA) /ctaocrypt/src/coding.c \
$( CYA) /ctaocrypt/src/ctc_asm.c \
$( CYA) /ctaocrypt/src/ctc_misc.c \
$( CYA) /ctaocrypt/src/cyassl_memory.c \
2010-09-07 21:06:06 +01:00
$( CYA) /ctaocrypt/src/des3.c \
$( CYA) /ctaocrypt/src/dh.c \
$( CYA) /ctaocrypt/src/dsa.c \
2011-07-21 21:50:18 +01:00
$( CYA) /ctaocrypt/src/ecc.c \
2010-09-07 21:06:06 +01:00
$( CYA) /ctaocrypt/src/hc128.c \
$( CYA) /ctaocrypt/src/hmac.c \
$( CYA) /ctaocrypt/src/integer.c \
$( CYA) /ctaocrypt/src/md4.c \
$( CYA) /ctaocrypt/src/md5.c \
2011-07-21 21:50:18 +01:00
$( CYA) /ctaocrypt/src/pwdbased.c \
2010-09-07 21:06:06 +01:00
$( CYA) /ctaocrypt/src/rabbit.c \
$( CYA) /ctaocrypt/src/random.c \
$( CYA) /ctaocrypt/src/ripemd.c \
$( CYA) /ctaocrypt/src/rsa.c \
$( CYA) /ctaocrypt/src/sha.c \
2011-07-21 21:50:18 +01:00
$( CYA) /ctaocrypt/src/sha256.c \
$( CYA) /ctaocrypt/src/sha512.c \
$( CYA) /ctaocrypt/src/tfm.c
2010-09-07 21:06:06 +01:00
cyassl :
2011-07-21 21:50:18 +01:00
$( CL) $( CYASRC) $( CYAFL) $( DEF)
2010-09-07 21:06:06 +01:00
lib *.obj /out:cyassl.lib
2010-06-15 12:49:52 +03:00
2010-05-03 21:46:42 +01:00
windows :
2010-09-12 22:10:03 +01:00
rc win32\r es.rc
2012-08-19 12:22:28 +01:00
$( CL) /I win32 main.c mongoose.c /GA $( LINK) win32\r es.res \
2010-09-12 22:10:03 +01:00
$( GUILIB) /out:$( PROG) .exe
2010-09-07 21:12:05 +01:00
$( CL) mongoose.c /GD $( LINK) /DLL /DEF:win32\d ll.def /out:_$( PROG) .dll
2010-05-03 21:46:42 +01:00
# Build for Windows under MinGW
2012-08-19 12:22:28 +01:00
#MINGWDBG= -DDEBUG -O0 -ggdb
2010-05-03 21:46:42 +01:00
MINGWDBG = -DNDEBUG -Os
2012-09-13 19:39:02 +03:00
MINGWOPT = -W -Wall -mthreads -Wl,--subsystem,console $( MINGWDBG) -DHAVE_STDINT $( GCC_WARNINGS) $( COPT)
#MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,windows $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
2010-05-03 21:46:42 +01:00
mingw :
2010-09-17 22:40:19 +01:00
windres win32\r es.rc win32\r es.o
2012-08-19 12:22:28 +01:00
$( CC) $( MINGWOPT) mongoose.c -lws2_32 \
2010-05-03 21:46:42 +01:00
-shared -Wl,--out-implib= $( PROG) .lib -o _$( PROG) .dll
2012-08-19 12:22:28 +01:00
$( CC) $( MINGWOPT) -Iwin32 mongoose.c main.c win32\r es.o -lws2_32 -ladvapi32 \
2010-09-17 22:40:19 +01:00
-o $( PROG) .exe
2010-05-03 21:46:42 +01:00
##########################################################################
### Manuals, cleanup, test, release
##########################################################################
man :
2010-08-30 17:13:26 +01:00
groff -man -T ascii mongoose.1 | col -b > mongoose.txt
groff -man -T ascii mongoose.1 | less
2010-05-03 21:46:42 +01:00
# "TEST=unit make test" - perform unit test only
# "TEST=embedded" - test embedded API by building and testing test/embed.c
# "TEST=basic_tests" - perform basic tests only (no CGI, SSI..)
2012-08-19 12:22:28 +01:00
tests :
2010-05-03 21:46:42 +01:00
perl test/test.pl $( TEST)
release : clean
2012-08-17 21:37:48 +01:00
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
2010-05-03 21:46:42 +01:00
clean :
2012-08-19 12:22:28 +01:00
rm -rf *.o *.core $( PROG) *.obj *.so $( PROG) .txt *.dSYM *.tgz $( PROG) .exe *.dll *.lib