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