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