Zdenko,
LIke I said previously, I assumed that whoever (as it turns out, you) did the modification with the
configure.ac file probably had a strong reason to do so - and obviously it's not possible for anyone to perfectly anticipate how a change is going to effect every possible use scenario on every possible system. It's admirable that Tesseract can run on so many different platforms and environments, but yeah, it doesn't come without headaches. I think we (or at least I) need to understand the build system better in order to use it properly.
The problem you mentioned with the openSUSE system (flags -g -O2 being appended) has been occurring on my system (OS X 10.9) too, ever since I started using Tesseract 3.02 (stable version) a month or so ago: when I said in my earlier post,
"On Mac OS X 10.9 with the default toolchain, the -O2 optimization level (due to --enable-debug) appears to be too aggressive".
I was mistakenly blaming --enable-debug for setting the flags to "-g -O2". The actual problem was the one you pointed out, with the flags "-g -O2" being appended and overriding the flags set by --enable-debug).
Anyway, my solution to this problem had been to set CXXFLAGS explicitly through the command-line, and it was working until you noticed the same problem on openSUSE and tried a different solution for it, causing my solution to break - that's how I comprehend the situation.
Coming to your proposed solution itself, i.e. adding the line ${CXXFLAGS=""} in
configure.ac:
What happens on OpenSuse when you run the configure script with the line ${CXXFLAGS=""}? On my OS X 10.9 system the first line that configure spits out on the screen is:
./configure: line 2506: : command not found
and a quick check shoes that "line 2506" in configure is in fact: ${CXXFLAGS=""}
so it appears that a side-effect of this method is the script tries to run CXXFLAGS (containing the empty string "") as an executable. Presumably no one has a command called CXXFLAGS on their path(!) so nothing is going to happen, but overall this does not seem to be a good thing to have happen.
Perhaps you should consider the solution I mentioned in my previous post:
CXXFLAGS=${CXXFLAGS:-""}
This lets the user override CXXFLAGS (assuming he knows what he's doing) while setting it to "" if he doesn't. And it doesn't cause CXXFLAGS to be executed.
---
I have read in some places that CXXFLAGS shouldn't be messed with
in
the build scripts because these flags are meant for the users and
overriding them in the scripts can cause surprises of the bad kind (as in my case).
Presumably the idea is that the user should know what they're doing
(which evidently isn't always the case, taking myself as an example! - but I'm trying to learn). But then again, I do not really know why
CXXFLAGS defaults to "-g -O2"
on some systems (it's probably a convention or standard) and what the
proper way is to deal with flag conflicts as in the case of
--enable-debug.
I don't want to waste too much of your time on this issue (I know I have). but this discussion about making a debug target is interesting:
http://stackoverflow.com/questions/4553735/gnu-autotools-debug-release-targetsThe accepted answer is similar to your approach, but (given my limited understanding) I'm inclined to agree with the the second answer (which is more highly voted), i.e. I feel that let the user (who wants to debug) pass in manually the appropriate flags themselves, instead of offering an --enable-debug option at all. But at the very least we need a more robust solution that avoids unexpected surprises and at least issues some warnings when conflicting flags are passed.