-# Grab CFLAGS, etc. from the profile...
-if [ -f /etc/portage/make.profile/make.defaults ]; then
- . /etc/portage/make.profile/make.defaults
-fi
+# Grab CFLAGS, etc. from our profile after first processing its parent
+# profiles recursively
+load_profile_defaults() {
+ local profile="${1}"
+ if [ -f "${profile}/parent" ]; then
+ for parent in $(cat "${profile}/parent"); do
+ local _parent_path="${profile}/${parent}"
+ load_profile_defaults "${_parent_path}"
+ done
+ fi
+
+ if [ -f "${profile}/make.defaults" ]; then
+ if [ -r "${profile}/make.defaults" ]; then
+ . "${profile}/make.defaults"
+ fi
+ fi
+}
+
+load_profile_defaults /etc/portage/make.profile
+