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