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