INTERNALS.Configure 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. Configure Internals
  2. ===================
  3. [ note: this file uses markdown for formatting ]
  4. Intro
  5. -----
  6. This is a collection of notes that are hopefully of interest to those
  7. who decide to dive into Configure and what it does. This is a living
  8. document and anyone is encouraged to add to it and submit changes.
  9. There's no claim for this document to be complete at any time, but it
  10. will hopefully reach such a point in time.
  11. ----------------------------------------------------------------------
  12. Parsing build.info files, processing conditions
  13. -----------------------------------------------
  14. Processing conditions in build.info files is done with the help of a
  15. condition stack that tell if a build.info should be processed or if it
  16. should just be skipped over. The possible states of the stack top are
  17. expressed in the following comment from Configure:
  18. # The top item of this stack has the following values
  19. # -2 positive already run and we found ELSE (following ELSIF should fail)
  20. # -1 positive already run (skip until ENDIF)
  21. # 0 negatives so far (if we're at a condition, check it)
  22. # 1 last was positive (don't skip lines until next ELSE, ELSIF or ENDIF)
  23. # 2 positive ELSE (following ELSIF should fail)
  24. Ground rule is that non-condition lines are skipped over if the
  25. stack top is > 0. Condition lines (IF, ELSIF, ELSE and ENDIF
  26. statements) need to be processed either way to keep track of the skip
  27. stack states, so they are a little more intricate.
  28. Instead of trying to describe in words, here are some example of what
  29. the skip stack should look like after each line is processed:
  30. Example 1:
  31. | IF[1] | 1 | |
  32. | ... whatever ... | | this line is processed |
  33. | IF[1] | 1 1 | |
  34. | ... whatever ... | | this line is processed |
  35. | ELSIF[1] | 1 -1 | |
  36. | ... whatever ... | | this line is skipped over |
  37. | ELSE | 1 -2 | |
  38. | ... whatever ... | | this line is skipped over |
  39. | ENDIF | 1 | |
  40. | ... whatever ... | | this line is processed |
  41. | ELSIF[1] | -1 | |
  42. | ... whatever ... | | this line is skipped over |
  43. | IF[1] | -1 -1 | |
  44. | ... whatever ... | | this line is skipped over |
  45. | ELSIF[1] | -1 -1 | |
  46. | ... whatever ... | | this line is skipped over |
  47. | ELSE | -1 -2 | |
  48. | ... whatever ... | | this line is skipped over |
  49. | ENDIF | -1 | |
  50. | ... whatever ... | | this line is skipped over |
  51. | ENDIF | | |
  52. Example 2:
  53. | IF[0] | 0 | |
  54. | ... whatever ... | | this line is skipped over |
  55. | IF[1] | 0 -1 | |
  56. | ... whatever ... | | this line is skipped over |
  57. | ELSIF[1] | 0 -1 | |
  58. | ... whatever ... | | this line is skipped over |
  59. | ELSE | 0 -2 | |
  60. | ... whatever ... | | this line is skipped over |
  61. | ENDIF | 0 | |
  62. | ... whatever ... | | this line is skipped over |
  63. | ELSIF[1] | 1 | |
  64. | ... whatever ... | | this line is processed |
  65. | IF[1] | 1 1 | |
  66. | ... whatever ... | | this line is processed |
  67. | ELSIF[1] | 1 -1 | |
  68. | ... whatever ... | | this line is skipped over |
  69. | ELSE | 1 -2 | |
  70. | ... whatever ... | | this line is skipped over |
  71. | ENDIF | 1 | |
  72. | ... whatever ... | | this line is processed |
  73. | ENDIF | | |
  74. Example 3:
  75. | IF[0] | 0 | |
  76. | ... whatever ... | | this line is skipped over |
  77. | IF[0] | 0 -1 | |
  78. | ... whatever ... | | this line is skipped over |
  79. | ELSIF[1] | 0 -1 | |
  80. | ... whatever ... | | this line is skipped over |
  81. | ELSE | 0 -2 | |
  82. | ... whatever ... | | this line is skipped over |
  83. | ENDIF | 0 | |
  84. | ... whatever ... | | this line is skipped over |
  85. | ELSIF[1] | 1 | |
  86. | ... whatever ... | | this line is processed |
  87. | IF[0] | 1 0 | |
  88. | ... whatever ... | | this line is skipped over |
  89. | ELSIF[1] | 1 1 | |
  90. | ... whatever ... | | this line is processed |
  91. | ELSE | 1 -2 | |
  92. | ... whatever ... | | this line is skipped over |
  93. | ENDIF | 1 | |
  94. | ... whatever ... | | this line is processed |
  95. | ENDIF | | |
  96. Example 4:
  97. | IF[0] | 0 | |
  98. | ... whatever ... | | this line is skipped over |
  99. | IF[0] | 0 -1 | |
  100. | ... whatever ... | | this line is skipped over |
  101. | ELSIF[0] | 0 -1 | |
  102. | ... whatever ... | | this line is skipped over |
  103. | ELSE | 0 -2 | |
  104. | ... whatever ... | | this line is skipped over |
  105. | ENDIF | 0 | |
  106. | ... whatever ... | | this line is skipped over |
  107. | ELSIF[1] | 1 | |
  108. | ... whatever ... | | this line is processed |
  109. | IF[0] | 1 0 | |
  110. | ... whatever ... | | this line is skipped over |
  111. | ELSIF[0] | 1 0 | |
  112. | ... whatever ... | | this line is skipped over |
  113. | ELSE | 1 2 | |
  114. | ... whatever ... | | this line is processed |
  115. | ENDIF | 1 | |
  116. | ... whatever ... | | this line is processed |
  117. | ENDIF | | |