jw-pkg/scripts/create-pkg-config.sh
Jan Lindemann 55fa0eaec5 $(TOPDIR), make, scripts: Search-and-replace ytools -> jw-build
This project was copied from ytools, with anything not related to providing
build-functionality left out. This commit replaces the occurences of ytools
with jw-build, and removes some but most certainly not all legacy ytools
references.

Signed-off-by: Jan Lindemann <jan@janware.com>
2017-04-07 12:15:48 +00:00

135 lines
2.1 KiB
Bash

#!/bin/bash
try_assign_sec()
{
local file="$1"
local sec="$2"
local val=`_jw-build_cat_section "$file" "$sec"`
[ -n "$val" ] && eval $3=\"$val\"
}
cleanup_requires()
{
# echo $@ | sed -e '
# s/\([a-zA-Z0-9.-]\+\) *\([a-zA-Z0-9.-]\+\) */\1, \2 /g
# #s/\([a-zA-Z-]\+\) *\([<>=]*\) *\([a-zA-Z0-9\.-]*\)/\1 \2 \3,/g
# #s/,,/,/g
# #s/,$//
# '
echo $@ | sed -e '
s/^ //g
s/\([ ]\|$\)\+/, /g
s/, $//
s/, $//
s/ *,* *\([<>=]\+\) *,* */ \1 /g
'
}
usage()
{
cat <<- EOT | sed 's/^ *|//'
|
| $myname [options]
|
| options are
|
| -h: display this help message and exit sucessfully
| -F filename read project description file
| -d "description" use description
|
EOT
goodbye $1
}
project_descr_file="$1"
myname=`basename $0`
set -e
eval set -- `getopt -- hF:d:n:s:p:v:c:l:V:r:R: "$@"`
while [ "$1" != -- ]; do
case $1 in
-h)
usage 0;;
-F)
project_descr_file="$2"
shift
;;
-d)
description="$2"
shift
;;
-n)
name="$2"
shift
;;
-s)
summary="$2"
shift
;;
-p)
prefix="$2"
shift
;;
-v)
version="$2"
shift
;;
-c)
cflags="$2"
shift
;;
-l)
libflags="$2"
shift
;;
-r)
requires_run="$2"
shift
;;
-R)
requires_build="$2"
shift
;;
-V)
variables="$variables$2\n"
shift
;;
*)
usage 1;;
esac
shift
done
shift
set +e
[ -r "$project_descr_file" ] && {
. jw-build-functions.sh
try_assign_sec $project_descr_file description descr
try_assign_sec $project_descr_file summary summary
try_assign_sec $project_descr_file requires_run requires_run
try_assign_sec $project_descr_file requires_build requires_build
}
[ "$variables" ] && echo -e "$variables"
cat <<-EOT
prefix=$prefix
exec_prefix=\${prefix}
includedir=\${prefix}/include
libdir=\${exec_prefix}/lib
Name: $name
Description: $summary
Version: $version
EOT
[ "$cflags" ] && echo "Cflags: $cflags"
[ "$libflags" ] && echo "Libs: $libflags"
[ "$requires_run" ] && echo "Requires: `cleanup_requires $requires_run`"
[ "$requires_build" ] && echo "Requires.private: `cleanup_requires $requires_build`"
# [ "$requires_devel" ] && ?? # not sure what to do with this
exit 0