Makefile.in 25.2 KB
Newer Older
1 2 3 4
##
## Makefile for OpenSSL
##

U
Ulf Möller 已提交
5 6 7
VERSION=
MAJOR=
MINOR=
8 9 10 11
SHLIB_VERSION_NUMBER=
SHLIB_VERSION_HISTORY=
SHLIB_MAJOR=
SHLIB_MINOR=
12
SHLIB_EXT=
13
PLATFORM=dist
14
OPTIONS=
15
CONFIGURE_ARGS=
16 17
SHLIB_TARGET=

18 19 20 21 22
# HERE indicates where this Makefile lives.  This can be used to indicate
# where sub-Makefiles are expected to be.  Currently has very limited usage,
# and should probably not be bothered with at all.
HERE=.

23 24 25 26
# INSTALL_PREFIX is for package builders so that they can configure
# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
# Normally it is left empty.
INSTALL_PREFIX=
27 28
INSTALLTOP=/usr/local/ssl

F
Finn Hakansson 已提交
29
# Do not edit this manually. Use Configure --openssldir=DIR to change this!
30
OPENSSLDIR=/usr/local/ssl
31

32 33 34 35
# NO_IDEA - Define to build without the IDEA algorithm
# NO_RC4  - Define to build without the RC4 algorithm
# NO_RC2  - Define to build without the RC2 algorithm
# THREADS - Define when building with threads, you will probably also need any
36
#           system defines as well, i.e. _REENTRANT for Solaris 2.[34]
37 38 39 40
# TERMIO  - Define the termio terminal subsystem, needed if sgtty is missing.
# TERMIOS - Define the termios terminal subsystem, Silicon Graphics.
# LONGCRYPT - Define to use HPUX 10.x's long password modification to crypt(3).
# DEVRANDOM - Give this the value of the 'random device' if your OS supports
41 42
#           one.  32 bytes will be read from this when the random
#           number generator is initalised.
43
# SSL_FORBID_ENULL - define if you want the server to be not able to use the
44
#           NULL encryption ciphers.
45 46 47
#
# LOCK_DEBUG - turns on lots of lock debug output :-)
# REF_CHECK - turn on some xyz_free() assertions.
48
# REF_PRINT - prints some stuff on structure free.
49
# MFUNC - Make all Malloc/Free/Realloc calls call
50 51 52 53 54
#       CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
#       call application defined callbacks via CRYPTO_set_mem_functions()
# MD5_ASM needs to be defined to use the x86 assembler for MD5
# SHA1_ASM needs to be defined to use the x86 assembler for SHA1
# RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160
55 56 57
# Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8.  It must
# equal 4.
# PKCS1_CHECK - pkcs1 tests.
58

59 60
CC= cc
CFLAG= -O
61
DEPFLAG= 
62
PEX_LIBS= 
63
EX_LIBS= 
64
EXE_EXT= 
65 66
ARFLAGS=
AR=ar $(ARFLAGS) r
67
RANLIB= ranlib
68
NM= nm
69
PERL= perl
R
Rich Salz 已提交
70 71
#RM= echo --
RM= rm -f
72
TAR= tar
R
Richard Levitte 已提交
73
TARFLAGS= --no-recursion
74
MAKEDEPPROG=makedepend
D
Dr. Stephen Henson 已提交
75
LIBDIR=lib
76

77 78 79 80 81
# We let the C compiler driver to take care of .s files. This is done in
# order to be excused from maintaining a separate set of architecture
# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
# gcc, then the driver will automatically translate it to -xarch=v8plus
# and pass it down to assembler.
82
AS=$(CC) -c
83
ASFLAG=$(CFLAG)
84

85 86 87 88 89 90
# For x86 assembler: Set PROCESSOR to 386 if you want to support
# the 80386.
PROCESSOR=

# CPUID module collects small commonly used assembler snippets
CPUID_OBJ= 
91
BN_ASM= bn_asm.o
92
EC_ASM=
93
DES_ENC= des_enc.o fcrypt_b.o
A
Andy Polyakov 已提交
94
AES_ENC= aes_core.o aes_cbc.o
95 96 97 98 99 100 101
BF_ENC= bf_enc.o
CAST_ENC= c_enc.o
RC4_ENC= rc4_enc.o
RC5_ENC= rc5_enc.o
MD5_ASM_OBJ= 
SHA1_ASM_OBJ= 
RMD160_ASM_OBJ= 
102
WP_ASM_OBJ=
103
CMLL_ENC=
104
MODES_ASM_OBJ=
105
ENGINES_ASM_OBJ=
106 107
CHACHA_ENC= chacha_enc.o
POLY1305_ASM_OBJ=
A
Andy Polyakov 已提交
108
PERLASM_SCHEME=
109

D
Dr. Stephen Henson 已提交
110 111 112 113
# Zlib stuff
ZLIB_INCLUDE=
LIBZLIB=

114 115 116 117
# This is the location of fipscanister.o and friends.
# The FIPS module build will place it $(INSTALLTOP)/lib
# but since $(INSTALLTOP) can only take the default value
# when the module is built it will be in /usr/local/ssl/lib
D
typo  
Dr. Stephen Henson 已提交
118
# $(INSTALLTOP) for this build may be different so hard
119 120 121 122 123
# code the path.

FIPSLIBDIR=/usr/local/ssl/$(LIBDIR)/

# The location of the library which contains fipscanister.o
124 125
# normally it will be libcrypto. If not compiling in FIPS mode
# at all this is empty making it a useful test for a FIPS compile.
126 127 128 129 130 131 132 133

FIPSCANLIB=

# Shared library base address. Currently only used on Windows.
#

BASEADDR=

134
DIRS=   crypto ssl engines apps test tools
135
ENGDIRS= ccgost
U
Ulf Möller 已提交
136
SHLIBDIRS= crypto ssl
137
INSTALL_SUBS= engines apps tools
U
Ulf Möller 已提交
138

139 140
# dirs in crypto to build
SDIRS=  \
141
	objects \
142 143
	md2 md4 md5 sha mdc2 hmac ripemd whrlpool poly1305 \
	des aes rc2 rc4 rc5 idea bf cast camellia seed chacha modes \
D
Dr. Stephen Henson 已提交
144
	bn ec rsa dsa dh dso engine \
145
	buffer bio stack lhash rand err \
146
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui \
M
Matt Caswell 已提交
147
	cms pqueue ts jpake srp store cmac ct async
A
Andy Polyakov 已提交
148 149
# keep in mind that the above list is adjusted by ./Configure
# according to no-xxx arguments...
150

151 152 153 154
# tests to perform.  "alltests" is a special word indicating that all tests
# should be performed.
TESTS = alltests

B
Ben Laurie 已提交
155
MAKEFILE= Makefile
156

157
MANDIR=$(OPENSSLDIR)/man
158 159
MAN1=1
MAN3=3
160
MANSUFFIX=
U
Ulf Möller 已提交
161 162
HTMLSUFFIX=html
HTMLDIR=$(OPENSSLDIR)/html
163 164
SHELL=/bin/sh

165
TOP=    .
166
LIBS=   libcrypto.a libssl.a
167 168 169 170
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
SHARED_SSL=libssl$(SHLIB_EXT)
SHARED_LIBS=
SHARED_LIBS_LINK_EXTS=
171
SHARED_LDFLAGS=
172 173

GENERAL=        Makefile
R
Ralf S. Engelschall 已提交
174
BASENAME=       openssl
175
NAME=           $(BASENAME)-$(VERSION)
R
Richard Levitte 已提交
176
TARFILE=        ../$(NAME).tar
177
HEADER=         e_os.h
178

R
Rich Salz 已提交
179 180 181 182 183 184 185 186 187 188 189
# Directories created on install if they don't exist.
INSTALLDIRS=	\
		$(INSTALL_PREFIX)$(INSTALLTOP)/bin \
		$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
		$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
		$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
		$(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
		$(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
		$(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
		$(INSTALL_PREFIX)$(OPENSSLDIR)/private

190
all: Makefile build_all
191

A
Andy Polyakov 已提交
192
# as we stick to -e, CLEARENV ensures that local variables in lower
193 194 195 196 197
# Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
# shell, which [annoyingly enough] terminates unset with error if VAR
# is not present:-( TOP= && unset TOP is tribute to HP-UX /bin/sh,
# which terminates unset with error if no variable was present:-(
CLEARENV=	TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS}	\
A
Andy Polyakov 已提交
198 199 200
		$${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}	\
		$${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}		\
		$${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL}	\
201
		$${HEADER+HEADER}				\
A
Andy Polyakov 已提交
202 203
		$${GENERAL+GENERAL} $${CFLAGS+CFLAGS}		\
		$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}		\
204
		$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS}	\
A
Andy Polyakov 已提交
205
		$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}	\
A
Andy Polyakov 已提交
206 207
		$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}

208 209 210
# LC_ALL=C ensures that error [and other] messages are delivered in
# same language for uniform treatment.
BUILDENV=	LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
211
		CC='$(CC)' CFLAG='$(CFLAG)' 			\
212
		AS='$(CC)' ASFLAG='$(CFLAG) -c'			\
213
		AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'	\
214
		CROSS_COMPILE='$(CROSS_COMPILE)'	\
215
		PERL='$(PERL)' ENGDIRS='$(ENGDIRS)'		\
D
Dr. Stephen Henson 已提交
216
		SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'	\
217 218
		INSTALL_PREFIX='$(INSTALL_PREFIX)'		\
		INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'	\
D
Dr. Stephen Henson 已提交
219
		LIBDIR='$(LIBDIR)'				\
220
		MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
221
		DEPFLAG='$(DEPFLAG)'                    	\
222 223
		MAKEDEPPROG='$(MAKEDEPPROG)'			\
		SHARED_LDFLAGS='$(SHARED_LDFLAGS)'		\
D
Dr. Stephen Henson 已提交
224
		ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'	\
225 226 227
		EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'	\
		SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)'	\
		PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)'	\
228
		CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'	\
R
Rich Salz 已提交
229
		EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'		\
230 231 232 233 234 235 236
		AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'	\
		BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)'	\
		RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)'	\
		SHA1_ASM_OBJ='$(SHA1_ASM_OBJ)'			\
		MD5_ASM_OBJ='$(MD5_ASM_OBJ)'			\
		RMD160_ASM_OBJ='$(RMD160_ASM_OBJ)'		\
		WP_ASM_OBJ='$(WP_ASM_OBJ)'			\
237
		MODES_ASM_OBJ='$(MODES_ASM_OBJ)'		\
238
		ENGINES_ASM_OBJ='$(ENGINES_ASM_OBJ)'		\
239 240
		CHACHA_ENC='$(CHACHA_ENC)'			\
		POLY1305_ASM_OBJ='$(POLY1305_ASM_OBJ)'		\
241
		PERLASM_SCHEME='$(PERLASM_SCHEME)'		\
242 243
		FIPSLIBDIR='${FIPSLIBDIR}'			\
		FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"	\
A
Andy Polyakov 已提交
244 245 246
		THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
# MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
# which in turn eliminates ambiguities in variable treatment with -e.
247

R
Richard Levitte 已提交
248 249 250 251 252 253 254 255 256
# BUILD_CMD is a generic macro to build a given target in a given
# subdirectory.  The target must be given through the shell variable
# `target' and the subdirectory to build in must be given through `dir'.
# This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
# BUILD_ONE_CMD instead.
#
# RECURSIVE_BUILD_CMD is a macro to build a given target in all
# subdirectories defined in $(DIRS).  It requires that the target
# is given through the shell variable `target'.
R
Rich Salz 已提交
257 258 259 260
#
# BUILD_ONE_CMD is a macro to build a given target in a given
# subdirectory if that subdirectory is part of $(DIRS).  It requires
# exactly the same shell variables as BUILD_CMD.
A
Andy Polyakov 已提交
261 262 263 264 265 266
BUILD_CMD=  if [ -d "$$dir" ]; then \
	    (	cd $$dir && echo "making $$target in $$dir..." && \
		$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
	    ) || exit 1; \
	    fi
RECURSIVE_BUILD_CMD=for dir in $(DIRS); do $(BUILD_CMD); done
267
BUILD_ONE_CMD=\
268
	if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
269 270
		$(BUILD_CMD); \
	fi
271

272
reflect:
A
Andy Polyakov 已提交
273
	@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
274

275
sub_all: build_all
276

277 278
build_all: build_libs build_apps build_tests build_tools

279 280 281 282
build_libs: build_libcrypto build_libssl openssl.pc

build_libcrypto: build_crypto build_engines libcrypto.pc
build_libssl: build_ssl libssl.pc
283 284

build_crypto:
285
	@dir=crypto; target=all; $(BUILD_ONE_CMD)
286
build_ssl: build_crypto
287
	@dir=ssl; target=all; $(BUILD_ONE_CMD)
288
build_engines: build_crypto
289
	@dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
290 291

build_apps: build_libs
292
	@dir=apps; target=all; $(BUILD_ONE_CMD)
293
build_tests: build_libs
294
	@dir=test; target=all; $(BUILD_ONE_CMD)
295
build_tools: build_libs
296
	@dir=tools; target=all; $(BUILD_ONE_CMD)
297 298 299

all_testapps: build_libs build_testapps
build_testapps:
300
	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
301

302
libcrypto$(SHLIB_EXT): libcrypto.a
303
	@if [ "$(SHLIB_TARGET)" != "" ]; then \
D
Dr. Stephen Henson 已提交
304 305 306 307
		if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
			FIPSLD_CC="$(CC)"; CC=fips/fipsld; \
			export CC FIPSLD_CC; \
		fi; \
308
		$(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
309 310
	else \
		echo "There's no support for shared libraries on this platform" >&2; \
311
		exit 1; \
312
	fi
313

314
libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
315
	@if [ "$(SHLIB_TARGET)" != "" ]; then \
316
		$(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
317 318
	else \
		echo "There's no support for shared libraries on this platform" >&2; \
319
		exit 1; \
320
	fi
321 322

clean-shared:
323
	@set -e; for i in $(SHLIBDIRS); do \
324 325 326 327 328 329 330
		if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
			tmp="$(SHARED_LIBS_LINK_EXTS)"; \
			for j in $${tmp:-x}; do \
				( set -x; rm -f lib$$i$$j ); \
			done; \
		fi; \
		( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
A
Andy Polyakov 已提交
331
		if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
332 333
			( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
		fi; \
334
	done
335

336
link-shared:
337
	@ set -e; for i in $(SHLIBDIRS); do \
338
		$(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
339 340
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
341
			symlink.$(SHLIB_TARGET); \
342
		libs="$$libs -l$$i"; \
343 344
	done

345 346 347
build-shared: do_$(SHLIB_TARGET) link-shared

do_$(SHLIB_TARGET):
348
	@ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
A
Andy Polyakov 已提交
349
		$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
350 351
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
352 353
			LIBDEPS="$$libs $(EX_LIBS)" \
			link_a.$(SHLIB_TARGET); \
354
		libs="-l$$i $$libs"; \
355 356
	done

357 358 359
libcrypto.pc: Makefile
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
360
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
361 362 363 364 365 366
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
	    echo 'Name: OpenSSL-libcrypto'; \
	    echo 'Description: OpenSSL cryptography library'; \
	    echo 'Version: '$(VERSION); \
	    echo 'Requires: '; \
D
Dr. Stephen Henson 已提交
367 368
	    echo 'Libs: -L$${libdir} -lcrypto'; \
	    echo 'Libs.private: $(EX_LIBS)'; \
369
	    echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
370 371 372 373

libssl.pc: Makefile
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
374
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
375 376
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
377
	    echo 'Name: OpenSSL-libssl'; \
378 379
	    echo 'Description: Secure Sockets Layer and cryptography libraries'; \
	    echo 'Version: '$(VERSION); \
380 381
	    echo 'Requires.private: libcrypto'; \
	    echo 'Libs: -L$${libdir} -lssl'; \
D
Dr. Stephen Henson 已提交
382
	    echo 'Libs.private: $(EX_LIBS)'; \
383
	    echo 'Cflags: -I$${includedir}' ) > libssl.pc
384

B
Ben Laurie 已提交
385
openssl.pc: Makefile
386 387
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
388
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
389 390 391 392 393
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
	    echo 'Name: OpenSSL'; \
	    echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
	    echo 'Version: '$(VERSION); \
394
	    echo 'Requires: libssl libcrypto' ) > openssl.pc
395

R
Rich Salz 已提交
396 397
Makefile: Makefile.in Configure config
	@echo "Makefile is older than Makefile.in, Configure or config."
398
	@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
399 400
	@false

401
libclean:
402
	rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
403

404
clean:	libclean
B
Ben Laurie 已提交
405
	rm -f */*/*.o */*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
R
Rich Salz 已提交
406
	rm -rf *.bak certs/.0
A
Andy Polyakov 已提交
407
	@set -e; target=clean; $(RECURSIVE_BUILD_CMD)
408
	rm -f $(LIBS) tags TAGS
409
	rm -f openssl.pc libssl.pc libcrypto.pc
410
	rm -f speed.* .pure
411
	rm -f $(TARFILE)
412 413

makefile.one: files
414
	$(PERL) util/mk1mf.pl >makefile.one; \
415 416
	sh util/do_ms.sh

U
Ulf Möller 已提交
417
files:
B
Ben Laurie 已提交
418
	$(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
A
Andy Polyakov 已提交
419
	@set -e; target=files; $(RECURSIVE_BUILD_CMD)
420

421 422
gentests:
	@(cd test && echo "generating dummy tests (if needed)..." && \
423
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
424

425
rehash: rehash.time
426
rehash.time: certs build_apps
427
	@if [ -z "$(CROSS_COMPILE)" ]; then \
428 429
		(OPENSSL="`pwd`/util/opensslwrap.sh"; \
		[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
R
Rich Salz 已提交
430 431
		OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
		export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
432 433
		$$OPENSSL rehash certs/demo \
		|| $(PERL) tools/c_rehash certs/demo) && \
434 435 436
		touch rehash.time; \
	else :; fi

437
test:   tests
438

R
Rich Salz 已提交
439
test_ordinals:
440
	TOP=$(TOP) PERL=$(PERL) $(PERL) test/run_tests.pl test_ordinals
R
Rich Salz 已提交
441

442
tests: rehash
443
	@(cd test && echo "testing..." && \
D
Dr. Stephen Henson 已提交
444
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
445 446 447
	@if [ -z "$(CROSS_COMPILE)" ]; then \
		OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \
	fi
448

449 450 451 452
list-tests:
	@(cd test && \
	        $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)

453 454 455
report:
	@$(PERL) util/selftest.pl

456
update: errors util/libeay.num util/ssleay.num TABLE test_ordinals
457 458
	@set -e; target=update; $(RECURSIVE_BUILD_CMD)

459
depend:
A
Andy Polyakov 已提交
460
	@set -e; target=depend; $(RECURSIVE_BUILD_CMD)
461

462 463 464
tags TAGS: FORCE
	rm -f TAGS tags
	-ctags -R .
465
	-etags `find . -name '*.[ch]' -o -name '*.pm'`
466 467

FORCE:
468 469

errors:
470
	$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
471
	$(PERL) util/mkerr.pl -recurse -write
472
	(cd engines; $(MAKE) PERL=$(PERL) errors)
473
	(cd crypto/ct; $(MAKE) PERL=$(PERL) errors)
474

475
util/libeay.num::
476
	$(PERL) util/mkdef.pl crypto update
477 478

util/ssleay.num::
479
	$(PERL) util/mkdef.pl ssl update
480

481
TABLE: Configure Configurations/*.conf
B
Bodo Möller 已提交
482
	(echo 'Output of `Configure TABLE'"':"; \
483
	$(PERL) Configure TABLE) > TABLE
484

485 486 487 488 489
# Build distribution tar-file. As the list of files returned by "find" is
# pretty long, on several platforms a "too many arguments" error or similar
# would occur. Therefore the list of files is temporarily stored into a file
# and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
# tar does not support the --files-from option.
R
Richard Levitte 已提交
490
TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
491
	                       --owner 0 --group 0 \
R
Richard Levitte 已提交
492
			       --transform 's|^|$(NAME)/|' \
R
Richard Levitte 已提交
493 494
			       -cvf -

R
Richard Levitte 已提交
495
$(TARFILE).list:
R
Richard Levitte 已提交
496 497
	find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \
	       \! -name '*.so' \! -name '*.so.*'  \! -name 'openssl' \
498
	       \! -name '*test' \! -name '.#*' \! -name '*~' \!	-type l \
R
Richard Levitte 已提交
499
	    | sort > $(TARFILE).list
R
Richard Levitte 已提交
500

R
Richard Levitte 已提交
501
tar: $(TARFILE).list
502 503 504
	find . -type d -print | xargs chmod 755
	find . -type f -print | xargs chmod a+r
	find . -type f -perm -0100 -print | xargs chmod a+x
R
Richard Levitte 已提交
505 506 507
	$(TAR_COMMAND) | gzip --best > $(TARFILE).gz
	rm -f $(TARFILE).list
	ls -l $(TARFILE).gz
508

R
Richard Levitte 已提交
509 510 511 512
tar-snap: $(TARFILE).list
	$(TAR_COMMAND) > $(TARFILE)
	rm -f $(TARFILE).list
	ls -l $(TARFILE)
513

514
dist:   
515
	$(PERL) Configure dist
516
	@$(MAKE) SDIRS='$(SDIRS)' clean
517
	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
518

519 520
install: all install_docs install_sw

R
Rich Salz 已提交
521 522
uninstall: uninstall_sw uninstall_docs

523
install_sw:
R
Rich Salz 已提交
524
	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
525 526 527
	@set -e; for i in include/openssl/*.h; do \
	(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$$i; \
	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$$i ); \
B
Bodo Möller 已提交
528
	done;
529
	@set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
530
	@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
531
	do \
532 533
		if [ -f "$$i" ]; then \
		(       echo installing $$i; \
D
Dr. Stephen Henson 已提交
534 535 536 537
			cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
			$(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
			chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
			mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
L
Lutz Jänicke 已提交
538 539
		fi; \
	done;
540
	@set -e; if [ -n "$(SHARED_LIBS)" ]; then \
541 542 543
		tmp="$(SHARED_LIBS)"; \
		for i in $${tmp:-x}; \
		do \
544
			if [ -f "$$i" -o -f "$$i.a" ]; then \
545
			(       echo installing $$i; \
546
				if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
547
					c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
548 549
					cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
					chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
550
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
D
Dr. Stephen Henson 已提交
551 552 553
					cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
554 555 556 557
				else \
					cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
558
				fi ); \
559 560 561 562 563 564
				if expr $(PLATFORM) : 'mingw' > /dev/null; then \
				(	case $$i in \
						*crypto*) i=libeay32.dll;; \
						*ssl*)    i=ssleay32.dll;; \
					esac; \
					echo installing $$i; \
R
Rich Salz 已提交
565 566 567
					cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
					chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
568
				fi; \
L
Lutz Jänicke 已提交
569
			fi; \
570 571
		done; \
		(	here="`pwd`"; \
D
Dr. Stephen Henson 已提交
572
			cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
573
			$(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
574 575 576 577
		if [ "$(INSTALLTOP)" != "/usr" ]; then \
			echo 'OpenSSL shared libraries have been installed in:'; \
			echo '  $(INSTALLTOP)'; \
		fi; \
578
	fi
D
Dr. Stephen Henson 已提交
579 580 581 582 583 584
	cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
	cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
	cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
585

R
Rich Salz 已提交
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
uninstall_sw:
	cd include/openssl && files=* && cd $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl && $(RM) $$files
	@for i in $(LIBS) ;\
	do \
		test -f "$$i" && \
		echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i && \
		$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
	done;
	@if [ -n "$(SHARED_LIBS)" ]; then \
		tmp="$(SHARED_LIBS)"; \
		for i in $${tmp:-x}; \
		do \
			if [ -f "$$i" -o -f "$$i.a" ]; then \
				if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
					c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
					echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
					$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
					echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
					$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
				else \
					echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
					$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
				fi; \
				if expr $(PLATFORM) : 'mingw' > /dev/null; then \
					case $$i in \
						*crypto*) i=libeay32.dll;; \
						*ssl*)    i=ssleay32.dll;; \
					esac; \
					echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
					$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
				fi; \
			fi; \
		done; \
	fi
	$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
	$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
	$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
	@target=uninstall; $(RECURSIVE_BUILD_CMD)

U
Ulf Möller 已提交
625 626
install_html_docs:
	here="`pwd`"; \
627
	filecase=; \
628
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
629 630
		filecase=-i; \
	esac; \
U
Ulf Möller 已提交
631
	for subdir in apps crypto ssl; do \
R
Rich Salz 已提交
632
		$(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
U
Ulf Möller 已提交
633 634 635 636 637
		for i in doc/$$subdir/*.pod; do \
			fn=`basename $$i .pod`; \
			echo "installing html/$$fn.$(HTMLSUFFIX)"; \
			cat $$i \
			| sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
638
			| pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
U
Ulf Möller 已提交
639 640 641 642 643 644
			| sed -r 's/<!DOCTYPE.*//g' \
			> $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
			$(PERL) util/extract-names.pl < $$i | \
				grep -v $$filecase "^$$fn\$$" | \
				(cd $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
				 while read n; do \
D
Dr. Stephen Henson 已提交
645
					PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
U
Ulf Möller 已提交
646 647 648 649
				 done); \
		done; \
	done

R
Rich Salz 已提交
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
uninstall_html_docs:
	here="`pwd`"; \
	filecase=; \
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
		filecase=-i; \
	esac; \
	for subdir in apps crypto ssl; do \
		for i in doc/$$subdir/*.pod; do \
			fn=`basename $$i .pod`; \
			$(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
			$(PERL) util/extract-names.pl < $$i | \
				grep -v $$filecase "^$$fn\$$" | \
				while read n; do \
					$(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
				done; \
		done; \
	done

668 669
install_docs:
	@$(PERL) $(TOP)/util/mkdir-p.pl \
670 671 672 673
		$(INSTALL_PREFIX)$(MANDIR)/man1 \
		$(INSTALL_PREFIX)$(MANDIR)/man3 \
		$(INSTALL_PREFIX)$(MANDIR)/man5 \
		$(INSTALL_PREFIX)$(MANDIR)/man7
674 675
	here="`pwd`"; \
	filecase=; \
676
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
677
		filecase=-i; \
A
Andy Polyakov 已提交
678
	esac; \
679
	set -e; for i in doc/apps/*.pod; do \
680
		fn=`basename $$i .pod`; \
681
		sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
682
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
683
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
684
		pod2man \
685
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
686
			--release=$(VERSION) `basename $$i`) \
687
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
688
		$(PERL) util/extract-names.pl < $$i | \
689 690
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
691 692
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
			 while read n; do \
D
Dr. Stephen Henson 已提交
693
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
694
			 done); \
695
	done; \
696
	set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
697
		fn=`basename $$i .pod`; \
698
		sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
699
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
700
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
701
		pod2man \
702
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
703
			--release=$(VERSION) `basename $$i`) \
704
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
705
		$(PERL) util/extract-names.pl < $$i | \
706 707
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
708 709
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
			 while read n; do \
D
Dr. Stephen Henson 已提交
710
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
711
			 done); \
712
	done
713

R
Rich Salz 已提交
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
uninstall_docs:
	@here="`pwd`"; \
	filecase=; \
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
		filecase=-i; \
	esac; \
	for i in doc/apps/*.pod; do \
		fn=`basename $$i .pod`; \
		sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
		echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
		$(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
		$(PERL) util/extract-names.pl < $$i | \
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
			while read n; do \
				echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
				$(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
			done; \
	done; \
	for i in doc/crypto/*.pod doc/ssl/*.pod; do \
		fn=`basename $$i .pod`; \
		sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
		echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
		$(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
		$(PERL) util/extract-names.pl < $$i | \
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
			while read n; do \
				echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
				$(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
			done; \
	done

747
# DO NOT DELETE THIS LINE -- make depend depends on it.