* On 18 Oct 2012, David Laight wrote: > Actually even C programs are a PITA if you are trying to crossbuild. > At the very least, they require special attention. > > Why not pipe through tr -cd in order to remove anything not alphanumeric > or sane punctuation. > Although I suspect that the only problem character is ". > > The more you can avoid in build tools, the better. > Even assuming a working awk, or some obscure grep options/variant > can be a problem, never mind monsters like perl and python.
But I can assume that if perl or python is present, it will accomplish this task in a predictable way. Neither sed nor awk is very portable in advanced usage; awk, nawk, gawk, mawk, etc have whole different language specifications, and sed has varying punctuation requirements in different implementations. The sed command you posted scares me quite a lot once I think about supporting it under six or seven different sed variants, from a Makefile that might be running under any of a dozen "make" programs, launching the sed via sh, ksh, bash, zsh, ash, pdksh, or .... Most of these combinations will work fine, but there are some that are pretty sketchy. I'm also not really interested in approximating what the compiler says it is with a printable US-ASCII reduction of its output. And I still don't know what to do about trigraphs under your suggestion, other than to explicitly escape each one, or to know how to disable trigraphs in each compiler that supports them. Anyway, I fundamentally just don't think that we can expect arbitrary compilers to tolerate arbitrary text in an arbitrary encoding with 0x22 escaped, as a C literal string. But I could be persuaded by examples of highly portable programs that do this successfully. I'm interested in predictable behavior much more than I'm interested in minimizing requirements for a compilation. I know I'm talking about narrow edge cases, but I don't think any of this is more of an edge case than a build platform that can't install Python (or Perl, or whatever), or a cross-compile that can't specify a native compiler in addition to the cross compiler. Am I wrong about that? Options that I see: 1. Nothing to see here, move along 2. Write it in perl and tcl too, and test for which version will run 3. Write it in shell and drink myself silly, in whichever order works best 4. Require "make NATIVECC=..." when cross-compiling I'm good with 1 or 4. I'll entertain strong arguments for 2 or 3, especially if you're buying, but I'm not sure either is a complete solution. 1 and 4 are, if you accept the transference of the problem to documented conditions for compilation. -- David Champion • d...@bikeshed.us