Convert CRYPTO_LOCK_{DH,DSA,RSA} to new multi-threading API
[openssl.git] / Makefile.in
1 ##
2 ## Makefile for OpenSSL
3 ##
4 ## {- join("\n## ", @autowarntext) -}
5
6 VERSION={- $config{version} -}
7 MAJOR={- $config{major} -}
8 MINOR={- $config{minor} -}
9 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
10 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
11 SHLIB_MAJOR={- $config{shlib_major} -}
12 SHLIB_MINOR={- $config{shlib_minor} -}
13 SHLIB_EXT={- $target{shared_extension} || ".so" -}
14 SHLIB_EXT_SIMPLE={- $target{shared_extension_simple} || ".so" -}
15 SHLIB_EXT_IMPORT={- $target{shared_import_extension} || "" -}
16 DSO_EXT={- $target{dso_extension} || ".so" -}
17 PLATFORM={- $config{target} -}
18 OPTIONS={- $config{options} -}
19 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
20 SHLIB_TARGET={- $target{shared_target} -}
21
22 # HERE indicates where this Makefile lives.  This can be used to indicate
23 # where sub-Makefiles are expected to be.  Currently has very limited usage,
24 # and should probably not be bothered with at all.
25 HERE=.
26
27 # DESTDIR is for package builders so that they can configure
28 # for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
29 # Normally it is left empty.
30 DESTDIR=
31
32 # Do not edit these manually. Use Configure with --prefix or --openssldir
33 # to change this!  Short explanation in the top comment in Configure
34 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
35               #
36               our $prefix = $config{prefix} || "/usr/local";
37               $prefix -}
38 OPENSSLDIR={- #
39               # The logic here is that if no --openssldir was given,
40               # OPENSSLDIR will get the value from $prefix plus "/ssl".
41               # If --openssldir was given and the value is an absolute
42               # path, OPENSSLDIR will get its value without change.
43               # If the value from --openssldir is a relative path,
44               # OPENSSLDIR will get $prefix with the --openssldir
45               # value appended as a subdirectory.
46               #
47               use File::Spec::Functions;
48               our $openssldir =
49                   $config{openssldir} ?
50                       (file_name_is_absolute($config{openssldir}) ?
51                            $config{openssldir}
52                            : catdir($prefix, $config{openssldir}))
53                       : catdir($prefix, "ssl");
54               $openssldir -}
55 LIBDIR={- #
56           # if $prefix/lib$target{multilib} is not an existing
57           # directory, then assume that it's not searched by linker
58           # automatically, in which case adding $target{multilib} suffix
59           # causes more grief than we're ready to tolerate, so don't...
60           our $multilib =
61               -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
62           our $libdir = $config{libdir} || "lib$multilib";
63           $libdir -}
64 ENGINESDIR={- use File::Spec::Functions;
65               catdir($prefix,$libdir,"engines") -}
66
67 # NO_IDEA - Define to build without the IDEA algorithm
68 # NO_RC4  - Define to build without the RC4 algorithm
69 # NO_RC2  - Define to build without the RC2 algorithm
70 # 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 # TERMIO  - Define the termio terminal subsystem, needed if sgtty is missing.
73 # TERMIOS - Define the termios terminal subsystem, Silicon Graphics.
74 # LONGCRYPT - Define to use HPUX 10.x's long password modification to crypt(3).
75 # DEVRANDOM - Give this the value of the 'random device' if your OS supports
76 #           one.  32 bytes will be read from this when the random
77 #           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 :-)
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 #       CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
86 #       call application defined callbacks via CRYPTO_set_mem_functions()
87 # MD5_ASM needs to be defined to use the x86 assembler for MD5
88 # SHA1_ASM needs to be defined to use the x86 assembler for SHA1
89 # RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160
90 # Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8.  It must
91 # equal 4.
92 # PKCS1_CHECK - pkcs1 tests.
93
94 CROSS_COMPILE= {- $config{cross_compile_prefix} -}
95 CC= $(CROSS_COMPILE){- $target{cc} -}
96 CFLAG={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -}
97 CFLAG_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
98 LDFLAG= {- $target{lflags} -} {- $config{lflags} -}
99 PLIB_LDFLAG= {- $target{plib_lflags} -} {- $config{plib_lflags} -}
100 EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
101 EXE_EXT= {- $target{exe_extension} -}
102 ARFLAGS= {- $target{arflags} -}
103 AR=$(CROSS_COMPILE){- $target{ar} -} $(ARFLAGS) r
104 RANLIB= {- $target{ranlib} -}
105 NM= $(CROSS_COMPILE){- $target{nm} -}
106 PERL= {- $config{perl} -}
107 #RM= echo --
108 RM= rm -f
109 TAR= tar
110 TARFLAGS= --no-recursion
111 MAKEDEPPROG=$(CROSS_COMPILE){- $config{makedepprog} -}
112
113 # We let the C compiler driver to take care of .s files. This is done in
114 # order to be excused from maintaining a separate set of architecture
115 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
116 # gcc, then the driver will automatically translate it to -xarch=v8plus
117 # and pass it down to assembler.
118 AS=$(CC) -c
119 ASFLAG=$(CFLAG)
120
121 # For x86 assembler: Set PROCESSOR to 386 if you want to support
122 # the 80386.
123 PROCESSOR= {- $config{processor} -}
124
125 # CPUID module collects small commonly used assembler snippets
126 APPS_OBJ={- $target{apps_obj} -}
127 CPUID_OBJ= {- $target{cpuid_obj} -}
128 UPLINK_OBJ= {- $target{uplink_obj} -}
129 BN_ASM= {- $target{bn_obj} -}
130 EC_ASM= {- $target{ec_obj} -}
131 DES_ENC= {- $target{des_obj} -}
132 AES_ENC= {- $target{aes_obj} -}
133 BF_ENC= {- $target{bf_obj} -}
134 CAST_ENC= {- $target{cast_obj} -}
135 RC4_ENC= {- $target{rc4_obj} -}
136 RC5_ENC= {- $target{rc5_obj} -}
137 MD5_ASM_OBJ= {- $target{md5_obj} -}
138 SHA1_ASM_OBJ= {- $target{sha1_obj} -}
139 RMD160_ASM_OBJ= {- $target{rmd160_obj} -}
140 WP_ASM_OBJ= {- $target{wp_obj} -}
141 CMLL_ENC= {- $target{cmll_obj} -}
142 MODES_ASM_OBJ= {- $target{modes_obj} -}
143 PADLOCK_ASM_OBJ= {- $target{padlock_obj} -}
144 CHACHA_ENC= {- $target{chacha_obj} -}
145 POLY1305_ASM_OBJ= {- $target{poly1305_obj} -}
146 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
147
148 # Zlib stuff
149 ZLIB_INCLUDE={- $withargs{zlib_include} -}
150 LIBZLIB={- $withargs{zlib_lib} -}
151
152 # This is the location of fipscanister.o and friends.
153 # The FIPS module build will place it $(INSTALLTOP)/lib
154 # but since $(INSTALLTOP) can only take the default value
155 # when the module is built it will be in /usr/local/ssl/lib
156 # $(INSTALLTOP) for this build may be different so hard
157 # code the path.
158
159 FIPSLIBDIR={- $config{fipslibdir} -}
160
161 # The location of the library which contains fipscanister.o
162 # normally it will be libcrypto. If not compiling in FIPS mode
163 # at all this is empty making it a useful test for a FIPS compile.
164
165 FIPSCANLIB={- $config{fips} ? "libcrypto" : "" -}
166
167 # Shared library base address. Currently only used on Windows.
168 #
169
170 BASEADDR={- $config{baseaddr} -}
171
172 DIRS=   {- join(" ", @{$config{dirs}}) -}
173 SHLIBDIRS= crypto ssl
174 INSTALL_SUBS= engines apps tools
175
176 # dirs in crypto to build
177 SDIRS=  {- join(" ", @{$config{sdirs}}) -}
178
179 # tests to perform.  "alltests" is a special word indicating that all tests
180 # should be performed.
181 TESTS = alltests
182
183 MAKEFILE= Makefile
184
185 MANDIR=$(INSTALLTOP)/share/man
186 MAN1=1
187 MAN3=3
188 MANSUFFIX=
189 HTMLSUFFIX=html
190 HTMLDIR=$(INSTALLTOP)/share/doc/$(BASENAME)/html
191 SHELL=/bin/sh
192
193 TOP=    .
194 LIBS=   libcrypto.a libssl.a
195 SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
196 SHARED_SSL=libssl$(SHLIB_EXT)
197 SHARED_LIBS={- $disabled{shared} ? '' : '$(SHARED_CRYPTO) $(SHARED_SSL)'  -}
198 SHARED_CFLAG={- $target{shared_cflag} -}
199 SHARED_LDFLAG={- $target{shared_ldflag}." ".$config{shared_ldflag}
200                  # Unlike other OSes (like Solaris, Linux, Tru64,
201                  # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
202                  # and FreeBSD) "demand" RPATH set on .so objects.
203                  # Apparently application RPATH is not global and
204                  # does not apply to .so linked with other .so.
205                  # Problem manifests itself when libssl.so fails to
206                  # load libcrypto.so. One can argue that we should
207                  # engrave this into Makefile.shared rules or into
208                  # BSD-* config lines above. Meanwhile let's try to
209                  # be cautious and pass -rpath to linker only when
210                  # $prefix is not /usr.
211                  . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
212                     ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
213 SHARED_RCFLAG={- $target{shared_rcflag} -}
214 DYNAMIC_ENGINES={- $config{dynamic_engines} -}
215
216 GENERAL=        Makefile
217 BASENAME=       openssl
218 NAME=           $(BASENAME)-$(VERSION)
219 TARFILE=        ../$(NAME).tar
220 HEADER=         e_os.h
221
222 # Directories created on install if they don't exist.
223 INSTALLDIRS=    \
224                 $(DESTDIR)$(INSTALLTOP)/bin \
225                 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR) \
226                 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines \
227                 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
228                 $(DESTDIR)$(INSTALLTOP)/include/openssl \
229                 $(DESTDIR)$(OPENSSLDIR)/misc \
230                 $(DESTDIR)$(OPENSSLDIR)/certs \
231                 $(DESTDIR)$(OPENSSLDIR)/private
232
233 ENGDIRS={- join(" ", @{$config{engdirs}}) -}
234
235 all: Makefile build_all_but_tests
236
237 # as we stick to -e, CLEARENV ensures that local variables in lower
238 # Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
239 # shell, which [annoyingly enough] terminates unset with error if VAR
240 # is not present:-( TOP= && unset TOP is tribute to HP-UX /bin/sh,
241 # which terminates unset with error if no variable was present:-(
242 CLEARENV=       TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS}     \
243                 $${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}       \
244                 $${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}           \
245                 $${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL} \
246                 $${HEADER+HEADER}                               \
247                 $${GENERAL+GENERAL} $${CFLAGS+CFLAGS}           \
248                 $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}           \
249                 $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
250                 $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}     \
251                 $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
252
253 # LC_ALL=C ensures that error [and other] messages are delivered in
254 # same language for uniform treatment.
255 BUILDENV=       LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
256                 CC='$(CC)' CFLAG='$(CFLAG)' CFLAG_Q='$(CFLAG_Q)'        \
257                 SHARED_CFLAG='$(SHARED_CFLAG)'                          \
258                 AS='$(CC)' ASFLAG='$(CFLAG) -c'                 \
259                 AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'        \
260                 CROSS_COMPILE='$(CROSS_COMPILE)'                \
261                 PERL='$(PERL)' DYNAMIC_ENGINES='$(DYNAMIC_ENGINES)'     \
262                 SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'     \
263                 DESTDIR='$(DESTDIR)'            \
264                 INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'   \
265                 LIBDIR='$(LIBDIR)'                              \
266                 SHARED_LDFLAG='$(SHARED_LDFLAG)'                \
267                 SHARED_RCFLAG='$(SHARED_RCFLAG)'                \
268                 ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'     \
269                 EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'       \
270                 SHLIB_EXT='$(SHLIB_EXT)' DSO_EXT='$(DSO_EXT)'   \
271                 SHLIB_TARGET='$(SHLIB_TARGET)'  \
272                 LDFLAG='$(LDFLAG)'                              \
273                 PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)'       \
274                 APPS_OBJ='$(APPS_OBJ)' UPLINK_OBJ='$(UPLINK_OBJ)'       \
275                 CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'     \
276                 EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'         \
277                 AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'     \
278                 BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)'       \
279                 RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)'       \
280                 ENGDIRS='$(ENGDIRS)'    \
281                 SHA1_ASM_OBJ='$(SHA1_ASM_OBJ)'                  \
282                 MD5_ASM_OBJ='$(MD5_ASM_OBJ)'                    \
283                 RMD160_ASM_OBJ='$(RMD160_ASM_OBJ)'              \
284                 WP_ASM_OBJ='$(WP_ASM_OBJ)'                      \
285                 MODES_ASM_OBJ='$(MODES_ASM_OBJ)'                \
286                 PADLOCK_ASM_OBJ='$(PADLOCK_ASM_OBJ)'            \
287                 CHACHA_ENC='$(CHACHA_ENC)'                      \
288                 POLY1305_ASM_OBJ='$(POLY1305_ASM_OBJ)'          \
289                 PERLASM_SCHEME='$(PERLASM_SCHEME)'              \
290                 FIPSLIBDIR='${FIPSLIBDIR}'                      \
291                 FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"      \
292                 THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
293 # MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
294 # which in turn eliminates ambiguities in variable treatment with -e.
295
296 # BUILD_CMD is a generic macro to build a given target in a given
297 # subdirectory.  The target must be given through the shell variable
298 # `target' and the subdirectory to build in must be given through `dir'.
299 # This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
300 # BUILD_ONE_CMD instead.
301 #
302 # RECURSIVE_BUILD_CMD is a macro to build a given target in all
303 # subdirectories defined in $(DIRS).  It requires that the target
304 # is given through the shell variable `target'.
305 #
306 # BUILD_ONE_CMD is a macro to build a given target in a given
307 # subdirectory if that subdirectory is part of $(DIRS).  It requires
308 # exactly the same shell variables as BUILD_CMD.
309 BUILD_CMD=  if [ -d "$$dir" ]; then \
310             (   cd $$dir && echo "making $$target in $$dir..." && \
311                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
312             ) || exit 1; \
313             fi
314 RECURSIVE_BUILD_CMD=for dir in $(DIRS); do $(BUILD_CMD); done
315 BUILD_ONE_CMD=\
316         if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
317                 $(BUILD_CMD); \
318         fi
319
320 reflect:
321         @[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
322
323 sub_all: build_all
324
325 build_all_but_tests: build_libs build_apps build_tools
326 build_all: build_all_but_tests build_tests
327
328 build_libs: build_libcrypto build_libssl openssl.pc
329
330 build_libcrypto: build_crypto build_engines libcrypto.pc
331 build_libssl: build_ssl libssl.pc
332
333 build_crypto:
334         @dir=crypto; target=all; $(BUILD_ONE_CMD)
335 build_ssl: build_crypto
336         @dir=ssl; target=all; $(BUILD_ONE_CMD)
337 build_engines: build_crypto
338         @dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
339
340 build_apps: build_libs
341         @dir=apps; target=all; $(BUILD_ONE_CMD)
342 build_tests: build_libs
343         @dir=test; target=all; $(BUILD_ONE_CMD)
344 build_tools: build_libs
345         @dir=tools; target=all; $(BUILD_ONE_CMD)
346
347 all_testapps: build_libs build_testapps
348 build_testapps:
349         @dir=crypto; target=testapps; $(BUILD_ONE_CMD)
350
351 libcrypto$(SHLIB_EXT): libcrypto.a
352         @if [ "$(SHLIB_TARGET)" != "" ]; then \
353                 if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
354                         FIPSLD_CC="$(CC)"; CC=fips/fipsld; \
355                         export CC FIPSLD_CC; \
356                 fi; \
357                 $(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
358         else \
359                 echo "There's no support for shared libraries on this platform" >&2; \
360                 exit 1; \
361         fi
362
363 libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
364         @if [ "$(SHLIB_TARGET)" != "" ]; then \
365                 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
366         else \
367                 echo "There's no support for shared libraries on this platform" >&2; \
368                 exit 1; \
369         fi
370
371 link-shared:
372         @ set -e; for i in $(SHLIBDIRS); do \
373                 $(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
374                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
375                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
376                         symlink.$(SHLIB_TARGET); \
377                 libs="$$libs -l$$i"; \
378         done
379
380 build-shared: do_$(SHLIB_TARGET) link-shared
381
382 do_$(SHLIB_TARGET):
383         @ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
384                 $(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
385                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
386                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
387                         LIBDEPS="$$libs $(EX_LIBS)" \
388                         link_shlib.$(SHLIB_TARGET); \
389                 libs="-l$$i $$libs"; \
390                 case "$(PLATFORM)" in \
391                 Cygwin*) \
392                         rm -f apps/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
393                         rm -f test/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
394                         cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll apps/; \
395                         cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll test/; \
396                         ;; \
397                 mingw*) \
398                         arch=; \
399                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
400                                 arch=-x64; \
401                         fi; \
402                         rm -f apps/lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll; \
403                         rm -f test/lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll; \
404                         cp lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll apps/; \
405                         cp lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll test/; \
406                         ;; \
407                 esac; \
408         done
409
410 libcrypto.pc: Makefile
411         @ ( echo 'prefix=$(INSTALLTOP)'; \
412             echo 'exec_prefix=$${prefix}'; \
413             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
414             echo 'includedir=$${prefix}/include'; \
415             echo ''; \
416             echo 'Name: OpenSSL-libcrypto'; \
417             echo 'Description: OpenSSL cryptography library'; \
418             echo 'Version: '$(VERSION); \
419             echo 'Requires: '; \
420             echo 'Libs: -L$${libdir} -lcrypto'; \
421             echo 'Libs.private: $(EX_LIBS)'; \
422             echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
423
424 libssl.pc: Makefile
425         @ ( echo 'prefix=$(INSTALLTOP)'; \
426             echo 'exec_prefix=$${prefix}'; \
427             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
428             echo 'includedir=$${prefix}/include'; \
429             echo ''; \
430             echo 'Name: OpenSSL-libssl'; \
431             echo 'Description: Secure Sockets Layer and cryptography libraries'; \
432             echo 'Version: '$(VERSION); \
433             echo 'Requires.private: libcrypto'; \
434             echo 'Libs: -L$${libdir} -lssl'; \
435             echo 'Libs.private: $(EX_LIBS)'; \
436             echo 'Cflags: -I$${includedir}' ) > libssl.pc
437
438 openssl.pc: Makefile
439         @ ( echo 'prefix=$(INSTALLTOP)'; \
440             echo 'exec_prefix=$${prefix}'; \
441             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
442             echo 'includedir=$${prefix}/include'; \
443             echo ''; \
444             echo 'Name: OpenSSL'; \
445             echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
446             echo 'Version: '$(VERSION); \
447             echo 'Requires: libssl libcrypto' ) > openssl.pc
448
449 Makefile: Makefile.in Configure config
450         @echo "Makefile is older than Makefile.in, Configure or config."
451         @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
452         @false
453
454 libclean:
455         rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
456
457 clean:  libclean
458         rm -f */*/*.o */*.o *.o core a.out fluff testlog make.log cctest cctest.c
459         rm -rf *.bak certs/.0
460         @set -e; target=clean; $(RECURSIVE_BUILD_CMD)
461         rm -f $(LIBS) tags TAGS
462         rm -f openssl.pc libssl.pc libcrypto.pc
463         rm -f speed.* .pure
464         rm -f $(TARFILE)
465
466 makefile.one: files
467         $(PERL) util/mk1mf.pl >makefile.one; \
468         sh util/do_ms.sh
469
470 files:
471         $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
472         @set -e; target=files; $(RECURSIVE_BUILD_CMD)
473
474 gentests:
475         @(cd test && echo "generating dummy tests (if needed)..." && \
476         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
477
478 test:   files tests
479
480 tests:  build_tests 
481         @(cd test && echo "testing..." && \
482         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
483         @if [ -z "$(CROSS_COMPILE)" ]; then \
484                 OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \
485         fi
486
487 list-tests:
488         @(cd test && \
489                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)
490
491 report:
492         @$(PERL) util/selftest.pl
493
494 tags TAGS: FORCE
495         rm -f TAGS tags
496         -ctags -R .
497         -etags `find . -name '*.[ch]' -o -name '*.pm'`
498
499 FORCE:
500
501 depend:
502         @set -e; target=depend; $(RECURSIVE_BUILD_CMD)
503
504 update: generate errors ordinals depend
505
506 generate:
507         (cd apps && PERL='${PERL}' $(MAKE) generate)
508         (cd crypto/bn && PERL='${PERL}' $(MAKE) generate)
509         (cd crypto/objects && PERL='${PERL}' $(MAKE) generate)
510
511 errors:
512         $(PERL) util/ck_errf.pl -strict */*.c */*/*.c
513         $(PERL) util/mkerr.pl -recurse -write
514         (cd engines; $(MAKE) PERL=$(PERL) errors)
515
516 ordinals: util/libcrypto.num util/libssl.num test_ordinals TABLE
517 util/libcrypto.num::
518         $(PERL) util/mkdef.pl crypto update
519 util/libssl.num::
520         $(PERL) util/mkdef.pl ssl update
521 test_ordinals:
522         TOP=$(TOP) PERL=$(PERL) $(PERL) test/run_tests.pl test_ordinals
523
524 TABLE: Configure Configurations/*.conf
525         (echo 'Output of `Configure TABLE'"':"; \
526         $(PERL) Configure TABLE) > TABLE
527
528 # Build distribution tar-file. As the list of files returned by "find" is
529 # pretty long, on several platforms a "too many arguments" error or similar
530 # would occur. Therefore the list of files is temporarily stored into a file
531 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
532 # tar does not support the --files-from option.
533 TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
534                                --owner 0 --group 0 \
535                                --transform 's|^|$(NAME)/|' \
536                                -cvf -
537
538 $(TARFILE).list:
539         git diff --quiet HEAD
540         git ls-files | sort > $(TARFILE).list
541
542 tar: $(TARFILE).list
543         find . -type d -print | xargs chmod 755
544         find . -type f -print | xargs chmod a+r
545         find . -type f -perm -0100 -print | xargs chmod a+x
546         $(TAR_COMMAND) | gzip --best > $(TARFILE).gz
547         rm -f $(TARFILE).list
548         ls -l $(TARFILE).gz
549
550 tar-snap: $(TARFILE).list
551         $(TAR_COMMAND) > $(TARFILE)
552         rm -f $(TARFILE).list
553         ls -l $(TARFILE)
554
555 dist:
556         $(PERL) Configure dist
557         @$(MAKE) SDIRS='$(SDIRS)' clean
558         @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
559
560 install: all install_docs install_sw
561
562 uninstall: uninstall_sw uninstall_docs
563
564 install_sw:
565         @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
566         @set -e; for i in include/openssl/*.h; do \
567         (cp $$i $(DESTDIR)$(INSTALLTOP)/$$i; \
568         chmod 644 $(DESTDIR)$(INSTALLTOP)/$$i ); \
569         done;
570         @set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
571         @set -e; liblist="$(LIBS)"; for i in $$liblist ;\
572         do \
573                 if [ -f "$$i" ]; then \
574                 (       echo installing $$i; \
575                         cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
576                         $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
577                         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
578                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
579                 fi; \
580         done;
581         @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
582                 tmp="$(SHARED_LIBS)"; \
583                 for i in $${tmp:-x}; \
584                 do \
585                         if [ -f "$$i" -o -f "$$i.a" ]; then \
586                                 case "$(PLATFORM)" in \
587                                 Cygwin*) \
588                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
589                                         echo installing $$c; \
590                                         cp $$c $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
591                                         chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
592                                         mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$c.new $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
593                                         echo installing $$i.a; \
594                                         cp $$i.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
595                                         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
596                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
597                                         ;; \
598                                 mingw*) \
599                                         arch=; \
600                                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
601                                                 arch=-x64; \
602                                         fi; \
603                                         m=`echo $$i | sed -e 's/\.dll$$/-$(SHLIB_MAJOR)_$(SHLIB_MINOR)'"$$arch"'.dll/'`; \
604                                         echo installing $$m; \
605                                         cp $$m $(DESTDIR)$(INSTALLTOP)/bin/$$m.new; \
606                                         chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$m.new; \
607                                         mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$m.new $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
608                                         echo installing $$i.a; \
609                                         cp $$i.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
610                                         chmod 555 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
611                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
612                                         ;; \
613                                 *) \
614                                         echo installing $$i; \
615                                         cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
616                                         chmod 555 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
617                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
618                                         ;; \
619                                 esac; \
620                         fi; \
621                 done; \
622                 (       here="`pwd`"; \
623                         cd $(DESTDIR)$(INSTALLTOP)/$(LIBDIR); \
624                         $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
625                 if [ "$(INSTALLTOP)" != "/usr" ]; then \
626                         echo 'OpenSSL shared libraries have been installed in:'; \
627                         echo '  $(INSTALLTOP)'; \
628                 fi; \
629         fi
630         cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
631         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
632         cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
633         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
634         cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
635         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
636
637 uninstall_sw:
638         cd include/openssl && files=* && cd $(DESTDIR)$(INSTALLTOP)/include/openssl && $(RM) $$files
639         @for i in $(LIBS) ;\
640         do \
641                 test -f "$$i" && \
642                 echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i && \
643                 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
644         done;
645         @if [ -n "$(SHARED_LIBS)" ]; then \
646                 tmp="$(SHARED_LIBS)"; \
647                 for i in $${tmp:-x}; \
648                 do \
649                         if [ -f "$$i" -o -f "$$i.a" ]; then \
650                                 case "$(PLATFORM)" in \
651                                 Cygwin*) \
652                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
653                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
654                                         $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
655                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
656                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
657                                         ;; \
658                                 mingw*) \
659                                         arch=; \
660                                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
661                                                 arch=-x64; \
662                                         fi; \
663                                         m=`echo $$i | sed -e 's/\.dll$$/-$(SHLIB_MAJOR)_$(SHLIB_MINOR)'"$$arch"'.dll/'`; \
664                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
665                                         $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
666                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
667                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
668                                         ;; \
669                                 *) \
670                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
671                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
672                                         ;; \
673                                 esac; \
674                         fi; \
675                 done; \
676         fi
677         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
678         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
679         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
680         @target=uninstall; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
681
682 install_html_docs:
683         here="`pwd`"; \
684         filecase=; \
685         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
686                 filecase=-i; \
687         esac; \
688         for subdir in apps crypto ssl; do \
689                 $(PERL) $(TOP)/util/mkdir-p $(DESTDIR)$(HTMLDIR)/$$subdir; \
690                 for i in doc/$$subdir/*.pod; do \
691                         fn=`basename $$i .pod`; \
692                         echo "installing html/$$fn.$(HTMLSUFFIX)"; \
693                         cat $$i \
694                         | sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
695                         | pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
696                         | sed -r 's/<!DOCTYPE.*//g' \
697                         > $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
698                         $(PERL) util/extract-names.pl < $$i | \
699                                 grep -v $$filecase "^$$fn\$$" | \
700                                 (cd $(DESTDIR)$(HTMLDIR)/$$subdir; \
701                                  while read n; do \
702                                         PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
703                                  done); \
704                 done; \
705         done
706
707 uninstall_html_docs:
708         here="`pwd`"; \
709         filecase=; \
710         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
711                 filecase=-i; \
712         esac; \
713         for subdir in apps crypto ssl; do \
714                 for i in doc/$$subdir/*.pod; do \
715                         fn=`basename $$i .pod`; \
716                         $(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
717                         $(PERL) util/extract-names.pl < $$i | \
718                                 grep -v $$filecase "^$$fn\$$" | \
719                                 while read n; do \
720                                         $(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
721                                 done; \
722                 done; \
723         done
724
725 install_docs:
726         @$(PERL) $(TOP)/util/mkdir-p.pl \
727                 $(DESTDIR)$(MANDIR)/man1 \
728                 $(DESTDIR)$(MANDIR)/man3 \
729                 $(DESTDIR)$(MANDIR)/man5 \
730                 $(DESTDIR)$(MANDIR)/man7
731         here="`pwd`"; \
732         filecase=; \
733         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
734                 filecase=-i; \
735         esac; \
736         set -e; for i in doc/apps/*.pod; do \
737                 fn=`basename $$i .pod`; \
738                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
739                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
740                 (cd `$(PERL) util/dirname.pl $$i`; \
741                 pod2man \
742                         --section=$$sec --center=OpenSSL \
743                         --release=$(VERSION) `basename $$i`) \
744                         >  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
745                 $(PERL) util/extract-names.pl < $$i | \
746                         (grep -v $$filecase "^$$fn\$$"; true) | \
747                         (grep -v "[     ]"; true) | \
748                         (cd $(DESTDIR)$(MANDIR)/man$$sec/; \
749                          while read n; do \
750                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
751                          done); \
752         done; \
753         set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
754                 fn=`basename $$i .pod`; \
755                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
756                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
757                 (cd `$(PERL) util/dirname.pl $$i`; \
758                 pod2man \
759                         --section=$$sec --center=OpenSSL \
760                         --release=$(VERSION) `basename $$i`) \
761                         >  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
762                 $(PERL) util/extract-names.pl < $$i | \
763                         (grep -v $$filecase "^$$fn\$$"; true) | \
764                         (grep -v "[     ]"; true) | \
765                         (cd $(DESTDIR)$(MANDIR)/man$$sec/; \
766                          while read n; do \
767                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
768                          done); \
769         done
770
771 uninstall_docs:
772         @here="`pwd`"; \
773         filecase=; \
774         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
775                 filecase=-i; \
776         esac; \
777         for i in doc/apps/*.pod; do \
778                 fn=`basename $$i .pod`; \
779                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
780                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
781                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
782                 $(PERL) util/extract-names.pl < $$i | \
783                         (grep -v $$filecase "^$$fn\$$"; true) | \
784                         (grep -v "[     ]"; true) | \
785                         while read n; do \
786                                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
787                                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
788                         done; \
789         done; \
790         for i in doc/crypto/*.pod doc/ssl/*.pod; do \
791                 fn=`basename $$i .pod`; \
792                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
793                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
794                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
795                 $(PERL) util/extract-names.pl < $$i | \
796                         (grep -v $$filecase "^$$fn\$$"; true) | \
797                         (grep -v "[     ]"; true) | \
798                         while read n; do \
799                                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
800                                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
801                         done; \
802         done
803
804 # DO NOT DELETE THIS LINE -- make depend depends on it.