Changeset 1877 for trunk/coin.m4


Ignore:
Timestamp:
Nov 28, 2010 2:45:08 PM (10 years ago)
Author:
stefan
Message:

in fallback mode, setup CFLAGS/LIBS_INSTALLED variables from parsing xxx.pc files that can be used to create addlibs files and examples Makefiles; change parsing of .pc files so that variables can be used inside .pc files; add automake conditional that says whether C++ compile is cl/icl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin.m4

    r1843 r1877  
    587587AC_LANG_POP(C++)
    588588
    589 # It seems that we need to cleanup something here for the Windows
     589coin_cxx_is_cl=false
     590# It seems that we need to cleanup something here for the Windows
    590591case "$CXX" in
    591592  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
    592593    sed -e 's/^void exit (int);//' confdefs.h >> confdefs.hh
    593594    mv confdefs.hh confdefs.h
     595    coin_cxx_is_cl=true
    594596    ;;
    595597esac
     598
     599# add automake conditional so we can recognize cl compiler in makefile
     600AM_CONDITIONAL(COIN_CXX_IS_CL, [test $coin_cxx_is_cl = true])
    596601
    597602# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
     
    22972302      m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
    22982303      m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
     2304      m4_toupper(myvar)_LIBS_INSTALLED="-lm $m4_toupper(myvar)_LIBS_INSTALLED"
    22992305    ])
    23002306  ;;
     
    23292335                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
    23302336                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
     2337                    m4_toupper(myvar)_LIBS_INSTALLED="-lz $m4_toupper(myvar)_LIBS_INSTALLED"
    23312338                  ])
    23322339                 ],
     
    23682375                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
    23692376                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
     2377                    m4_toupper(myvar)_LIBS_INSTALLED="-lbz2 $m4_toupper(myvar)_LIBS_INSTALLED"
    23702378                  ])
    23712379                 ],
     
    24192427                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
    24202428                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
     2429                    m4_toupper(myvar)_LIBS_INSTALLED="-lreadline $LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
    24212430                  ])
    24222431                 ],
     
    27792788      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
    27802789      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
     2790      m4_toupper(myvar)_LIBS_INSTALLED="$$2LIB $m4_toupper(myvar)_LIBS_INSTALLED"
    27812791    ])
    27822792   
     
    40764086# checks also dependencies of $2.  Note that the PACKAGE_DATA variable is
    40774087# set to the content of datadir of the first .pc file that is parsed.
     4088# Finally, for each X in the third argument, also variables
     4089# X_CFLAGS_INSTALLED and X_LIBS_INSTALLED are setup. They contain the compiler
     4090# and linker flags for X when all projects have been installed. Their content
     4091# is assembled from the .pc files that correspond to installed projects. I.e.,
     4092# whenever a file proj-uninstalled.pc is parsed, then also a corresponding
     4093# proj.pc file is parsed for compiler and linker flags, if available in the
     4094# same directory.
    40784095#
    40794096# If .pc files for all projects in $2 and their dependencies is found,
     
    40984115m4_tolower(coin_has_$1)=notGiven
    40994116m4_toupper($1_LIBS)=
     4117m4_toupper($1_LIBS_INSTALLED)=
    41004118m4_toupper($1_CFLAGS)=
     4119m4_toupper($1_CFLAGS_INSTALLED)=
    41014120m4_toupper($1_DATA)=
    41024121
     
    41064125# we first expand the list of projects to process by adding all dependencies just behind the project which depends on it
    41074126# further, we collect the list of corresponding .pc files, but do this in reverse order, because we need this order afterwards
     4127# the latter we also do with .pc files corresponding to the installed projects, which will be needed to setup Makefiles for examples
    41084128# also, we setup the DATA variable
    41094129allproj=""
    41104130allpcfiles=""
     4131allpcifiles=""
    41114132while test "x$projtoprocess" != x ; do
    41124133
     
    41184139    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
    41194140      # the base directory configure should have setup coin_subdirs.txt in a way that it does not contain projects that should be skipped, so we do not need to test this here again
    4120       if test -r "$dir/$proj-uninstalled.pc" ; then
     4141      if test -r "$dir/${proj}-uninstalled.pc" ; then
    41214142        pcfile="$dir/$proj-uninstalled.pc"
     4143        if test -r "$dir/${proj}.pc" ; then
     4144          pcifile="$dir/${proj}.pc"
     4145        else
     4146          AC_MSG_WARN([Found $pcfile, but $dir/${proj}.pc is not available. This may break Makefile's of examples.])
     4147          pcifile=
     4148        fi
    41224149        break
    41234150      fi
     
    41454172      allproj=fail
    41464173      break 2
     4174    fi
     4175   
     4176    if test "x$pcifile" != x ; then
     4177      allpcifiles="$pcifile:$allpcifiles"
    41474178    fi
    41484179
     
    41754206    fi
    41764207
    4177     # reconstruct the directory where the .pc file is located
    4178     pcfiledir=[`echo $pcfile | sed -e 's/\/[^\/]*$//'`]
    4179 
    4180     # read CFLAGS from $pcfile and add CYGPATH_W cludge into include flags
    4181     projcflags=`sed -n -e 's/Cflags://p' "$pcfile"`
     4208    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
     4209    #   replace "Libs:" by "echo projlibs="
     4210    #   replace "Cflags:" by "echo projcflags="
     4211    #   remove every line starting with <some word>:
     4212    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/[a-zA-Z]:/d' $pcfile`]
     4213
     4214    # set projcflags and projlibs variables by running $pcfilemod
     4215    eval `sh -c "$pcfilemod"`
     4216
     4217    # add CYGPATH_W cludge into include flags and set CFLAGS variable
    41824218    projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
    41834219    m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
    41844220
    4185     # read LIBS from $pcfile and replace -L${libdir} by absolute path to build directory in linker flags
    4186     # we assume that the build directory is $pcfiledir/src if this directory exists, otherwise we assume that it is $pcfiledir
    4187     projlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' "$pcfile"`
    4188     if test "x$projlibs" != x ; then
    4189       if test -d "${pcfiledir}/src" ; then
    4190         projlibs="-L`cd "${pcfiledir}/src"; pwd` $projlibs"
    4191       else
    4192         projlibs="-L`cd "$pcfiledir"; pwd` $projlibs"
    4193       fi
    4194     else
    4195       projlibs=`sed -n -e 's/Libs://p' "$pcfile"`
    4196     fi
     4221    # set LIBS variable
    41974222    m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
    41984223
     
    42024227  done
    42034228  IFS="$save_IFS"
     4229
     4230
     4231  # now go through the list of .pc files for installed projects and assemble compiler and linker flags
     4232  # important is here again to obey the reverse order that has been setup before,
     4233  # since then libraries that are required by several others should be after these other libraries
     4234  pcfilesprocessed=""
     4235
     4236  save_IFS="$IFS"
     4237  IFS=":"
     4238  for pcfile in $allpcifiles ; do
     4239
     4240    # if $pcfile has been processed already, skip this round
     4241    if test "x$pcfilesprocessed" != x ; then
     4242      for pcfiledone in $pcfilesprocessed ; do
     4243        if test "$pcfiledone" = "$pcfile" ; then
     4244          continue 2
     4245        fi
     4246      done
     4247    fi
     4248
     4249    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
     4250    #   replace "Libs:" by "echo projlibs="
     4251    #   replace "Cflags:" by "echo projcflags="
     4252    #   remove every line starting with <some word>:
     4253    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/[a-zA-Z]:/d' $pcfile`]
     4254
     4255    # set projcflags and projlibs variables by running $pcfilemod
     4256    eval `sh -c "$pcfilemod"`
     4257
     4258    # add CYGPATH_W cludge into include flags and set CFLAGS variable
     4259    projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
     4260    m4_toupper($1_CFLAGS_INSTALLED)="$projcflags $m4_toupper($1_CFLAGS_INSTALLED)"
     4261
     4262    # set LIBS variable
     4263    m4_toupper($1_LIBS_INSTALLED)="$projlibs $m4_toupper($1_LIBS_INSTALLED)"
     4264
     4265    # remember that we have processed $pcfile
     4266    pcfilesprocessed="$pcfilesprocessed:$pcfile"
     4267
     4268  done
     4269  IFS="$save_IFS"
     4270
    42044271
    42054272  # finish up
     
    42124279    m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
    42134280    m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
     4281    m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1)_CFLAGS_INSTALLED $m4_toupper(myvar)_CFLAGS_INSTALLED"
     4282    m4_toupper(myvar)_LIBS_INSTALLED="$m4_toupper($1)_LIBS_INSTALLED $m4_toupper(myvar)_LIBS_INSTALLED"
     4283    AC_SUBST(m4_toupper(myvar)_CFLAGS_INSTALLED)
     4284    AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
    42144285  ])
    42154286
     
    42244295      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
    42254296    fi
     4297    if test -n "$m4_toupper($1)_CFLAGS_INSTALLED" ; then
     4298      AC_MSG_NOTICE([$1 CFLAGS_INSTALLED are $m4_toupper($1)_CFLAGS_INSTALLED])
     4299    fi
     4300    if test -n "$m4_toupper($1)_LIBS_INSTALLED" ; then
     4301      AC_MSG_NOTICE([$1 LIBS_INSTALLED   are $m4_toupper($1)_LIBS_INSTALLED])
     4302    fi
    42264303    coin_foreach_w([myvar], [$3], [
     4304      AC_MSG_NOTICE([])
    42274305      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
    42284306      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
     4307      AC_MSG_NOTICE([myvar CFLAGS_INSTALLED are $m4_toupper(myvar)_CFLAGS_INSTALLED])
     4308      AC_MSG_NOTICE([myvar LIBS_INSTALLED   are $m4_toupper(myvar)_LIBS_INSTALLED])
    42294309    ])
    42304310  fi
     
    43884468    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
    43894469    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
     4470    m4_toupper(myvar)_LIBS_INSTALLED="$BLAS_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
    43904471  ])
    43914472 
     
    43984479  AC_SUBST(m4_toupper(myvar)_PCLIBS)
    43994480  AC_SUBST(m4_toupper(myvar)_LIBS)
     4481  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
    44004482])
    44014483
     
    45524634    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
    45534635    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
     4636    m4_toupper(myvar)_LIBS_INSTALLED="$LAPACK_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
    45544637  ])
    45554638 
     
    45624645  AC_SUBST(m4_toupper(myvar)_PCLIBS)
    45634646  AC_SUBST(m4_toupper(myvar)_LIBS)
     4647  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
    45644648])
    45654649
Note: See TracChangeset for help on using the changeset viewer.