[crosstool-ng] Menuconfig problems on Mac OS X

Ben Greenfield ben@cogs.com
Sun Jun 26 17:05:00 GMT 2011


On Jun 26, 2011, at 12:59 PM, Ben Greenfield wrote:

> Yann, All,
> 
> I'm mostly a lurker and OS X user but here is my 2 cents. On how I expect the platform to perform.
> 
> On Jun 26, 2011, at 12:43 PM, Yann E. MORIN wrote:
>> 
>> From what I understand from the messages on the list, the problem with
>> MacOS-X is that there can be two different implementations of the same
>> thing. For example, one can use the native gcc (from X-Code?), or the
>> gcc from MacPorts; and those two are different beasts. Same seems to go
>> for curses. And probably a bunch of other things.
>> 
>> I do not want to add too many workarounds / shortcuts / escape ways for
>> each possible combinations.
>> 
>> So, either we support MacOS-X without MacPorts at all, or we require
>> MacPorts to be installed, and take everything from there.
> 
> I would say dev tools distributed from the the mothership  /usr/bin/, /usr/sbin/, .... the toolchain's resources should be found under /usr/.
> If one wanted to have a macports version then the tool chain would be found in /opt/local/. Some make a synlink to /usr/local/
> If one wanted to roll their own they could put it where ever they like.
> 
> The decision is then does apple distribute a toolchain that can work unmodified if the answer is no. Then use macports /opt/local or /usr/local.
> 
> Thanks for everything,
> 
> Ben
> 
> 
>> 
>> Of course, it could be that I completely mis-understood your different
>> mails (yours and Bryan's), so I'd like that you all clarify the situation
>> beforehand.
>> 
>> Also, it could be interesting to push these changes upstream as well,
>> where it makes sense to.
>> 
>> But, back to the patch in #20f02d426e15. I won't revert it as is, because:
>> 
>>> diff --git a/kconfig/kconfig.mk b/kconfig/kconfig.mk
>>> --- a/kconfig/kconfig.mk
>>> +++ b/kconfig/kconfig.mk
>>> @@ -65,7 +65,7 @@
>>> 
>>> check_lxdialog = $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh
>>> 
>>> # Build flags
>>> 
>>> -CFLAGS = 
>>> +CFLAGS =
>>> 
>>> LDFLAGS =
>>> 
>> 
>> Spurious trailing space.
>> 
>>> # Compiler flags to use gettext
>>> diff --git a/kconfig/lxdialog/check-lxdialog.sh b/kconfig/lxdialog/check-lxdialog.sh
>>> --- a/kconfig/lxdialog/check-lxdialog.sh
>>> +++ b/kconfig/lxdialog/check-lxdialog.sh
>>> @@ -1,14 +1,24 @@
>>> 
>>> #!/bin/sh
>>> # Check ncurses compatibility
>>> 
>>> +OS=`uname`
>>> +
>>> +# Under MACOS make sure that the macports-installed version is used.
>>> +case "$OS" in
>>> +       Darwin) BASEDIR="/opt/local";;
>>> +       *)      BASEDIR="/usr";;
>>> +esac
>>> +
>>> +INCLUDEPATH="${BASEDIR}/include"
>>> +LIBPATH="${BASEDIR}/lib"
>>> +
>>> 
>>> # What library to link
>>> ldflags()
>>> {
>>>        for ext in so a dylib ; do
>>>                for lib in ncursesw ncurses curses ; do
>>> -                       $cc -print-file-name=lib${lib}.${ext} | grep -q /
>>> -                       if [ $? -eq 0 ]; then
>>> -                               echo "-l${lib}"
>>> +                       if [ -f "${LIBPATH}/lib${lib}.${ext}" ]; then
>>> +                               echo "-L${LIBPATH} -l${lib}"
>> 
>> Why don't you leave $cc tell you if it knows where to find that specific
>> library? Is it because the gcc on Darwin does not know about the option
>> -print-file-name ?
>> 
>> Or why not:
>>> -                       $cc -print-file-name=lib${lib}.${ext} | grep -q /
>>> +                       $cc -L${LIBPATH} -print-file-name=lib${lib}.${ext} | grep -q /
>>>                        if [ $? -eq 0 ]; then
>>> -                               echo "-l${lib}"
>>> +                               echo "-L${LIBPATH} -l${lib}"
>> 
>> In which case the -L${LIBPATH} should be passed from the caller to
>> check-lxdialog.sh, in kconfig/kconfig.mk:
>>  ifeq ($(shell uname -s),Darwin)
>>  LDFLAGS += -L/opt/local/lib
>>  endif # Darwin
>>  NCURSES_LDFLAGS = $(shell $(SHELL) $(check_lxdialog) -ldflags $(HOST_CC) $(LDFLAGS))
>> 
>>>                                exit
>>>                        fi
>>>                done
>>> @@ -19,14 +29,20 @@
>>> 
>>> # Where is ncurses.h?
>>> ccflags()
>>> {
>>> 
>>> -       if [ -f /usr/include/ncurses/ncurses.h ]; then
>>> -               echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
>>> -       elif [ -f /usr/include/ncurses/curses.h ]; then
>>> -               echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
>>> -       elif [ -f /usr/include/ncurses.h ]; then
>>> -               echo '-DCURSES_LOC="<ncurses.h>"'
>>> +       if [ -f "${INCLUDEPATH}/ncursesw/ncurses.h" ]; then
>>> +               echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncursesw/ncurses.h>\""
>>> +       elif [ -f "${INCLUDEPATH}/ncurses/ncurses.h" ]; then
>>> +               echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses/ncurses.h>\""
>>> +       elif [ -f "${INCLUDEPATH}/ncursesw/curses.h" ]; then
>>> +               echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncursesw/curses.h>\""
>>> +       elif [ -f "${INCLUDEPATH}/ncurses/curses.h" ]; then
>>> +               echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses/curses.h>\""
>>> +       elif [ -f "${INCLUDEPATH}/ncurses.h" ]; then
>>> +               echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<ncurses.h>\""
>>> +       elif [ -f "${INCLUDEPATH}/curses.h" ]; then
>>> +               echo "-I${INCLUDEPATH} \"-DCURSES_LOC=<curses.h>\""
>>>        else
>>> -               echo '-DCURSES_LOC="<curses.h>"'
>>> +               exit 1
>>>        fi
>>> }
>>> 
>> 
>> This hunk no longer applies, due to new tests being done.
>> Also, the test should be done the way we test for libs. We just should let
>> $cc try to include the stuff, rather than just check for its existence.
>> Maybe smthg along the lines of:
>> 
>> ccflags() {
>>  for i in ncurse/ncurses.h  \
>>           ncurses/curses.h  \
>>           ncursesw/curses.h \
>>           ncurses.h         \
>>  ; do
>>    $cc -xc - -o $tmp 2>/dev/null <<'EOF'
>> #include "${i}"
>> EOF
>>    if [ $? -eq 0 ]; then
>>      echo "-DCURSES_LOC=\"<${i}>\"
>>      exit
>>    fi
>>  done
>>  echo "** Unable to bnlabla..."
>>  exit 1
>> }
>> 
>> Then if we can get a sane check-lxdialog.sh, we can just not sync it from
>> upstream, and even probably push it upstream.
>> 
>>> @@ -36,7 +52,8 @@
>>> 
>>> # Check if we can link to ncurses
>>> check() {
>>> 
>>> -        $cc -xc - -o $tmp 2>/dev/null <<'EOF'
>>> +        IF=`echo $(ccflags) | sed -e 's/"//g'`
>>> +        $cc $IF $(ldflags) -xc - -o $tmp 2>/dev/null <<'EOF'
>>> #include CURSES_LOC
>>> main() {}
>>> EOF
>> 
>> This hunk is not needed, because $cc does contain the CFLAGS and the LDFLAGS.
>> See where it's being called:
>>  kconfig/kconfig.mk:84:
>>    $(SILENT)$(SHELL) $(check_lxdialog) -check $(HOST_CC) $(NCURSES_CFLAGS) $(NCURSES_LDFLAGS)
>> 
>> NCURSES_CFLAGS and _LDFLAGS are set thus:
>>  kconfig/kconfig.mk:78:
>>    NCURSES_CFLAGS = $(shell $(SHELL) $(check_lxdialog) -ccflags)
>>    NCURSES_LDFLAGS = $(shell $(SHELL) $(check_lxdialog) -ldflags $(HOST_CC))
>> 
>> and how cc is set:
>>  kconfig/lxdialog/check-lxdialog.sh:65:
>>    cc=""
>>    case "$1" in
>>            "-check")
>>                    shift
>>                    cc="$@"
>>                    check
>>                    ;;
>>    [--SNIP--]
>> 
>> So $cc will indeed contain all that is needed to compile + link against the
>> curses lib.
>> 
>> Regards,
>> Yann E. MORIN.
>> 
>> -- 
>> .-----------------.--------------------.------------------.--------------------.
>> |  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
>> | +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
>> | +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
>> | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
>> '------------------------------^-------^------------------^--------------------'
>> 
>> --
>> For unsubscribe information see http://sourceware.org/lists.html#faq
>> 
> 


--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list