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