unix-Makefile.tmpl 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  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; 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. doc-nits:
  642. (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
  643. if [ -s doc-nits ] ; then cat doc-nits; rm doc-nits ; exit 1; fi
  644. # Test coverage is a good idea for the future
  645. #coverage: $(PROGRAMS) $(TESTPROGRAMS)
  646. # ...
  647. lint:
  648. lint -DLINT $(INCLUDES) $(SRCS)
  649. generate_apps:
  650. ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
  651. < apps/openssl.cnf > apps/openssl-vms.cnf )
  652. generate_crypto_bn:
  653. ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
  654. generate_crypto_objects:
  655. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
  656. crypto/objects/objects.txt \
  657. crypto/objects/obj_mac.num \
  658. > crypto/objects/obj_mac.new && \
  659. mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
  660. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
  661. crypto/objects/objects.txt \
  662. crypto/objects/obj_mac.num \
  663. > include/openssl/obj_mac.h )
  664. ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
  665. include/openssl/obj_mac.h \
  666. > crypto/objects/obj_dat.h )
  667. ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
  668. crypto/objects/obj_mac.num \
  669. crypto/objects/obj_xref.txt \
  670. > crypto/objects/obj_xref.h )
  671. generate_crypto_conf:
  672. ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
  673. > crypto/conf/conf_def.h )
  674. generate_crypto_asn1:
  675. ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
  676. > crypto/asn1/charmap.h )
  677. generate_fuzz_oids:
  678. ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
  679. crypto/objects/obj_dat.h \
  680. > fuzz/oids.txt )
  681. # Set to -force to force a rebuild
  682. ERROR_REBUILD=
  683. errors:
  684. ( cd $(SRCDIR); $(PERL) util/ck_errf.pl -strict */*.c */*/*.c )
  685. ( b=`pwd`; cd $(SRCDIR); \
  686. $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
  687. ( b=`pwd`; cd $(SRCDIR)/engines; \
  688. for E in *.ec ; do \
  689. $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
  690. -conf $$E `basename $$E .ec`.c ; \
  691. done )
  692. ordinals:
  693. ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
  694. ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
  695. test_ordinals:
  696. ( cd test; \
  697. SRCTOP=../$(SRCDIR) \
  698. BLDTOP=../$(BLDDIR) \
  699. $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
  700. tags TAGS: FORCE
  701. rm -f TAGS tags
  702. -ctags -R .
  703. -etags `find . -name '*.[ch]' -o -name '*.pm'`
  704. # Release targets (note: only available on Unix) #####################
  705. # If your tar command doesn't support --owner and --group, make sure to
  706. # use one that does, for example GNU tar
  707. TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cf -
  708. PREPARE_CMD=:
  709. tar:
  710. set -e; \
  711. TMPDIR=/var/tmp/openssl-copy.$$$$; \
  712. DISTDIR=$(NAME); \
  713. mkdir -p $$TMPDIR/$$DISTDIR; \
  714. (cd $(SRCDIR); \
  715. excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
  716. excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
  717. echo "$$excl_re"; \
  718. git ls-tree -r --name-only --full-tree HEAD \
  719. | egrep -v "$$excl_re" \
  720. | while read F; do \
  721. mkdir -p $$TMPDIR/$$DISTDIR/`dirname $$F`; \
  722. cp $$F $$TMPDIR/$$DISTDIR/$$F; \
  723. done); \
  724. (cd $$TMPDIR/$$DISTDIR; \
  725. $(PREPARE_CMD); \
  726. find . -type d -print | xargs chmod 755; \
  727. find . -type f -print | xargs chmod a+r; \
  728. find . -type f -perm -0100 -print | xargs chmod a+x); \
  729. (cd $$TMPDIR; $(TAR_COMMAND) $$DISTDIR) \
  730. | (cd $(SRCDIR); gzip --best > $(TARFILE).gz); \
  731. rm -rf $$TMPDIR
  732. cd $(SRCDIR); ls -l $(TARFILE).gz
  733. dist:
  734. @$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' TARFILE="$(TARFILE)" NAME="$(NAME)" tar
  735. # Helper targets #####################################################
  736. link-utils: $(BLDDIR)/util/opensslwrap.sh
  737. $(BLDDIR)/util/opensslwrap.sh: configdata.pm
  738. @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
  739. mkdir -p "$(BLDDIR)/util"; \
  740. ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
  741. fi
  742. FORCE:
  743. # Building targets ###################################################
  744. libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
  745. libcrypto.pc:
  746. @ ( echo 'prefix=$(INSTALLTOP)'; \
  747. echo 'exec_prefix=$${prefix}'; \
  748. if [ -n "$(LIBDIR)" ]; then \
  749. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  750. else \
  751. echo 'libdir=$(libdir)'; \
  752. fi; \
  753. echo 'includedir=$${prefix}/include'; \
  754. echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
  755. echo ''; \
  756. echo 'Name: OpenSSL-libcrypto'; \
  757. echo 'Description: OpenSSL cryptography library'; \
  758. echo 'Version: '$(VERSION); \
  759. echo 'Libs: -L$${libdir} -lcrypto'; \
  760. echo 'Libs.private: $(LIB_EX_LIBS)'; \
  761. echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
  762. libssl.pc:
  763. @ ( echo 'prefix=$(INSTALLTOP)'; \
  764. echo 'exec_prefix=$${prefix}'; \
  765. if [ -n "$(LIBDIR)" ]; then \
  766. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  767. else \
  768. echo 'libdir=$(libdir)'; \
  769. fi; \
  770. echo 'includedir=$${prefix}/include'; \
  771. echo ''; \
  772. echo 'Name: OpenSSL-libssl'; \
  773. echo 'Description: Secure Sockets Layer and cryptography libraries'; \
  774. echo 'Version: '$(VERSION); \
  775. echo 'Requires.private: libcrypto'; \
  776. echo 'Libs: -L$${libdir} -lssl'; \
  777. echo 'Cflags: -I$${includedir}' ) > libssl.pc
  778. openssl.pc:
  779. @ ( echo 'prefix=$(INSTALLTOP)'; \
  780. echo 'exec_prefix=$${prefix}'; \
  781. if [ -n "$(LIBDIR)" ]; then \
  782. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  783. else \
  784. echo 'libdir=$(libdir)'; \
  785. fi; \
  786. echo 'includedir=$${prefix}/include'; \
  787. echo ''; \
  788. echo 'Name: OpenSSL'; \
  789. echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
  790. echo 'Version: '$(VERSION); \
  791. echo 'Requires: libssl libcrypto' ) > openssl.pc
  792. configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
  793. @echo "Detected changed: $?"
  794. $(PERL) configdata.pm -r
  795. @echo "**************************************************"
  796. @echo "*** ***"
  797. @echo "*** Please run the same make command again ***"
  798. @echo "*** ***"
  799. @echo "**************************************************"
  800. @false
  801. reconfigure reconf:
  802. $(PERL) configdata.pm -r
  803. {-
  804. use File::Basename;
  805. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
  806. # Helper function to figure out dependencies on libraries
  807. # It takes a list of library names and outputs a list of dependencies
  808. sub compute_lib_depends {
  809. if ($disabled{shared}) {
  810. return map { lib($_) } @_;
  811. }
  812. # Depending on shared libraries:
  813. # On Windows POSIX layers, we depend on {libname}.dll.a
  814. # On Unix platforms, we depend on {shlibname}.so
  815. return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
  816. }
  817. sub generatesrc {
  818. my %args = @_;
  819. my $generator = join(" ", @{$args{generator}});
  820. my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
  821. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  822. my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
  823. if ($args{src} !~ /\.[sS]$/) {
  824. if ($args{generator}->[0] =~ m|^.*\.in$|) {
  825. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  826. "util", "dofile.pl")),
  827. rel2abs($config{builddir}));
  828. return <<"EOF";
  829. $args{src}: $args{generator}->[0] $deps
  830. \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  831. "-o$target{build_file}" $generator > \$@
  832. EOF
  833. } else {
  834. return <<"EOF";
  835. $args{src}: $args{generator}->[0] $deps
  836. \$(PERL)$generator_incs $generator > \$@
  837. EOF
  838. }
  839. } else {
  840. if ($args{generator}->[0] =~ /\.pl$/) {
  841. $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
  842. } elsif ($args{generator}->[0] =~ /\.m4$/) {
  843. $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
  844. } elsif ($args{generator}->[0] =~ /\.S$/) {
  845. $generator = undef;
  846. } else {
  847. die "Generator type for $args{src} unknown: $generator\n";
  848. }
  849. my $cppflags = {
  850. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  851. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  852. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  853. } -> {$args{intent}};
  854. if (defined($generator)) {
  855. return <<"EOF";
  856. $args{src}: $args{generator}->[0] $deps
  857. $generator \$@
  858. EOF
  859. }
  860. return <<"EOF";
  861. $args{src}: $args{generator}->[0] $deps
  862. \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
  863. \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
  864. EOF
  865. }
  866. }
  867. # Should one wonder about the end of the Perl snippet, it's because this
  868. # second regexp eats up line endings as well, if the removed path is the
  869. # last in the line. We may therefore need to put back a line ending.
  870. sub src2obj {
  871. my %args = @_;
  872. (my $obj = $args{obj}) =~ s|\.o$||;
  873. my @srcs = @{$args{srcs}};
  874. my $srcs = join(" ", @srcs);
  875. my $deps = join(" ", @srcs, @{$args{deps}});
  876. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  877. my $cmd;
  878. my $cmdflags;
  879. my $cmdcompile;
  880. if (grep /\.rc$/, @srcs) {
  881. $cmd = '$(RC)';
  882. $cmdflags = '$(RCFLAGS)';
  883. $cmdcompile = '';
  884. } elsif (grep /\.(cc|cpp)$/, @srcs) {
  885. $cmd = '$(CXX)';
  886. $cmdcompile = ' -c';
  887. $cmdflags = {
  888. lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  889. dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
  890. bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
  891. } -> {$args{intent}};
  892. } else {
  893. $cmd = '$(CC)';
  894. $cmdcompile = ' -c';
  895. $cmdflags = {
  896. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  897. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  898. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  899. } -> {$args{intent}};
  900. }
  901. my $recipe;
  902. # extension-specific rules
  903. if (grep /\.s$/, @srcs) {
  904. $recipe .= <<"EOF";
  905. $obj$objext: $deps
  906. $cmd $cmdflags -c -o \$\@ $srcs
  907. EOF
  908. } elsif (grep /\.S$/, @srcs) {
  909. # Originally there was mutli-step rule with $(CC) -E file.S
  910. # followed by $(CC) -c file.s. It compensated for one of
  911. # legacy platform compiler's inability to handle .S files.
  912. # The platform is long discontinued by vendor so there is
  913. # hardly a point to drag it along...
  914. $recipe .= <<"EOF";
  915. $obj$objext: $deps
  916. $cmd $incs $cmdflags -c -o \$\@ $srcs
  917. EOF
  918. } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
  919. && !grep /\.rc$/, @srcs) {
  920. $recipe .= <<"EOF";
  921. $obj$objext: $deps
  922. $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
  923. \@touch $obj$depext.tmp
  924. \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
  925. rm -f $obj$depext.tmp; \\
  926. else \\
  927. mv $obj$depext.tmp $obj$depext; \\
  928. fi
  929. EOF
  930. } else {
  931. $recipe .= <<"EOF";
  932. $obj$objext: $deps
  933. $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
  934. EOF
  935. if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
  936. $recipe .= <<"EOF";
  937. \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
  938. > $obj$depext
  939. EOF
  940. }
  941. }
  942. return $recipe;
  943. }
  944. # On Unix, we build shlibs from static libs, so we're ignoring the
  945. # object file array. We *know* this routine is only called when we've
  946. # configure 'shared'.
  947. sub libobj2shlib {
  948. my %args = @_;
  949. my $lib = $args{lib};
  950. my $shlib = $args{shlib};
  951. my $libd = dirname($lib);
  952. my $libn = basename($lib);
  953. (my $libname = $libn) =~ s/^lib//;
  954. my @linkdirs = ();
  955. foreach (@{args{deps}}) {
  956. my $d = dirname($_);
  957. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  958. }
  959. my $linkflags = join("", map { "-L$_ " } @linkdirs);
  960. my $linklibs = join("", map { my $f = basename($_);
  961. (my $l = $f) =~ s/^lib//;
  962. " -l$l" } @{$args{deps}});
  963. my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
  964. grep { $_ !~ m/\.(?:def|map)$/ }
  965. @{$args{objs}};
  966. my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
  967. my @deps = compute_lib_depends(@{$args{deps}});
  968. die "More than one exported symbol map" if scalar @defs > 1;
  969. my $objs = join(" ", @objs);
  970. my $deps = join(" ", @objs, @defs, @deps);
  971. my $target = shlib_simple($lib);
  972. my $target_full = shlib($lib);
  973. my $shared_soname = "";
  974. $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
  975. if defined $target{shared_sonameflag};
  976. my $shared_imp = "";
  977. $shared_imp .= ' '.$target{shared_impflag}.basename($target)
  978. if defined $target{shared_impflag};
  979. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  980. my $recipe = <<"EOF";
  981. # When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
  982. # that two files get produced, {shlibname}.dll and {libname}.dll.a.
  983. # With all other Unix platforms, we often build a shared library with the
  984. # SO version built into the file name and a symlink without the SO version
  985. # It's not necessary to have both as targets. The choice falls on the
  986. # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
  987. # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
  988. $target: $deps
  989. \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
  990. -o $target_full$shared_def $objs \\
  991. $linklibs \$(LIB_EX_LIBS)
  992. EOF
  993. if (windowsdll()) {
  994. $recipe .= <<"EOF";
  995. rm -f apps/$shlib'\$(SHLIB_EXT)'
  996. rm -f test/$shlib'\$(SHLIB_EXT)'
  997. rm -f fuzz/$shlib'\$(SHLIB_EXT)'
  998. cp -p $shlib'\$(SHLIB_EXT)' apps/
  999. cp -p $shlib'\$(SHLIB_EXT)' test/
  1000. cp -p $shlib'\$(SHLIB_EXT)' fuzz/
  1001. EOF
  1002. } else {
  1003. $recipe .= <<"EOF";
  1004. if [ '$target' != '$target_full' ]; then \\
  1005. rm -f $target; \\
  1006. ln -s $target_full $target; \\
  1007. fi
  1008. EOF
  1009. }
  1010. }
  1011. sub obj2dso {
  1012. my %args = @_;
  1013. my $dso = $args{lib};
  1014. my $dsod = dirname($dso);
  1015. my $dson = basename($dso);
  1016. my @linkdirs = ();
  1017. foreach (@{args{deps}}) {
  1018. my $d = dirname($_);
  1019. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1020. }
  1021. my $linkflags = join("", map { "-L$_ " } @linkdirs);
  1022. my $linklibs = join("", map { my $f = basename($_);
  1023. (my $l = $f) =~ s/^lib//;
  1024. " -l$l" } @{$args{deps}});
  1025. my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
  1026. grep { $_ !~ m/\.(?:def|map)$/ }
  1027. @{$args{objs}};
  1028. my @deps = compute_lib_depends(@{$args{deps}});
  1029. my $objs = join(" ", @objs);
  1030. my $deps = join(" ", @deps);
  1031. my $target = dso($dso);
  1032. return <<"EOF";
  1033. $target: $objs $deps
  1034. \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
  1035. -o $target $objs \\
  1036. $linklibs \$(DSO_EX_LIBS)
  1037. EOF
  1038. }
  1039. sub obj2lib {
  1040. my %args = @_;
  1041. (my $lib = $args{lib}) =~ s/\.a$//;
  1042. my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
  1043. my $objs = join(" ", @objs);
  1044. return <<"EOF";
  1045. $lib$libext: $objs
  1046. \$(AR) \$(ARFLAGS) \$\@ \$\?
  1047. \$(RANLIB) \$\@ || echo Never mind.
  1048. EOF
  1049. }
  1050. sub obj2bin {
  1051. my %args = @_;
  1052. my $bin = $args{bin};
  1053. my $bind = dirname($bin);
  1054. my $binn = basename($bin);
  1055. my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
  1056. @{$args{objs}});
  1057. my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
  1058. my @linkdirs = ();
  1059. foreach (@{args{deps}}) {
  1060. next if $_ =~ /\.a$/;
  1061. my $d = dirname($_);
  1062. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1063. }
  1064. my $linkflags = join("", map { "-L$_ " } @linkdirs);
  1065. my $linklibs = join("", map { if ($_ =~ /\.a$/) {
  1066. " $_";
  1067. } else {
  1068. my $f = basename($_);
  1069. (my $l = $f) =~ s/^lib//;
  1070. " -l$l"
  1071. }
  1072. } @{$args{deps}});
  1073. my $cmd = '$(CC)';
  1074. my $cmdflags = '$(BIN_CFLAGS)';
  1075. if (grep /_cc\.o$/, @{$args{objs}}) {
  1076. $cmd = '$(CXX)';
  1077. $cmdflags = '$(BIN_CXXFLAGS)';
  1078. }
  1079. return <<"EOF";
  1080. $bin$exeext: $objs $deps
  1081. rm -f $bin$exeext
  1082. \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
  1083. -o $bin$exeext $objs \\
  1084. $linklibs \$(BIN_EX_LIBS)
  1085. EOF
  1086. }
  1087. sub in2script {
  1088. my %args = @_;
  1089. my $script = $args{script};
  1090. my $sources = join(" ", @{$args{sources}});
  1091. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1092. "util", "dofile.pl")),
  1093. rel2abs($config{builddir}));
  1094. return <<"EOF";
  1095. $script: $sources
  1096. \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  1097. "-o$target{build_file}" $sources > "$script"
  1098. chmod a+x $script
  1099. EOF
  1100. }
  1101. sub generatedir {
  1102. my %args = @_;
  1103. my $dir = $args{dir};
  1104. my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
  1105. my @actions = ();
  1106. my %extinfo = ( dso => $dsoext,
  1107. lib => $libext,
  1108. bin => $exeext );
  1109. foreach my $type (("dso", "lib", "bin", "script")) {
  1110. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  1111. # For lib object files, we could update the library. However, it
  1112. # was decided that it's enough to build the directory local object
  1113. # files, so we don't need to add any actions, and the dependencies
  1114. # are already taken care of.
  1115. if ($type ne "lib") {
  1116. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  1117. if (dirname($prod) eq $dir) {
  1118. push @deps, $prod.$extinfo{$type};
  1119. } else {
  1120. push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
  1121. }
  1122. }
  1123. }
  1124. }
  1125. my $deps = join(" ", @deps);
  1126. my $actions = join("\n", "", @actions);
  1127. return <<"EOF";
  1128. $args{dir} $args{dir}/: $deps$actions
  1129. EOF
  1130. }
  1131. "" # Important! This becomes part of the template result.
  1132. -}