2
0

Depends.pp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. There's also
  25. // $[compile_sources], which is the union of all the others: any
  26. // source files that are actually compiled and result in a generated
  27. // .o (or .obj) file.
  28. // Finally, we build up $[composite_list] out here to list all of
  29. // the composite files generated for all targets.
  30. // This is done at this point, within Depends.pp, so that the
  31. // various Template.*.pp files will be able to reliably access
  32. // $[compile_sources] from the different directories.
  33. #define composite_list
  34. // Tag all the static libraries by defining the "lib_is_static" variable.
  35. #if $[WINDOWS_PLATFORM]
  36. #forscopes static_lib_target ss_lib_target
  37. #define lib_is_static 1
  38. #end static_lib_target ss_lib_target
  39. #else
  40. #forscopes static_lib_target
  41. #define lib_is_static 1
  42. #end static_lib_target
  43. #endif
  44. #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
  45. // We can optimize quite a bit by evaluating now several of the key
  46. // deferred variables defined in Globals.pp. This way they won't need
  47. // to get repeatedly reevaluated as each directory examines each
  48. // other.
  49. #define build_directory $[build_directory]
  50. #define build_target $[build_target]
  51. #define active_local_libs $[active_local_libs]
  52. #define active_component_libs $[active_component_libs]
  53. #define active_libs $[active_libs]
  54. #define get_sources $[get_sources]
  55. #define get_igatescan $[get_igatescan]
  56. #define get_igateoutput $[get_igateoutput]
  57. #define get_igatedb $[get_igatedb]
  58. #define get_igatemscan $[get_igatemscan]
  59. #define get_igatemout $[get_igatemout]
  60. // Report a warning for nonexisting dependencies.
  61. #define nonexisting $[unmapped all_libs,$[LOCAL_LIBS]]
  62. #if $[ne $[nonexisting],]
  63. #print Warning: Lib(s) $[nonexisting], referenced in $[DIRNAME]/$[TARGET], not found.
  64. #endif
  65. #set DEPENDABLE_HEADERS $[DEPENDABLE_HEADERS] $[filter %.h %.I %.T %_src.cxx,$[get_sources]] $[included_sources]
  66. // Now compute the source files.
  67. #define c_sources $[filter %.c,$[get_sources]]
  68. #define cxx_sources $[filter-out %_src.cxx,$[filter %.cxx %.cpp,$[get_sources]]]
  69. #define yxx_sources $[filter %.yxx,$[get_sources]]
  70. #define lxx_sources $[filter %.lxx,$[get_sources]]
  71. // Define what the object files are.
  72. #foreach file $[c_sources] $[cxx_sources] $[yxx_sources] $[lxx_sources]
  73. #define $[file]_obj $[patsubst %.c %.cxx %.cpp %.yxx %.lxx,$[ODIR]/$[obj_prefix]%$[OBJ],$[notdir $[file]]]
  74. #push 1 $[file]_obj
  75. #end file
  76. #if $[USE_SINGLE_COMPOSITE_SOURCEFILE]
  77. #if $[> $[words $[cxx_sources]], 1]
  78. // If we have multiple C++ files, put them together into one
  79. // composite file.
  80. #define composite_file $[ODIR]/$[TARGET]_composite.cxx
  81. #set composite_list $[composite_list] $[composite_file]
  82. #define $[composite_file]_sources $[cxx_sources]
  83. #define $[composite_file]_obj $[ODIR]/$[TARGET]_composite$[OBJ]
  84. #push 1 $[composite_file]_sources
  85. #push 1 $[composite_file]_obj
  86. #set cxx_sources $[composite_file]
  87. #endif
  88. #if $[> $[words $[c_sources]], 1]
  89. // If we have multiple C files, put them together into one
  90. // composite file also.
  91. #define composite_file $[ODIR]/$[TARGET]_composite_c.c
  92. #set composite_list $[composite_list] $[composite_file]
  93. #define $[composite_file]_sources $[c_sources]
  94. #define $[composite_file]_obj $[ODIR]/$[TARGET]_composite_c$[OBJ]
  95. #push 1 $[composite_file]_sources
  96. #push 1 $[composite_file]_obj
  97. #set c_sources $[composite_file]
  98. #endif
  99. #endif
  100. // Add the bison- and flex-generated .cxx files, as well as the
  101. // interrogate-generated files, to the compile list, too. These
  102. // never get added to composite files, though, mainly because they
  103. // tend to be very large files themselves.
  104. #foreach source_file $[yxx_sources] $[lxx_sources]
  105. #define generated_file $[patsubst %.yxx %.lxx,%.cxx,$[source_file]]
  106. #define $[generated_file]_obj $[patsubst %.yxx %.lxx,$[ODIR]/$[TARGET]_%$[OBJ],$[source_file]]
  107. #define $[generated_file]_sources $[source_file]
  108. #push 1 $[generated_file]_obj
  109. #set cxx_sources $[cxx_sources] $[generated_file]
  110. #end source_file
  111. #if $[get_igateoutput]
  112. #define generated_file $[get_igateoutput]
  113. #define $[generated_file]_obj $[get_igateoutput:%.cxx=%$[OBJ]]
  114. #define $[generated_file]_sources $[get_igatescan]
  115. #push 1 $[generated_file]_obj
  116. #set cxx_sources $[cxx_sources] $[generated_file]
  117. #endif
  118. #if $[get_igatemout]
  119. #define generated_file $[get_igatemout]
  120. #define $[generated_file]_obj $[get_igatemout:%.cxx=%$[OBJ]]
  121. #define $[generated_file]_sources none
  122. #push 1 $[generated_file]_obj
  123. #set cxx_sources $[cxx_sources] $[generated_file]
  124. #endif
  125. #define compile_sources $[c_sources] $[cxx_sources]
  126. #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
  127. // Allow the user to define additional EXTRA_DEPENDS targets in each
  128. // Sources.pp.
  129. #define DEPEND_DIRS \
  130. $[sort $[EXTRA_DEPENDS] $[all_libs $[DIRNAME],$[get_depend_libs]]]
  131. #set DEPENDABLE_HEADERS $[sort $[DEPENDABLE_HEADERS] $[EXTRA_DEPENDABLE_HEADERS]]
  132. #endif
  133. #endif // DIR_TYPE