Makefile.in 25.8 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 65 66 67 68 69 70 71 72
CROSS_COMPILE= {- $config{cross_compile_prefix} -}
CC= $(CROSS_COMPILE){- $target{cc} -}
CFLAG= {- $config{cflags} -}
DEPFLAG= {- $config{depflags} -}
PEX_LIBS= {- $config{prelflags} -}
EX_LIBS= {- $config{lflags} -}
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 78
MAKEDEPPROG=$(CROSS_COMPILE){- $config{makedepprog} -}
LIBDIR={- $config{libdir} -}
79

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

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

# CPUID module collects small commonly used assembler snippets
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
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 已提交
108
PADLOCK_ASM_OBJ= {- $target{padlock_obj} -}
109 110 111
CHACHA_ENC= {- $target{chacha_obj} -}
POLY1305_ASM_OBJ= {- $target{poly1305_obj} -}
PERLASM_SCHEME= {- $target{perlasm_scheme} -}
112

D
Dr. Stephen Henson 已提交
113
# Zlib stuff
114 115
ZLIB_INCLUDE={- $withargs{zlib-include} -}
LIBZLIB={- $withargs{zlib-lib} -}
D
Dr. Stephen Henson 已提交
116

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
# code the path.

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

# 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
FIPSCANLIB={- $config{fips} ? "libcrypto" : "" -}
131 132 133 134

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

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

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

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

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

B
Ben Laurie 已提交
148
MAKEFILE= Makefile
149

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

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

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

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

182
all: Makefile build_all
183

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

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

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

264
reflect:
A
Andy Polyakov 已提交
265
	@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
266

267
sub_all: build_all
268

269 270
build_all: build_libs build_apps build_tests build_tools

271 272 273 274
build_libs: build_libcrypto build_libssl openssl.pc

build_libcrypto: build_crypto build_engines libcrypto.pc
build_libssl: build_ssl libssl.pc
275 276

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

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

all_testapps: build_libs build_testapps
build_testapps:
292
	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
293

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

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

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

323 324 325
build-shared: do_$(SHLIB_TARGET) link-shared

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

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

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

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

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

379
libclean:
380
	rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
381

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

makefile.one: files
392
	$(PERL) util/mk1mf.pl >makefile.one; \
393 394
	sh util/do_ms.sh

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

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

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

415
test:   tests
416

R
Rich Salz 已提交
417

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

425 426 427 428
list-tests:
	@(cd test && \
	        $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)

429 430 431
report:
	@$(PERL) util/selftest.pl

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

FORCE:
438

R
Rich Salz 已提交
439 440 441 442 443 444
depend:
	@set -e; target=depend; $(RECURSIVE_BUILD_CMD)

update: generate errors ordinals depend

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

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

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

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

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

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

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

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

494
dist:   
495
	$(PERL) Configure dist
496
	@$(MAKE) SDIRS='$(SDIRS)' clean
497
	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
498

499 500
install: all install_docs install_sw

R
Rich Salz 已提交
501 502
uninstall: uninstall_sw uninstall_docs

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

R
Rich Salz 已提交
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 602 603 604
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 已提交
605 606
install_html_docs:
	here="`pwd`"; \
607
	filecase=; \
608
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
609 610
		filecase=-i; \
	esac; \
U
Ulf Möller 已提交
611
	for subdir in apps crypto ssl; do \
R
Rich Salz 已提交
612
		$(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
U
Ulf Möller 已提交
613 614 615 616 617
		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' \
618
			| pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
U
Ulf Möller 已提交
619 620 621 622 623 624
			| 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 已提交
625
					PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
U
Ulf Möller 已提交
626 627 628 629
				 done); \
		done; \
	done

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

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

R
Rich Salz 已提交
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 724 725 726
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

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