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