bn/asm/x86_64-mont5.pl: unify gather procedure in hardly used path
[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 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 test:   files tests
475
476 tests:  build_tests 
477         @(cd test && echo "testing..." && \
478         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
479         @if [ -z "$(CROSS_COMPILE)" ]; then \
480                 OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \
481         fi
482
483 list-tests:
484         @(cd test && \
485                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)
486
487 report:
488         @$(PERL) util/selftest.pl
489
490 tags TAGS: FORCE
491         rm -f TAGS tags
492         -ctags -R .
493         -etags `find . -name '*.[ch]' -o -name '*.pm'`
494
495 FORCE:
496
497 depend:
498         @set -e; target=depend; $(RECURSIVE_BUILD_CMD)
499
500 update: generate errors ordinals depend
501
502 generate:
503         (cd apps && PERL='${PERL}' $(MAKE) generate)
504         (cd crypto/bn && PERL='${PERL}' $(MAKE) generate)
505         (cd crypto/objects && PERL='${PERL}' $(MAKE) generate)
506
507 errors:
508         $(PERL) util/ck_errf.pl -strict */*.c */*/*.c
509         $(PERL) util/mkerr.pl -recurse -write
510         (cd engines; $(MAKE) PERL=$(PERL) errors)
511
512 ordinals: util/libeay.num util/ssleay.num test_ordinals TABLE
513 util/libeay.num::
514         $(PERL) util/mkdef.pl crypto update
515 util/ssleay.num::
516         $(PERL) util/mkdef.pl ssl update
517 test_ordinals:
518         TOP=$(TOP) PERL=$(PERL) $(PERL) test/run_tests.pl test_ordinals
519
520 TABLE: Configure Configurations/*.conf
521         (echo 'Output of `Configure TABLE'"':"; \
522         $(PERL) Configure TABLE) > TABLE
523
524 # Build distribution tar-file. As the list of files returned by "find" is
525 # pretty long, on several platforms a "too many arguments" error or similar
526 # would occur. Therefore the list of files is temporarily stored into a file
527 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
528 # tar does not support the --files-from option.
529 TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
530                                --owner 0 --group 0 \
531                                --transform 's|^|$(NAME)/|' \
532                                -cvf -
533
534 $(TARFILE).list:
535         git diff --quiet HEAD
536         git ls-files | sort > $(TARFILE).list
537
538 tar: $(TARFILE).list
539         find . -type d -print | xargs chmod 755
540         find . -type f -print | xargs chmod a+r
541         find . -type f -perm -0100 -print | xargs chmod a+x
542         $(TAR_COMMAND) | gzip --best > $(TARFILE).gz
543         rm -f $(TARFILE).list
544         ls -l $(TARFILE).gz
545
546 tar-snap: $(TARFILE).list
547         $(TAR_COMMAND) > $(TARFILE)
548         rm -f $(TARFILE).list
549         ls -l $(TARFILE)
550
551 dist:
552         $(PERL) Configure dist
553         @$(MAKE) SDIRS='$(SDIRS)' clean
554         @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
555
556 install: all install_docs install_sw
557
558 uninstall: uninstall_sw uninstall_docs
559
560 install_sw:
561         @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
562         @set -e; for i in include/openssl/*.h; do \
563         (cp $$i $(DESTDIR)$(INSTALLTOP)/$$i; \
564         chmod 644 $(DESTDIR)$(INSTALLTOP)/$$i ); \
565         done;
566         @set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
567         @set -e; liblist="$(LIBS)"; for i in $$liblist ;\
568         do \
569                 if [ -f "$$i" ]; then \
570                 (       echo installing $$i; \
571                         cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
572                         $(RANLIB) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
573                         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
574                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
575                 fi; \
576         done;
577         @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
578                 tmp="$(SHARED_LIBS)"; \
579                 for i in $${tmp:-x}; \
580                 do \
581                         if [ -f "$$i" -o -f "$$i.a" ]; then \
582                                 case "$(PLATFORM)" in \
583                                 Cygwin*) \
584                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
585                                         echo installing $$c; \
586                                         cp $$c $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
587                                         chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$c.new; \
588                                         mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$c.new $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
589                                         echo installing $$i.a; \
590                                         cp $$i.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
591                                         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
592                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
593                                         ;; \
594                                 mingw*) \
595                                         arch=; \
596                                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
597                                                 arch=-x64; \
598                                         fi; \
599                                         m=`echo $$i | sed -e 's/\.dll$$/-$(SHLIB_MAJOR)_$(SHLIB_MINOR)'"$$arch"'.dll/'`; \
600                                         echo installing $$m; \
601                                         cp $$m $(DESTDIR)$(INSTALLTOP)/bin/$$m.new; \
602                                         chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$m.new; \
603                                         mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$m.new $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
604                                         echo installing $$i.a; \
605                                         cp $$i.a $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
606                                         chmod 555 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new; \
607                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
608                                         ;; \
609                                 *) \
610                                         echo installing $$i; \
611                                         cp $$i $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
612                                         chmod 555 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
613                                         mv -f $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
614                                         ;; \
615                                 esac; \
616                         fi; \
617                 done; \
618                 (       here="`pwd`"; \
619                         cd $(DESTDIR)$(INSTALLTOP)/$(LIBDIR); \
620                         $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
621                 if [ "$(INSTALLTOP)" != "/usr" ]; then \
622                         echo 'OpenSSL shared libraries have been installed in:'; \
623                         echo '  $(INSTALLTOP)'; \
624                 fi; \
625         fi
626         cp libcrypto.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
627         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
628         cp libssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
629         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
630         cp openssl.pc $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
631         chmod 644 $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
632
633 uninstall_sw:
634         cd include/openssl && files=* && cd $(DESTDIR)$(INSTALLTOP)/include/openssl && $(RM) $$files
635         @for i in $(LIBS) ;\
636         do \
637                 test -f "$$i" && \
638                 echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i && \
639                 $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
640         done;
641         @if [ -n "$(SHARED_LIBS)" ]; then \
642                 tmp="$(SHARED_LIBS)"; \
643                 for i in $${tmp:-x}; \
644                 do \
645                         if [ -f "$$i" -o -f "$$i.a" ]; then \
646                                 case "$(PLATFORM)" in \
647                                 Cygwin*) \
648                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
649                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
650                                         $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$c; \
651                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
652                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
653                                         ;; \
654                                 mingw*) \
655                                         arch=; \
656                                         if expr $(PLATFORM) : mingw64 > /dev/null; then \
657                                                 arch=-x64; \
658                                         fi; \
659                                         m=`echo $$i | sed -e 's/\.dll$$/-$(SHLIB_MAJOR)_$(SHLIB_MINOR)'"$$arch"'.dll/'`; \
660                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
661                                         $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$m; \
662                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
663                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i.a; \
664                                         ;; \
665                                 *) \
666                                         echo $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
667                                         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/$$i; \
668                                         ;; \
669                                 esac; \
670                         fi; \
671                 done; \
672         fi
673         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
674         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
675         $(RM) $(DESTDIR)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
676         @target=uninstall; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
677
678 install_html_docs:
679         here="`pwd`"; \
680         filecase=; \
681         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
682                 filecase=-i; \
683         esac; \
684         for subdir in apps crypto ssl; do \
685                 $(PERL) $(TOP)/util/mkdir-p $(DESTDIR)$(HTMLDIR)/$$subdir; \
686                 for i in doc/$$subdir/*.pod; do \
687                         fn=`basename $$i .pod`; \
688                         echo "installing html/$$fn.$(HTMLSUFFIX)"; \
689                         cat $$i \
690                         | sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
691                         | pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
692                         | sed -r 's/<!DOCTYPE.*//g' \
693                         > $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
694                         $(PERL) util/extract-names.pl < $$i | \
695                                 grep -v $$filecase "^$$fn\$$" | \
696                                 (cd $(DESTDIR)$(HTMLDIR)/$$subdir; \
697                                  while read n; do \
698                                         PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
699                                  done); \
700                 done; \
701         done
702
703 uninstall_html_docs:
704         here="`pwd`"; \
705         filecase=; \
706         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
707                 filecase=-i; \
708         esac; \
709         for subdir in apps crypto ssl; do \
710                 for i in doc/$$subdir/*.pod; do \
711                         fn=`basename $$i .pod`; \
712                         $(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
713                         $(PERL) util/extract-names.pl < $$i | \
714                                 grep -v $$filecase "^$$fn\$$" | \
715                                 while read n; do \
716                                         $(RM) $(DESTDIR)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
717                                 done; \
718                 done; \
719         done
720
721 install_docs:
722         @$(PERL) $(TOP)/util/mkdir-p.pl \
723                 $(DESTDIR)$(MANDIR)/man1 \
724                 $(DESTDIR)$(MANDIR)/man3 \
725                 $(DESTDIR)$(MANDIR)/man5 \
726                 $(DESTDIR)$(MANDIR)/man7
727         here="`pwd`"; \
728         filecase=; \
729         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
730                 filecase=-i; \
731         esac; \
732         set -e; for i in doc/apps/*.pod; do \
733                 fn=`basename $$i .pod`; \
734                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
735                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
736                 (cd `$(PERL) util/dirname.pl $$i`; \
737                 pod2man \
738                         --section=$$sec --center=OpenSSL \
739                         --release=$(VERSION) `basename $$i`) \
740                         >  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
741                 $(PERL) util/extract-names.pl < $$i | \
742                         (grep -v $$filecase "^$$fn\$$"; true) | \
743                         (grep -v "[     ]"; true) | \
744                         (cd $(DESTDIR)$(MANDIR)/man$$sec/; \
745                          while read n; do \
746                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
747                          done); \
748         done; \
749         set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
750                 fn=`basename $$i .pod`; \
751                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
752                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
753                 (cd `$(PERL) util/dirname.pl $$i`; \
754                 pod2man \
755                         --section=$$sec --center=OpenSSL \
756                         --release=$(VERSION) `basename $$i`) \
757                         >  $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
758                 $(PERL) util/extract-names.pl < $$i | \
759                         (grep -v $$filecase "^$$fn\$$"; true) | \
760                         (grep -v "[     ]"; true) | \
761                         (cd $(DESTDIR)$(MANDIR)/man$$sec/; \
762                          while read n; do \
763                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
764                          done); \
765         done
766
767 uninstall_docs:
768         @here="`pwd`"; \
769         filecase=; \
770         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
771                 filecase=-i; \
772         esac; \
773         for i in doc/apps/*.pod; do \
774                 fn=`basename $$i .pod`; \
775                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
776                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
777                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
778                 $(PERL) util/extract-names.pl < $$i | \
779                         (grep -v $$filecase "^$$fn\$$"; true) | \
780                         (grep -v "[     ]"; true) | \
781                         while read n; do \
782                                 echo $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
783                                 $(RM) $(DESTDIR)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
784                         done; \
785         done; \
786         for i in doc/crypto/*.pod doc/ssl/*.pod; do \
787                 fn=`basename $$i .pod`; \
788                 sec=`$(PERL) util/extract-section.pl 3 < $$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
800 # DO NOT DELETE THIS LINE -- make depend depends on it.