Makefile.in 28.2 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
# DESTDIR is for package builders so that they can configure
25 26
# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
# Normally it is left empty.
27
DESTDIR=
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 33 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
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") -}
63

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

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

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

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

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

D
Dr. Stephen Henson 已提交
144
# Zlib stuff
145 146
ZLIB_INCLUDE={- $withargs{zlib_include} -}
LIBZLIB={- $withargs{zlib_lib} -}
D
Dr. Stephen Henson 已提交
147

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

155
FIPSLIBDIR={- $config{fipslibdir} -}
156 157

# The location of the library which contains fipscanister.o
158 159
# 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.
160

161
FIPSCANLIB={- $config{fips} ? "libcrypto" : "" -}
162 163 164 165

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

166
BASEADDR={- $config{baseaddr} -}
167

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

172
# dirs in crypto to build
173
SDIRS=  {- join(" ", @{$config{sdirs}}) -}
174

175 176 177 178
# tests to perform.  "alltests" is a special word indicating that all tests
# should be performed.
TESTS = alltests

B
Ben Laurie 已提交
179
MAKEFILE= Makefile
180

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

189
TOP=    .
190
LIBS=   libcrypto.a libssl.a
191 192
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
SHARED_SSL=libssl$(SHLIB_EXT)
193
SHARED_LIBS={- '$(SHARED_CRYPTO) $(SHARED_SSL)' if (!$config{no_shared}) -}
194 195 196 197 198 199 200 201 202 203 204 205 206 207
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)" : "") -}
208
SHARED_RCFLAG={- $target{shared_rcflag} -}
209 210

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

R
Rich Salz 已提交
216 217
# Directories created on install if they don't exist.
INSTALLDIRS=	\
218 219 220 221 222 223 224 225
		$(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 已提交
226

227
all: Makefile build_all_but_tests
228

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

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

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

309
reflect:
A
Andy Polyakov 已提交
310
	@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
311

312
sub_all: build_all
313

314 315
build_all_but_tests: build_libs build_apps build_tools
build_all: build_all_but_tests build_tests
316

317 318 319 320
build_libs: build_libcrypto build_libssl openssl.pc

build_libcrypto: build_crypto build_engines libcrypto.pc
build_libssl: build_ssl libssl.pc
321 322

build_crypto:
323
	@dir=crypto; target=all; $(BUILD_ONE_CMD)
324
build_ssl: build_crypto
325
	@dir=ssl; target=all; $(BUILD_ONE_CMD)
326
build_engines: build_crypto
327
	@dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
328 329

build_apps: build_libs
330
	@dir=apps; target=all; $(BUILD_ONE_CMD)
331
build_tests: build_libs
332
	@dir=test; target=all; $(BUILD_ONE_CMD)
333
build_tools: build_libs
334
	@dir=tools; target=all; $(BUILD_ONE_CMD)
335 336 337

all_testapps: build_libs build_testapps
build_testapps:
338
	@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
339

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

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

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

369 370 371
build-shared: do_$(SHLIB_TARGET) link-shared

do_$(SHLIB_TARGET):
372
	@ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
A
Andy Polyakov 已提交
373
		$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
374 375
			LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
			LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
376 377
			LIBDEPS="$$libs $(EX_LIBS)" \
			link_a.$(SHLIB_TARGET); \
378
		libs="-l$$i $$libs"; \
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
		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; \
396 397
	done

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

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

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

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

442
libclean:
443
	rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
444

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

makefile.one: files
455
	$(PERL) util/mk1mf.pl >makefile.one; \
456 457
	sh util/do_ms.sh

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

462 463
gentests:
	@(cd test && echo "generating dummy tests (if needed)..." && \
464
	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
465

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

R
Rich Salz 已提交
478
test:   files tests
479

R
Rich Salz 已提交
480

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

488 489 490 491
list-tests:
	@(cd test && \
	        $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)

492 493 494
report:
	@$(PERL) util/selftest.pl

495 496 497
tags TAGS: FORCE
	rm -f TAGS tags
	-ctags -R .
498
	-etags `find . -name '*.[ch]' -o -name '*.pm'`
499 500

FORCE:
501

R
Rich Salz 已提交
502 503 504 505 506 507
depend:
	@set -e; target=depend; $(RECURSIVE_BUILD_CMD)

update: generate errors ordinals depend

generate:
508 509 510
	(cd apps && PERL='${PERL}' $(MAKE) generate)
	(cd crypto/bn && PERL='${PERL}' $(MAKE) generate)
	(cd crypto/objects && PERL='${PERL}' $(MAKE) generate)
R
Rich Salz 已提交
511

512
errors:
513
	$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
514
	$(PERL) util/mkerr.pl -recurse -write
515
	(cd engines; $(MAKE) PERL=$(PERL) errors)
516
	(cd crypto/ct; $(MAKE) PERL=$(PERL) errors)
517

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

526
TABLE: Configure Configurations/*.conf
B
Bodo Möller 已提交
527
	(echo 'Output of `Configure TABLE'"':"; \
528
	$(PERL) Configure TABLE) > TABLE
529

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

R
Richard Levitte 已提交
540
$(TARFILE).list:
541 542
	git diff --quiet HEAD
	git ls-files | sort > $(TARFILE).list
R
Richard Levitte 已提交
543

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

R
Richard Levitte 已提交
552 553 554 555
tar-snap: $(TARFILE).list
	$(TAR_COMMAND) > $(TARFILE)
	rm -f $(TARFILE).list
	ls -l $(TARFILE)
556

R
Rich Salz 已提交
557
dist:
558
	$(PERL) Configure dist
559
	@$(MAKE) SDIRS='$(SDIRS)' clean
560
	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
561

562 563
install: all install_docs install_sw

R
Rich Salz 已提交
564 565
uninstall: uninstall_sw uninstall_docs

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

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

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

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

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

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

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