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