Makefile.org 26.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 29 30
INSTALLTOP=/usr/local/ssl

# Do not edit this manually. Use Configure --openssldir=DIR do change this!
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. _REENTERANT 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 50
# CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff
# MFUNC - Make all Malloc/Free/Realloc calls call
51 52 53 54 55
#       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
56 57 58
# Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8.  It must
# equal 4.
# PKCS1_CHECK - pkcs1 tests.
59

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

78 79 80 81 82
# 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.
83
AS=$(CC) -c
84
ASFLAG=$(CFLAG)
85

86 87 88 89 90 91
# 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= 
92
BN_ASM= bn_asm.o
93
EC_ASM=
94
DES_ENC= des_enc.o fcrypt_b.o
A
Andy Polyakov 已提交
95
AES_ENC= aes_core.o aes_cbc.o
96 97 98 99 100 101 102
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= 
103
WP_ASM_OBJ=
104
CMLL_ENC=
105
MODES_ASM_OBJ=
106
ENGINES_ASM_OBJ=
A
Andy Polyakov 已提交
107
PERLASM_SCHEME=
108

109 110
# KRB5 stuff
KRB5_INCLUDES=
111
LIBKRB5=
112

D
Dr. Stephen Henson 已提交
113 114 115 116
# Zlib stuff
ZLIB_INCLUDE=
LIBZLIB=

117 118 119 120
# 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 已提交
121
# $(INSTALLTOP) for this build may be different so hard
122 123 124 125 126
# code the path.

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

# The location of the library which contains fipscanister.o
127 128
# 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.
129 130 131 132 133 134 135 136

FIPSCANLIB=

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

BASEADDR=

137
DIRS=   crypto ssl engines apps test tools
138
ENGDIRS= ccgost
U
Ulf Möller 已提交
139
SHLIBDIRS= crypto ssl
140
INSTALL_SUBS= engines apps tools
U
Ulf Möller 已提交
141

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

154 155 156 157
# tests to perform.  "alltests" is a special word indicating that all tests
# should be performed.
TESTS = alltests

B
Ben Laurie 已提交
158
MAKEFILE= Makefile
159

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

168
TOP=    .
169
ONEDIRS=out tmp
U
Ulf Möller 已提交
170
EDIRS=  times doc bugs util include certs ms shlib mt demos perl sf dep VMS
171
WDIRS=  windows
172
LIBS=   libcrypto.a libssl.a
173 174 175 176
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
SHARED_SSL=libssl$(SHLIB_EXT)
SHARED_LIBS=
SHARED_LIBS_LINK_EXTS=
177
SHARED_LDFLAGS=
178 179

GENERAL=        Makefile
R
Ralf S. Engelschall 已提交
180
BASENAME=       openssl
181 182 183
NAME=           $(BASENAME)-$(VERSION)
TARFILE=        $(NAME).tar
WTARFILE=       $(NAME)-win.tar
184
EXHEADER=       e_os2.h
185
HEADER=         e_os.h
186

R
Rich Salz 已提交
187 188 189 190 191 192 193 194 195 196 197
# 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

198
all: Makefile build_all openssl.pc libssl.pc libcrypto.pc
199

A
Andy Polyakov 已提交
200
# as we stick to -e, CLEARENV ensures that local variables in lower
201 202 203 204 205
# 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 已提交
206 207 208 209 210 211
		$${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}	\
		$${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}		\
		$${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL}	\
		$${EXHEADER+EXHEADER} $${HEADER+HEADER}		\
		$${GENERAL+GENERAL} $${CFLAGS+CFLAGS}		\
		$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}		\
212
		$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS}	\
A
Andy Polyakov 已提交
213
		$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}	\
A
Andy Polyakov 已提交
214 215
		$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}

216 217
BUILDENV=	PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)' \
		CC='$(CC)' CFLAG='$(CFLAG)' 			\
218
		AS='$(CC)' ASFLAG='$(CFLAG) -c'			\
219
		AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'	\
220
		CROSS_COMPILE='$(CROSS_COMPILE)'	\
221
		PERL='$(PERL)' ENGDIRS='$(ENGDIRS)'		\
D
Dr. Stephen Henson 已提交
222
		SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'	\
223 224
		INSTALL_PREFIX='$(INSTALL_PREFIX)'		\
		INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'	\
D
Dr. Stephen Henson 已提交
225
		LIBDIR='$(LIBDIR)'				\
226 227 228 229 230
		MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
		DEPFLAG='-DOPENSSL_NO_DEPRECATED $(DEPFLAG)'	\
		MAKEDEPPROG='$(MAKEDEPPROG)'			\
		SHARED_LDFLAGS='$(SHARED_LDFLAGS)'		\
		KRB5_INCLUDES='$(KRB5_INCLUDES)' LIBKRB5='$(LIBKRB5)'	\
D
Dr. Stephen Henson 已提交
231
		ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'	\
232 233 234
		EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'	\
		SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)'	\
		PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)'	\
235
		CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'	\
R
Rich Salz 已提交
236
		EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'		\
237 238 239 240 241 242 243
		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)'			\
244
		MODES_ASM_OBJ='$(MODES_ASM_OBJ)'		\
245
		ENGINES_ASM_OBJ='$(ENGINES_ASM_OBJ)'		\
246
		PERLASM_SCHEME='$(PERLASM_SCHEME)'		\
247 248
		FIPSLIBDIR='${FIPSLIBDIR}'			\
		FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"	\
A
Andy Polyakov 已提交
249 250 251
		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.
252

R
Richard Levitte 已提交
253 254 255 256 257 258 259 260 261
# 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 已提交
262 263 264 265
#
# 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 已提交
266 267 268 269 270 271
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
272
BUILD_ONE_CMD=\
273
	if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
274 275
		$(BUILD_CMD); \
	fi
276

277
reflect:
A
Andy Polyakov 已提交
278
	@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
279

280
sub_all: build_all
281

282 283
build_all: build_libs build_apps build_tests build_tools

284
build_libs: build_crypto build_ssl build_engines
285 286

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

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

all_testapps: build_libs build_testapps
build_testapps:
302
	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
303

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

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

clean-shared:
325
	@set -e; for i in $(SHLIBDIRS); do \
326 327 328 329 330 331 332
		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 已提交
333
		if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
334 335
			( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
		fi; \
336
	done
337

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

347 348 349
build-shared: do_$(SHLIB_TARGET) link-shared

do_$(SHLIB_TARGET):
350
	@ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
D
Dr. Stephen Henson 已提交
351
		if [ "$$i" = "ssl" -a -n "$(LIBKRB5)" ]; then \
352 353
			libs="$(LIBKRB5) $$libs"; \
		fi; \
A
Andy Polyakov 已提交
354
		$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
355 356
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
357 358
			LIBDEPS="$$libs $(EX_LIBS)" \
			link_a.$(SHLIB_TARGET); \
359
		libs="-l$$i $$libs"; \
360 361
	done

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

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

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

401 402
Makefile: Makefile.org Configure config
	@echo "Makefile is older than Makefile.org, Configure or config."
403
	@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
404 405
	@false

406
libclean:
407
	rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
408

409
clean:	libclean
410
	rm -f shlib/*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
R
Rich Salz 已提交
411
	rm -rf *.bak certs/.0
A
Andy Polyakov 已提交
412
	@set -e; target=clean; $(RECURSIVE_BUILD_CMD)
413
	rm -f $(LIBS) tags TAGS
414
	rm -f openssl.pc libssl.pc libcrypto.pc
415
	rm -f speed.* .pure
416
	rm -f $(TARFILE)
417
	@set -e; for i in $(ONEDIRS) ;\
418
	do \
419
	rm -fr $$i/*; \
420 421 422
	done

makefile.one: files
423
	$(PERL) util/mk1mf.pl >makefile.one; \
424 425
	sh util/do_ms.sh

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

430 431
gentests:
	@(cd test && echo "generating dummy tests (if needed)..." && \
432
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
433

434
dclean:
A
Andy Polyakov 已提交
435
	@set -e; target=dclean; $(RECURSIVE_BUILD_CMD)
436

437 438
rehash: rehash.time
rehash.time: certs apps
439
	@if [ -z "$(CROSS_COMPILE)" ]; then \
440 441 442 443
		(OPENSSL="`pwd`/util/opensslwrap.sh"; \
		[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
		OPENSSL_DEBUG_MEMORY=on; \
		export OPENSSL OPENSSL_DEBUG_MEMORY; \
B
Ben Laurie 已提交
444
		$(PERL) tools/c_rehash certs/demo) && \
445 446 447
		touch rehash.time; \
	else :; fi

448
test:   tests
449

450
tests: rehash
451
	@(cd test && echo "testing..." && \
D
Dr. Stephen Henson 已提交
452 453
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
	OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a
454

455 456 457
report:
	@$(PERL) util/selftest.pl

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

lint:
A
Andy Polyakov 已提交
462
	@set -e; target=lint; $(RECURSIVE_BUILD_CMD)
463

464 465 466 467 468 469
tags TAGS: FORCE
	rm -f TAGS tags
	-ctags -R .
	-etags -R .

FORCE:
470 471

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

476 477 478
stacks:
	$(PERL) util/mkstack.pl -write

479
util/libeay.num::
480
	$(PERL) util/mkdef.pl crypto update
481 482

util/ssleay.num::
483
	$(PERL) util/mkdef.pl ssl update
484

485 486 487 488
crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl include/openssl/obj_mac.h
	$(PERL) crypto/objects/obj_dat.pl include/openssl/obj_mac.h crypto/objects/obj_dat.h
include/openssl/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
	$(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num include/openssl/obj_mac.h
489
crypto/objects/obj_xref.h: crypto/objects/objxref.pl crypto/objects/obj_xref.txt crypto/objects/obj_mac.num
490
	$(PERL) crypto/objects/objxref.pl crypto/objects/obj_mac.num crypto/objects/obj_xref.txt >crypto/objects/obj_xref.h
491

492 493 494
apps/openssl-vms.cnf: apps/openssl.cnf
	$(PERL) VMS/VMSify-conf.pl < apps/openssl.cnf > apps/openssl-vms.cnf

495 496 497 498
crypto/bn/bn_prime.h: crypto/bn/bn_prime.pl
	$(PERL) crypto/bn/bn_prime.pl >crypto/bn/bn_prime.h


499
TABLE: Configure Configurations/*.conf
B
Bodo Möller 已提交
500
	(echo 'Output of `Configure TABLE'"':"; \
501
	$(PERL) Configure TABLE) > TABLE
502

503
update: errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h crypto/objects/obj_xref.h apps/openssl-vms.cnf crypto/bn/bn_prime.h TABLE depend
504

505 506 507 508 509
# 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.
510
tar:
511 512 513
	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
514
	find * \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
515
	$(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
516
	tardy --user_number=0  --user_name=openssl \
R
Ralf S. Engelschall 已提交
517 518
	      --group_number=0 --group_name=openssl \
	      --prefix=openssl-$(VERSION) - |\
519
	gzip --best >../$(TARFILE).gz; \
520
	rm -f ../$(TARFILE).list; \
521
	ls -l ../$(TARFILE).gz
522

523 524
tar-snap:
	@$(TAR) $(TARFLAGS) -cvf - \
525
		`find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \! -name '*.so' \! -name '*.so.*'  \! -name 'openssl' \! -name '*test' \! -name '.#*' \! -name '*~' | sort` |\
526 527 528 529 530
	tardy --user_number=0  --user_name=openssl \
	      --group_number=0 --group_name=openssl \
	      --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
	ls -l ../$(TARFILE)

531
dist:   
532
	$(PERL) Configure dist
533
	@$(MAKE) dist_pem_h
534 535
	@$(MAKE) SDIRS='$(SDIRS)' clean
	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' tar
536 537

dist_pem_h:
A
Andy Polyakov 已提交
538
	(cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
539

540 541
install: all install_docs install_sw

R
Rich Salz 已提交
542 543
uninstall: uninstall_sw uninstall_docs

544
install_sw:
R
Rich Salz 已提交
545
	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
546 547 548
	@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 已提交
549
	done;
550
	@set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
551
	@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
552
	do \
553 554
		if [ -f "$$i" ]; then \
		(       echo installing $$i; \
D
Dr. Stephen Henson 已提交
555 556 557 558
			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 已提交
559 560
		fi; \
	done;
561
	@set -e; if [ -n "$(SHARED_LIBS)" ]; then \
562 563 564
		tmp="$(SHARED_LIBS)"; \
		for i in $${tmp:-x}; \
		do \
565
			if [ -f "$$i" -o -f "$$i.a" ]; then \
566
			(       echo installing $$i; \
567
				if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
568
					c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
569 570
					cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
					chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
571
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
D
Dr. Stephen Henson 已提交
572 573 574
					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; \
575 576 577 578
				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; \
579
				fi ); \
580 581 582 583 584 585
				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 已提交
586 587 588
					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 ); \
589
				fi; \
L
Lutz Jänicke 已提交
590
			fi; \
591 592
		done; \
		(	here="`pwd`"; \
D
Dr. Stephen Henson 已提交
593
			cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
594
			$(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
595 596 597 598
		if [ "$(INSTALLTOP)" != "/usr" ]; then \
			echo 'OpenSSL shared libraries have been installed in:'; \
			echo '  $(INSTALLTOP)'; \
		fi; \
599
	fi
D
Dr. Stephen Henson 已提交
600 601 602 603 604 605
	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
606

R
Rich Salz 已提交
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
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 已提交
646 647
install_html_docs:
	here="`pwd`"; \
648
	filecase=; \
649
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
650 651
		filecase=-i; \
	esac; \
U
Ulf Möller 已提交
652
	for subdir in apps crypto ssl; do \
R
Rich Salz 已提交
653
		$(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
U
Ulf Möller 已提交
654 655 656 657 658
		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' \
659
			| pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
U
Ulf Möller 已提交
660 661 662 663 664 665
			| 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 已提交
666
					PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
U
Ulf Möller 已提交
667 668 669 670
				 done); \
		done; \
	done

R
Rich Salz 已提交
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
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

689 690
install_docs:
	@$(PERL) $(TOP)/util/mkdir-p.pl \
691 692 693 694
		$(INSTALL_PREFIX)$(MANDIR)/man1 \
		$(INSTALL_PREFIX)$(MANDIR)/man3 \
		$(INSTALL_PREFIX)$(MANDIR)/man5 \
		$(INSTALL_PREFIX)$(MANDIR)/man7
695 696
	here="`pwd`"; \
	filecase=; \
697
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
698
		filecase=-i; \
A
Andy Polyakov 已提交
699
	esac; \
700
	set -e; for i in doc/apps/*.pod; do \
701
		fn=`basename $$i .pod`; \
702
		sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
703
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
704
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
705
		pod2man \
706
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
707
			--release=$(VERSION) `basename $$i`) \
708
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
709
		$(PERL) util/extract-names.pl < $$i | \
710 711
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
712 713
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
			 while read n; do \
D
Dr. Stephen Henson 已提交
714
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
715
			 done); \
716
	done; \
717
	set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
718
		fn=`basename $$i .pod`; \
719
		sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
720
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
721
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
722
		pod2man \
723
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
724
			--release=$(VERSION) `basename $$i`) \
725
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
726
		$(PERL) util/extract-names.pl < $$i | \
727 728
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
729 730
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
			 while read n; do \
D
Dr. Stephen Henson 已提交
731
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
732
			 done); \
733
	done
734

R
Rich Salz 已提交
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
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

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