The molden ebuilds use error-prone syntax. Here is a patch that prevents the need for sedding the makefile. The problem with the previous code was that it assumed none of the variables would contain a colon, and there's no reason to do all that work.
Created attachment 28714 [details, diff] patch for molden-4.0.ebuild
Full explanation of the patch: 1. Remove all the sedding. There are a few problems with using sed like this: First it relies on future versions of the Makefile using the same formatting. Second it uses ${CFLAGS} in a sed expression, which has the potential to screw up sed if anything in ${CFLAGS} is a sed meta-character. Third, there was no checking (|| die) after the expressions, so you'd never know if sed were to stop working. Fourth, it makes a lot more sense to move variable dependencies into src_compile() where they're actually used. 2. The "use alpha && append-flags -mieee" was something I found in the molden documentation or Makefile while reading through. Since I work on alpha I know essentially what it does: protection against floating point exception on divide-by-zero. Additionally it makes floating point math work correctly instead of just quickly. 3. Next, declare an array named args. We use an array because it lets us have a list with items that include spaces, similar to using positional parameters ($1, $2, "$@", etc) but storing in a named location. 4. Assign a list to the array. Here are the elements in the array: CC="${CC} ${CFLAGS}" This is a single element in the array, which contains spaces. It will be passed to make as an argument to override the Makefile's default CC ${FC:+FC="${FC}" LDR="${FC}"} Okay, this takes a little explanation. :-) The first thing to understand is this: ${VAR:+blah}. This means: If VAR is empty then substitute nothing, otherwise substitute blah. In this case VAR is FC and blah is FC="${FC}" LDR="${FC}". So the result? If FC is set, then we'll add 2 elements to the array: FC="${FC}" and LDR="${FC}". If FC is unset or empty, then we'll add nothing to the array. Make sense? This construct is particularly useful when making conditional assignments to an array. ${FFLAGS:+FFLAGS="${FFLAGS}"} This is pretty much the same as FC above emake "${args[@]}" This passes the args array to emake on the cmdline, preserving spacing. It's exactly like doing "$@" but uses the args array instead of the positional parameters. The result would look something like this: emake CC="gcc -mcpu=alphaev67 -O3 -pipe -mieee" \ FFLAGS="-my -fflags" emake "${args[@]}" moldenogl This is the reason we stuffed everything into args instead of putting it all on the cmdline. It's because we need to call emake more than once and we want to avoid duplicated information in the ebuild. Hope this helps!
Fixed. Thanks for inspiring me to read up on some advanced bash.