Depends.pp 5.9 KB

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