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

6 7 8 9 10 11 12
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} -}
13 14 15 16
SHLIB_EXT={- $target{shared_extension} || ".so" -}
SHLIB_EXT_SIMPLE={- $target{shared_extension_simple} || ".so" -}
SHLIB_EXT_IMPORT={- $target{shared_import_extension} || "" -}
DSO_EXT={- $target{dso_extension} || ".so" -}
17 18 19 20
PLATFORM={- $config{target} -}
OPTIONS={- $config{options} -}
CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
SHLIB_TARGET={- $target{shared_target} -}
21

22 23 24 25 26
# 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=.

27
# DESTDIR is for package builders so that they can configure
28 29
# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
# Normally it is left empty.
30
DESTDIR=
31

32 33
# Do not edit these manually. Use Configure with --prefix or --openssldir
# to change this!  Short explanation in the top comment in Configure
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
	      #
	      our $prefix = $config{prefix} || "/usr/local";
              $prefix -}
OPENSSLDIR={- #
	      # The logic here is that if no --openssldir was given,
	      # OPENSSLDIR will get the value from $prefix plus "/ssl".
	      # If --openssldir was given and the value is an absolute
	      # path, OPENSSLDIR will get its value without change.
	      # If the value from --openssldir is a relative path,
	      # OPENSSLDIR will get $prefix with the --openssldir
	      # value appended as a subdirectory.
	      #
              use File::Spec::Functions;
              our $openssldir =
                  $config{openssldir} ?
                      (file_name_is_absolute($config{openssldir}) ?
                           $config{openssldir}
                           : catdir($prefix, $config{openssldir}))
                      : catdir($prefix, "ssl");
              $openssldir -}
LIBDIR={- #
          # if $prefix/lib$target{multilib} is not an existing
          # directory, then assume that it's not searched by linker
          # automatically, in which case adding $target{multilib} suffix
          # causes more grief than we're ready to tolerate, so don't...
          our $multilib =
              -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
          our $libdir = $config{libdir} || "lib$multilib";
          $libdir -}
ENGINESDIR={- use File::Spec::Functions;
              catdir($prefix,$libdir,"engines") -}
66

67 68 69 70
# 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
71
#           system defines as well, i.e. _REENTRANT for Solaris 2.[34]
72 73 74 75
# 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
76 77
#           one.  32 bytes will be read from this when the random
#           number generator is initalised.
78
# SSL_FORBID_ENULL - define if you want the server to be not able to use the
79
#           NULL encryption ciphers.
80 81
#
# LOCK_DEBUG - turns on lots of lock debug output :-)
R
Rich Salz 已提交
82
# REF_DEBUG - turn on some xyz_free() assertions.
83
# REF_PRINT - prints some stuff on structure free.
84
# MFUNC - Make all Malloc/Free/Realloc calls call
85 86 87 88 89
#       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
90 91 92
# Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8.  It must
# equal 4.
# PKCS1_CHECK - pkcs1 tests.
93

94 95
CROSS_COMPILE= {- $config{cross_compile_prefix} -}
CC= $(CROSS_COMPILE){- $target{cc} -}
96 97
CFLAG={- our $cflags2 = join(" ",(map { "-D".$_} @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $config{cflags} -}
CFLAG_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
98 99
LDFLAG= {- $config{lflags} -}
PLIB_LDFLAG= {- $config{plib_lflags} -}
100
EX_LIBS= {- $config{ex_libs} -}
101 102 103 104 105 106
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 已提交
107 108
#RM= echo --
RM= rm -f
109
TAR= tar
R
Richard Levitte 已提交
110
TARFLAGS= --no-recursion
111
MAKEDEPPROG=$(CROSS_COMPILE){- $config{makedepprog} -}
112

113 114 115 116 117
# 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.
118
AS=$(CC) -c
119
ASFLAG=$(CFLAG)
120

121 122
# For x86 assembler: Set PROCESSOR to 386 if you want to support
# the 80386.
123
PROCESSOR= {- $config{processor} -}
124 125

# CPUID module collects small commonly used assembler snippets
126
APPS_OBJ={- $target{apps_obj} -}
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
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 已提交
142
PADLOCK_ASM_OBJ= {- $target{padlock_obj} -}
143 144 145
CHACHA_ENC= {- $target{chacha_obj} -}
POLY1305_ASM_OBJ= {- $target{poly1305_obj} -}
PERLASM_SCHEME= {- $target{perlasm_scheme} -}
146

D
Dr. Stephen Henson 已提交
147
# Zlib stuff
148 149
ZLIB_INCLUDE={- $withargs{zlib_include} -}
LIBZLIB={- $withargs{zlib_lib} -}
D
Dr. Stephen Henson 已提交
150

151 152 153 154
# 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 已提交
155
# $(INSTALLTOP) for this build may be different so hard
156 157
# code the path.

158
FIPSLIBDIR={- $config{fipslibdir} -}
159 160

# The location of the library which contains fipscanister.o
161 162
# 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.
163

164
FIPSCANLIB={- $config{fips} ? "libcrypto" : "" -}
165 166 167 168

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

169
BASEADDR={- $config{baseaddr} -}
170

171
DIRS=   {- join(" ", @{$config{dirs}}) -}
U
Ulf Möller 已提交
172
SHLIBDIRS= crypto ssl
173
INSTALL_SUBS= engines apps tools
U
Ulf Möller 已提交
174

175
# dirs in crypto to build
176
SDIRS=  {- join(" ", @{$config{sdirs}}) -}
177

178 179 180 181
# tests to perform.  "alltests" is a special word indicating that all tests
# should be performed.
TESTS = alltests

B
Ben Laurie 已提交
182
MAKEFILE= Makefile
183

184
MANDIR=$(INSTALLTOP)/share/man
185 186
MAN1=1
MAN3=3
187
MANSUFFIX=
U
Ulf Möller 已提交
188
HTMLSUFFIX=html
189
HTMLDIR=$(INSTALLTOP)/share/doc/$(BASENAME)/html
190 191
SHELL=/bin/sh

192
TOP=    .
193
LIBS=   libcrypto.a libssl.a
194 195
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
SHARED_SSL=libssl$(SHLIB_EXT)
196
SHARED_LIBS={- '$(SHARED_CRYPTO) $(SHARED_SSL)' if (!$config{no_shared}) -}
197 198 199 200 201 202 203 204 205 206 207 208 209 210
SHARED_LDFLAG={- $target{shared_ldflag}
                 # Unlike other OSes (like Solaris, Linux, Tru64,
                 # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
                 # and FreeBSD) "demand" RPATH set on .so objects.
                 # Apparently application RPATH is not global and
                 # does not apply to .so linked with other .so.
                 # Problem manifests itself when libssl.so fails to
                 # load libcrypto.so. One can argue that we should
                 # engrave this into Makefile.shared rules or into
                 # BSD-* config lines above. Meanwhile let's try to
                 # be cautious and pass -rpath to linker only when
                 # $prefix is not /usr.
                 . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
                    ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
211
SHARED_RCFLAG={- $target{shared_rcflag} -}
212 213

GENERAL=        Makefile
R
Ralf S. Engelschall 已提交
214
BASENAME=       openssl
215
NAME=           $(BASENAME)-$(VERSION)
R
Richard Levitte 已提交
216
TARFILE=        ../$(NAME).tar
217
HEADER=         e_os.h
218

R
Rich Salz 已提交
219 220
# Directories created on install if they don't exist.
INSTALLDIRS=	\
221 222 223 224 225 226 227 228
		$(DESTDIR)$(INSTALLTOP)/bin \
		$(DESTDIR)$(INSTALLTOP)/$(LIBDIR) \
		$(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines \
		$(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
		$(DESTDIR)$(INSTALLTOP)/include/openssl \
		$(DESTDIR)$(OPENSSLDIR)/misc \
		$(DESTDIR)$(OPENSSLDIR)/certs \
		$(DESTDIR)$(OPENSSLDIR)/private
R
Rich Salz 已提交
229

230
all: Makefile build_all_but_tests
231

A
Andy Polyakov 已提交
232
# as we stick to -e, CLEARENV ensures that local variables in lower
233 234 235 236 237
# 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 已提交
238 239 240
		$${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}	\
		$${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}		\
		$${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL}	\
241
		$${HEADER+HEADER}				\
A
Andy Polyakov 已提交
242 243
		$${GENERAL+GENERAL} $${CFLAGS+CFLAGS}		\
		$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}		\
244
		$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS}	\
A
Andy Polyakov 已提交
245
		$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}	\
A
Andy Polyakov 已提交
246 247
		$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}

248 249 250
# 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)'\
251
		CC='$(CC)' CFLAG='$(CFLAG)' CFLAG_Q='$(CFLAG_Q)'	\
252
		AS='$(CC)' ASFLAG='$(CFLAG) -c'			\
253
		AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'	\
254
		CROSS_COMPILE='$(CROSS_COMPILE)'	\
M
Matt Caswell 已提交
255
		PERL='$(PERL)'	\
D
Dr. Stephen Henson 已提交
256
		SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'	\
257
		DESTDIR='$(DESTDIR)'		\
258
		INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'	\
D
Dr. Stephen Henson 已提交
259
		LIBDIR='$(LIBDIR)'				\
260
		SHARED_LDFLAG='$(SHARED_LDFLAG)'		\
261
		SHARED_RCFLAG='$(SHARED_RCFLAG)'		\
D
Dr. Stephen Henson 已提交
262
		ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'	\
263
		EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'	\
264 265
		SHLIB_EXT='$(SHLIB_EXT)' DSO_EXT='$(DSO_EXT)'	\
		SHLIB_TARGET='$(SHLIB_TARGET)'	\
266 267
		LDFLAG='$(LDFLAG)'				\
		PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)'	\
268
		APPS_OBJ='$(APPS_OBJ)'				\
269
		CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'	\
R
Rich Salz 已提交
270
		EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'		\
271 272 273 274 275 276 277
		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)'			\
278
		MODES_ASM_OBJ='$(MODES_ASM_OBJ)'		\
R
Richard Levitte 已提交
279
		PADLOCK_ASM_OBJ='$(PADLOCK_ASM_OBJ)'		\
280 281
		CHACHA_ENC='$(CHACHA_ENC)'			\
		POLY1305_ASM_OBJ='$(POLY1305_ASM_OBJ)'		\
282
		PERLASM_SCHEME='$(PERLASM_SCHEME)'		\
283 284
		FIPSLIBDIR='${FIPSLIBDIR}'			\
		FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"	\
A
Andy Polyakov 已提交
285 286 287
		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.
288

R
Richard Levitte 已提交
289 290 291 292 293 294 295 296 297
# 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 已提交
298 299 300 301
#
# 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 已提交
302 303 304 305 306 307
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
308
BUILD_ONE_CMD=\
309
	if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
310 311
		$(BUILD_CMD); \
	fi
312

313
reflect:
A
Andy Polyakov 已提交
314
	@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
315

316
sub_all: build_all
317

318 319
build_all_but_tests: build_libs build_apps build_tools
build_all: build_all_but_tests build_tests
320

321 322 323 324
build_libs: build_libcrypto build_libssl openssl.pc

build_libcrypto: build_crypto build_engines libcrypto.pc
build_libssl: build_ssl libssl.pc
325 326

build_crypto:
327
	@dir=crypto; target=all; $(BUILD_ONE_CMD)
328
build_ssl: build_crypto
329
	@dir=ssl; target=all; $(BUILD_ONE_CMD)
330
build_engines: build_crypto
331
	@dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
332 333

build_apps: build_libs
334
	@dir=apps; target=all; $(BUILD_ONE_CMD)
335
build_tests: build_libs
336
	@dir=test; target=all; $(BUILD_ONE_CMD)
337
build_tools: build_libs
338
	@dir=tools; target=all; $(BUILD_ONE_CMD)
339 340 341

all_testapps: build_libs build_testapps
build_testapps:
342
	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
343

344
libcrypto$(SHLIB_EXT): libcrypto.a
345
	@if [ "$(SHLIB_TARGET)" != "" ]; then \
D
Dr. Stephen Henson 已提交
346 347 348 349
		if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
			FIPSLD_CC="$(CC)"; CC=fips/fipsld; \
			export CC FIPSLD_CC; \
		fi; \
350
		$(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
351 352
	else \
		echo "There's no support for shared libraries on this platform" >&2; \
353
		exit 1; \
354
	fi
355

356
libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
357
	@if [ "$(SHLIB_TARGET)" != "" ]; then \
358
		$(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
359 360
	else \
		echo "There's no support for shared libraries on this platform" >&2; \
361
		exit 1; \
362
	fi
363

364
link-shared:
365
	@ set -e; for i in $(SHLIBDIRS); do \
366
		$(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
367 368
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
369
			symlink.$(SHLIB_TARGET); \
370
		libs="$$libs -l$$i"; \
371 372
	done

373 374 375
build-shared: do_$(SHLIB_TARGET) link-shared

do_$(SHLIB_TARGET):
376
	@ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
A
Andy Polyakov 已提交
377
		$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
378 379
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
380
			LIBDEPS="$$libs $(EX_LIBS)" \
381
			link_shlib.$(SHLIB_TARGET); \
382
		libs="-l$$i $$libs"; \
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
		case "$(PLATFORM)" in \
		Cygwin*) \
			rm -f apps/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
			rm -f test/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
			cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll apps/; \
			cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll test/; \
			;; \
		mingw*) \
			case $$i in \
				crypto) i=libeay32;; \
				ssl) i=ssleay32;; \
			esac; \
			rm -f apps/$$i.dll; \
			rm -f test/$$i.dll; \
			cp $$i.dll apps/; \
			cp $$i.dll test/; \
		esac; \
400 401
	done

402 403 404
libcrypto.pc: Makefile
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
405
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
406 407 408 409 410 411
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
	    echo 'Name: OpenSSL-libcrypto'; \
	    echo 'Description: OpenSSL cryptography library'; \
	    echo 'Version: '$(VERSION); \
	    echo 'Requires: '; \
D
Dr. Stephen Henson 已提交
412 413
	    echo 'Libs: -L$${libdir} -lcrypto'; \
	    echo 'Libs.private: $(EX_LIBS)'; \
414
	    echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
415 416 417 418

libssl.pc: Makefile
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
419
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
420 421
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
422
	    echo 'Name: OpenSSL-libssl'; \
423 424
	    echo 'Description: Secure Sockets Layer and cryptography libraries'; \
	    echo 'Version: '$(VERSION); \
425 426
	    echo 'Requires.private: libcrypto'; \
	    echo 'Libs: -L$${libdir} -lssl'; \
D
Dr. Stephen Henson 已提交
427
	    echo 'Libs.private: $(EX_LIBS)'; \
428
	    echo 'Cflags: -I$${includedir}' ) > libssl.pc
429

B
Ben Laurie 已提交
430
openssl.pc: Makefile
431 432
	@ ( echo 'prefix=$(INSTALLTOP)'; \
	    echo 'exec_prefix=$${prefix}'; \
D
Dr. Stephen Henson 已提交
433
	    echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
434 435 436 437 438
	    echo 'includedir=$${prefix}/include'; \
	    echo ''; \
	    echo 'Name: OpenSSL'; \
	    echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
	    echo 'Version: '$(VERSION); \
439
	    echo 'Requires: libssl libcrypto' ) > openssl.pc
440

R
Rich Salz 已提交
441 442
Makefile: Makefile.in Configure config
	@echo "Makefile is older than Makefile.in, Configure or config."
443
	@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
444 445
	@false

446
libclean:
447
	rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
448

449
clean:	libclean
B
Ben Laurie 已提交
450
	rm -f */*/*.o */*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
R
Rich Salz 已提交
451
	rm -rf *.bak certs/.0
A
Andy Polyakov 已提交
452
	@set -e; target=clean; $(RECURSIVE_BUILD_CMD)
453
	rm -f $(LIBS) tags TAGS
454
	rm -f openssl.pc libssl.pc libcrypto.pc
455
	rm -f speed.* .pure
456
	rm -f $(TARFILE)
457 458

makefile.one: files
459
	$(PERL) util/mk1mf.pl >makefile.one; \
460 461
	sh util/do_ms.sh

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

466 467
gentests:
	@(cd test && echo "generating dummy tests (if needed)..." && \
468
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
469

470
rehash: rehash.time
471
rehash.time: certs build_apps build_tools
472
	@if [ -z "$(CROSS_COMPILE)" ]; then \
473 474
		(OPENSSL="`pwd`/util/opensslwrap.sh"; \
		[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
R
Rich Salz 已提交
475 476
		OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
		export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
477 478
		$$OPENSSL rehash certs/demo \
		|| $(PERL) tools/c_rehash certs/demo) && \
479 480 481
		touch rehash.time; \
	else :; fi

R
Rich Salz 已提交
482
test:   files tests
483

R
Rich Salz 已提交
484

485
tests:  build_tests rehash
486
	@(cd test && echo "testing..." && \
D
Dr. Stephen Henson 已提交
487
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
488 489 490
	@if [ -z "$(CROSS_COMPILE)" ]; then \
		OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \
	fi
491

492 493 494 495
list-tests:
	@(cd test && \
	        $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)

496 497 498
report:
	@$(PERL) util/selftest.pl

499 500 501
tags TAGS: FORCE
	rm -f TAGS tags
	-ctags -R .
502
	-etags `find . -name '*.[ch]' -o -name '*.pm'`
503 504

FORCE:
505

R
Rich Salz 已提交
506 507 508 509 510 511
depend:
	@set -e; target=depend; $(RECURSIVE_BUILD_CMD)

update: generate errors ordinals depend

generate:
512 513 514
	(cd apps && PERL='${PERL}' $(MAKE) generate)
	(cd crypto/bn && PERL='${PERL}' $(MAKE) generate)
	(cd crypto/objects && PERL='${PERL}' $(MAKE) generate)
R
Rich Salz 已提交
515

516
errors:
517
	$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
518
	$(PERL) util/mkerr.pl -recurse -write
519
	(cd engines; $(MAKE) PERL=$(PERL) errors)
520
	(cd crypto/ct; $(MAKE) PERL=$(PERL) errors)
521

R
Rich Salz 已提交
522
ordinals: util/libeay.num util/ssleay.num test_ordinals TABLE
523
util/libeay.num::
524
	$(PERL) util/mkdef.pl crypto update
525
util/ssleay.num::
526
	$(PERL) util/mkdef.pl ssl update
R
Rich Salz 已提交
527 528
test_ordinals:
	TOP=$(TOP) PERL=$(PERL) $(PERL) test/run_tests.pl test_ordinals
529

530
TABLE: Configure Configurations/*.conf
B
Bodo Möller 已提交
531
	(echo 'Output of `Configure TABLE'"':"; \
532
	$(PERL) Configure TABLE) > TABLE
533

534 535 536 537 538
# 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 已提交
539
TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
540
			       --owner 0 --group 0 \
R
Richard Levitte 已提交
541
			       --transform 's|^|$(NAME)/|' \
R
Richard Levitte 已提交
542 543
			       -cvf -

R
Richard Levitte 已提交
544
$(TARFILE).list:
545 546
	git diff --quiet HEAD
	git ls-files | sort > $(TARFILE).list
R
Richard Levitte 已提交
547

R
Richard Levitte 已提交
548
tar: $(TARFILE).list
549 550 551
	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 已提交
552 553 554
	$(TAR_COMMAND) | gzip --best > $(TARFILE).gz
	rm -f $(TARFILE).list
	ls -l $(TARFILE).gz
555

R
Richard Levitte 已提交
556 557 558 559
tar-snap: $(TARFILE).list
	$(TAR_COMMAND) > $(TARFILE)
	rm -f $(TARFILE).list
	ls -l $(TARFILE)
560

R
Rich Salz 已提交
561
dist:
562
	$(PERL) Configure dist
563
	@$(MAKE) SDIRS='$(SDIRS)' clean
564
	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
565

566 567
install: all install_docs install_sw

R
Rich Salz 已提交
568 569
uninstall: uninstall_sw uninstall_docs

570
install_sw:
R
Rich Salz 已提交
571
	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
572
	@set -e; for i in include/openssl/*.h; do \
573 574
	(cp $$i $(DESTDIR)$(INSTALLTOP)/$$i; \
	chmod 644 $(DESTDIR)$(INSTALLTOP)/$$i ); \
B
Bodo Möller 已提交
575
	done;
576
	@set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
577
	@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
578
	do \
579 580
		if [ -f "$$i" ]; then \
		(       echo installing $$i; \
581 582 583 584
			cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
			$(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
			chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
			mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
L
Lutz Jänicke 已提交
585 586
		fi; \
	done;
587
	@set -e; if [ -n "$(SHARED_LIBS)" ]; then \
588 589 590
		tmp="$(SHARED_LIBS)"; \
		for i in $${tmp:-x}; \
		do \
591
			if [ -f "$$i" -o -f "$$i.a" ]; then \
592
			(       echo installing $$i; \
593
				if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
594
					c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
595 596 597 598 599 600
					cp $$c $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
					chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
					mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$c.new $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
					cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
601
				else \
602 603 604
					cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					chmod 555 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
					mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
605
				fi ); \
606 607 608 609 610 611
				if expr $(PLATFORM) : 'mingw' > /dev/null; then \
				(	case $$i in \
						*crypto*) i=libeay32.dll;; \
						*ssl*)    i=ssleay32.dll;; \
					esac; \
					echo installing $$i; \
612 613 614
					cp $$i $(DESTDIR)$(INSTALLTOP)/bin/$$i.new; \
					chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$i.new; \
					mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$i.new $(DESTDIR)$(INSTALLTOP)/bin/$$i ); \
615
				fi; \
L
Lutz Jänicke 已提交
616
			fi; \
617 618
		done; \
		(	here="`pwd`"; \
619
			cd $(DESTDIR)$(INSTALLTOP)/$(LIBDIR); \
620
			$(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
621 622 623 624
		if [ "$(INSTALLTOP)" != "/usr" ]; then \
			echo 'OpenSSL shared libraries have been installed in:'; \
			echo '  $(INSTALLTOP)'; \
		fi; \
625
	fi
626 627 628 629 630 631
	cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
	chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
	cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
	chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
	cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
	chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
632

R
Rich Salz 已提交
633
uninstall_sw:
634
	cd include/openssl && files=* && cd $(DESTDIR)$(INSTALLTOP)/include/openssl && $(RM) $$files
R
Rich Salz 已提交
635 636 637
	@for i in $(LIBS) ;\
	do \
		test -f "$$i" && \
638 639
		echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i && \
		$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
R
Rich Salz 已提交
640 641 642 643 644 645 646 647
	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/'`; \
648 649 650 651
					echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
					$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
					echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
					$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
R
Rich Salz 已提交
652
				else \
653 654
					echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
					$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
R
Rich Salz 已提交
655 656 657 658 659 660
				fi; \
				if expr $(PLATFORM) : 'mingw' > /dev/null; then \
					case $$i in \
						*crypto*) i=libeay32.dll;; \
						*ssl*)    i=ssleay32.dll;; \
					esac; \
661 662
					echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$i; \
					$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$i; \
R
Rich Salz 已提交
663 664 665 666
				fi; \
			fi; \
		done; \
	fi
667 668 669
	$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
	$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
	$(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
670
	@target=uninstall; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
R
Rich Salz 已提交
671

U
Ulf Möller 已提交
672 673
install_html_docs:
	here="`pwd`"; \
674
	filecase=; \
675
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
676 677
		filecase=-i; \
	esac; \
U
Ulf Möller 已提交
678
	for subdir in apps crypto ssl; do \
679
		$(PERL) $(TOP)/util/mkdir-p $(DESTDIR)$(HTMLDIR)/$$subdir; \
U
Ulf Möller 已提交
680 681 682 683 684
		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' \
685
			| pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
U
Ulf Möller 已提交
686
			| sed -r 's/<!DOCTYPE.*//g' \
687
			> $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
U
Ulf Möller 已提交
688 689
			$(PERL) util/extract-names.pl < $$i | \
				grep -v $$filecase "^$$fn\$$" | \
690
				(cd $(DESTDIR)$(HTMLDIR)/$$subdir; \
U
Ulf Möller 已提交
691
				 while read n; do \
D
Dr. Stephen Henson 已提交
692
					PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
U
Ulf Möller 已提交
693 694 695 696
				 done); \
		done; \
	done

R
Rich Salz 已提交
697 698 699 700 701 702 703 704 705
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`; \
706
			$(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
R
Rich Salz 已提交
707 708 709
			$(PERL) util/extract-names.pl < $$i | \
				grep -v $$filecase "^$$fn\$$" | \
				while read n; do \
710
					$(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
R
Rich Salz 已提交
711 712 713 714
				done; \
		done; \
	done

715 716
install_docs:
	@$(PERL) $(TOP)/util/mkdir-p.pl \
717 718 719 720
		$(DESTDIR)$(MANDIR)/man1 \
		$(DESTDIR)$(MANDIR)/man3 \
		$(DESTDIR)$(MANDIR)/man5 \
		$(DESTDIR)$(MANDIR)/man7
721 722
	here="`pwd`"; \
	filecase=; \
723
	case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
724
		filecase=-i; \
A
Andy Polyakov 已提交
725
	esac; \
726
	set -e; for i in doc/apps/*.pod; do \
727
		fn=`basename $$i .pod`; \
728
		sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
729
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
730
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
731
		pod2man \
732
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
733
			--release=$(VERSION) `basename $$i`) \
734
			>  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
735
		$(PERL) util/extract-names.pl < $$i | \
736 737
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
738
			(cd $(DESTDIR)$(MANDIR)/man$$sec/; \
739
			 while read n; do \
D
Dr. Stephen Henson 已提交
740
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
741
			 done); \
742
	done; \
743
	set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
744
		fn=`basename $$i .pod`; \
745
		sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
746
		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
747
		(cd `$(PERL) util/dirname.pl $$i`; \
R
Rich Salz 已提交
748
		pod2man \
749
			--section=$$sec --center=OpenSSL \
R
Rich Salz 已提交
750
			--release=$(VERSION) `basename $$i`) \
751
			>  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
752
		$(PERL) util/extract-names.pl < $$i | \
753 754
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
755
			(cd $(DESTDIR)$(MANDIR)/man$$sec/; \
756
			 while read n; do \
D
Dr. Stephen Henson 已提交
757
				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
758
			 done); \
759
	done
760

R
Rich Salz 已提交
761 762 763 764 765 766 767 768 769
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`; \
770 771
		echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
		$(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
R
Rich Salz 已提交
772 773 774 775
		$(PERL) util/extract-names.pl < $$i | \
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
			while read n; do \
776 777
				echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
				$(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
R
Rich Salz 已提交
778 779 780 781 782
			done; \
	done; \
	for i in doc/crypto/*.pod doc/ssl/*.pod; do \
		fn=`basename $$i .pod`; \
		sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
783 784
		echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
		$(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
R
Rich Salz 已提交
785 786 787 788
		$(PERL) util/extract-names.pl < $$i | \
			(grep -v $$filecase "^$$fn\$$"; true) | \
			(grep -v "[	]"; true) | \
			while read n; do \
789 790
				echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
				$(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
R
Rich Salz 已提交
791 792 793
			done; \
	done

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