Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 1 | # |
| 2 | # This file is part of the coreboot project. |
| 3 | # |
| 4 | # Copyright (C) 2016 Intel Corporation. |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; version 2 of the License. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | |
| 16 | ########################################################################### |
Lee Leahy | ce8ff85 | 2016-08-02 08:23:17 -0700 | [diff] [blame] | 17 | # Instructions |
| 18 | ########################################################################### |
| 19 | # |
| 20 | # Create new control files for checklist: |
| 21 | # |
| 22 | # 1. Remove any selection for CREATE_BOARD_CHECKLIST |
| 23 | # 2. Remove any selection for MAKE_CHECKLIST_PUBLIC |
| 24 | # 3. make |
| 25 | # 4. nm build/cbfs/fallback/<stage>.debug > <stage>_symbols.txt |
| 26 | # 6. sed 's/^...........//' <stage>_symbols.txt > <stage>_complete.dat |
| 27 | # 7. grep -F " W " <stage>_symbols.txt | sed 's/^...........//' \ |
| 28 | # > <stage>_optional.dat |
| 29 | # 8. Edit <stage>_complete.dat to remove any symbols that are not |
| 30 | # desired in the report |
| 31 | # 9. Edit <stage>_optional.dat to remove any symbols that are |
| 32 | # required to be implemented |
| 33 | # |
| 34 | # Create a board checklist: |
| 35 | # |
| 36 | # 1. select CREATE_BOARD_CHECKLIST |
| 37 | # 2. Optionally: select MAKE_CHECKLIST_PUBLIC |
| 38 | # 3. Specify CONFIG_CHECKLIST_DATA_FILE_LOCATION |
| 39 | # 4. make |
| 40 | # |
| 41 | # Build Errors: |
| 42 | # * No checklist built - verify CREATE_BOARD_CHECKLIST is selected in |
| 43 | # board Kconfig file. Do a make clean |
| 44 | # * <stage>_complete.dat not found - verify that |
| 45 | # CONFIG_CHECKLIST_DATA_FILE_LOCATION points to the directory |
| 46 | # containing the checklist data files. Build the checklist |
| 47 | # data files if necessary. |
| 48 | # * Segmentation fault - most likely caused by $(NM_$(class)) not being |
| 49 | # set. |
| 50 | # |
| 51 | ########################################################################### |
Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 52 | # Build the board implementation checklist |
| 53 | ########################################################################### |
| 54 | |
| 55 | # Only build the checklist for boards under development |
| 56 | ifeq ($(CONFIG_CREATE_BOARD_CHECKLIST),y) |
| 57 | |
| 58 | # |
| 59 | # Extract the symbol table from the image |
| 60 | # |
| 61 | %.symbol_table: %.elf %.debug |
Lee Leahy | 3741a0b | 2016-08-02 17:40:11 -0700 | [diff] [blame] | 62 | $(NM_$(class)) $(*D)/$(*F).debug > $@ |
| 63 | $(NM_$(class)) $< >> $@ |
Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 64 | |
| 65 | # |
| 66 | # All symbols in the image |
| 67 | # |
| 68 | # 1. Remove the address and symbol type |
| 69 | # 2. Sort the table into alphabetical order |
| 70 | # 3. Remove any duplicates |
| 71 | # |
| 72 | %.symbols: %.symbol_table |
| 73 | sed 's/^...........//' $< > $@.tmp |
| 74 | sort $@.tmp > $@.tmp2 |
| 75 | uniq $@.tmp2 > $@ |
| 76 | rm $@.tmp $@.tmp2 |
| 77 | |
| 78 | # |
| 79 | # Weak symbols in the image |
| 80 | # |
| 81 | # 1. Find the weak symbols |
| 82 | # 2. Remove the address and symbol type |
| 83 | # 3. Sort the table into alphabetical order |
| 84 | # 4. Remove any duplicates |
| 85 | # |
| 86 | %.weak: %.symbol_table |
| 87 | grep -F " W " $< | sed 's/^...........//' > $@.tmp |
| 88 | sort $@.tmp > $@.tmp2 |
| 89 | uniq $@.tmp2 > $@ |
| 90 | rm $@.tmp $@.tmp2 |
| 91 | |
| 92 | # |
| 93 | # Expected symbols in the image |
| 94 | # |
| 95 | # 1. Get the complete list of expected symbols in the image |
| 96 | # 2. Sort the table into alphabetical order |
| 97 | # 3. Remove any duplicates |
| 98 | # |
| 99 | %.expected: %.symbol_table |
| 100 | cp $(CONFIG_CHECKLIST_DATA_FILE_LOCATION)/$(basename $(*F))_complete.dat $@.tmp |
Lee Leahy | 3440db5 | 2016-08-02 12:26:44 -0700 | [diff] [blame] | 101 | cat $(CONFIG_CHECKLIST_DATA_FILE_LOCATION)/$(basename $(*F))_optional.dat >> $@.tmp |
Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 102 | # If no separate verstage, combine verstage and romstage routines into a single list |
| 103 | if [ "$(*F)" = "romstage" ]; then \ |
| 104 | if [ ! -e $(*D)/verstage.elf ]; then \ |
| 105 | if [ ! -e $(*D)/postcar.elf ]; then \ |
| 106 | cat $(CONFIG_CHECKLIST_DATA_FILE_LOCATION)/verstage_complete.dat >> $@.tmp; \ |
Lee Leahy | 3440db5 | 2016-08-02 12:26:44 -0700 | [diff] [blame] | 107 | cat $(CONFIG_CHECKLIST_DATA_FILE_LOCATION)/verstage_optional.dat >> $@.tmp; \ |
Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 108 | fi; \ |
| 109 | fi; \ |
| 110 | fi |
| 111 | sort $@.tmp > $@.tmp2 |
| 112 | uniq $@.tmp2 > $@ |
| 113 | rm $@.tmp $@.tmp2 |
| 114 | |
| 115 | # |
| 116 | # Optional symbols in the image |
| 117 | # |
| 118 | # 1. Get the list of optional symbols in the image |
| 119 | # 2. Sort the table into alphabetical order |
| 120 | # 3. Remove any duplicates |
| 121 | # |
| 122 | %.optional: %.symbol_table |
| 123 | cp $(CONFIG_CHECKLIST_DATA_FILE_LOCATION)/$(basename $(*F))_optional.dat $@.tmp |
| 124 | # If no separate verstage, combine verstage and romstage routines into a single list |
| 125 | if [ "$(*F)" = "romstage" ]; then \ |
| 126 | if [ ! -e $(*D)/verstage.elf ]; then \ |
| 127 | if [ ! -e $(*D)/postcar.elf ]; then \ |
| 128 | cat $(CONFIG_CHECKLIST_DATA_FILE_LOCATION)/verstage_optional.dat >> $@.tmp; \ |
| 129 | fi; \ |
| 130 | fi; \ |
| 131 | fi |
| 132 | sort $@.tmp > $@.tmp2 |
| 133 | uniq $@.tmp2 > $@ |
| 134 | rm $@.tmp $@.tmp2 |
| 135 | |
| 136 | # |
| 137 | # Expected Symbols Optional Weak Done Type |
| 138 | # no yes no d/c yes Don't display |
| 139 | # yes no no no no Required - not implemented |
| 140 | # yes no yes no no Optional - not implemented |
| 141 | # yes yes yes yes no Optional - not implemented |
| 142 | # yes yes no no yes Required - implemented |
| 143 | # yes yes yes no yes Required - implemented |
| 144 | # |
| 145 | # Implemented routines are in the symbol table and are not weak |
| 146 | # |
| 147 | # 1. Remove expected symbols which are not in the image (not implemented yet) |
| 148 | # 2. Remove weak symbols from the list (not implemented yet) |
| 149 | # |
| 150 | %.done: %.symbols %.expected %.weak %.optional |
| 151 | comm -12 $(*D)/$(*F).expected $(*D)/$(*F).symbols | sed "s/^[ \t]*//" > $@.tmp |
| 152 | comm -23 $@.tmp $(*D)/$(*F).weak | sed "s/^[ \t]*//" > $@ |
| 153 | rm $@.tmp |
| 154 | |
| 155 | # |
| 156 | # Remove any routines that are implemented |
| 157 | # |
| 158 | %.optional2: %.optional %.done |
| 159 | comm -23 $^ | sed "s/^[ \t]*//" > $@ |
| 160 | |
| 161 | # |
| 162 | # Remove any implemented or optional routines |
| 163 | # |
| 164 | %.tbd: %.expected %.done %.optional2 |
| 165 | comm -23 $(*D)/$(*F).expected $(*D)/$(*F).done | sed "s/^[ \t]*//" > $@.tmp |
| 166 | comm -23 $@.tmp $(*D)/$(*F).optional2 | sed "s/^[ \t]*//" > $@ |
| 167 | rm $@.tmp |
| 168 | |
| 169 | # |
| 170 | # Build the implementation table for each stage |
| 171 | # 1. Color code the rows |
| 172 | # * Done table rows are in green |
| 173 | # * Optional table rows are in yellow |
| 174 | # * TBD table rows are in red |
| 175 | # 2. Add the row termination |
| 176 | # 3. Sort the rows into alphabetical order |
| 177 | # |
| 178 | %.table_rows: %.optional2 %.done %.expected %.tbd |
| 179 | sed -e 's/^/<tr bgcolor=#c0ffc0><td>Required<\/td><td>/' $(*D)/$(basename $(*F)).done > $@.tmp |
| 180 | sed -e 's/^/<tr bgcolor=#ffffc0><td>Optional<\/td><td>/' $(*D)/$(basename $(*F)).optional2 >> $@.tmp |
| 181 | if [ -s $(*D)/$(basename $(*F)).tbd ]; then \ |
| 182 | sed -e 's/^/<tr bgcolor=#ffc0c0><td>Required<\/td><td>/' $(*D)/$(basename $(*F)).tbd >> $@.tmp; \ |
| 183 | fi |
| 184 | sed -e 's/$$/<\/td><\/tr>/' -i $@.tmp |
| 185 | sort -t ">" -k4 $@.tmp > $@ |
| 186 | rm $@.tmp |
| 187 | |
| 188 | # |
| 189 | # Count the lines in the done file |
| 190 | # |
| 191 | done_lines = $$(wc -l $(*D)/$(basename $(*F)).done | sed 's/ .*//') |
| 192 | |
| 193 | # |
| 194 | # Count the lines in the optional file |
| 195 | # |
| 196 | optional_lines = $$(wc -l $(*D)/$(basename $(*F)).optional2 | sed 's/ .*//') |
| 197 | |
| 198 | # |
| 199 | # Count the lines in the expected file |
| 200 | # |
| 201 | expected_lines = $$(wc -l $(*D)/$(basename $(*F)).expected | sed 's/ .*//') |
| 202 | |
| 203 | # Compute the percentage done by routine count |
| 204 | percent_complete = $$(($(done_lines) * 100 / ($(expected_lines) - $(optional_lines)))) |
| 205 | |
| 206 | # |
| 207 | # Build the table |
| 208 | # 1. Add the table header |
| 209 | # 2. Add the table rows |
| 210 | # 3. Add the table trailer |
| 211 | # |
| 212 | %.html: %.table_rows |
| 213 | echo "<table border=1>" > $@ |
| 214 | echo "<tr><th colspan=2>$(basename $(*F)): $(percent_complete)% Done</th></tr>" >> $@ |
| 215 | echo "<tr><th>Type</th><th>Routine</td></tr>" >> $@ |
| 216 | cat $< >> $@ |
| 217 | echo "</table>" >> $@ |
| 218 | |
| 219 | # |
| 220 | # Determine which HTML files to include into the webpage |
| 221 | # |
Lee Leahy | c9bf8bf | 2016-06-05 18:45:22 -0700 | [diff] [blame] | 222 | ifeq ($(CONFIG_C_ENVIRONMENT_BOOTBLOCK),y) |
| 223 | html_table_files += $(objcbfs)/bootblock.html |
| 224 | endif |
Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 225 | ifeq ($(CONFIG_SEPARATE_VERSTAGE),y) |
| 226 | html_table_files += $(objcbfs)/verstage.html |
| 227 | endif |
Lee Leahy | 72fe7ac | 2016-08-02 17:46:12 -0700 | [diff] [blame] | 228 | html_table_files += $(objcbfs)/romstage.html |
Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 229 | ifeq ($(CONFIG_POSTCAR_STAGE),y) |
| 230 | html_table_files += $(objcbfs)/postcar.html |
| 231 | endif |
Lee Leahy | 72fe7ac | 2016-08-02 17:46:12 -0700 | [diff] [blame] | 232 | html_table_files += $(objcbfs)/ramstage.html |
Lee Leahy | fc3741f | 2016-05-26 17:12:17 -0700 | [diff] [blame] | 233 | |
| 234 | # |
| 235 | # Create a list with each file on a separate line |
| 236 | # |
| 237 | list_of_html_files = $(subst _NEWLINE_,${\n},${html_table_files}) |
| 238 | |
| 239 | # |
| 240 | # Get the date for the webpage |
| 241 | # |
| 242 | current_date_time = $$(date +"%Y/%m/%d %T %Z") |
| 243 | |
| 244 | # |
| 245 | # Build the webpage from the implementation tables |
| 246 | # 1. Add the header to the webpage |
| 247 | # 2. Add the legend to the webpage |
| 248 | # 3. Use a table to place stage tables side-by-side |
| 249 | # 4. Add the stage tables to the webpage |
| 250 | # 5. Separate the stage tables |
| 251 | # 6. Terminate the outer table |
| 252 | # 7. Add the trailer to the webpage |
| 253 | # |
| 254 | $(obj)/$(CONFIG_MAINBOARD_PART_NUMBER)_checklist.html: $(html_table_files) |
| 255 | echo "<html>" > $@ |
| 256 | echo "<head>" >> $@ |
| 257 | echo "<title>$(CONFIG_MAINBOARD_PART_NUMBER) Implementation Status</title>" >> $@ |
| 258 | echo "</title>" >> $@ |
| 259 | echo "<body>" >> $@ |
| 260 | echo "<h1>$(CONFIG_MAINBOARD_PART_NUMBER) Implementation Status<br>$(current_date_time)</h1>" >> $@ |
| 261 | echo "<table>" >> $@ |
| 262 | echo " <tr><td colspan=2><b>Legend</b></td></tr>" >> $@ |
| 263 | echo " <tr><td bgcolor=\"#ffc0c0\">Red</td><td>Required - To-be-implemented</td></tr>" >> $@ |
| 264 | echo " <tr><td bgcolor=\"#ffffc0\">Yellow</td><td>Optional</td></tr>" >> $@ |
| 265 | echo " <tr><td bgcolor=\"#c0ffc0\">Green</td><td>Implemented</td></tr>" >> $@ |
| 266 | echo "</table>" >> $@ |
| 267 | echo "<table>" >> $@ |
| 268 | echo " <tr valign=\"top\">" >> $@ |
| 269 | for table in $(list_of_html_files); do \ |
| 270 | echo " <td>" >> $@; \ |
| 271 | cat $$table >> $@; \ |
| 272 | echo " </td>" >> $@; \ |
| 273 | echo " <td width=5> </td>" >> $@; \ |
| 274 | done |
| 275 | echo " </tr>" >> $@ |
| 276 | echo "</table>" >> $@ |
| 277 | echo "</body>" >> $@ |
| 278 | echo "</html>" >> $@ |
| 279 | |
| 280 | # |
| 281 | # Copy the output file into the Documentation directory |
| 282 | # |
| 283 | Documentation/$(CONFIG_MAINBOARD_VENDOR)/Board/$(CONFIG_MAINBOARD_PART_NUMBER)_checklist.html: $(obj)/$(CONFIG_MAINBOARD_PART_NUMBER)_checklist.html |
| 284 | if [ ! -d Documentation/$(CONFIG_MAINBOARD_VENDOR) ]; then \ |
| 285 | mkdir Documentation/$(CONFIG_MAINBOARD_VENDOR); \ |
| 286 | fi |
| 287 | if [ ! -d Documentation/$(CONFIG_MAINBOARD_VENDOR)/Board ]; then \ |
| 288 | mkdir Documentation/$(CONFIG_MAINBOARD_VENDOR)/Board; \ |
| 289 | fi |
| 290 | cp $< $@ |
| 291 | |
| 292 | # |
| 293 | # Determine where to place the output file |
| 294 | # |
| 295 | ifeq ($(CONFIG_MAKE_CHECKLIST_PUBLIC),y) |
| 296 | INTERMEDIATE+=Documentation/$(CONFIG_MAINBOARD_VENDOR)/Board/$(CONFIG_MAINBOARD_PART_NUMBER)_checklist.html |
| 297 | else |
| 298 | INTERMEDIATE+=$(obj)/$(CONFIG_MAINBOARD_PART_NUMBER)_checklist.html |
| 299 | endif |
| 300 | |
| 301 | endif |