Depends.pp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // Depends.pp
  3. //
  4. // This file is loaded and run after each Sources.pp is read. It
  5. // defines the inter-directory dependencies, which is useful for
  6. // determining build order.
  7. //
  8. #if $[eq $[DIR_TYPE], toplevel]
  9. #define DEPENDABLE_HEADERS $[CONFIG_HEADER]
  10. #elif $[or $[eq $[DIR_TYPE], src], $[eq $[DIR_TYPE], metalib]]
  11. #if $[eq $[DEPEND_DIRS],]
  12. // DEPENDABLE_HEADERS is supposed to be the primary purpose of this
  13. // file: here we generate the list of source files that might be
  14. // included in some other source file, and hence is relevant to the
  15. // automatically-generated dependency chain.
  16. // We generate this variable by walking through all of the targets
  17. // and building it up.
  18. #define DEPENDABLE_HEADERS
  19. // We will also need to sort out the types files we will actually
  20. // compile within each directory, as well as the lists of files that
  21. // go into each composite.
  22. // We define $[c_sources], $[cxx_sources], $[yxx_sources], and
  23. // $[lxx_sources] within each target, which lists original files as
  24. // well as synthetic composite files. We also now add
  25. // $[cxx_interrogate_sources], which are the C++ files generated by
  26. // interrogate. Under OSX, we want to compile these files
  27. // separately.
  28. // Finally, there's $[compile_sources], which is the union of all
  29. // the others: any source files that are actually compiled and
  30. // result in a generated .o (or .obj) file.
  31. // Finally, we build up $[composite_list] out here to list all of
  32. // the composite files generated for all targets.
  33. // This is done at this point, within Depends.pp, so that the
  34. // various Template.*.pp files will be able to reliably access
  35. // $[compile_sources] from the different directories.
  36. #define composite_list
  37. // Tag all the static libraries by defining the "lib_is_static" variable.
  38. #forscopes static_lib_target
  39. #define lib_is_static 1
  40. #end static_lib_target
  41. #if $[WINDOWS_PLATFORM]
  42. #forscopes ss_lib_target
  43. #define lib_is_static 1
  44. #end ss_lib_target
  45. #endif
  46. #if $[LINK_ALL_STATIC]
  47. #forscopes metalib_target ss_lib_target lib_target
  48. #define lib_is_static 1
  49. #end metalib_target ss_lib_target lib_target
  50. #endif
  51. #forscopes metalib_target lib_target noinst_lib_target test_lib_target static_lib_target dynamic_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
  52. // We can optimize quite a bit by evaluating now several of the key
  53. // deferred variables defined in Globals.pp. This way they won't need
  54. // to get repeatedly reevaluated as each directory examines each
  55. // other.
  56. #define build_directory $[build_directory]
  57. #define build_target $[build_target]
  58. #define active_local_libs $[active_local_libs]
  59. #define active_component_libs $[active_component_libs]
  60. #define active_libs $[active_libs]
  61. #define get_sources $[get_sources]
  62. #define get_igatescan $[get_igatescan]
  63. #define get_igateoutput $[get_igateoutput]
  64. #define get_igatedb $[get_igatedb]
  65. #define get_igatemscan $[get_igatemscan]
  66. #define get_igatemout $[get_igatemout]
  67. // Report a warning for nonexisting dependencies.
  68. #define nonexisting $[unmapped all_libs,$[LOCAL_LIBS]]
  69. #if $[ne $[nonexisting],]
  70. #print Warning: Lib(s) $[nonexisting], referenced in $[DIRNAME]/$[TARGET], not found.
  71. #endif
  72. #set DEPENDABLE_HEADERS $[DEPENDABLE_HEADERS] $[filter %.h %.I %.T %_src.cxx,$[get_sources]] $[included_sources]
  73. // Now compute the source files.
  74. #define c_sources $[filter-out %_src.c,$[filter %.c,$[get_sources]]]
  75. #define mm_sources $[filter %.mm,$[get_sources]]
  76. #define cxx_sources $[filter-out %_src.cxx,$[filter %.cxx %.cpp,$[get_sources]]]
  77. #define cxx_interrogate_sources
  78. #if $[PYTHON_MODULE_ONLY]
  79. #set cxx_interrogate_sources $[cxx_sources]
  80. #set cxx_sources
  81. #endif
  82. #define yxx_sources $[filter %.yxx,$[get_sources]]
  83. #define lxx_sources $[filter %.lxx,$[get_sources]]
  84. // Define what the object files are.
  85. #foreach file $[c_sources] $[mm_sources] $[cxx_sources] $[cxx_interrogate_sources] $[yxx_sources] $[lxx_sources]
  86. #define $[file]_obj $[patsubst %.c %.cxx %.mm %.cpp %.yxx %.lxx,$[ODIR]/$[obj_prefix]%$[OBJ],$[notdir $[file]]]
  87. #push 1 $[file]_obj
  88. #end file
  89. #if $[and $[not $[DONT_COMBINE]],$[or $[USE_SINGLE_COMPOSITE_SOURCEFILE],$[USE_TAU]]]
  90. #if $[> $[words $[cxx_sources]], 1]
  91. // If we have multiple C++ files, put them together into one
  92. // composite file.
  93. #define composite_file $[ODIR]/$[TARGET]_composite.cxx
  94. #set composite_list $[composite_list] $[composite_file]
  95. #define $[composite_file]_sources $[cxx_sources]
  96. #define $[composite_file]_obj $[ODIR]/$[TARGET]_composite$[OBJ]
  97. #push 1 $[composite_file]_sources
  98. #push 1 $[composite_file]_obj
  99. #if $[PYTHON_MODULE_ONLY]
  100. #set cxx_interrogate_sources $[composite_file]
  101. #else
  102. #set cxx_sources $[composite_file]
  103. #endif
  104. #endif
  105. #if $[> $[words $[c_sources]], 1]
  106. // If we have multiple C files, put them together into one
  107. // composite file also.
  108. #define composite_file $[ODIR]/$[TARGET]_composite_c.c
  109. #set composite_list $[composite_list] $[composite_file]
  110. #define $[composite_file]_sources $[c_sources]
  111. #define $[composite_file]_obj $[ODIR]/$[TARGET]_composite_c$[OBJ]
  112. #push 1 $[composite_file]_sources
  113. #push 1 $[composite_file]_obj
  114. #set c_sources $[composite_file]
  115. #endif
  116. #endif
  117. // Add the bison- and flex-generated .cxx files, as well as the
  118. // interrogate-generated files, to the compile list, too. These
  119. // never get added to composite files, though, mainly because they
  120. // tend to be very large files themselves.
  121. #foreach source_file $[yxx_sources] $[lxx_sources]
  122. #define generated_file $[patsubst %.yxx %.lxx,%.cxx,$[source_file]]
  123. #define $[generated_file]_obj $[patsubst %.yxx %.lxx,$[ODIR]/$[TARGET]_%$[OBJ],$[source_file]]
  124. #define $[generated_file]_sources $[source_file]
  125. #push 1 $[generated_file]_obj
  126. #set cxx_sources $[cxx_sources] $[generated_file]
  127. #end source_file
  128. #if $[and $[build_directory],$[get_igateoutput]]
  129. #define generated_file $[get_igateoutput]
  130. #define $[generated_file]_obj $[get_igateoutput:%.cxx=%$[OBJ]]
  131. // #define $[generated_file]_sources $[get_igatescan]
  132. #push 1 $[generated_file]_obj
  133. // We add this to cxx_sources instead of cxx_interrogate_sources,
  134. // even though it's an interrogate-generated file, because it's
  135. // not a module file--we really only accumulate module files into
  136. // cxx_interrogate_sources.
  137. #set cxx_sources $[cxx_sources] $[generated_file]
  138. #endif
  139. #if $[get_igatemout]
  140. #define generated_file $[get_igatemout]
  141. #define $[generated_file]_obj $[get_igatemout:%.cxx=%$[OBJ]]
  142. #define $[generated_file]_sources none
  143. #push 1 $[generated_file]_obj
  144. #set cxx_interrogate_sources $[cxx_interrogate_sources] $[generated_file]
  145. #endif
  146. #define compile_sources $[c_sources] $[mm_sources] $[cxx_sources] $[cxx_interrogate_sources]
  147. #end metalib_target lib_target noinst_lib_target test_lib_target static_lib_target dynamic_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
  148. // Allow the user to define additional EXTRA_DEPENDS targets in each
  149. // Sources.pp.
  150. #define DEPEND_DIRS \
  151. $[sort $[EXTRA_DEPENDS] $[all_libs $[DIRNAME],$[get_depend_libs]]]
  152. #set DEPENDABLE_HEADERS $[sort $[DEPENDABLE_HEADERS] $[EXTRA_DEPENDABLE_HEADERS]]
  153. #endif
  154. #endif // DIR_TYPE