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