Makefile.in 25.6 KB
Newer Older
1 2 3
##
## Makefile for OpenSSL
##
R
Richard Levitte 已提交
4
## {- join("\n## ", @autowarntext) -}
5

6 7 8 9 10 11 12 13 14 15 16 17
VERSION={- $config{version} -}
MAJOR={- $config{major} -}
MINOR={- $config{minor} -}
SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
SHLIB_MAJOR={- $config{shlib_major} -}
SHLIB_MINOR={- $config{shlib_minor} -}
SHLIB_EXT={- $target{shared_extension} -}
PLATFORM={- $config{target} -}
OPTIONS={- $config{options} -}
CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
SHLIB_TARGET={- $target{shared_target} -}
18

19 20 21 22 23
# 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=.

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.
27
INSTALL_PREFIX={- $config{install_prefix} -}
28

29 30
# Do not edit these manually. Use Configure with --prefix or --openssldir
# to change this!  Short explanation in the top comment in Configure
31 32
INSTALLTOP={- $config{prefix} -}
OPENSSLDIR={- $config{openssldir} -}
33

34 35 36 37
# 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
38
#           system defines as well, i.e. _REENTRANT for Solaris 2.[34]
39 40 41 42
# 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
43 44
#           one.  32 bytes will be read from this when the random
#           number generator is initalised.
45
# SSL_FORBID_ENULL - define if you want the server to be not able to use the
46
#           NULL encryption ciphers.
47 48 49
#
# LOCK_DEBUG - turns on lots of lock debug output :-)
# REF_CHECK - turn on some xyz_free() assertions.
50
# REF_PRINT - prints some stuff on structure free.
51
# MFUNC - Make all Malloc/Free/Realloc calls call
52 53 54 55 56
#       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
57 58 59
# Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8.  It must
# equal 4.
# PKCS1_CHECK - pkcs1 tests.
60

61 62 63 64
CROSS_COMPILE= {- $config{cross_compile_prefix} -}
CC= $(CROSS_COMPILE){- $target{cc} -}
CFLAG= {- $config{cflags} -}
DEPFLAG= {- $config{depflags} -}
65 66
LDFLAGS= {- $config{lflags} -}
EX_LIBS= {- $config{ex_libs} -}
67 68 69 70 71 72
EXE_EXT= {- $target{exe_extension} -}
ARFLAGS= {- $target{arflags} -}
AR=$(CROSS_COMPILE){- $target{ar} -} $(ARFLAGS) r
RANLIB= {- $target{ranlib} -}
NM= $(CROSS_COMPILE){- $target{nm} -}
PERL= {- $config{perl} -}
R
Rich Salz 已提交
73 74
#RM= echo --
RM= rm -f
75
TAR= tar
R
Richard Levitte 已提交
76
TARFLAGS= --no-recursion
77
LIBDIR={- $config{libdir} -}
78

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

87 88
# For x86 assembler: Set PROCESSOR to 386 if you want to support
# the 80386.
89
PROCESSOR= {- $config{processor} -}
90 91

# CPUID module collects small commonly used assembler snippets
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
CPUID_OBJ= {- $target{cpuid_obj} -}
BN_ASM= {- $target{bn_obj} -}
EC_ASM= {- $target{ec_obj} -}
DES_ENC= {- $target{des_obj} -}
AES_ENC= {- $target{aes_obj} -}
BF_ENC= {- $target{bf_obj} -}
CAST_ENC= {- $target{cast_obj} -}
RC4_ENC= {- $target{rc4_obj} -}
RC5_ENC= {- $target{rc5_obj} -}
MD5_ASM_OBJ= {- $target{md5_obj} -}
SHA1_ASM_OBJ= {- $target{sha1_obj} -}
RMD160_ASM_OBJ= {- $target{rmd160_obj} -}
WP_ASM_OBJ= {- $target{wp_obj} -}
CMLL_ENC= {- $target{cmll_obj} -}
MODES_ASM_OBJ= {- $target{modes_obj} -}
R
Richard Levitte 已提交
107
PADLOCK_ASM_OBJ= {- $target{padlock_obj} -}
108 109 110
CHACHA_ENC= {- $target{chacha_obj} -}
POLY1305_ASM_OBJ= {- $target{poly1305_obj} -}
PERLASM_SCHEME= {- $target{perlasm_scheme} -}
111

D
Dr. Stephen Henson 已提交
112
# Zlib stuff
113 114
ZLIB_INCLUDE={- $withargs{zlib_include} -}
LIBZLIB={- $withargs{zlib_lib} -}
D
Dr. Stephen Henson 已提交
115

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

123
FIPSLIBDIR={- $config{fipslibdir} -}
124 125

# The location of the library which contains fipscanister.o
126 127
# 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.
128

129
FIPSCANLIB={- $config{fips} ? "libcrypto" : "" -}
130 131 132 133

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

134
BASEADDR={- $config{baseaddr} -}
135

136
DIRS=   {- join(" ", @{$config{dirs}}) -}
U
Ulf Möller 已提交
137
SHLIBDIRS= crypto ssl
138
INSTALL_SUBS= engines apps tools
U
Ulf Möller 已提交
139

140
# dirs in crypto to build
141
SDIRS=  {- join(" ", @{$config{sdirs}}) -}
142

143 144 145 146
# tests to perform.  "alltests" is a special word indicating that all tests
# should be performed.
TESTS = alltests

B
Ben Laurie 已提交
147
MAKEFILE= Makefile
148

149
MANDIR=$(INSTALLTOP)/share/man
150 151
MAN1=1
MAN3=3
152
MANSUFFIX=
U
Ulf Möller 已提交
153
HTMLSUFFIX=html
154
HTMLDIR=$(INSTALLTOP)/share/doc/$(BASENAME)/html
155 156
SHELL=/bin/sh

157
TOP=    .
158
LIBS=   libcrypto.a libssl.a
159 160
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
SHARED_SSL=libssl$(SHLIB_EXT)
161 162
SHARED_LIBS={- '$(SHARED_CRYPTO) $(SHARED_SSL)' if (!$config{no_shared}) -}
SHARED_LDFLAGS={- $target{shared_ldflag} -}
163 164

GENERAL=        Makefile
R
Ralf S. Engelschall 已提交
165
BASENAME=       openssl
166
NAME=           $(BASENAME)-$(VERSION)
R
Richard Levitte 已提交
167
TARFILE=        ../$(NAME).tar
168
HEADER=         e_os.h
169

R
Rich Salz 已提交
170 171 172 173 174 175 176 177 178 179 180
# 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

181
all: Makefile build_all
182

A
Andy Polyakov 已提交
183
# as we stick to -e, CLEARENV ensures that local variables in lower
184 185 186 187 188
# 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 已提交
189 190 191
		$${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}	\
		$${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}		\
		$${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL}	\
192
		$${HEADER+HEADER}				\
A
Andy Polyakov 已提交
193 194
		$${GENERAL+GENERAL} $${CFLAGS+CFLAGS}		\
		$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}		\
195
		$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS}	\
A
Andy Polyakov 已提交
196
		$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}	\
A
Andy Polyakov 已提交
197 198
		$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}

199 200 201
# 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)'\
202
		CC='$(CC)' CFLAG='$(CFLAG)' 			\
203
		AS='$(CC)' ASFLAG='$(CFLAG) -c'			\
204
		AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'	\
205
		CROSS_COMPILE='$(CROSS_COMPILE)'	\
M
Matt Caswell 已提交
206
		PERL='$(PERL)'	\
D
Dr. Stephen Henson 已提交
207
		SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'	\
208 209
		INSTALL_PREFIX='$(INSTALL_PREFIX)'		\
		INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'	\
D
Dr. Stephen Henson 已提交
210
		LIBDIR='$(LIBDIR)'				\
211
		DEPFLAG='$(DEPFLAG)'                    	\
212
		SHARED_LDFLAGS='$(SHARED_LDFLAGS)'		\
D
Dr. Stephen Henson 已提交
213
		ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'	\
214 215
		EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'	\
		SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)'	\
216
		LDFLAGS='$(LDFLAGS)' EX_LIBS='$(EX_LIBS)'	\
217
		CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'	\
R
Rich Salz 已提交
218
		EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'		\
219 220 221 222 223 224 225
		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)'			\
226
		MODES_ASM_OBJ='$(MODES_ASM_OBJ)'		\
R
Richard Levitte 已提交
227
		PADLOCK_ASM_OBJ='$(PADLOCK_ASM_OBJ)'		\
228 229
		CHACHA_ENC='$(CHACHA_ENC)'			\
		POLY1305_ASM_OBJ='$(POLY1305_ASM_OBJ)'		\
230
		PERLASM_SCHEME='$(PERLASM_SCHEME)'		\
231 232
		FIPSLIBDIR='${FIPSLIBDIR}'			\
		FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"	\
A
Andy Polyakov 已提交
233 234 235
		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.
236

R
Richard Levitte 已提交
237 238 239 240 241 242 243 244 245
# 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 已提交
246 247 248 249
#
# 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 已提交
250 251 252 253 254 255
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
256
BUILD_ONE_CMD=\
257
	if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
258 259
		$(BUILD_CMD); \
	fi
260

261
reflect:
A
Andy Polyakov 已提交
262
	@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
263

264
sub_all: build_all
265

266 267
build_all: build_libs build_apps build_tests build_tools

268 269 270 271
build_libs: build_libcrypto build_libssl openssl.pc

build_libcrypto: build_crypto build_engines libcrypto.pc
build_libssl: build_ssl libssl.pc
272 273

build_crypto:
274
	@dir=crypto; target=all; $(BUILD_ONE_CMD)
275
build_ssl: build_crypto
276
	@dir=ssl; target=all; $(BUILD_ONE_CMD)
277
build_engines: build_crypto
278
	@dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
279 280

build_apps: build_libs
281
	@dir=apps; target=all; $(BUILD_ONE_CMD)
282
build_tests: build_libs
283
	@dir=test; target=all; $(BUILD_ONE_CMD)
284
build_tools: build_libs
285
	@dir=tools; target=all; $(BUILD_ONE_CMD)
286 287 288

all_testapps: build_libs build_testapps
build_testapps:
289
	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
290

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

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

311
link-shared:
312
	@ set -e; for i in $(SHLIBDIRS); do \
313
		$(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
314 315
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
316
			symlink.$(SHLIB_TARGET); \
317
		libs="$$libs -l$$i"; \
318 319
	done

320 321 322
build-shared: do_$(SHLIB_TARGET) link-shared

do_$(SHLIB_TARGET):
323
	@ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
A
Andy Polyakov 已提交
324
		$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
325 326
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
327 328
			LIBDEPS="$$libs $(EX_LIBS)" \
			link_a.$(SHLIB_TARGET); \
329
		libs="-l$$i $$libs"; \
330 331
	done

332 333 334
libcrypto.pc: Makefile
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
335
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
336 337 338 339 340 341
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
	    echo 'Name: OpenSSL-libcrypto'; \
	    echo 'Description: OpenSSL cryptography library'; \
	    echo 'Version: '$(VERSION); \
	    echo 'Requires: '; \
D
Dr. Stephen Henson 已提交
342 343
	    echo 'Libs: -L$${libdir} -lcrypto'; \
	    echo 'Libs.private: $(EX_LIBS)'; \
344
	    echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
345 346 347 348

libssl.pc: Makefile
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
349
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
350 351
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
352
	    echo 'Name: OpenSSL-libssl'; \
353 354
	    echo 'Description: Secure Sockets Layer and cryptography libraries'; \
	    echo 'Version: '$(VERSION); \
355 356
	    echo 'Requires.private: libcrypto'; \
	    echo 'Libs: -L$${libdir} -lssl'; \
D
Dr. Stephen Henson 已提交
357
	    echo 'Libs.private: $(EX_LIBS)'; \
358
	    echo 'Cflags: -I$${includedir}' ) > libssl.pc
359

B
Ben Laurie 已提交
360
openssl.pc: Makefile
361 362
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
363
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
364 365 366 367 368
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
	    echo 'Name: OpenSSL'; \
	    echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
	    echo 'Version: '$(VERSION); \
369
	    echo 'Requires: libssl libcrypto' ) > openssl.pc
370

R
Rich Salz 已提交
371 372
Makefile: Makefile.in Configure config
	@echo "Makefile is older than Makefile.in, Configure or config."
373
	@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
374 375
	@false

376
libclean:
377
	rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
378

379
clean:	libclean
B
Ben Laurie 已提交
380
	rm -f */*/*.o */*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
R
Rich Salz 已提交
381
	rm -rf *.bak certs/.0
A
Andy Polyakov 已提交
382
	@set -e; target=clean; $(RECURSIVE_BUILD_CMD)
383
	rm -f $(LIBS) tags TAGS
384
	rm -f openssl.pc libssl.pc libcrypto.pc
385
	rm -f speed.* .pure
386
	rm -f $(TARFILE)
387 388

makefile.one: files
389
	$(PERL) util/mk1mf.pl >makefile.one; \
390 391
	sh util/do_ms.sh

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

396 397
gentests:
	@(cd test && echo "generating dummy tests (if needed)..." && \
398
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
399

400
rehash: rehash.time
401
rehash.time: certs build_apps build_tools
402
	@if [ -z "$(CROSS_COMPILE)" ]; then \
403 404
		(OPENSSL="`pwd`/util/opensslwrap.sh"; \
		[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
R
Rich Salz 已提交
405 406
		OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
		export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
407 408
		$$OPENSSL rehash certs/demo \
		|| $(PERL) tools/c_rehash certs/demo) && \
409 410 411
		touch rehash.time; \
	else :; fi

412
test:   tests
413

R
Rich Salz 已提交
414

415
tests: rehash
416
	@(cd test && echo "testing..." && \
D
Dr. Stephen Henson 已提交
417
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
418 419 420
	@if [ -z "$(CROSS_COMPILE)" ]; then \
		OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \
	fi
421

422 423 424 425
list-tests:
	@(cd test && \
	        $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)

426 427 428
report:
	@$(PERL) util/selftest.pl

429 430 431
tags TAGS: FORCE
	rm -f TAGS tags
	-ctags -R .
432
	-etags `find . -name '*.[ch]' -o -name '*.pm'`
433 434

FORCE:
435

R
Rich Salz 已提交
436 437 438 439 440 441
depend:
	@set -e; target=depend; $(RECURSIVE_BUILD_CMD)

update: generate errors ordinals depend

generate:
442 443 444
	(cd apps && PERL='${PERL}' $(MAKE) generate)
	(cd crypto/bn && PERL='${PERL}' $(MAKE) generate)
	(cd crypto/objects && PERL='${PERL}' $(MAKE) generate)
R
Rich Salz 已提交
445

446
errors:
447
	$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
448
	$(PERL) util/mkerr.pl -recurse -write
449
	(cd engines; $(MAKE) PERL=$(PERL) errors)
450
	(cd crypto/ct; $(MAKE) PERL=$(PERL) errors)
451

R
Rich Salz 已提交
452
ordinals: util/libeay.num util/ssleay.num test_ordinals TABLE
453
util/libeay.num::
454
	$(PERL) util/mkdef.pl crypto update
455
util/ssleay.num::
456
	$(PERL) util/mkdef.pl ssl update
R
Rich Salz 已提交
457 458
test_ordinals:
	TOP=$(TOP) PERL=$(PERL) $(PERL) test/run_tests.pl test_ordinals
459

460
TABLE: Configure Configurations/*.conf
B
Bodo Möller 已提交
461
	(echo 'Output of `Configure TABLE'"':"; \
462
	$(PERL) Configure TABLE) > TABLE
463

464 465 466 467 468
# 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 已提交
469
TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
470
			       --owner 0 --group 0 \
R
Richard Levitte 已提交
471
			       --transform 's|^|$(NAME)/|' \
R
Richard Levitte 已提交
472 473
			       -cvf -

R
Richard Levitte 已提交
474
$(TARFILE).list:
475 476
	git diff --quiet HEAD
	git ls-files | sort > $(TARFILE).list
R
Richard Levitte 已提交
477

R
Richard Levitte 已提交
478
tar: $(TARFILE).list
479 480 481
	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 已提交
482 483 484
	$(TAR_COMMAND) | gzip --best > $(TARFILE).gz
	rm -f $(TARFILE).list
	ls -l $(TARFILE).gz
485

R
Richard Levitte 已提交
486 487 488 489
tar-snap: $(TARFILE).list
	$(TAR_COMMAND) > $(TARFILE)
	rm -f $(TARFILE).list
	ls -l $(TARFILE)
490

491
dist:   
492
	$(PERL) Configure dist
493
	@$(MAKE) SDIRS='$(SDIRS)' clean
494
	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
495

496 497
install: all install_docs install_sw

R
Rich Salz 已提交
498 499
uninstall: uninstall_sw uninstall_docs

500
install_sw:
R
Rich Salz 已提交
501
	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
502 503 504
	@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 已提交
505
	done;
506
	@set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
507
	@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
508
	do \
509 510
		if [ -f "$$i" ]; then \
		(       echo installing $$i; \
D
Dr. Stephen Henson 已提交
511 512 513 514
			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 已提交
515 516
		fi; \
	done;
517
	@set -e; if [ -n "$(SHARED_LIBS)" ]; then \
518 519 520
		tmp="$(SHARED_LIBS)"; \
		for i in $${tmp:-x}; \
		do \
521
			if [ -f "$$i" -o -f "$$i.a" ]; then \
522
			(       echo installing $$i; \
523
				if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
524
					c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
525 526
					cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
					chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
527
					mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
D
Dr. Stephen Henson 已提交
528 529 530
					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; \
531 532 533 534
				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; \
535
				fi ); \
536 537 538 539 540 541
				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 已提交
542 543 544
					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 ); \
545
				fi; \
L
Lutz Jänicke 已提交
546
			fi; \
547 548
		done; \
		(	here="`pwd`"; \
D
Dr. Stephen Henson 已提交
549
			cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
550
			$(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
551 552 553 554
		if [ "$(INSTALLTOP)" != "/usr" ]; then \
			echo 'OpenSSL shared libraries have been installed in:'; \
			echo '  $(INSTALLTOP)'; \
		fi; \
555
	fi
D
Dr. Stephen Henson 已提交
556 557 558 559 560 561
	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
562

R
Rich Salz 已提交
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
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 已提交
602 603
install_html_docs:
	here="`pwd`"; \
604
	filecase=; \
605
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
606 607
		filecase=-i; \
	esac; \
U
Ulf Möller 已提交
608
	for subdir in apps crypto ssl; do \
R
Rich Salz 已提交
609
		$(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
U
Ulf Möller 已提交
610 611 612 613 614
		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' \
615
			| pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
U
Ulf Möller 已提交
616 617 618 619 620 621
			| 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 已提交
622
					PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
U
Ulf Möller 已提交
623 624 625 626
				 done); \
		done; \
	done

R
Rich Salz 已提交
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
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

645 646
install_docs:
	@$(PERL) $(TOP)/util/mkdir-p.pl \
647 648 649 650
		$(INSTALL_PREFIX)$(MANDIR)/man1 \
		$(INSTALL_PREFIX)$(MANDIR)/man3 \
		$(INSTALL_PREFIX)$(MANDIR)/man5 \
		$(INSTALL_PREFIX)$(MANDIR)/man7
651 652
	here="`pwd`"; \
	filecase=; \
653
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
654
		filecase=-i; \
A
Andy Polyakov 已提交
655
	esac; \
656
	set -e; for i in doc/apps/*.pod; do \
657
		fn=`basename $$i .pod`; \
658
		sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
659
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
660
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
661
		pod2man \
662
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
663
			--release=$(VERSION) `basename $$i`) \
664
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
665
		$(PERL) util/extract-names.pl < $$i | \
666 667
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
668 669
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
			 while read n; do \
D
Dr. Stephen Henson 已提交
670
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
671
			 done); \
672
	done; \
673
	set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
674
		fn=`basename $$i .pod`; \
675
		sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
676
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
677
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
678
		pod2man \
679
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
680
			--release=$(VERSION) `basename $$i`) \
681
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
682
		$(PERL) util/extract-names.pl < $$i | \
683 684
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
685 686
			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
			 while read n; do \
D
Dr. Stephen Henson 已提交
687
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
688
			 done); \
689
	done
690

R
Rich Salz 已提交
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723
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

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