Makefile.org 26.0 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

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

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

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

# The location of the library which contains fipscanister.o
123 124
# 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.
125 126 127 128 129 130 131 132

FIPSCANLIB=

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

BASEADDR=

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

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

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

B
Ben Laurie 已提交
154
MAKEFILE= Makefile
155

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

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

GENERAL=        Makefile
R
Ralf S. Engelschall 已提交
173
BASENAME=       openssl
174 175 176 177
NAME=           $(BASENAME)-$(VERSION)
TARFILE=        $(NAME).tar
WTARFILE=       $(NAME)-win.tar
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 openssl.pc libssl.pc libcrypto.pc
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
BUILDENV=	PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)' \
		CC='$(CC)' CFLAG='$(CFLAG)' 			\
210
		AS='$(CC)' ASFLAG='$(CFLAG) -c'			\
211
		AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'	\
212
		CROSS_COMPILE='$(CROSS_COMPILE)'	\
213
		PERL='$(PERL)' ENGDIRS='$(ENGDIRS)'		\
D
Dr. Stephen Henson 已提交
214
		SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'	\
215 216
		INSTALL_PREFIX='$(INSTALL_PREFIX)'		\
		INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'	\
D
Dr. Stephen Henson 已提交
217
		LIBDIR='$(LIBDIR)'				\
218 219 220 221 222
		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 已提交
223
		ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'	\
224 225 226
		EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'	\
		SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)'	\
		PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)'	\
227
		CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'	\
R
Rich Salz 已提交
228
		EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'		\
229 230 231 232 233 234 235
		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)'			\
236
		MODES_ASM_OBJ='$(MODES_ASM_OBJ)'		\
237
		ENGINES_ASM_OBJ='$(ENGINES_ASM_OBJ)'		\
238
		PERLASM_SCHEME='$(PERLASM_SCHEME)'		\
239 240
		FIPSLIBDIR='${FIPSLIBDIR}'			\
		FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"	\
A
Andy Polyakov 已提交
241 242 243
		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.
244

R
Richard Levitte 已提交
245 246 247 248 249 250 251 252 253
# 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 已提交
254 255 256 257
#
# 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 已提交
258 259 260 261 262 263
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
264
BUILD_ONE_CMD=\
265
	if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
266 267
		$(BUILD_CMD); \
	fi
268

269
reflect:
A
Andy Polyakov 已提交
270
	@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
271

272
sub_all: build_all
273

274 275
build_all: build_libs build_apps build_tests build_tools

276
build_libs: build_crypto build_ssl build_engines
277 278

build_crypto:
279
	@dir=crypto; target=all; $(BUILD_ONE_CMD)
280
build_ssl: build_crypto
281
	@dir=ssl; target=all; $(BUILD_ONE_CMD)
282
build_engines: build_crypto
283
	@dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
284 285

build_apps: build_libs
286
	@dir=apps; target=all; $(BUILD_ONE_CMD)
287
build_tests: build_libs
288
	@dir=test; target=all; $(BUILD_ONE_CMD)
289
build_tools: build_libs
290
	@dir=tools; target=all; $(BUILD_ONE_CMD)
291 292 293

all_testapps: build_libs build_testapps
build_testapps:
294
	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
295

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

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

clean-shared:
317
	@set -e; for i in $(SHLIBDIRS); do \
318 319 320 321 322 323 324
		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 已提交
325
		if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
326 327
			( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
		fi; \
328
	done
329

330
link-shared:
331
	@ set -e; for i in $(SHLIBDIRS); do \
332
		$(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
333 334
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
335
			symlink.$(SHLIB_TARGET); \
336
		libs="$$libs -l$$i"; \
337 338
	done

339 340 341
build-shared: do_$(SHLIB_TARGET) link-shared

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

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

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

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

393 394
Makefile: Makefile.org Configure config
	@echo "Makefile is older than Makefile.org, Configure or config."
395
	@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
396 397
	@false

398
libclean:
399
	rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
400

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

makefile.one: files
411
	$(PERL) util/mk1mf.pl >makefile.one; \
412 413
	sh util/do_ms.sh

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

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

422
dclean:
A
Andy Polyakov 已提交
423
	@set -e; target=dclean; $(RECURSIVE_BUILD_CMD)
424

425 426
rehash: rehash.time
rehash.time: certs 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; \
B
Ben Laurie 已提交
432
		$(PERL) tools/c_rehash certs/demo) && \
433 434 435
		touch rehash.time; \
	else :; fi

436
test:   tests
437

438
tests: rehash
439
	@(cd test && echo "testing..." && \
D
Dr. Stephen Henson 已提交
440 441
	$(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
442

443 444 445
report:
	@$(PERL) util/selftest.pl

446
depend:
A
Andy Polyakov 已提交
447
	@set -e; target=depend; $(RECURSIVE_BUILD_CMD)
448 449

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

452 453 454 455 456 457
tags TAGS: FORCE
	rm -f TAGS tags
	-ctags -R .
	-etags -R .

FORCE:
458 459

errors:
460
	$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
461
	$(PERL) util/mkerr.pl -recurse -write
462
	(cd engines; $(MAKE) PERL=$(PERL) errors)
463

464 465 466
stacks:
	$(PERL) util/mkstack.pl -write

467
util/libeay.num::
468
	$(PERL) util/mkdef.pl crypto update
469 470

util/ssleay.num::
471
	$(PERL) util/mkdef.pl ssl update
472

473 474 475 476
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
477
crypto/objects/obj_xref.h: crypto/objects/objxref.pl crypto/objects/obj_xref.txt crypto/objects/obj_mac.num
478
	$(PERL) crypto/objects/objxref.pl crypto/objects/obj_mac.num crypto/objects/obj_xref.txt >crypto/objects/obj_xref.h
479

480 481 482
apps/openssl-vms.cnf: apps/openssl.cnf
	$(PERL) VMS/VMSify-conf.pl < apps/openssl.cnf > apps/openssl-vms.cnf

483 484 485 486
crypto/bn/bn_prime.h: crypto/bn/bn_prime.pl
	$(PERL) crypto/bn/bn_prime.pl >crypto/bn/bn_prime.h


487
TABLE: Configure Configurations/*.conf
B
Bodo Möller 已提交
488
	(echo 'Output of `Configure TABLE'"':"; \
489
	$(PERL) Configure TABLE) > TABLE
490

491
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
492

493 494 495 496 497
# 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.
498
tar:
499 500 501
	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
502
	find * \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
503
	$(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
504
	tardy --user_number=0  --user_name=openssl \
R
Ralf S. Engelschall 已提交
505 506
	      --group_number=0 --group_name=openssl \
	      --prefix=openssl-$(VERSION) - |\
507
	gzip --best >../$(TARFILE).gz; \
508
	rm -f ../$(TARFILE).list; \
509
	ls -l ../$(TARFILE).gz
510

511 512
tar-snap:
	@$(TAR) $(TARFLAGS) -cvf - \
513
		`find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \! -name '*.so' \! -name '*.so.*'  \! -name 'openssl' \! -name '*test' \! -name '.#*' \! -name '*~' | sort` |\
514 515 516 517 518
	tardy --user_number=0  --user_name=openssl \
	      --group_number=0 --group_name=openssl \
	      --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
	ls -l ../$(TARFILE)

519
dist:   
520
	$(PERL) Configure dist
521
	@$(MAKE) dist_pem_h
522 523
	@$(MAKE) SDIRS='$(SDIRS)' clean
	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' tar
524 525

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

528 529
install: all install_docs install_sw

R
Rich Salz 已提交
530 531
uninstall: uninstall_sw uninstall_docs

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

R
Rich Salz 已提交
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 625 626 627 628 629 630 631 632 633
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 已提交
634 635
install_html_docs:
	here="`pwd`"; \
636
	filecase=; \
637
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
638 639
		filecase=-i; \
	esac; \
U
Ulf Möller 已提交
640
	for subdir in apps crypto ssl; do \
R
Rich Salz 已提交
641
		$(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
U
Ulf Möller 已提交
642 643 644 645 646
		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' \
647
			| pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
U
Ulf Möller 已提交
648 649 650 651 652 653
			| 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 已提交
654
					PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
U
Ulf Möller 已提交
655 656 657 658
				 done); \
		done; \
	done

R
Rich Salz 已提交
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
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

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

R
Rich Salz 已提交
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
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

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