Skip to content
Snippets Groups Projects
PROJECT_NAME-config.in.in 1.93 KiB
#!/bin/sh
#######################################################################################################################
#
# Shell script to output compiler and linker flags for use in plain Makefiles or at command line.
#
#######################################################################################################################

#######################################################################################################################
#
# IMPORTANT NOTE:
#
# DO NOT MODIFY THIS FILE inside a project. Instead update the project-template repository and pull the change from
# there. Make sure to keep the file generic, since it will be used by other projects, too.
#
# If you have modified this file inside a project despite this warning, make sure to cherry-pick all your changes
# into the project-template repository immediately.
#
#######################################################################################################################

print_usage(){
    echo -n "usage: $0 [--version] [--cppflags] [--ldflags]" 1>&2
    if [ -n "@@PROJECT_NAME@_MEXFLAGS@" ]; then
      echo " [--mexflags]" 1>&2
      echo -n " The mexflags are only for use with MATLABs mex." 1>&2
    fi
    echo ""
}

if  [ $# -eq 0 ]; then
    print_usage
    exit 1
fi

# The variables are all prepared in CMAKE and also provided by
# Find@PROJECT_NAME@.cmake, so dependent applications can create consistent
# Makefiles.
while [ $# -gt 0 ]; do
    case "$1" in
      --cppflags)
        OUTPUT="${OUTPUT} @@PROJECT_NAME@_CXX_FLAGS_MAKEFILE@"
        shift;;
      --ldflags)
        OUTPUT="${OUTPUT} @@PROJECT_NAME@_LINKER_FLAGS_MAKEFILE@"
        shift;;
      --version)
        OUTPUT="${OUTPUT} @@PROJECT_NAME@_SOVERSION@"
        shift;;
      --mexflags)
        OUTPUT="${OUTPUT} @@PROJECT_NAME@_MEXFLAGS@"
        shift;;
      *)
        echo "invalid option: $1" 1>&2
        print_usage
        exit 2;;
    esac
done

echo ${OUTPUT}