Use config scripts, not pkgconfig

This commit is contained in:
Laurence Withers 2006-12-08 15:08:09 +00:00
parent 50e0fbc594
commit 6c6aba6d43
13 changed files with 239 additions and 72 deletions

View File

@ -2,7 +2,7 @@ build_target @NAME@
# make paths (this is for Gentoo in particular) # make paths (this is for Gentoo in particular)
build_dir_tree "${LIBDIR}" || return 1 build_dir_tree "${LIBDIR}" || return 1
build_dir_tree "${PKGCONFDIR}" || return 1 build_dir_tree "${BINDIR}" || return 1
build_dir_tree "${INCLUDEDIR}" || return 1 build_dir_tree "${INCLUDEDIR}" || return 1
# install library # install library
@ -20,16 +20,19 @@ install_symlink "${BASE}" "${MAJOR}" "${LIBDIR}"
echo "Installing header file '${@CNAME@_HEADER}' into ${INCLUDEDIR}" echo "Installing header file '${@CNAME@_HEADER}' into ${INCLUDEDIR}"
install_header ${@CNAME@_HEADER} ${INCLUDEDIR} 0644 || return 1 install_header ${@CNAME@_HEADER} ${INCLUDEDIR} 0644 || return 1
# install pkgconfig file # install config script
echo "Installing package config file into ${PKGCONFDIR}" echo "Installing config script into ${PKGCONFDIR}"
PKGCONFFILE=${PKGCONFDIR}/@NAME@.pc CONFFILE="${BINDIR}/@NAME@-config"
do_cmd rm -f ${PKGCONFFILE}
do_cmd_redir ${PKGCONFFILE} sed \ do_cmd rm -f "${CONFFILE}"
do_cmd_redir "${CONFFILE}" sed \
-e "s,@VERSION@,${VERSION}," \ -e "s,@VERSION@,${VERSION}," \
-e "s,@LIBDIR@,${FINALLIBDIR}," \ -e "s,@LIB_DIR@,${FINALLIBDIR}," \
-e "s,@INCLUDEDIR@,${FINALINCLUDEDIR}," \ -e "s,@INCLUDE_DIR@,${FINALINCLUDEDIR}," \
src/@NAME@/pkgconf.in -e "s,@DEP_CFLAGS@,${@CNAME@_DEP_CFLAGS}," \
do_cmd chmod 0644 ${PKGCONFFILE} -e "s,@DEP_LIBS@,${@CNAME@_DEP_LIBS}," \
src/@NAME@/config-script
do_cmd chmod 0644 "${CONFFILE}"
print_success "Done" print_success "Done"
# kate: @KATE_MODELINE@ # kate: @KATE_MODELINE@

View File

@ -3,6 +3,8 @@
# @CNAME@_BUILT # @CNAME@_BUILT
# @CNAME@_HEADER # @CNAME@_HEADER
# @CNAME@_BASE # @CNAME@_BASE
# @CNAME@_DEP_CFLAGS
# @CNAME@_DEP_LIBS
if [ -z ${@CNAME@_BUILT} ] if [ -z ${@CNAME@_BUILT} ]
then then
@ -10,7 +12,9 @@ then
source src/@NAME@/soversion source src/@NAME@/soversion
@CNAME@="obj/${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}" @CNAME@="obj/${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}"
SO_EXTRA="-lstdc++ -lc" # @TODO@ libs, cflags @CNAME@_DEP_CFLAGS="" # @TODO@ cflags
@CNAME@_DEP_LIBS="" # @TODO@ libs
SO_EXTRA="${@CNAME@_DEP_CFLAGS} ${@CNAME@_DEP_LIBS} -lstdc++ -lc"
echo "Building library ${@CNAME@}..." echo "Building library ${@CNAME@}..."

View File

@ -0,0 +1,97 @@
#!/bin/bash
# @P@/src/@NAME@/config-script
#
# @NAME@-config template. Variables are finalised at install time.
#
dep_cflags="@DEP_CFLAGS@"
dep_libs="@DEP_LIBS@"
include_dir="@INCLUDE_DIR@"
include_dir_set="no"
lib_dir="@LIB_DIR@"
lib_dir_set="no"
usage() {
cat <<EOF
Usage: libgcf2-config [OPTIONS] [LIBRARIES]
Options:
[--version]
[--libs]
[--libdir[=DIR]]
[--cflags]
[--includedir[=DIR]]
EOF
exit $1
}
[ $# -eq 0 ] && usage 1 1>&2
while [ $# -gt 0 ]
do
case "$1" in
-*=*)
optarg="$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//')"
;;
*)
optarg=""
;;
esac
case "$1" in
--libdir=*)
lib_dir="${optarg}"
lib_dir_set="yes"
;;
--libdir)
echo_lib_dir="yes"
;;
--includedir=*)
include_dir="${optarg}"
include_dir_set="yes"
;;
--includedir)
echo_include_dir="yes"
;;
--version)
echo "@VERSION@"
exit 0
;;
--cflags)
[ "${include_dir}" != "/usr/include" ] && includes="-I${include_dir}"
echo_cflags="yes"
;;
--libs)
echo_libs="yes"
;;
*)
usage 1 1>&2
;;
esac
shift
done
[ "${echo_prefix}" == "yes" ] && echo "${prefix}"
[ "${echo_exec_prefix}" == "yes" ] && echo "${exec_prefix}"
[ "${echo_cflags}" == "yes" ] && echo "${dep_cflags} ${includes}"
[ "${echo_libs}" == "yes" ] && echo "${dep_libs} -L${lib_dir} -l@NAMEMINUSL@"
# vim: @VIM_MODELINE@
# kate: @KATE_MODELINE@

View File

@ -11,10 +11,10 @@ shift
if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ]
then then
echo "Warning: your module name does not begin with 'lib'. You will" echo "Warning: your module name does not begin with 'lib'. You will"
echo "have to fix up your pkgconfig file manually, etc." echo "have to fix up your -config file manually, etc."
NAMEMINUSL="@TODO@" NAMEMINUSL="@TODO@"
else else
NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')" NAMEMINUSL="$(echo ${NAME} | sed -e 's,^lib,,')"
fi fi
do_parameter_subst NAMEMINUSL HEADER_NAME do_parameter_subst NAMEMINUSL HEADER_NAME

View File

@ -1,21 +0,0 @@
# @P@/src/lib/@NAME@/pkgconf.in
#
# Metadata file for pkg-config
# ( http://www.freedesktop.org/software/pkgconfig/ )
#
# (c)2006, @AUTHOR@, <@EMAIL@>.
# Released under the GNU GPLv2. See file COPYING or
# http://www.gnu.org/copyleft/gpl.html for details.
#
# Name, description
Name: @TODO@
Description: @TODO@
Version: @VERSION@
# Requirements
Requires:
# Compilation information
Libs: -L@LIBDIR@ @NAMEMINUSL@
Cflags: -I@INCLUDEDIR@

View File

@ -1,4 +1,4 @@
/* @P@/src/clib/BottomHeader.h /* @P@/src/@NAME@/BottomHeader.h
* *
* (c)2006, @AUTHOR@, <@EMAIL@>. * (c)2006, @AUTHOR@, <@EMAIL@>.
* Released under the GNU GPLv2. See file COPYING or * Released under the GNU GPLv2. See file COPYING or

View File

@ -1,4 +1,4 @@
/* @P@/src/@NAME@@NAME@/TopSource.c /* @P@/src/@NAME@/TopSource.c
* *
* (c)2006, @AUTHOR@, <@EMAIL@>. * (c)2006, @AUTHOR@, <@EMAIL@>.
* Released under the GNU GPLv2. See file COPYING or * Released under the GNU GPLv2. See file COPYING or

View File

@ -2,7 +2,7 @@ build_target @NAME@
# make paths (this is for Gentoo in particular) # make paths (this is for Gentoo in particular)
build_dir_tree "${LIBDIR}" || return 1 build_dir_tree "${LIBDIR}" || return 1
build_dir_tree "${PKGCONFDIR}" || return 1 build_dir_tree "${BINDIR}" || return 1
build_dir_tree "${INCLUDEDIR}" || return 1 build_dir_tree "${INCLUDEDIR}" || return 1
# install library # install library
@ -20,16 +20,20 @@ install_symlink "${BASE}" "${MAJOR}" "${LIBDIR}"
echo "Installing header file '${@CNAME@_HEADER}' into ${INCLUDEDIR}" echo "Installing header file '${@CNAME@_HEADER}' into ${INCLUDEDIR}"
install_header ${@CNAME@_HEADER} ${INCLUDEDIR} 0644 || return 1 install_header ${@CNAME@_HEADER} ${INCLUDEDIR} 0644 || return 1
# install pkgconfig file # install config script
echo "Installing package config file into ${PKGCONFDIR}" echo "Installing config script into ${BINDIR}"
PKGCONFFILE=${PKGCONFDIR}/@NAME@.pc CONFFILE="${BINDIR}/@NAME@-config"
do_cmd rm -f ${PKGCONFFILE}
do_cmd_redir ${PKGCONFFILE} sed \ do_cmd rm -f "${CONFFILE}"
do_cmd_redir "${CONFFILE}" sed \
-e "s,@VERSION@,${VERSION}," \ -e "s,@VERSION@,${VERSION}," \
-e "s,@LIBDIR@,${FINALLIBDIR}," \ -e "s,@DEP_CFLAGS@,${@CNAME@_DEP_CFLAGS}," \
-e "s,@INCLUDEDIR@,${FINALINCLUDEDIR}," \ -e "s,@DEP_LIBS@,${@CNAME@_DEP_LIBS}," \
src/@NAME@/pkgconf.in -e "s,@LIB_DIR@,${FINALLIBDIR}," \
do_cmd chmod 0644 ${PKGCONFFILE} -e "s,@INCLUDE_DIR@,${FINALINCLUDEDIR}," \
src/@NAME@/config-script
do_cmd chmod 0755 "${CONFFILE}"
print_success "Done" print_success "Done"
# kate: @KATE_MODELINE@ # kate: @KATE_MODELINE@

View File

@ -3,6 +3,8 @@
# @CNAME@_BUILT # @CNAME@_BUILT
# @CNAME@_HEADER # @CNAME@_HEADER
# @CNAME@_BASE # @CNAME@_BASE
# @CNAME@_DEP_CFLAGS
# @CNAME@_DEP_LIBS
if [ -z ${@CNAME@_BUILT} ] if [ -z ${@CNAME@_BUILT} ]
then then
@ -10,7 +12,9 @@ then
source src/@NAME@/soversion source src/@NAME@/soversion
@CNAME@="obj/${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}" @CNAME@="obj/${@CNAME@_BASE}.so.${SOMAJOR}.${SOMINOR}.${SOMICRO}"
SO_EXTRA="-lc" # @TODO@ libs, cflags @CNAME@_DEP_CFLAGS="" # @TODO@ cflags
@CNAME@_DEP_LIBS="" # @TODO@ libs
SO_EXTRA="${@CNAME@_DEP_CFLAGS} ${@CNAME@_DEP_LIBS} -lc"
echo "Building library ${@CNAME@}..." echo "Building library ${@CNAME@}..."

View File

@ -0,0 +1,97 @@
#!/bin/bash
# @P@/src/@NAME@/config-script
#
# @NAME@-config template. Variables are finalised at install time.
#
dep_cflags="@DEP_CFLAGS@"
dep_libs="@DEP_LIBS@"
include_dir="@INCLUDE_DIR@"
include_dir_set="no"
lib_dir="@LIB_DIR@"
lib_dir_set="no"
usage() {
cat <<EOF
Usage: libgcf2-config [OPTIONS] [LIBRARIES]
Options:
[--version]
[--libs]
[--libdir[=DIR]]
[--cflags]
[--includedir[=DIR]]
EOF
exit $1
}
[ $# -eq 0 ] && usage 1 1>&2
while [ $# -gt 0 ]
do
case "$1" in
-*=*)
optarg="$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//')"
;;
*)
optarg=""
;;
esac
case "$1" in
--libdir=*)
lib_dir="${optarg}"
lib_dir_set="yes"
;;
--libdir)
echo_lib_dir="yes"
;;
--includedir=*)
include_dir="${optarg}"
include_dir_set="yes"
;;
--includedir)
echo_include_dir="yes"
;;
--version)
echo "@VERSION@"
exit 0
;;
--cflags)
[ "${include_dir}" != "/usr/include" ] && includes="-I${include_dir}"
echo_cflags="yes"
;;
--libs)
echo_libs="yes"
;;
*)
usage 1 1>&2
;;
esac
shift
done
[ "${echo_prefix}" == "yes" ] && echo "${prefix}"
[ "${echo_exec_prefix}" == "yes" ] && echo "${exec_prefix}"
[ "${echo_cflags}" == "yes" ] && echo "${dep_cflags} ${includes}"
[ "${echo_libs}" == "yes" ] && echo "${dep_libs} -L${lib_dir} -l@NAMEMINUSL@"
# vim: @VIM_MODELINE@
# kate: @KATE_MODELINE@

View File

@ -11,10 +11,10 @@ shift
if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ] if [ "$(echo ${NAME} | cut -b1-3)" != "lib" ]
then then
echo "Warning: your module name does not begin with 'lib'. You will" echo "Warning: your module name does not begin with 'lib'. You will"
echo "have to fix up your pkgconfig file manually, etc." echo "have to fix up your -config script manually, etc."
NAMEMINUSL="@TODO@" NAMEMINUSL="@TODO@"
else else
NAMEMINUSL="-l$(echo ${NAME} | sed -e 's,^lib,,')" NAMEMINUSL="$(echo ${NAME} | sed -e 's,^lib,,')"
fi fi
do_parameter_subst NAMEMINUSL HEADER_NAME do_parameter_subst NAMEMINUSL HEADER_NAME

View File

@ -1,21 +0,0 @@
# @P@/src/lib/clib/pkgconf.in
#
# Metadata file for pkg-config
# ( http://www.freedesktop.org/software/pkgconfig/ )
#
# (c)2006, @AUTHOR@, <@EMAIL@>.
# Released under the GNU GPLv2. See file COPYING or
# http://www.gnu.org/copyleft/gpl.html for details.
#
# Name, description
Name: @TODO@
Description: @TODO@
Version: @VERSION@
# Requirements
Requires:
# Compilation information
Libs: -L@LIBDIR@ @NAMEMINUSL@
Cflags: -I@INCLUDEDIR@

View File

@ -30,7 +30,7 @@ then
echo " available modules:" echo " available modules:"
for i in scripts/build.* for i in scripts/build.*
do do
echo $i | sed "s,scripts/build\.\([^.]*\)\.\(.*\), lang: \1 type: \2," echo $i | sed "s,scripts/build\.\([^.]*\)\.\(.*\), module: \1 lang: \2,"
done done
exit 1 exit 1
fi fi