unix-Makefile.tmpl 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  1. ##
  2. ## Makefile for OpenSSL
  3. ##
  4. ## {- join("\n## ", @autowarntext) -}
  5. {-
  6. our $objext = $target{obj_extension} || ".o";
  7. our $depext = $target{dep_extension} || ".d";
  8. our $exeext = $target{exe_extension} || "";
  9. our $libext = $target{lib_extension} || ".a";
  10. our $shlibext = $target{shared_extension} || ".so";
  11. our $shlibvariant = $target{shlib_variant} || "";
  12. our $shlibextsimple = $target{shared_extension_simple} || ".so";
  13. our $shlibextimport = $target{shared_import_extension} || "";
  14. our $dsoext = $target{dso_extension} || ".so";
  15. our $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
  16. sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
  17. our $sover_dirname = $config{shlib_version_number};
  18. $sover_dirname =~ s|\.|_|g
  19. if $config{target} =~ /^mingw/;
  20. # shlib and shlib_simple both take a static library name and figure
  21. # out what the shlib name should be.
  22. #
  23. # When OpenSSL is configured "no-shared", these functions will just
  24. # return empty lists, making them suitable to join().
  25. #
  26. # With Windows DLL producers, shlib($libname) will return the shared
  27. # library name (which usually is different from the static library
  28. # name) with the default shared extension appended to it, while
  29. # shlib_simple($libname) will return the static library name with
  30. # the shared extension followed by ".a" appended to it. The former
  31. # result is used as the runtime shared library while the latter is
  32. # used as the DLL import library.
  33. #
  34. # On all Unix systems, shlib($libname) will return the library name
  35. # with the default shared extension, while shlib_simple($libname)
  36. # will return the name from shlib($libname) with any SO version number
  37. # removed. On some systems, they may therefore return the exact same
  38. # string.
  39. sub shlib {
  40. my $lib = shift;
  41. return () if $disabled{shared} || $lib =~ /\.a$/;
  42. return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
  43. }
  44. sub shlib_simple {
  45. my $lib = shift;
  46. return () if $disabled{shared} || $lib =~ /\.a$/;
  47. if (windowsdll()) {
  48. return $lib . '$(SHLIB_EXT_IMPORT)';
  49. }
  50. return $lib . '$(SHLIB_EXT_SIMPLE)';
  51. }
  52. # Easy fixing of static library names
  53. sub lib {
  54. (my $lib = shift) =~ s/\.a$//;
  55. return $lib . $libext;
  56. }
  57. # dso is a complement to shlib / shlib_simple that returns the
  58. # given libname with the simple shared extension (possible SO version
  59. # removed). This differs from shlib_simple() by being unconditional.
  60. sub dso {
  61. my $engine = shift;
  62. return $engine . $dsoext;
  63. }
  64. # This makes sure things get built in the order they need
  65. # to. You're welcome.
  66. sub dependmagic {
  67. my $target = shift;
  68. return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
  69. }
  70. '';
  71. -}
  72. PLATFORM={- $config{target} -}
  73. OPTIONS={- $config{options} -}
  74. CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
  75. SRCDIR={- $config{sourcedir} -}
  76. BLDDIR={- $config{builddir} -}
  77. VERSION={- $config{version} -}
  78. MAJOR={- $config{major} -}
  79. MINOR={- $config{minor} -}
  80. SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
  81. SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
  82. SHLIB_MAJOR={- $config{shlib_major} -}
  83. SHLIB_MINOR={- $config{shlib_minor} -}
  84. SHLIB_TARGET={- $target{shared_target} -}
  85. SHLIB_EXT={- $shlibext -}
  86. SHLIB_EXT_SIMPLE={- $shlibextsimple -}
  87. SHLIB_EXT_IMPORT={- $shlibextimport -}
  88. LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
  89. SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
  90. SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
  91. ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
  92. PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
  93. SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
  94. {- output_off() if $disabled{makedepend}; "" -}
  95. DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
  96. grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
  97. keys %{$unified_info{sources}}); -}
  98. {- output_on() if $disabled{makedepend}; "" -}
  99. GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
  100. GENERATED={- # common0.tmpl provides @generated
  101. join(" ", @generated ) -}
  102. INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
  103. INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
  104. INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
  105. INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
  106. INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
  107. {- output_off() if $disabled{apps}; "" -}
  108. BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
  109. MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget
  110. {- output_on() if $disabled{apps}; "" -}
  111. APPS_OPENSSL={- use File::Spec::Functions;
  112. catfile("apps","openssl") -}
  113. # DESTDIR is for package builders so that they can configure for, say,
  114. # /usr/ and yet have everything installed to /tmp/somedir/usr/.
  115. # Normally it is left empty.
  116. DESTDIR=
  117. # Do not edit these manually. Use Configure with --prefix or --openssldir
  118. # to change this! Short explanation in the top comment in Configure
  119. INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
  120. #
  121. our $prefix = $config{prefix} || "/usr/local";
  122. $prefix -}
  123. OPENSSLDIR={- #
  124. # The logic here is that if no --openssldir was given,
  125. # OPENSSLDIR will get the value from $prefix plus "/ssl".
  126. # If --openssldir was given and the value is an absolute
  127. # path, OPENSSLDIR will get its value without change.
  128. # If the value from --openssldir is a relative path,
  129. # OPENSSLDIR will get $prefix with the --openssldir
  130. # value appended as a subdirectory.
  131. #
  132. use File::Spec::Functions;
  133. our $openssldir =
  134. $config{openssldir} ?
  135. (file_name_is_absolute($config{openssldir}) ?
  136. $config{openssldir}
  137. : catdir($prefix, $config{openssldir}))
  138. : catdir($prefix, "ssl");
  139. $openssldir -}
  140. LIBDIR={- our $libdir = $config{libdir};
  141. unless ($libdir) {
  142. #
  143. # if $prefix/lib$target{multilib} is not an existing
  144. # directory, then assume that it's not searched by linker
  145. # automatically, in which case adding $target{multilib} suffix
  146. # causes more grief than we're ready to tolerate, so don't...
  147. our $multilib =
  148. -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
  149. $libdir = "lib$multilib";
  150. }
  151. file_name_is_absolute($libdir) ? "" : $libdir -}
  152. # $(libdir) is chosen to be compatible with the GNU coding standards
  153. libdir={- file_name_is_absolute($libdir)
  154. ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
  155. ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
  156. # Convenience variable for those who want to set the rpath in shared
  157. # libraries and applications
  158. LIBRPATH=$(libdir)
  159. MANDIR=$(INSTALLTOP)/share/man
  160. DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
  161. HTMLDIR=$(DOCDIR)/html
  162. # MANSUFFIX is for the benefit of anyone who may want to have a suffix
  163. # appended after the manpage file section number. "ssl" is popular,
  164. # resulting in files such as config.5ssl rather than config.5.
  165. MANSUFFIX=
  166. HTMLSUFFIX=html
  167. # For "optional" echo messages, to get "real" silence
  168. ECHO = echo
  169. ##### User defined commands and flags ################################
  170. # We let the C compiler driver to take care of .s files. This is done in
  171. # order to be excused from maintaining a separate set of architecture
  172. # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
  173. # gcc, then the driver will automatically translate it to -xarch=v8plus
  174. # and pass it down to assembler. In any case, we do not define AS or
  175. # ASFLAGS for this reason.
  176. CROSS_COMPILE={- $config{CROSS_COMPILE} -}
  177. CC=$(CROSS_COMPILE){- $config{CC} -}
  178. CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
  179. CPPFLAGS={- our $cppflags1 = join(" ",
  180. (map { "-D".$_} @{$config{CPPDEFINES}}),
  181. (map { "-I".$_} @{$config{CPPINCLUDES}}),
  182. @{$config{CPPFLAGS}}) -}
  183. CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
  184. CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
  185. LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
  186. EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
  187. MAKEDEPEND={- $config{makedepprog} -}
  188. PERL={- $config{perl} -}
  189. AR=$(CROSS_COMPILE){- $config{AR} -}
  190. ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
  191. RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
  192. RC= $(CROSS_COMPILE){- $config{RC} -}
  193. RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
  194. RM= rm -f
  195. RMDIR= rmdir
  196. TAR= {- $target{TAR} || "tar" -}
  197. TARFLAGS= {- $target{TARFLAGS} -}
  198. BASENAME= openssl
  199. NAME= $(BASENAME)-$(VERSION)
  200. TARFILE= ../$(NAME).tar
  201. ##### Project flags ##################################################
  202. # Variables starting with CNF_ are common variables for all product types
  203. CNF_CPPFLAGS={- our $cppflags2 =
  204. join(' ', $target{cppflags} || (),
  205. (map { "-D".$_} @{$target{defines}},
  206. @{$config{defines}}),
  207. (map { "-I".$_} @{$target{includes}},
  208. @{$config{includes}}),
  209. @{$config{cppflags}}) -}
  210. CNF_CFLAGS={- join(' ', $target{cflags} || (),
  211. @{$config{cflags}}) -}
  212. CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
  213. @{$config{cxxflags}}) -}
  214. CNF_LDFLAGS={- join(' ', $target{lflags} || (),
  215. @{$config{lflags}}) -}
  216. CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
  217. @{$config{ex_libs}}) -}
  218. # Variables starting with LIB_ are used to build library object files
  219. # and shared libraries.
  220. # Variables starting with DSO_ are used to build DSOs and their object files.
  221. # Variables starting with BIN_ are used to build programs and their object
  222. # files.
  223. LIB_CPPFLAGS={- our $lib_cppflags =
  224. join(' ', $target{lib_cppflags} || (),
  225. $target{shared_cppflag} || (),
  226. (map { '-D'.$_ }
  227. @{$config{lib_defines}},
  228. @{$config{shared_defines}}),
  229. @{$config{lib_cppflags}},
  230. @{$config{shared_cppflag}});
  231. join(' ', $lib_cppflags,
  232. (map { '-D'.$_ }
  233. 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
  234. 'ENGINESDIR="\"$(ENGINESDIR)\""'),
  235. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  236. LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
  237. $target{shared_cflag} || (),
  238. @{$config{lib_cflags}},
  239. @{$config{shared_cflag}},
  240. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  241. LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
  242. $target{shared_cxxflag} || (),
  243. @{$config{lib_cxxflags}},
  244. @{$config{shared_cxxflag}},
  245. '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
  246. LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
  247. $config{shared_ldflag} || (),
  248. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  249. LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  250. DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
  251. $target{module_cppflags} || (),
  252. @{$config{dso_cppflags}},
  253. @{$config{module_cppflags}},
  254. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  255. DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
  256. $target{module_cflags} || (),
  257. @{$config{dso_cflags}},
  258. @{$config{module_cflags}},
  259. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  260. DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
  261. $target{module_cxxflags} || (),
  262. @{$config{dso_cxxflags}},
  263. @{$config{module_cxxflag}},
  264. '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
  265. DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
  266. $target{module_ldflags} || (),
  267. @{$config{dso_ldflags}},
  268. @{$config{module_ldflags}},
  269. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  270. DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  271. BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
  272. @{$config{bin_cppflags}},
  273. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  274. BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
  275. @{$config{bin_cflags}},
  276. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  277. BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
  278. @{$config{bin_cxxflags}},
  279. '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
  280. BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
  281. @{$config{bin_lflags}},
  282. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  283. BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  284. # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
  285. CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
  286. $cppflags2 =~ s|([\\"])|\\$1|g;
  287. $lib_cppflags =~ s|([\\"])|\\$1|g;
  288. join(' ', $lib_cppflags || (), $cppflags2 || (),
  289. $cppflags1 || ()) -}
  290. PERLASM_SCHEME= {- $target{perlasm_scheme} -}
  291. # For x86 assembler: Set PROCESSOR to 386 if you want to support
  292. # the 80386.
  293. PROCESSOR= {- $config{processor} -}
  294. # We want error [and other] messages in English. Trouble is that make(1)
  295. # doesn't pass macros down as environment variables unless there already
  296. # was corresponding variable originally set. In other words we can only
  297. # reassign environment variables, but not set new ones, not in portable
  298. # manner that is. That's why we reassign several, just to be sure...
  299. LC_ALL=C
  300. LC_MESSAGES=C
  301. LANG=C
  302. # The main targets ###################################################
  303. {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
  304. {- dependmagic('build_libs'); -}: build_libs_nodep
  305. {- dependmagic('build_engines'); -}: build_engines_nodep
  306. {- dependmagic('build_programs'); -}: build_programs_nodep
  307. build_generated: $(GENERATED_MANDATORY)
  308. build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
  309. build_engines_nodep: $(ENGINES)
  310. build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
  311. # Kept around for backward compatibility
  312. build_apps build_tests: build_programs
  313. # Convenience target to prebuild all generated files, not just the mandatory
  314. # ones
  315. build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
  316. @ : {- output_off() if $disabled{makedepend}; "" -}
  317. @echo "Warning: consider configuring with no-makedepend, because if"
  318. @echo " target system doesn't have $(PERL),"
  319. @echo " then make will fail..."
  320. @ : {- output_on() if $disabled{makedepend}; "" -}
  321. test: tests
  322. {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
  323. @ : {- output_off() if $disabled{tests}; "" -}
  324. ( cd test; \
  325. mkdir -p test-runs; \
  326. SRCTOP=../$(SRCDIR) \
  327. BLDTOP=../$(BLDDIR) \
  328. RESULT_D=test-runs \
  329. PERL="$(PERL)" \
  330. EXE_EXT={- $exeext -} \
  331. OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
  332. OPENSSL_DEBUG_MEMORY=on \
  333. $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
  334. @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  335. @echo "Tests are not supported with your chosen Configure options"
  336. @ : {- output_on() if !$disabled{tests}; "" -}
  337. list-tests:
  338. @ : {- output_off() if $disabled{tests}; "" -}
  339. @SRCTOP="$(SRCDIR)" \
  340. $(PERL) $(SRCDIR)/test/run_tests.pl list
  341. @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  342. @echo "Tests are not supported with your chosen Configure options"
  343. @ : {- output_on() if !$disabled{tests}; "" -}
  344. install: install_sw install_ssldirs install_docs
  345. uninstall: uninstall_docs uninstall_sw
  346. libclean:
  347. @set -e; for s in $(SHLIB_INFO); do \
  348. if [ "$$s" = ";" ]; then continue; fi; \
  349. s1=`echo "$$s" | cut -f1 -d";"`; \
  350. s2=`echo "$$s" | cut -f2 -d";"`; \
  351. $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
  352. $(RM) apps/$$s1; \
  353. $(RM) test/$$s1; \
  354. $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
  355. $(RM) $$s1; \
  356. if [ "$$s1" != "$$s2" ]; then \
  357. $(ECHO) $(RM) $$s2; \
  358. $(RM) $$s2; \
  359. fi; \
  360. done
  361. $(RM) $(LIBS)
  362. $(RM) *.map
  363. clean: libclean
  364. $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
  365. $(RM) $(GENERATED_MANDATORY) $(GENERATED)
  366. -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
  367. -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
  368. $(RM) core
  369. $(RM) tags TAGS doc-nits
  370. $(RM) -r test/test-runs
  371. $(RM) openssl.pc libcrypto.pc libssl.pc
  372. -$(RM) `find . -type l -a \! -path "./.git/*"`
  373. $(RM) $(TARFILE)
  374. distclean: clean
  375. $(RM) configdata.pm
  376. $(RM) Makefile
  377. # We check if any depfile is newer than Makefile and decide to
  378. # concatenate only if that is true.
  379. depend:
  380. @: {- output_off() if $disabled{makedepend}; "" -}
  381. @$(PERL) $(SRCDIR)/util/add-depends.pl {-
  382. defined $makedepprog && $makedepprog =~ /\/makedepend/
  383. ? 'makedepend' : 'gcc' -}
  384. @: {- output_on() if $disabled{makedepend}; "" -}
  385. # Install helper targets #############################################
  386. install_sw: all install_dev install_engines install_runtime
  387. uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
  388. install_docs: install_man_docs install_html_docs
  389. uninstall_docs: uninstall_man_docs uninstall_html_docs
  390. $(RM) -r -v $(DESTDIR)$(DOCDIR)
  391. install_ssldirs:
  392. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
  393. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
  394. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
  395. @set -e; for x in dummy $(MISC_SCRIPTS); do \
  396. if [ "$$x" = "dummy" ]; then continue; fi; \
  397. fn=`basename $$x`; \
  398. $(ECHO) "install $$x -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  399. cp $$x $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
  400. chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
  401. mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
  402. $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
  403. done
  404. @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
  405. @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
  406. @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
  407. @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
  408. @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
  409. $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
  410. cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
  411. chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
  412. fi
  413. @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
  414. @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
  415. @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
  416. @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
  417. @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
  418. $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
  419. cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
  420. chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
  421. fi
  422. install_dev:
  423. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  424. @$(ECHO) "*** Installing development files"
  425. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
  426. @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
  427. @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  428. @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
  429. @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
  430. @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
  431. @set -e; for i in $(SRCDIR)/include/openssl/*.h \
  432. $(BLDDIR)/include/openssl/*.h; do \
  433. fn=`basename $$i`; \
  434. $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  435. cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
  436. chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
  437. done
  438. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
  439. @set -e; for l in $(INSTALL_LIBS); do \
  440. fn=`basename $$l`; \
  441. $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
  442. cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
  443. $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
  444. chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
  445. mv -f $(DESTDIR)$(libdir)/$$fn.new \
  446. $(DESTDIR)$(libdir)/$$fn; \
  447. done
  448. @ : {- output_off() if $disabled{shared}; "" -}
  449. @set -e; for s in $(INSTALL_SHLIB_INFO); do \
  450. s1=`echo "$$s" | cut -f1 -d";"`; \
  451. s2=`echo "$$s" | cut -f2 -d";"`; \
  452. fn1=`basename $$s1`; \
  453. fn2=`basename $$s2`; \
  454. : {- output_off() if windowsdll(); "" -}; \
  455. $(ECHO) "install $$s1 -> $(DESTDIR)$(libdir)/$$fn1"; \
  456. cp $$s1 $(DESTDIR)$(libdir)/$$fn1.new; \
  457. chmod 755 $(DESTDIR)$(libdir)/$$fn1.new; \
  458. mv -f $(DESTDIR)$(libdir)/$$fn1.new \
  459. $(DESTDIR)$(libdir)/$$fn1; \
  460. if [ "$$fn1" != "$$fn2" ]; then \
  461. $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
  462. ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
  463. fi; \
  464. : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
  465. $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
  466. cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
  467. chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
  468. mv -f $(DESTDIR)$(libdir)/$$fn2.new \
  469. $(DESTDIR)$(libdir)/$$fn2; \
  470. : {- output_on() unless windowsdll(); "" -}; \
  471. done
  472. @ : {- output_on() if $disabled{shared}; "" -}
  473. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
  474. @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
  475. @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
  476. @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
  477. @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
  478. @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
  479. @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
  480. @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
  481. @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
  482. @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
  483. uninstall_dev:
  484. @$(ECHO) "*** Uninstalling development files"
  485. @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
  486. @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  487. @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
  488. @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -}
  489. @set -e; for i in $(SRCDIR)/include/openssl/*.h \
  490. $(BLDDIR)/include/openssl/*.h; do \
  491. fn=`basename $$i`; \
  492. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  493. $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
  494. done
  495. -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
  496. -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
  497. @set -e; for l in $(INSTALL_LIBS); do \
  498. fn=`basename $$l`; \
  499. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
  500. $(RM) $(DESTDIR)$(libdir)/$$fn; \
  501. done
  502. @ : {- output_off() if $disabled{shared}; "" -}
  503. @set -e; for s in $(INSTALL_SHLIB_INFO); do \
  504. s1=`echo "$$s" | cut -f1 -d";"`; \
  505. s2=`echo "$$s" | cut -f2 -d";"`; \
  506. fn1=`basename $$s1`; \
  507. fn2=`basename $$s2`; \
  508. : {- output_off() if windowsdll(); "" -}; \
  509. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
  510. $(RM) $(DESTDIR)$(libdir)/$$fn1; \
  511. if [ "$$fn1" != "$$fn2" ]; then \
  512. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
  513. $(RM) $(DESTDIR)$(libdir)/$$fn2; \
  514. fi; \
  515. : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
  516. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
  517. $(RM) $(DESTDIR)$(libdir)/$$fn2; \
  518. : {- output_on() unless windowsdll(); "" -}; \
  519. done
  520. @ : {- output_on() if $disabled{shared}; "" -}
  521. $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
  522. $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
  523. $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
  524. -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
  525. -$(RMDIR) $(DESTDIR)$(libdir)
  526. install_engines:
  527. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  528. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
  529. @$(ECHO) "*** Installing engines"
  530. @set -e; for e in dummy $(INSTALL_ENGINES); do \
  531. if [ "$$e" = "dummy" ]; then continue; fi; \
  532. fn=`basename $$e`; \
  533. $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
  534. cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
  535. chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
  536. mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
  537. $(DESTDIR)$(ENGINESDIR)/$$fn; \
  538. done
  539. uninstall_engines:
  540. @$(ECHO) "*** Uninstalling engines"
  541. @set -e; for e in dummy $(INSTALL_ENGINES); do \
  542. if [ "$$e" = "dummy" ]; then continue; fi; \
  543. fn=`basename $$e`; \
  544. if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
  545. continue; \
  546. fi; \
  547. $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
  548. $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
  549. done
  550. -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
  551. install_runtime:
  552. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  553. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
  554. @ : {- output_off() if windowsdll(); "" -}
  555. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
  556. @ : {- output_on() if windowsdll(); "" -}
  557. @$(ECHO) "*** Installing runtime files"
  558. @set -e; for s in dummy $(INSTALL_SHLIBS); do \
  559. if [ "$$s" = "dummy" ]; then continue; fi; \
  560. fn=`basename $$s`; \
  561. : {- output_off() unless windowsdll(); "" -}; \
  562. $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  563. cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  564. chmod 644 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  565. mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
  566. $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  567. : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
  568. $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
  569. cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
  570. chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
  571. mv -f $(DESTDIR)$(libdir)/$$fn.new \
  572. $(DESTDIR)$(libdir)/$$fn; \
  573. : {- output_on() if windowsdll(); "" -}; \
  574. done
  575. @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
  576. if [ "$$x" = "dummy" ]; then continue; fi; \
  577. fn=`basename $$x`; \
  578. $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  579. cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  580. chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  581. mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
  582. $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  583. done
  584. @set -e; for x in dummy $(BIN_SCRIPTS); do \
  585. if [ "$$x" = "dummy" ]; then continue; fi; \
  586. fn=`basename $$x`; \
  587. $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  588. cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  589. chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  590. mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
  591. $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  592. done
  593. uninstall_runtime:
  594. @$(ECHO) "*** Uninstalling runtime files"
  595. @set -e; for x in dummy $(INSTALL_PROGRAMS); \
  596. do \
  597. if [ "$$x" = "dummy" ]; then continue; fi; \
  598. fn=`basename $$x`; \
  599. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  600. $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  601. done;
  602. @set -e; for x in dummy $(BIN_SCRIPTS); \
  603. do \
  604. if [ "$$x" = "dummy" ]; then continue; fi; \
  605. fn=`basename $$x`; \
  606. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  607. $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  608. done
  609. @ : {- output_off() unless windowsdll(); "" -}
  610. @set -e; for s in dummy $(INSTALL_SHLIBS); do \
  611. if [ "$$s" = "dummy" ]; then continue; fi; \
  612. fn=`basename $$s`; \
  613. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  614. $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  615. done
  616. @ : {- output_on() unless windowsdll(); "" -}
  617. -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
  618. install_man_docs:
  619. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  620. @$(ECHO) "*** Installing manpages"
  621. $(PERL) $(SRCDIR)/util/process_docs.pl \
  622. --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
  623. uninstall_man_docs:
  624. @$(ECHO) "*** Uninstalling manpages"
  625. $(PERL) $(SRCDIR)/util/process_docs.pl \
  626. --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
  627. --remove
  628. install_html_docs:
  629. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  630. @$(ECHO) "*** Installing HTML manpages"
  631. $(PERL) $(SRCDIR)/util/process_docs.pl \
  632. --destdir=$(DESTDIR)$(HTMLDIR) --type=html
  633. uninstall_html_docs:
  634. @$(ECHO) "*** Uninstalling manpages"
  635. $(PERL) $(SRCDIR)/util/process_docs.pl \
  636. --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
  637. # Developer targets (note: these are only available on Unix) #########
  638. update: generate errors ordinals
  639. generate: generate_apps generate_crypto_bn generate_crypto_objects \
  640. generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
  641. .PHONY: doc-nits
  642. doc-nits:
  643. (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
  644. @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
  645. else echo 'doc-nits: no errors.'; rm doc-nits ; fi
  646. # Test coverage is a good idea for the future
  647. #coverage: $(PROGRAMS) $(TESTPROGRAMS)
  648. # ...
  649. lint:
  650. lint -DLINT $(INCLUDES) $(SRCS)
  651. generate_apps:
  652. ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
  653. < apps/openssl.cnf > apps/openssl-vms.cnf )
  654. generate_crypto_bn:
  655. ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
  656. generate_crypto_objects:
  657. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
  658. crypto/objects/objects.txt \
  659. crypto/objects/obj_mac.num \
  660. > crypto/objects/obj_mac.new && \
  661. mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
  662. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
  663. crypto/objects/objects.txt \
  664. crypto/objects/obj_mac.num \
  665. > include/openssl/obj_mac.h )
  666. ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
  667. include/openssl/obj_mac.h \
  668. > crypto/objects/obj_dat.h )
  669. ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
  670. crypto/objects/obj_mac.num \
  671. crypto/objects/obj_xref.txt \
  672. > crypto/objects/obj_xref.h )
  673. generate_crypto_conf:
  674. ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
  675. > crypto/conf/conf_def.h )
  676. generate_crypto_asn1:
  677. ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
  678. > crypto/asn1/charmap.h )
  679. generate_fuzz_oids:
  680. ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
  681. crypto/objects/obj_dat.h \
  682. > fuzz/oids.txt )
  683. # Set to -force to force a rebuild
  684. ERROR_REBUILD=
  685. errors:
  686. ( b=`pwd`; set -e; cd $(SRCDIR); \
  687. $(PERL) util/ck_errf.pl -strict -internal; \
  688. $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
  689. ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
  690. for E in *.ec ; do \
  691. $(PERL) ../util/ck_errf.pl -strict \
  692. -conf $$E `basename $$E .ec`.c; \
  693. $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
  694. -conf $$E `basename $$E .ec`.c ; \
  695. done )
  696. ordinals:
  697. ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
  698. ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
  699. test_ordinals:
  700. ( cd test; \
  701. SRCTOP=../$(SRCDIR) \
  702. BLDTOP=../$(BLDDIR) \
  703. $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
  704. tags TAGS: FORCE
  705. rm -f TAGS tags
  706. -ctags -R .
  707. -etags `find . -name '*.[ch]' -o -name '*.pm'`
  708. # Release targets (note: only available on Unix) #####################
  709. # If your tar command doesn't support --owner and --group, make sure to
  710. # use one that does, for example GNU tar
  711. TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cf -
  712. PREPARE_CMD=:
  713. tar:
  714. set -e; \
  715. TMPDIR=/var/tmp/openssl-copy.$$$$; \
  716. DISTDIR=$(NAME); \
  717. mkdir -p $$TMPDIR/$$DISTDIR; \
  718. (cd $(SRCDIR); \
  719. excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
  720. excl_re="^(fuzz/corpora|Configurations/.*\.norelease\.conf|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
  721. echo "$$excl_re"; \
  722. git ls-tree -r --name-only --full-tree HEAD \
  723. | egrep -v "$$excl_re" \
  724. | while read F; do \
  725. mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
  726. cp $$F $$TMPDIR/$$DISTDIR/$$F; \
  727. done); \
  728. (cd $$TMPDIR/$$DISTDIR; \
  729. $(PREPARE_CMD); \
  730. find . -type d -print | xargs chmod 755; \
  731. find . -type f -print | xargs chmod a+r; \
  732. find . -type f -perm -0100 -print | xargs chmod a+x); \
  733. (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
  734. | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
  735. rm -rf $$TMPDIR
  736. cd $(SRCDIR); ls -l $(TARFILE).gz
  737. dist:
  738. @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
  739. # Helper targets #####################################################
  740. link-utils: $(BLDDIR)/util/opensslwrap.sh
  741. $(BLDDIR)/util/opensslwrap.sh: configdata.pm
  742. @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
  743. mkdir -p "$(BLDDIR)/util"; \
  744. ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
  745. fi
  746. FORCE:
  747. # Building targets ###################################################
  748. libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
  749. libcrypto.pc:
  750. @ ( echo 'prefix=$(INSTALLTOP)'; \
  751. echo 'exec_prefix=$${prefix}'; \
  752. if [ -n "$(LIBDIR)" ]; then \
  753. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  754. else \
  755. echo 'libdir=$(libdir)'; \
  756. fi; \
  757. echo 'includedir=$${prefix}/include'; \
  758. echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
  759. echo ''; \
  760. echo 'Name: OpenSSL-libcrypto'; \
  761. echo 'Description: OpenSSL cryptography library'; \
  762. echo 'Version: '$(VERSION); \
  763. echo 'Libs: -L$${libdir} -lcrypto'; \
  764. echo 'Libs.private: $(LIB_EX_LIBS)'; \
  765. echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
  766. libssl.pc:
  767. @ ( echo 'prefix=$(INSTALLTOP)'; \
  768. echo 'exec_prefix=$${prefix}'; \
  769. if [ -n "$(LIBDIR)" ]; then \
  770. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  771. else \
  772. echo 'libdir=$(libdir)'; \
  773. fi; \
  774. echo 'includedir=$${prefix}/include'; \
  775. echo ''; \
  776. echo 'Name: OpenSSL-libssl'; \
  777. echo 'Description: Secure Sockets Layer and cryptography libraries'; \
  778. echo 'Version: '$(VERSION); \
  779. echo 'Requires.private: libcrypto'; \
  780. echo 'Libs: -L$${libdir} -lssl'; \
  781. echo 'Cflags: -I$${includedir}' ) > libssl.pc
  782. openssl.pc:
  783. @ ( echo 'prefix=$(INSTALLTOP)'; \
  784. echo 'exec_prefix=$${prefix}'; \
  785. if [ -n "$(LIBDIR)" ]; then \
  786. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  787. else \
  788. echo 'libdir=$(libdir)'; \
  789. fi; \
  790. echo 'includedir=$${prefix}/include'; \
  791. echo ''; \
  792. echo 'Name: OpenSSL'; \
  793. echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
  794. echo 'Version: '$(VERSION); \
  795. echo 'Requires: libssl libcrypto' ) > openssl.pc
  796. configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
  797. @echo "Detected changed: $?"
  798. $(PERL) configdata.pm -r
  799. @echo "**************************************************"
  800. @echo "*** ***"
  801. @echo "*** Please run the same make command again ***"
  802. @echo "*** ***"
  803. @echo "**************************************************"
  804. @false
  805. reconfigure reconf:
  806. $(PERL) configdata.pm -r
  807. {-
  808. use File::Basename;
  809. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
  810. # Helper function to figure out dependencies on libraries
  811. # It takes a list of library names and outputs a list of dependencies
  812. sub compute_lib_depends {
  813. if ($disabled{shared}) {
  814. return map { lib($_) } @_;
  815. }
  816. # Depending on shared libraries:
  817. # On Windows POSIX layers, we depend on {libname}.dll.a
  818. # On Unix platforms, we depend on {shlibname}.so
  819. return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
  820. }
  821. sub generatesrc {
  822. my %args = @_;
  823. my $generator = join(" ", @{$args{generator}});
  824. my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
  825. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  826. my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
  827. if ($args{src} !~ /\.[sS]$/) {
  828. if ($args{generator}->[0] =~ m|^.*\.in$|) {
  829. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  830. "util", "dofile.pl")),
  831. rel2abs($config{builddir}));
  832. return <<"EOF";
  833. $args{src}: $args{generator}->[0] $deps
  834. \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  835. "-o$target{build_file}" $generator > \$@
  836. EOF
  837. } else {
  838. return <<"EOF";
  839. $args{src}: $args{generator}->[0] $deps
  840. \$(PERL)$generator_incs $generator > \$@
  841. EOF
  842. }
  843. } else {
  844. if ($args{generator}->[0] =~ /\.pl$/) {
  845. $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
  846. } elsif ($args{generator}->[0] =~ /\.m4$/) {
  847. $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
  848. } elsif ($args{generator}->[0] =~ /\.S$/) {
  849. $generator = undef;
  850. } else {
  851. die "Generator type for $args{src} unknown: $generator\n";
  852. }
  853. my $cppflags = {
  854. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  855. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  856. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  857. } -> {$args{intent}};
  858. if (defined($generator)) {
  859. return <<"EOF";
  860. $args{src}: $args{generator}->[0] $deps
  861. $generator \$@
  862. EOF
  863. }
  864. return <<"EOF";
  865. $args{src}: $args{generator}->[0] $deps
  866. \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
  867. \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
  868. EOF
  869. }
  870. }
  871. # Should one wonder about the end of the Perl snippet, it's because this
  872. # second regexp eats up line endings as well, if the removed path is the
  873. # last in the line. We may therefore need to put back a line ending.
  874. sub src2obj {
  875. my %args = @_;
  876. (my $obj = $args{obj}) =~ s|\.o$||;
  877. my @srcs = @{$args{srcs}};
  878. my $srcs = join(" ", @srcs);
  879. my $deps = join(" ", @srcs, @{$args{deps}});
  880. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  881. my $cmd;
  882. my $cmdflags;
  883. my $cmdcompile;
  884. if (grep /\.rc$/, @srcs) {
  885. $cmd = '$(RC)';
  886. $cmdflags = '$(RCFLAGS)';
  887. $cmdcompile = '';
  888. } elsif (grep /\.(cc|cpp)$/, @srcs) {
  889. $cmd = '$(CXX)';
  890. $cmdcompile = ' -c';
  891. $cmdflags = {
  892. lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  893. dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
  894. bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
  895. } -> {$args{intent}};
  896. } else {
  897. $cmd = '$(CC)';
  898. $cmdcompile = ' -c';
  899. $cmdflags = {
  900. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  901. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  902. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  903. } -> {$args{intent}};
  904. }
  905. my $recipe;
  906. # extension-specific rules
  907. if (grep /\.s$/, @srcs) {
  908. $recipe .= <<"EOF";
  909. $obj$objext: $deps
  910. $cmd $cmdflags -c -o \$\@ $srcs
  911. EOF
  912. } elsif (grep /\.S$/, @srcs) {
  913. # Originally there was mutli-step rule with $(CC) -E file.S
  914. # followed by $(CC) -c file.s. It compensated for one of
  915. # legacy platform compiler's inability to handle .S files.
  916. # The platform is long discontinued by vendor so there is
  917. # hardly a point to drag it along...
  918. $recipe .= <<"EOF";
  919. $obj$objext: $deps
  920. $cmd $incs $cmdflags -c -o \$\@ $srcs
  921. EOF
  922. } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
  923. && !grep /\.rc$/, @srcs) {
  924. $recipe .= <<"EOF";
  925. $obj$objext: $deps
  926. $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
  927. \@touch $obj$depext.tmp
  928. \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
  929. rm -f $obj$depext.tmp; \\
  930. else \\
  931. mv $obj$depext.tmp $obj$depext; \\
  932. fi
  933. EOF
  934. } else {
  935. $recipe .= <<"EOF";
  936. $obj$objext: $deps
  937. $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
  938. EOF
  939. if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
  940. $recipe .= <<"EOF";
  941. \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
  942. > $obj$depext
  943. EOF
  944. }
  945. }
  946. return $recipe;
  947. }
  948. # On Unix, we build shlibs from static libs, so we're ignoring the
  949. # object file array. We *know* this routine is only called when we've
  950. # configure 'shared'.
  951. sub libobj2shlib {
  952. my %args = @_;
  953. my $lib = $args{lib};
  954. my $shlib = $args{shlib};
  955. my $libd = dirname($lib);
  956. my $libn = basename($lib);
  957. (my $libname = $libn) =~ s/^lib//;
  958. my @linkdirs = ();
  959. foreach (@{args{deps}}) {
  960. my $d = dirname($_);
  961. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  962. }
  963. my $linkflags = join("", map { "-L$_ " } @linkdirs);
  964. my $linklibs = join("", map { my $f = basename($_);
  965. (my $l = $f) =~ s/^lib//;
  966. " -l$l" } @{$args{deps}});
  967. my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
  968. grep { $_ !~ m/\.(?:def|map)$/ }
  969. @{$args{objs}};
  970. my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
  971. my @deps = compute_lib_depends(@{$args{deps}});
  972. die "More than one exported symbol map" if scalar @defs > 1;
  973. my $objs = join(" ", @objs);
  974. my $deps = join(" ", @objs, @defs, @deps);
  975. my $target = shlib_simple($lib);
  976. my $target_full = shlib($lib);
  977. my $shared_soname = "";
  978. $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
  979. if defined $target{shared_sonameflag};
  980. my $shared_imp = "";
  981. $shared_imp .= ' '.$target{shared_impflag}.basename($target)
  982. if defined $target{shared_impflag};
  983. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  984. my $recipe = <<"EOF";
  985. # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
  986. # that two files get produced, {shlibname}.dll and {libname}.dll.a.
  987. # With all other Unix platforms, we often build a shared library with the
  988. # SO version built into the file name and a symlink without the SO version
  989. # It's not necessary to have both as targets. The choice falls on the
  990. # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
  991. # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
  992. $target: $deps
  993. \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
  994. -o $target_full$shared_def $objs \\
  995. $linklibs \$(LIB_EX_LIBS)
  996. EOF
  997. if (windowsdll()) {
  998. $recipe .= <<"EOF";
  999. rm -f apps/$shlib'\$(SHLIB_EXT)'
  1000. rm -f test/$shlib'\$(SHLIB_EXT)'
  1001. rm -f fuzz/$shlib'\$(SHLIB_EXT)'
  1002. cp -p $shlib'\$(SHLIB_EXT)' apps/
  1003. cp -p $shlib'\$(SHLIB_EXT)' test/
  1004. cp -p $shlib'\$(SHLIB_EXT)' fuzz/
  1005. EOF
  1006. } else {
  1007. $recipe .= <<"EOF";
  1008. if [ '$target' != '$target_full' ]; then \\
  1009. rm -f $target; \\
  1010. ln -s $target_full $target; \\
  1011. fi
  1012. EOF
  1013. }
  1014. }
  1015. sub obj2dso {
  1016. my %args = @_;
  1017. my $dso = $args{lib};
  1018. my $dsod = dirname($dso);
  1019. my $dson = basename($dso);
  1020. my @linkdirs = ();
  1021. foreach (@{args{deps}}) {
  1022. my $d = dirname($_);
  1023. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1024. }
  1025. my $linkflags = join("", map { "-L$_ " } @linkdirs);
  1026. my $linklibs = join("", map { my $f = basename($_);
  1027. (my $l = $f) =~ s/^lib//;
  1028. " -l$l" } @{$args{deps}});
  1029. my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
  1030. grep { $_ !~ m/\.(?:def|map)$/ }
  1031. @{$args{objs}};
  1032. my @deps = compute_lib_depends(@{$args{deps}});
  1033. my $objs = join(" ", @objs);
  1034. my $deps = join(" ", @deps);
  1035. my $target = dso($dso);
  1036. return <<"EOF";
  1037. $target: $objs $deps
  1038. \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
  1039. -o $target $objs \\
  1040. $linklibs \$(DSO_EX_LIBS)
  1041. EOF
  1042. }
  1043. sub obj2lib {
  1044. my %args = @_;
  1045. (my $lib = $args{lib}) =~ s/\.a$//;
  1046. my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
  1047. my $objs = join(" ", @objs);
  1048. return <<"EOF";
  1049. $lib$libext: $objs
  1050. \$(AR) \$(ARFLAGS) \$\@ \$\?
  1051. \$(RANLIB) \$\@ || echo Never mind.
  1052. EOF
  1053. }
  1054. sub obj2bin {
  1055. my %args = @_;
  1056. my $bin = $args{bin};
  1057. my $bind = dirname($bin);
  1058. my $binn = basename($bin);
  1059. my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
  1060. @{$args{objs}});
  1061. my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
  1062. my @linkdirs = ();
  1063. foreach (@{args{deps}}) {
  1064. next if $_ =~ /\.a$/;
  1065. my $d = dirname($_);
  1066. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1067. }
  1068. my $linkflags = join("", map { "-L$_ " } @linkdirs);
  1069. my $linklibs = join("", map { if ($_ =~ /\.a$/) {
  1070. " $_";
  1071. } else {
  1072. my $f = basename($_);
  1073. (my $l = $f) =~ s/^lib//;
  1074. " -l$l"
  1075. }
  1076. } @{$args{deps}});
  1077. my $cmd = '$(CC)';
  1078. my $cmdflags = '$(BIN_CFLAGS)';
  1079. if (grep /_cc\.o$/, @{$args{objs}}) {
  1080. $cmd = '$(CXX)';
  1081. $cmdflags = '$(BIN_CXXFLAGS)';
  1082. }
  1083. return <<"EOF";
  1084. $bin$exeext: $objs $deps
  1085. rm -f $bin$exeext
  1086. \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
  1087. -o $bin$exeext $objs \\
  1088. $linklibs \$(BIN_EX_LIBS)
  1089. EOF
  1090. }
  1091. sub in2script {
  1092. my %args = @_;
  1093. my $script = $args{script};
  1094. my $sources = join(" ", @{$args{sources}});
  1095. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1096. "util", "dofile.pl")),
  1097. rel2abs($config{builddir}));
  1098. return <<"EOF";
  1099. $script: $sources
  1100. \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  1101. "-o$target{build_file}" $sources > "$script"
  1102. chmod a+x $script
  1103. EOF
  1104. }
  1105. sub generatedir {
  1106. my %args = @_;
  1107. my $dir = $args{dir};
  1108. my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
  1109. my @actions = ();
  1110. my %extinfo = ( dso => $dsoext,
  1111. lib => $libext,
  1112. bin => $exeext );
  1113. foreach my $type (("dso", "lib", "bin", "script")) {
  1114. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  1115. # For lib object files, we could update the library. However, it
  1116. # was decided that it's enough to build the directory local object
  1117. # files, so we don't need to add any actions, and the dependencies
  1118. # are already taken care of.
  1119. if ($type ne "lib") {
  1120. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  1121. if (dirname($prod) eq $dir) {
  1122. push @deps, $prod.$extinfo{$type};
  1123. } else {
  1124. push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
  1125. }
  1126. }
  1127. }
  1128. }
  1129. my $deps = join(" ", @deps);
  1130. my $actions = join("\n", "", @actions);
  1131. return <<"EOF";
  1132. $args{dir} $args{dir}/: $deps$actions
  1133. EOF
  1134. }
  1135. "" # Important! This becomes part of the template result.
  1136. -}