Debian Codegraph @

build_tools/make_buildopts_h

raw symbols SCIP
1 #!/bin/sh
2
3 GREP=${GREP:-grep}
4 MD5=${MD5:-md5sum}
5
6 cat << END
7 /*
8 * buildopts.h
9 * Automatically generated
10 */
11
12 END
13
14 if ${GREP} "AST_DEVMODE" makeopts | ${GREP} -q "yes"
15 then
16 echo "#define AST_DEVMODE 1"
17 # AST_DEVMODE is no longer an API/ABI affecting option so it no longer
18 # gets added to BUILDOPTS.
19 fi
20
21 ADD_CFLAGS_TO_BUILDOPTS=false
22 MENUSELECT_CFLAGS=$(${GREP} -e "^MENUSELECT_CFLAGS" menuselect.makeopts)
23 echo "$MENUSELECT_CFLAGS" | grep -q -e "ADD_CFLAGS_TO_BUILDOPTS_H" && ADD_CFLAGS_TO_BUILDOPTS=true
24
25 # Clean up MENUSELECT_CFLAGS by removing the "MENUSELECT_CFLAGS="
26 # at the front, the "ADD_CFLAGS_TO_BUILDOPTS_H" flag, and any "-D"
27 # entries.
28 MENUSELECT_CFLAGS=$( echo "$MENUSELECT_CFLAGS" | \
29 sed -r -e "s/(MENUSELECT_CFLAGS=|ADD_CFLAGS_TO_BUILDOPTS_H|-D)//g")
30
31 # This is a list of flags that don't affect the ABI.
32 # "ADD_CFLAGS_TO_BUILDOPTS_H" is NOT set, we'll filter these
33 # out of the buildopts.h file.
34 #
35 # These used to always be filtered out but if they're not in
36 # buildopts.h, many IDEs will show them as undefined and mark
37 # any code blocks enabled by them as disabled.
38 #
39 # The original reasoning for removing them was that trivial
40 # changes to the buildopts.h file will cause ccache to
41 # invalidate any source files that use it and increase the
42 # compile time. It's not such a huge deal these days but
43 # to preserve backwards behavior the default is still to
44 # remove them.
45 #
46 # The ABI-breaking flags are always included in buildopts.h.
47
48 # This variable is used by sed so it needs to be a valid
49 # regex which will be surrounded by parens.]
50 FILTER_OUT="\
51 AO2_DEBUG|BETTER_BACKTRACES|BUILD_NATIVE|\
52 COMPILE_DOUBLE|DEBUG_CHAOS|DEBUG_SCHEDULER|\
53 DONT_OPTIMIZE|DUMP_SCHEDULER|\
54 LOTS_OF_SPANS|MALLOC_DEBUG|RADIO_RELAX|\
55 REBUILD_PARSERS|REF_DEBUG|USE_HOARD_ALLOCATOR"
56
57 # Create buildopts.h
58
59 INCLUDE_CFLAGS="$MENUSELECT_CFLAGS"
60 # Do the filter-out if needed.
61 if ! $ADD_CFLAGS_TO_BUILDOPTS ; then
62 INCLUDE_CFLAGS=$( echo "$MENUSELECT_CFLAGS" | \
63 sed -r -e "s/(${FILTER_OUT})//g")
64 fi
65
66 # Output the defines.
67 for x in ${INCLUDE_CFLAGS}; do
68 echo "#define ${x} 1"
69 done
70
71 # We NEVER include the non-ABI-breaking flags in the
72 # BUILDOPTS or use them to calculate the checksum so
73 # we always filter out any that may exist.
74 # After the filter-out, we also need to convert the
75 # possibly-multi-spaced MENUSELECT_CFLAGS to a nice
76 # comma-separated list.
77 # I.E.
78 # Remove leading spaces.
79 # Convert consecutive interior spaces to a single space.
80 # Remove trailing spaces.
81 # Convert the now-single-spaces in the interior to ", ".
82 BUILDOPTS=$( echo "$MENUSELECT_CFLAGS" | \
83 sed -r -e "s/(${FILTER_OUT}|LOW_MEMORY)//g" -e "s/^\s+//g;s/\s+/ /g;s/\s+$//g;s/\s/, /g" )
84
85 # Calculate the checksum on only the ABI-breaking flags.
86 BUILDSUM=$(echo "${BUILDOPTS}" | ${MD5} | cut -c1-32)
87
88 echo "#define AST_BUILDOPT_SUM \"${BUILDSUM}\""
89 echo "#define AST_BUILDOPTS \"${BUILDOPTS}\""
90
91 # However, it'd be nice to see the non-ABI-breaking flags
92 # when you do a "core show settings" so we create a separate
93 # define for them.
94 BUILDOPTS_ALL=$( echo "$MENUSELECT_CFLAGS" | \
95 sed -r -e "s/^\s+//g;s/\s+/ /g;s/\s+$//g;s/\s/, /g" )
96 echo "#define AST_BUILDOPTS_ALL \"${BUILDOPTS_ALL}\""