Depends.pp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. #if $[WINDOWS_PLATFORM]
  39. #forscopes static_lib_target ss_lib_target
  40. #define lib_is_static 1
  41. #end static_lib_target ss_lib_target
  42. #else
  43. #forscopes static_lib_target
  44. #define lib_is_static 1
  45. #end static_lib_target
  46. #endif
  47. #forscopes metalib_target lib_target noinst_lib_target test_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
  48. // We can optimize quite a bit by evaluating now several of the key
  49. // deferred variables defined in Globals.pp. This way they won't need
  50. // to get repeatedly reevaluated as each directory examines each
  51. // other.
  52. #define build_directory $[build_directory]
  53. #define build_target $[build_target]
  54. #define active_local_libs $[active_local_libs]
  55. #define active_component_libs $[active_component_libs]
  56. #define active_libs $[active_libs]
  57. #define get_sources $[get_sources]
  58. #define get_igatescan $[get_igatescan]
  59. #define get_igateoutput $[get_igateoutput]
  60. #define get_igatedb $[get_igatedb]
  61. #define get_igatemscan $[get_igatemscan]
  62. #define get_igatemout $[get_igatemout]
  63. // Report a warning for nonexisting dependencies.
  64. #define nonexisting $[unmapped all_libs,$[LOCAL_LIBS]]
  65. #if $[ne $[nonexisting],]
  66. #print Warning: Lib(s) $[nonexisting], referenced in $[DIRNAME]/$[TARGET], not found.
  67. #endif
  68. #set DEPENDABLE_HEADERS $[DEPENDABLE_HEADERS] $[filter %.h %.I %.T %_src.cxx,$[get_sources]] $[included_sources]
  69. // Now compute the source files.
  70. #define c_sources $[filter %.c,$[get_sources]]
  71. #define cxx_sources $[filter-out %_src.cxx,$[filter %.cxx %.mm %.cpp,$[get_sources]]]
  72. #define cxx_interrogate_sources
  73. #if $[PYTHON_MODULE_ONLY]
  74. #set cxx_interrogate_sources $[cxx_sources]
  75. #set cxx_sources
  76. #endif
  77. #define yxx_sources $[filter %.yxx,$[get_sources]]
  78. #define lxx_sources $[filter %.lxx,$[get_sources]]
  79. // Define what the object files are.
  80. #foreach file $[c_sources] $[cxx_sources] $[cxx_interrogate_sources] $[yxx_sources] $[lxx_sources]
  81. #define $[file]_obj $[patsubst %.c %.cxx %.mm %.cpp %.yxx %.lxx,$[ODIR]/$[obj_prefix]%$[OBJ],$[notdir $[file]]]
  82. #push 1 $[file]_obj
  83. #end file
  84. #if $[and $[not $[DONT_COMBINE]],$[or $[USE_SINGLE_COMPOSITE_SOURCEFILE],$[USE_TAU]]]
  85. #if $[> $[words $[cxx_sources]], 1]
  86. // If we have multiple C++ files, put them together into one
  87. // composite file.
  88. #define composite_file $[ODIR]/$[TARGET]_composite.cxx
  89. #set composite_list $[composite_list] $[composite_file]
  90. #define $[composite_file]_sources $[cxx_sources]
  91. #define $[composite_file]_obj $[ODIR]/$[TARGET]_composite$[OBJ]
  92. #push 1 $[composite_file]_sources
  93. #push 1 $[composite_file]_obj
  94. #if $[PYTHON_MODULE_ONLY]
  95. #set cxx_interrogate_sources $[composite_file]
  96. #else
  97. #set cxx_sources $[composite_file]
  98. #endif
  99. #endif
  100. #if $[> $[words $[c_sources]], 1]
  101. // If we have multiple C files, put them together into one
  102. // composite file also.
  103. #define composite_file $[ODIR]/$[TARGET]_composite_c.c
  104. #set composite_list $[composite_list] $[composite_file]
  105. #define $[composite_file]_sources $[c_sources]
  106. #define $[composite_file]_obj $[ODIR]/$[TARGET]_composite_c$[OBJ]
  107. #push 1 $[composite_file]_sources
  108. #push 1 $[composite_file]_obj
  109. #set c_sources $[composite_file]
  110. #endif
  111. #endif
  112. // Add the bison- and flex-generated .cxx files, as well as the
  113. // interrogate-generated files, to the compile list, too. These
  114. // never get added to composite files, though, mainly because they
  115. // tend to be very large files themselves.
  116. #foreach source_file $[yxx_sources] $[lxx_sources]
  117. #define generated_file $[patsubst %.yxx %.lxx,%.cxx,$[source_file]]
  118. #define $[generated_file]_obj $[patsubst %.yxx %.lxx,$[ODIR]/$[TARGET]_%$[OBJ],$[source_file]]
  119. #define $[generated_file]_sources $[source_file]
  120. #push 1 $[generated_file]_obj
  121. #set cxx_sources $[cxx_sources] $[generated_file]
  122. #end source_file
  123. #if $[get_igateoutput]
  124. #define generated_file $[get_igateoutput]
  125. #define $[generated_file]_obj $[get_igateoutput:%.cxx=%$[OBJ]]
  126. #define $[generated_file]_sources $[get_igatescan]
  127. #push 1 $[generated_file]_obj
  128. // We add this to cxx_sources instead of cxx_interrogate_sources,
  129. // even though it's an interrogate-generated file, because it's
  130. // not a module file--we really only accumulate module files into
  131. // cxx_interrogate_sources.
  132. #set cxx_sources $[cxx_sources] $[generated_file]
  133. #endif
  134. #if $[get_igatemout]
  135. #define generated_file $[get_igatemout]
  136. #define $[generated_file]_obj $[get_igatemout:%.cxx=%$[OBJ]]
  137. #define $[generated_file]_sources none
  138. #push 1 $[generated_file]_obj
  139. #set cxx_interrogate_sources $[cxx_interrogate_sources] $[generated_file]
  140. #endif
  141. #define compile_sources $[c_sources] $[cxx_sources] $[cxx_interrogate_sources]
  142. #end metalib_target lib_target noinst_lib_target test_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
  143. // Allow the user to define additional EXTRA_DEPENDS targets in each
  144. // Sources.pp.
  145. #define DEPEND_DIRS \
  146. $[sort $[EXTRA_DEPENDS] $[all_libs $[DIRNAME],$[get_depend_libs]]]
  147. #set DEPENDABLE_HEADERS $[sort $[DEPENDABLE_HEADERS] $[EXTRA_DEPENDABLE_HEADERS]]
  148. #endif
  149. #endif // DIR_TYPE