Big rename fest of MingW shared libraries
[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".$_} @{$config{defines}},"OPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","ENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"")) -} {- $config{cflags} -}
97 CFLAG_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
98 LDFLAG= {- $config{lflags} -}
99 PLIB_LDFLAG= {- $config{plib_lflags} -}
100 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 BN_ASM= {- $target{bn_obj} -}
129 EC_ASM= {- $target{ec_obj} -}
130 DES_ENC= {- $target{des_obj} -}
131 AES_ENC= {- $target{aes_obj} -}
132 BF_ENC= {- $target{bf_obj} -}
133 CAST_ENC= {- $target{cast_obj} -}
134 RC4_ENC= {- $target{rc4_obj} -}
135 RC5_ENC= {- $target{rc5_obj} -}
136 MD5_ASM_OBJ= {- $target{md5_obj} -}
137 SHA1_ASM_OBJ= {- $target{sha1_obj} -}
138 RMD160_ASM_OBJ= {- $target{rmd160_obj} -}
139 WP_ASM_OBJ= {- $target{wp_obj} -}
140 CMLL_ENC= {- $target{cmll_obj} -}
141 MODES_ASM_OBJ= {- $target{modes_obj} -}
142 PADLOCK_ASM_OBJ= {- $target{padlock_obj} -}
143 CHACHA_ENC= {- $target{chacha_obj} -}
144 POLY1305_ASM_OBJ= {- $target{poly1305_obj} -}
145 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
146
147 # Zlib stuff
148 ZLIB_INCLUDE={- $withargs{zlib_include} -}
149 LIBZLIB={- $withargs{zlib_lib} -}
150
151 # This is the location of fipscanister.o and friends.
152 # The FIPS module build will place it $(INSTALLTOP)/lib
153 # but since $(INSTALLTOP) can only take the default value
154 # when the module is built it will be in /usr/local/ssl/lib
155 # $(INSTALLTOP) for this build may be different so hard
156 # code the path.
157
158 FIPSLIBDIR={- $config{fipslibdir} -}
159
160 # The location of the library which contains fipscanister.o
161 # normally it will be libcrypto. If not compiling in FIPS mode
162 # at all this is empty making it a useful test for a FIPS compile.
163
164 FIPSCANLIB={- $config{fips} ? "libcrypto" : "" -}
165
166 # Shared library base address. Currently only used on Windows.
167 #
168
169 BASEADDR={- $config{baseaddr} -}
170
171 DIRS=   {- join(" ", @{$config{dirs}}) -}
172 SHLIBDIRS= crypto ssl
173 INSTALL_SUBS= engines apps tools
174
175 # dirs in crypto to build
176 SDIRS=  {- join(" ", @{$config{sdirs}}) -}
177
178 # tests to perform.  "alltests" is a special word indicating that all tests
179 # should be performed.
180 TESTS = alltests
181
182 MAKEFILE= Makefile
183
184 MANDIR=$(INSTALLTOP)/share/man
185 MAN1=1
186 MAN3=3
187 MANSUFFIX=
188 HTMLSUFFIX=html
189 HTMLDIR=$(INSTALLTOP)/share/doc/$(BASENAME)/html
190 SHELL=/bin/sh
191
192 TOP=    .
193 LIBS=   libcrypto.a libssl.a
194 SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
195 SHARED_SSL=libssl$(SHLIB_EXT)
196 SHARED_LIBS={- '$(SHARED_CRYPTO) $(SHARED_SSL)' if (!$config{no_shared}) -}
197 SHARED_LDFLAG={- $target{shared_ldflag}
198                  # Unlike other OSes (like Solaris, Linux, Tru64,
199                  # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
200                  # and FreeBSD) "demand" RPATH set on .so objects.
201                  # Apparently application RPATH is not global and
202                  # does not apply to .so linked with other .so.
203                  # Problem manifests itself when libssl.so fails to
204                  # load libcrypto.so. One can argue that we should
205                  # engrave this into Makefile.shared rules or into
206                  # BSD-* config lines above. Meanwhile let's try to
207                  # be cautious and pass -rpath to linker only when
208                  # $prefix is not /usr.
209                  . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
210                     ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
211 SHARED_RCFLAG={- $target{shared_rcflag} -}
212
213 GENERAL=        Makefile
214 BASENAME=       openssl
215 NAME=           $(BASENAME)-$(VERSION)
216 TARFILE=        ../$(NAME).tar
217 HEADER=         e_os.h
218
219 # Directories created on install if they don't exist.
220 INSTALLDIRS=    \
221                 $(DESTDIR)$(INSTALLTOP)/bin \
222                 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR) \
223                 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/engines \
224                 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
225                 $(DESTDIR)$(INSTALLTOP)/include/openssl \
226                 $(DESTDIR)$(OPENSSLDIR)/misc \
227                 $(DESTDIR)$(OPENSSLDIR)/certs \
228                 $(DESTDIR)$(OPENSSLDIR)/private
229
230 all: Makefile build_all_but_tests
231
232 # as we stick to -e, CLEARENV ensures that local variables in lower
233 # Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
234 # shell, which [annoyingly enough] terminates unset with error if VAR
235 # is not present:-( TOP= && unset TOP is tribute to HP-UX /bin/sh,
236 # which terminates unset with error if no variable was present:-(
237 CLEARENV=       TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS}     \
238                 $${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}       \
239                 $${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}           \
240                 $${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL} \
241                 $${HEADER+HEADER}                               \
242                 $${GENERAL+GENERAL} $${CFLAGS+CFLAGS}           \
243                 $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}           \
244                 $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
245                 $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}     \
246                 $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
247
248 # LC_ALL=C ensures that error [and other] messages are delivered in
249 # same language for uniform treatment.
250 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)'        \
255                 PERL='$(PERL)'  \
256                 SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'     \
257                 DESTDIR='$(DESTDIR)'            \
258                 INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'   \
259                 LIBDIR='$(LIBDIR)'                              \
260                 SHARED_LDFLAG='$(SHARED_LDFLAG)'                \
261                 SHARED_RCFLAG='$(SHARED_RCFLAG)'                \
262                 ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'     \
263                 EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'       \
264                 SHLIB_EXT='$(SHLIB_EXT)' DSO_EXT='$(DSO_EXT)'   \
265                 SHLIB_TARGET='$(SHLIB_TARGET)'  \
266                 LDFLAG='$(LDFLAG)'                              \
267                 PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)'       \
268                 APPS_OBJ='$(APPS_OBJ)'                          \
269                 CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'     \
270                 EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'         \
271                 AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'     \
272                 BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)'       \
273                 RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)'       \
274                 SHA1_ASM_OBJ='$(SHA1_ASM_OBJ)'                  \
275                 MD5_ASM_OBJ='$(MD5_ASM_OBJ)'                    \
276                 RMD160_ASM_OBJ='$(RMD160_ASM_OBJ)'              \
277                 WP_ASM_OBJ='$(WP_ASM_OBJ)'                      \
278                 MODES_ASM_OBJ='$(MODES_ASM_OBJ)'                \
279                 PADLOCK_ASM_OBJ='$(PADLOCK_ASM_OBJ)'            \
280                 CHACHA_ENC='$(CHACHA_ENC)'                      \
281                 POLY1305_ASM_OBJ='$(POLY1305_ASM_OBJ)'          \
282                 PERLASM_SCHEME='$(PERLASM_SCHEME)'              \
283                 FIPSLIBDIR='${FIPSLIBDIR}'                      \
284                 FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"      \
285                 THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
286 # MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
287 # which in turn eliminates ambiguities in variable treatment with -e.
288
289 # BUILD_CMD is a generic macro to build a given target in a given
290 # subdirectory.  The target must be given through the shell variable
291 # `target' and the subdirectory to build in must be given through `dir'.
292 # This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
293 # BUILD_ONE_CMD instead.
294 #
295 # RECURSIVE_BUILD_CMD is a macro to build a given target in all
296 # subdirectories defined in $(DIRS).  It requires that the target
297 # is given through the shell variable `target'.
298 #
299 # BUILD_ONE_CMD is a macro to build a given target in a given
300 # subdirectory if that subdirectory is part of $(DIRS).  It requires
301 # exactly the same shell variables as BUILD_CMD.
302 BUILD_CMD=  if [ -d "$$dir" ]; then \
303             (   cd $$dir && echo "making $$target in $$dir..." && \
304                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
305             ) || exit 1; \
306             fi
307 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                 $(BUILD_CMD); \
311         fi
312
313 reflect:
314         @[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
315
316 sub_all: build_all
317
318 build_all_but_tests: build_libs build_apps build_tools
319 build_all: build_all_but_tests build_tests
320
321 build_libs: build_libcrypto build_libssl openssl.pc
322
323 build_libcrypto: build_crypto build_engines libcrypto.pc
324 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 all_testapps: build_libs build_testapps
341 build_testapps:
342         @dir=crypto; target=testapps; $(BUILD_ONE_CMD)
343
344 libcrypto$(SHLIB_EXT): libcrypto.a
345         @if [ "$(SHLIB_TARGET)" != "" ]; then \
346                 if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
347                         FIPSLD_CC="$(CC)"; CC=fips/fipsld; \
348                         export CC FIPSLD_CC; \
349                 fi; \
350                 $(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
351         else \
352                 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         else \
360                 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                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
368                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
369                         symlink.$(SHLIB_TARGET); \
370                 libs="$$libs -l$$i"; \
371         done
372
373 build-shared: do_$(SHLIB_TARGET) link-shared
374
375 do_$(SHLIB_TARGET):
376         @ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
377                 $(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
378                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
379                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
380                         LIBDEPS="$$libs $(EX_LIBS)" \
381                         link_shlib.$(SHLIB_TARGET); \
382                 libs="-l$$i $$libs"; \
383                 case "$(PLATFORM)" in \
384                 Cygwin*) \
385                         rm -f apps/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
386                         rm -f test/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
387                         cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll apps/; \
388                         cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll test/; \
389                         ;; \
390                 mingw*) \
391                         arch=; \
392                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
393                                 arch=-x64; \
394                         fi; \
395                         rm -f apps/lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll; \
396                         rm -f test/lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll; \
397                         cp lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll apps/; \
398                         cp lib$$i-$(SHLIB_MAJOR)_$(SHLIB_MINOR)$$arch.dll test/; \
399                         ;; \
400                 esac; \
401         done
402
403 libcrypto.pc: Makefile
404         @ ( echo 'prefix=$(INSTALLTOP)'; \
405             echo 'exec_prefix=$${prefix}'; \
406             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
407             echo 'includedir=$${prefix}/include'; \
408             echo ''; \
409             echo 'Name: OpenSSL-libcrypto'; \
410             echo 'Description: OpenSSL cryptography library'; \
411             echo 'Version: '$(VERSION); \
412             echo 'Requires: '; \
413             echo 'Libs: -L$${libdir} -lcrypto'; \
414             echo 'Libs.private: $(EX_LIBS)'; \
415             echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
416
417 libssl.pc: Makefile
418         @ ( echo 'prefix=$(INSTALLTOP)'; \
419             echo 'exec_prefix=$${prefix}'; \
420             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
421             echo 'includedir=$${prefix}/include'; \
422             echo ''; \
423             echo 'Name: OpenSSL-libssl'; \
424             echo 'Description: Secure Sockets Layer and cryptography libraries'; \
425             echo 'Version: '$(VERSION); \
426             echo 'Requires.private: libcrypto'; \
427             echo 'Libs: -L$${libdir} -lssl'; \
428             echo 'Libs.private: $(EX_LIBS)'; \
429             echo 'Cflags: -I$${includedir}' ) > libssl.pc
430
431 openssl.pc: Makefile
432         @ ( echo 'prefix=$(INSTALLTOP)'; \
433             echo 'exec_prefix=$${prefix}'; \
434             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
435             echo 'includedir=$${prefix}/include'; \
436             echo ''; \
437             echo 'Name: OpenSSL'; \
438             echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
439             echo 'Version: '$(VERSION); \
440             echo 'Requires: libssl libcrypto' ) > openssl.pc
441
442 Makefile: Makefile.in Configure config
443         @echo "Makefile is older than Makefile.in, Configure or config."
444         @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
445         @false
446
447 libclean:
448         rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
449
450 clean:  libclean
451         rm -f */*/*.o */*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
452         rm -rf *.bak certs/.0
453         @set -e; target=clean; $(RECURSIVE_BUILD_CMD)
454         rm -f $(LIBS) tags TAGS
455         rm -f openssl.pc libssl.pc libcrypto.pc
456         rm -f speed.* .pure
457         rm -f $(TARFILE)
458
459 makefile.one: files
460         $(PERL) util/mk1mf.pl >makefile.one; \
461         sh util/do_ms.sh
462
463 files:
464         $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
465         @set -e; target=files; $(RECURSIVE_BUILD_CMD)
466
467 gentests:
468         @(cd test && echo "generating dummy tests (if needed)..." && \
469         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
470
471 rehash: rehash.time
472 rehash.time: certs build_apps build_tools
473         @if [ -z "$(CROSS_COMPILE)" ]; then \
474                 (OPENSSL="`pwd`/util/opensslwrap.sh"; \
475                 [ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
476                 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
477                 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
478                 $$OPENSSL rehash certs/demo \
479                 || $(PERL) tools/c_rehash certs/demo) && \
480                 touch rehash.time; \
481         else :; fi
482
483 test:   files tests
484
485
486 tests:  build_tests rehash
487         @(cd test && echo "testing..." && \
488         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
489         @if [ -z "$(CROSS_COMPILE)" ]; then \
490                 OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \
491         fi
492
493 list-tests:
494         @(cd test && \
495                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)
496
497 report:
498         @$(PERL) util/selftest.pl
499
500 tags TAGS: FORCE
501         rm -f TAGS tags
502         -ctags -R .
503         -etags `find . -name '*.[ch]' -o -name '*.pm'`
504
505 FORCE:
506
507 depend:
508         @set -e; target=depend; $(RECURSIVE_BUILD_CMD)
509
510 update: generate errors ordinals depend
511
512 generate:
513         (cd apps && PERL='${PERL}' $(MAKE) generate)
514         (cd crypto/bn && PERL='${PERL}' $(MAKE) generate)
515         (cd crypto/objects && PERL='${PERL}' $(MAKE) generate)
516
517 errors:
518         $(PERL) util/ck_errf.pl -strict */*.c */*/*.c
519         $(PERL) util/mkerr.pl -recurse -write
520         (cd engines; $(MAKE) PERL=$(PERL) errors)
521         (cd crypto/ct; $(MAKE) PERL=$(PERL) errors)
522
523 ordinals: util/libeay.num util/ssleay.num test_ordinals TABLE
524 util/libeay.num::
525         $(PERL) util/mkdef.pl crypto update
526 util/ssleay.num::
527         $(PERL) util/mkdef.pl ssl update
528 test_ordinals:
529         TOP=$(TOP) PERL=$(PERL) $(PERL) test/run_tests.pl test_ordinals
530
531 TABLE: Configure Configurations/*.conf
532         (echo 'Output of `Configure TABLE'"':"; \
533         $(PERL) Configure TABLE) > TABLE
534
535 # Build distribution tar-file. As the list of files returned by "find" is
536 # pretty long, on several platforms a "too many arguments" error or similar
537 # would occur. Therefore the list of files is temporarily stored into a file
538 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
539 # tar does not support the --files-from option.
540 TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
541                                --owner 0 --group 0 \
542                                --transform 's|^|$(NAME)/|' \
543                                -cvf -
544
545 $(TARFILE).list:
546         git diff --quiet HEAD
547         git ls-files | sort > $(TARFILE).list
548
549 tar: $(TARFILE).list
550         find . -type d -print | xargs chmod 755
551         find . -type f -print | xargs chmod a+r
552         find . -type f -perm -0100 -print | xargs chmod a+x
553         $(TAR_COMMAND) | gzip --best > $(TARFILE).gz
554         rm -f $(TARFILE).list
555         ls -l $(TARFILE).gz
556
557 tar-snap: $(TARFILE).list
558         $(TAR_COMMAND) > $(TARFILE)
559         rm -f $(TARFILE).list
560         ls -l $(TARFILE)
561
562 dist:
563         $(PERL) Configure dist
564         @$(MAKE) SDIRS='$(SDIRS)' clean
565         @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
566
567 install: all install_docs install_sw
568
569 uninstall: uninstall_sw uninstall_docs
570
571 install_sw:
572         @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
573         @set -e; for i in include/openssl/*.h; do \
574         (cp $$i $(DESTDIR)$(INSTALLTOP)/$$i; \
575         chmod 644 $(DESTDIR)$(INSTALLTOP)/$$i ); \
576         done;
577         @set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
578         @set -e; liblist="$(LIBS)"; for i in $$liblist ;\
579         do \
580                 if [ -f "$$i" ]; then \
581                 (       echo installing $$i; \
582                         cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
583                         $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
584                         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
585                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
586                 fi; \
587         done;
588         @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
589                 tmp="$(SHARED_LIBS)"; \
590                 for i in $${tmp:-x}; \
591                 do \
592                         if [ -f "$$i" -o -f "$$i.a" ]; then \
593                                 case "$(PLATFORM)" in \
594                                 Cygwin*) \
595                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
596                                         echo installing $$c; \
597                                         cp $$c $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
598                                         chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
599                                         mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$c.new $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
600                                         echo installing $$i.a; \
601                                         cp $$i.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
602                                         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
603                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
604                                         ;; \
605                                 mingw*) \
606                                         arch=; \
607                                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
608                                                 arch=-x64; \
609                                         fi; \
610                                         m=`echo $$i | sed -e 's/\.dll$$/-$(SHLIB_MAJOR)_$(SHLIB_MINOR)'"$$arch"'.dll/'`; \
611                                         echo installing $$m; \
612                                         cp $$m $(DESTDIR)$(INSTALLTOP)/bin/$$m.new; \
613                                         chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$m.new; \
614                                         mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$m.new $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
615                                         echo installing $$i.a; \
616                                         cp $$i.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
617                                         chmod 555 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
618                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
619                                         ;; \
620                                 *) \
621                                         echo installing $$i; \
622                                         cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
623                                         chmod 555 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
624                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
625                                         ;; \
626                                 esac; \
627                         fi; \
628                 done; \
629                 (       here="`pwd`"; \
630                         cd $(DESTDIR)$(INSTALLTOP)/$(LIBDIR); \
631                         $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
632                 if [ "$(INSTALLTOP)" != "/usr" ]; then \
633                         echo 'OpenSSL shared libraries have been installed in:'; \
634                         echo '  $(INSTALLTOP)'; \
635                 fi; \
636         fi
637         cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
638         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
639         cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
640         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
641         cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
642         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
643
644 uninstall_sw:
645         cd include/openssl && files=* && cd $(DESTDIR)$(INSTALLTOP)/include/openssl && $(RM) $$files
646         @for i in $(LIBS) ;\
647         do \
648                 test -f "$$i" && \
649                 echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i && \
650                 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
651         done;
652         @if [ -n "$(SHARED_LIBS)" ]; then \
653                 tmp="$(SHARED_LIBS)"; \
654                 for i in $${tmp:-x}; \
655                 do \
656                         if [ -f "$$i" -o -f "$$i.a" ]; then \
657                                 case "$(PLATFORM)" in \
658                                 Cygwin*) \
659                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
660                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
661                                         $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
662                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
663                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
664                                         ;; \
665                                 mingw*) \
666                                         arch=; \
667                                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
668                                                 arch=-x64; \
669                                         fi; \
670                                         m=`echo $$i | sed -e 's/\.dll$$/-$(SHLIB_MAJOR)_$(SHLIB_MINOR)'"$$arch"'.dll/'`; \
671                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
672                                         $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
673                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
674                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
675                                         ;; \
676                                 *) \
677                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
678                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
679                                         ;; \
680                                 esac; \
681                         fi; \
682                 done; \
683         fi
684         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
685         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
686         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
687         @target=uninstall; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
688
689 install_html_docs:
690         here="`pwd`"; \
691         filecase=; \
692         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
693                 filecase=-i; \
694         esac; \
695         for subdir in apps crypto ssl; do \
696                 $(PERL) $(TOP)/util/mkdir-p $(DESTDIR)$(HTMLDIR)/$$subdir; \
697                 for i in doc/$$subdir/*.pod; do \
698                         fn=`basename $$i .pod`; \
699                         echo "installing html/$$fn.$(HTMLSUFFIX)"; \
700                         cat $$i \
701                         | sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
702                         | pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
703                         | sed -r 's/<!DOCTYPE.*//g' \
704                         > $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
705                         $(PERL) util/extract-names.pl < $$i | \
706                                 grep -v $$filecase "^$$fn\$$" | \
707                                 (cd $(DESTDIR)$(HTMLDIR)/$$subdir; \
708                                  while read n; do \
709                                         PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
710                                  done); \
711                 done; \
712         done
713
714 uninstall_html_docs:
715         here="`pwd`"; \
716         filecase=; \
717         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
718                 filecase=-i; \
719         esac; \
720         for subdir in apps crypto ssl; do \
721                 for i in doc/$$subdir/*.pod; do \
722                         fn=`basename $$i .pod`; \
723                         $(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
724                         $(PERL) util/extract-names.pl < $$i | \
725                                 grep -v $$filecase "^$$fn\$$" | \
726                                 while read n; do \
727                                         $(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
728                                 done; \
729                 done; \
730         done
731
732 install_docs:
733         @$(PERL) $(TOP)/util/mkdir-p.pl \
734                 $(DESTDIR)$(MANDIR)/man1 \
735                 $(DESTDIR)$(MANDIR)/man3 \
736                 $(DESTDIR)$(MANDIR)/man5 \
737                 $(DESTDIR)$(MANDIR)/man7
738         here="`pwd`"; \
739         filecase=; \
740         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
741                 filecase=-i; \
742         esac; \
743         set -e; for i in doc/apps/*.pod; do \
744                 fn=`basename $$i .pod`; \
745                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
746                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
747                 (cd `$(PERL) util/dirname.pl $$i`; \
748                 pod2man \
749                         --section=$$sec --center=OpenSSL \
750                         --release=$(VERSION) `basename $$i`) \
751                         >  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
752                 $(PERL) util/extract-names.pl < $$i | \
753                         (grep -v $$filecase "^$$fn\$$"; true) | \
754                         (grep -v "[     ]"; true) | \
755                         (cd $(DESTDIR)$(MANDIR)/man$$sec/; \
756                          while read n; do \
757                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
758                          done); \
759         done; \
760         set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
761                 fn=`basename $$i .pod`; \
762                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
763                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
764                 (cd `$(PERL) util/dirname.pl $$i`; \
765                 pod2man \
766                         --section=$$sec --center=OpenSSL \
767                         --release=$(VERSION) `basename $$i`) \
768                         >  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
769                 $(PERL) util/extract-names.pl < $$i | \
770                         (grep -v $$filecase "^$$fn\$$"; true) | \
771                         (grep -v "[     ]"; true) | \
772                         (cd $(DESTDIR)$(MANDIR)/man$$sec/; \
773                          while read n; do \
774                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
775                          done); \
776         done
777
778 uninstall_docs:
779         @here="`pwd`"; \
780         filecase=; \
781         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
782                 filecase=-i; \
783         esac; \
784         for i in doc/apps/*.pod; do \
785                 fn=`basename $$i .pod`; \
786                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
787                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
788                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
789                 $(PERL) util/extract-names.pl < $$i | \
790                         (grep -v $$filecase "^$$fn\$$"; true) | \
791                         (grep -v "[     ]"; true) | \
792                         while read n; do \
793                                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
794                                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
795                         done; \
796         done; \
797         for i in doc/crypto/*.pod doc/ssl/*.pod; do \
798                 fn=`basename $$i .pod`; \
799                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
800                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
801                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
802                 $(PERL) util/extract-names.pl < $$i | \
803                         (grep -v $$filecase "^$$fn\$$"; true) | \
804                         (grep -v "[     ]"; true) | \
805                         while read n; do \
806                                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
807                                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
808                         done; \
809         done
810
811 # DO NOT DELETE THIS LINE -- make depend depends on it.