unix-Makefile.tmpl 53 KB

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