Add support for shared_rcflag, useful for windres (Cygwin and Mingw)
[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 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                 $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
219                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
220                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
221                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
222                 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
223                 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
224                 $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
225                 $(INSTALL_PREFIX)$(OPENSSLDIR)/private
226
227 all: Makefile build_all
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                 INSTALL_PREFIX='$(INSTALL_PREFIX)'              \
255                 INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'   \
256                 LIBDIR='$(LIBDIR)'                              \
257                 DEPFLAG='$(DEPFLAG)'                            \
258                 SHARED_LDFLAG='$(SHARED_LDFLAG)'                \
259                 SHARED_RCFLAG='$(SHARED_RCFLAG)'                \
260                 ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'     \
261                 EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'       \
262                 SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
263                 LDFLAG='$(LDFLAG)'                              \
264                 PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)'       \
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: build_libs build_apps build_tests build_tools
315
316 build_libs: build_libcrypto build_libssl openssl.pc
317
318 build_libcrypto: build_crypto build_engines libcrypto.pc
319 build_libssl: build_ssl libssl.pc
320
321 build_crypto:
322         @dir=crypto; target=all; $(BUILD_ONE_CMD)
323 build_ssl: build_crypto
324         @dir=ssl; target=all; $(BUILD_ONE_CMD)
325 build_engines: build_crypto
326         @dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
327
328 build_apps: build_libs
329         @dir=apps; target=all; $(BUILD_ONE_CMD)
330 build_tests: build_libs
331         @dir=test; target=all; $(BUILD_ONE_CMD)
332 build_tools: build_libs
333         @dir=tools; target=all; $(BUILD_ONE_CMD)
334
335 all_testapps: build_libs build_testapps
336 build_testapps:
337         @dir=crypto; target=testapps; $(BUILD_ONE_CMD)
338
339 libcrypto$(SHLIB_EXT): libcrypto.a
340         @if [ "$(SHLIB_TARGET)" != "" ]; then \
341                 if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
342                         FIPSLD_CC="$(CC)"; CC=fips/fipsld; \
343                         export CC FIPSLD_CC; \
344                 fi; \
345                 $(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
346         else \
347                 echo "There's no support for shared libraries on this platform" >&2; \
348                 exit 1; \
349         fi
350
351 libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
352         @if [ "$(SHLIB_TARGET)" != "" ]; then \
353                 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
354         else \
355                 echo "There's no support for shared libraries on this platform" >&2; \
356                 exit 1; \
357         fi
358
359 link-shared:
360         @ set -e; for i in $(SHLIBDIRS); do \
361                 $(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
362                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
363                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
364                         symlink.$(SHLIB_TARGET); \
365                 libs="$$libs -l$$i"; \
366         done
367
368 build-shared: do_$(SHLIB_TARGET) link-shared
369
370 do_$(SHLIB_TARGET):
371         @ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
372                 $(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
373                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
374                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
375                         LIBDEPS="$$libs $(EX_LIBS)" \
376                         link_a.$(SHLIB_TARGET); \
377                 libs="-l$$i $$libs"; \
378                 case "$(PLATFORM)" in \
379                 Cygwin*) \
380                         rm -f apps/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
381                         rm -f test/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
382                         cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll apps/; \
383                         cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll test/; \
384                         ;; \
385                 mingw*) \
386                         case $$i in \
387                                 crypto) i=libeay32;; \
388                                 ssl) i=ssleay32;; \
389                         esac; \
390                         rm -f apps/$$i.dll; \
391                         rm -f test/$$i.dll; \
392                         cp $$i.dll apps/; \
393                         cp $$i.dll test/; \
394                 esac; \
395         done
396
397 libcrypto.pc: Makefile
398         @ ( echo 'prefix=$(INSTALLTOP)'; \
399             echo 'exec_prefix=$${prefix}'; \
400             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
401             echo 'includedir=$${prefix}/include'; \
402             echo ''; \
403             echo 'Name: OpenSSL-libcrypto'; \
404             echo 'Description: OpenSSL cryptography library'; \
405             echo 'Version: '$(VERSION); \
406             echo 'Requires: '; \
407             echo 'Libs: -L$${libdir} -lcrypto'; \
408             echo 'Libs.private: $(EX_LIBS)'; \
409             echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
410
411 libssl.pc: Makefile
412         @ ( echo 'prefix=$(INSTALLTOP)'; \
413             echo 'exec_prefix=$${prefix}'; \
414             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
415             echo 'includedir=$${prefix}/include'; \
416             echo ''; \
417             echo 'Name: OpenSSL-libssl'; \
418             echo 'Description: Secure Sockets Layer and cryptography libraries'; \
419             echo 'Version: '$(VERSION); \
420             echo 'Requires.private: libcrypto'; \
421             echo 'Libs: -L$${libdir} -lssl'; \
422             echo 'Libs.private: $(EX_LIBS)'; \
423             echo 'Cflags: -I$${includedir}' ) > libssl.pc
424
425 openssl.pc: Makefile
426         @ ( echo 'prefix=$(INSTALLTOP)'; \
427             echo 'exec_prefix=$${prefix}'; \
428             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
429             echo 'includedir=$${prefix}/include'; \
430             echo ''; \
431             echo 'Name: OpenSSL'; \
432             echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
433             echo 'Version: '$(VERSION); \
434             echo 'Requires: libssl libcrypto' ) > openssl.pc
435
436 Makefile: Makefile.in Configure config
437         @echo "Makefile is older than Makefile.in, Configure or config."
438         @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
439         @false
440
441 libclean:
442         rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
443
444 clean:  libclean
445         rm -f */*/*.o */*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
446         rm -rf *.bak certs/.0
447         @set -e; target=clean; $(RECURSIVE_BUILD_CMD)
448         rm -f $(LIBS) tags TAGS
449         rm -f openssl.pc libssl.pc libcrypto.pc
450         rm -f speed.* .pure
451         rm -f $(TARFILE)
452
453 makefile.one: files
454         $(PERL) util/mk1mf.pl >makefile.one; \
455         sh util/do_ms.sh
456
457 files:
458         $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
459         @set -e; target=files; $(RECURSIVE_BUILD_CMD)
460
461 gentests:
462         @(cd test && echo "generating dummy tests (if needed)..." && \
463         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
464
465 rehash: rehash.time
466 rehash.time: certs build_apps build_tools
467         @if [ -z "$(CROSS_COMPILE)" ]; then \
468                 (OPENSSL="`pwd`/util/opensslwrap.sh"; \
469                 [ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
470                 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
471                 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
472                 $$OPENSSL rehash certs/demo \
473                 || $(PERL) tools/c_rehash certs/demo) && \
474                 touch rehash.time; \
475         else :; fi
476
477 test:   files tests
478
479
480 tests: rehash
481         @(cd test && echo "testing..." && \
482         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
483         @if [ -z "$(CROSS_COMPILE)" ]; then \
484                 OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \
485         fi
486
487 list-tests:
488         @(cd test && \
489                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. list-tests)
490
491 report:
492         @$(PERL) util/selftest.pl
493
494 tags TAGS: FORCE
495         rm -f TAGS tags
496         -ctags -R .
497         -etags `find . -name '*.[ch]' -o -name '*.pm'`
498
499 FORCE:
500
501 depend:
502         @set -e; target=depend; $(RECURSIVE_BUILD_CMD)
503
504 update: generate errors ordinals depend
505
506 generate:
507         (cd apps && PERL='${PERL}' $(MAKE) generate)
508         (cd crypto/bn && PERL='${PERL}' $(MAKE) generate)
509         (cd crypto/objects && PERL='${PERL}' $(MAKE) generate)
510
511 errors:
512         $(PERL) util/ck_errf.pl -strict */*.c */*/*.c
513         $(PERL) util/mkerr.pl -recurse -write
514         (cd engines; $(MAKE) PERL=$(PERL) errors)
515         (cd crypto/ct; $(MAKE) PERL=$(PERL) errors)
516
517 ordinals: util/libeay.num util/ssleay.num test_ordinals TABLE
518 util/libeay.num::
519         $(PERL) util/mkdef.pl crypto update
520 util/ssleay.num::
521         $(PERL) util/mkdef.pl ssl update
522 test_ordinals:
523         TOP=$(TOP) PERL=$(PERL) $(PERL) test/run_tests.pl test_ordinals
524
525 TABLE: Configure Configurations/*.conf
526         (echo 'Output of `Configure TABLE'"':"; \
527         $(PERL) Configure TABLE) > TABLE
528
529 # Build distribution tar-file. As the list of files returned by "find" is
530 # pretty long, on several platforms a "too many arguments" error or similar
531 # would occur. Therefore the list of files is temporarily stored into a file
532 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
533 # tar does not support the --files-from option.
534 TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
535                                --owner 0 --group 0 \
536                                --transform 's|^|$(NAME)/|' \
537                                -cvf -
538
539 $(TARFILE).list:
540         git diff --quiet HEAD
541         git ls-files | sort > $(TARFILE).list
542
543 tar: $(TARFILE).list
544         find . -type d -print | xargs chmod 755
545         find . -type f -print | xargs chmod a+r
546         find . -type f -perm -0100 -print | xargs chmod a+x
547         $(TAR_COMMAND) | gzip --best > $(TARFILE).gz
548         rm -f $(TARFILE).list
549         ls -l $(TARFILE).gz
550
551 tar-snap: $(TARFILE).list
552         $(TAR_COMMAND) > $(TARFILE)
553         rm -f $(TARFILE).list
554         ls -l $(TARFILE)
555
556 dist:
557         $(PERL) Configure dist
558         @$(MAKE) SDIRS='$(SDIRS)' clean
559         @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
560
561 install: all install_docs install_sw
562
563 uninstall: uninstall_sw uninstall_docs
564
565 install_sw:
566         @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
567         @set -e; for i in include/openssl/*.h; do \
568         (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$$i; \
569         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$$i ); \
570         done;
571         @set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
572         @set -e; liblist="$(LIBS)"; for i in $$liblist ;\
573         do \
574                 if [ -f "$$i" ]; then \
575                 (       echo installing $$i; \
576                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
577                         $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
578                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
579                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
580                 fi; \
581         done;
582         @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
583                 tmp="$(SHARED_LIBS)"; \
584                 for i in $${tmp:-x}; \
585                 do \
586                         if [ -f "$$i" -o -f "$$i.a" ]; then \
587                         (       echo installing $$i; \
588                                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
589                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
590                                         cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
591                                         chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
592                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
593                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
594                                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
595                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
596                                 else \
597                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
598                                         chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
599                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
600                                 fi ); \
601                                 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
602                                 (       case $$i in \
603                                                 *crypto*) i=libeay32.dll;; \
604                                                 *ssl*)    i=ssleay32.dll;; \
605                                         esac; \
606                                         echo installing $$i; \
607                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
608                                         chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
609                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
610                                 fi; \
611                         fi; \
612                 done; \
613                 (       here="`pwd`"; \
614                         cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
615                         $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
616                 if [ "$(INSTALLTOP)" != "/usr" ]; then \
617                         echo 'OpenSSL shared libraries have been installed in:'; \
618                         echo '  $(INSTALLTOP)'; \
619                 fi; \
620         fi
621         cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
622         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
623         cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
624         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
625         cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
626         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
627
628 uninstall_sw:
629         cd include/openssl && files=* && cd $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl && $(RM) $$files
630         @for i in $(LIBS) ;\
631         do \
632                 test -f "$$i" && \
633                 echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i && \
634                 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
635         done;
636         @if [ -n "$(SHARED_LIBS)" ]; then \
637                 tmp="$(SHARED_LIBS)"; \
638                 for i in $${tmp:-x}; \
639                 do \
640                         if [ -f "$$i" -o -f "$$i.a" ]; then \
641                                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
642                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
643                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
644                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
645                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
646                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
647                                 else \
648                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
649                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
650                                 fi; \
651                                 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
652                                         case $$i in \
653                                                 *crypto*) i=libeay32.dll;; \
654                                                 *ssl*)    i=ssleay32.dll;; \
655                                         esac; \
656                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
657                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
658                                 fi; \
659                         fi; \
660                 done; \
661         fi
662         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
663         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
664         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
665         @target=uninstall; $(RECURSIVE_BUILD_CMD)
666
667 install_html_docs:
668         here="`pwd`"; \
669         filecase=; \
670         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
671                 filecase=-i; \
672         esac; \
673         for subdir in apps crypto ssl; do \
674                 $(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
675                 for i in doc/$$subdir/*.pod; do \
676                         fn=`basename $$i .pod`; \
677                         echo "installing html/$$fn.$(HTMLSUFFIX)"; \
678                         cat $$i \
679                         | sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
680                         | pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
681                         | sed -r 's/<!DOCTYPE.*//g' \
682                         > $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
683                         $(PERL) util/extract-names.pl < $$i | \
684                                 grep -v $$filecase "^$$fn\$$" | \
685                                 (cd $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
686                                  while read n; do \
687                                         PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
688                                  done); \
689                 done; \
690         done
691
692 uninstall_html_docs:
693         here="`pwd`"; \
694         filecase=; \
695         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
696                 filecase=-i; \
697         esac; \
698         for subdir in apps crypto ssl; do \
699                 for i in doc/$$subdir/*.pod; do \
700                         fn=`basename $$i .pod`; \
701                         $(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
702                         $(PERL) util/extract-names.pl < $$i | \
703                                 grep -v $$filecase "^$$fn\$$" | \
704                                 while read n; do \
705                                         $(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
706                                 done; \
707                 done; \
708         done
709
710 install_docs:
711         @$(PERL) $(TOP)/util/mkdir-p.pl \
712                 $(INSTALL_PREFIX)$(MANDIR)/man1 \
713                 $(INSTALL_PREFIX)$(MANDIR)/man3 \
714                 $(INSTALL_PREFIX)$(MANDIR)/man5 \
715                 $(INSTALL_PREFIX)$(MANDIR)/man7
716         here="`pwd`"; \
717         filecase=; \
718         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
719                 filecase=-i; \
720         esac; \
721         set -e; for i in doc/apps/*.pod; do \
722                 fn=`basename $$i .pod`; \
723                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
724                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
725                 (cd `$(PERL) util/dirname.pl $$i`; \
726                 pod2man \
727                         --section=$$sec --center=OpenSSL \
728                         --release=$(VERSION) `basename $$i`) \
729                         >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
730                 $(PERL) util/extract-names.pl < $$i | \
731                         (grep -v $$filecase "^$$fn\$$"; true) | \
732                         (grep -v "[     ]"; true) | \
733                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
734                          while read n; do \
735                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
736                          done); \
737         done; \
738         set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
739                 fn=`basename $$i .pod`; \
740                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
741                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
742                 (cd `$(PERL) util/dirname.pl $$i`; \
743                 pod2man \
744                         --section=$$sec --center=OpenSSL \
745                         --release=$(VERSION) `basename $$i`) \
746                         >  $(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                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
751                          while read n; do \
752                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
753                          done); \
754         done
755
756 uninstall_docs:
757         @here="`pwd`"; \
758         filecase=; \
759         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
760                 filecase=-i; \
761         esac; \
762         for i in doc/apps/*.pod; do \
763                 fn=`basename $$i .pod`; \
764                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
765                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
766                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
767                 $(PERL) util/extract-names.pl < $$i | \
768                         (grep -v $$filecase "^$$fn\$$"; true) | \
769                         (grep -v "[     ]"; true) | \
770                         while read n; do \
771                                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
772                                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
773                         done; \
774         done; \
775         for i in doc/crypto/*.pod doc/ssl/*.pod; do \
776                 fn=`basename $$i .pod`; \
777                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
778                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
779                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
780                 $(PERL) util/extract-names.pl < $$i | \
781                         (grep -v $$filecase "^$$fn\$$"; true) | \
782                         (grep -v "[     ]"; true) | \
783                         while read n; do \
784                                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
785                                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
786                         done; \
787         done
788
789 # DO NOT DELETE THIS LINE -- make depend depends on it.