Author: brane
Date: Thu Jul  3 08:36:09 2025
New Revision: 1926932

URL: http://svn.apache.org/viewvc?rev=1926932&view=rev
Log:
in the SCons build, generate a relocatable pkgconfig file.

* SConstruct: When generating the .pc file, use paths relative to
${pcfiledir} and ${prefix} for the prefix and libdir, respectively.

Modified:
    serf/trunk/SConstruct

Modified: serf/trunk/SConstruct
URL: 
http://svn.apache.org/viewvc/serf/trunk/SConstruct?rev=1926932&r1=1926931&r2=1926932&view=diff
==============================================================================
--- serf/trunk/SConstruct (original)
+++ serf/trunk/SConstruct Thu Jul  3 08:36:09 2025
@@ -673,12 +673,18 @@ for d in env['LIBPATH']:
   env.Append(RPATH=[':'+d])
 
 # Set up the construction of serf-*.pc
+def unsubst(string):
+  '''There are things that SCons just shouldn't Subst.'''
+  return string.replace('$', '$$')
+
+pkgprefix = os.path.relpath(env.subst('$PREFIX'), 
env.subst('$LIBDIR/pkgconfig'))
+pkglibdir = os.path.relpath(env.subst('$LIBDIR'), env.subst('$PREFIX'))
 pkgconfig = env.Textfile('serf-%d.pc' % (MAJOR,),
                          env.File('build/serf.pc.in'),
                          SUBST_DICT = {
                            '@MAJOR@': str(MAJOR),
-                           '@PREFIX@': re.escape(str(env['PREFIX'])),
-                           '@LIBDIR@': re.escape(str(env['LIBDIR'])),
+                           '@PREFIX@': unsubst('${pcfiledir}/' + pkgprefix),
+                           '@LIBDIR@': unsubst('${prefix}/' + pkglibdir),
                            '@INCLUDE_SUBDIR@': 'serf-%d' % (MAJOR,),
                            '@VERSION@': '%d.%d.%d' % (MAJOR, MINOR, PATCH),
                            '@LIBS@': '%s %s %s %s -lz' % (apu_libs, apr_libs,


Reply via email to