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