Depends.pp 6.3 KB

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