summaryrefslogtreecommitdiffstats
path: root/source/l/glibc/glibc.SlackBuild
blob: 38d11fc276d6d2f0ee6f82867718d29ae6940a51 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
#!/bin/bash

# Copyright 2006, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024  Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Extended to build 32-bit compatibility libraries on x86_64,
# by Fred Emmott <mail@fredemmott.co.uk>. No copyright claim.
# Simplified to produce combined packages (no separate compat-32),
# by Eric Hameleers <alien@slackware.com>
# Merged into main glibc.SlackBuild and adjusted to be capable of
# building as pure 64-bit, pure 32-bit, or multilib
# by Patrick Volkerding <volkerdi@slackware.com>

cd $(dirname $0) ; CWD=$(pwd)

PKGNAM=glibc
VERSION=${VERSION:-$(echo glibc-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
CHECKOUT=${CHECKOUT:-""}
BUILD=${BUILD:-5}

# An optional tag for after the version number in the package's filename:
#VERTAG=_multilib

# An optional tag for after the build number in the package's filename:
#TAG=alien

# I was considering disabling NSCD, but MoZes talked me out of it.  :)
#DISABLE_NSCD=" --disable-nscd "

# $ARCH may be preset, otherwise i686 (pentium4) is the Slackware default.
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i686 ;;
    arm*) export ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
       *) export ARCH=$( uname -m ) ;;
  esac
fi

# Try to figure out if we want multilib (or set MULTILIB= manually):
if [ "$ARCH" = "x86_64" -a -f /usr/lib/libgcc_s.so ]; then
  MULTILIB=${MULTILIB:-"--enable-multilib"}
else
  MULTILIB=${MULTILIB:-"--disable-multilib"}
fi

# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "glibc-${VERSION}${VERTAG}-$ARCH-${BUILD}${TAG}.txz"
  echo "glibc-i18n-${VERSION}${VERTAG}-$ARCH-${BUILD}${TAG}.txz"
  echo "glibc-profile-${VERSION}${VERTAG}-$ARCH-${BUILD}${TAG}.txz"
  echo "aaa_glibc-solibs-${VERSION}${VERTAG}-$ARCH-${BUILD}${TAG}.txz"
  exit 0
fi

# How many jobs to run in parallel:
NUMJOBS=${NUMJOBS:-" -j $(expr $(nproc) + 1) "}

# Work around -Werror failure with gcc-10.2.0.
# NOTE: Until the next glibc release takes care of this issue, this will
# likely need to be updated with every new gcc release's version. Yes, we
# could pass --disable-werror by default, but I'd rather not just shove a
# stick in it like that.
if [ "$(gcc -dumpversion)" = "10.2.0" ]; then
  if [ "$VERSION" = "2.30" ]; then
    WERROR="--disable-werror"
  fi
fi

# Define the build flags for both 64-bit and 32-bit x86 before using them
# below. We'll possibly need them both later on...
# -mstackrealign is needed for compatibilty with legacy binaries that
# keep 4-byte stack alignment.
# -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer are required by
# both nouveau and the nvidia driver to prevent crashes and hangs.
# We could also possibly add these:
# -fno-tree-vectorize -fno-tree-loop-vectorize -fno-tree-slp-vectorize
# But since we're already requiring at least a pentium4, I'm not sure
# what the benefit would be, so we won't do this yet.
X86FLAGS32="-O3 -march=pentium4 -mtune=generic -mstackrealign -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
X86FLAGS64="-O3 -march=x86-64 -mtune=generic -fPIC"

# I'll break this out as an option for fun  :-)
case $ARCH  in
  i686)
    OPTIMIZ="${X86FLAGS32}"
    LIBDIRSUFFIX=""
    TARGET=${TARGET:-i686}
    ;;
  x86_64)
    OPTIMIZ="${X86FLAGS64}"
    LIBDIRSUFFIX="64"
    TARGET=${TARGET:-x86_64}
    TARGET32=${TARGET32:-i686}
    ;;
  *)
    OPTIMIZ="-O3"
    LIBDIRSUFFIX=""
    TARGET=${TARGET:-"$ARCH"}
    ;;
esac

# Hand off the $ARCH variable to $SLACKWARE_ARCH to avoid confusing glibc:
SLACKWARE_ARCH=$ARCH
unset ARCH

CVSVER=${VERSION}${CHECKOUT}

# NOTE!!!  glibc needs to be built against the sanitized kernel headers,
# which will be installed under /usr/include by the kernel-headers package.
# Be sure the correct version of the headers package is installed BEFORE
# building glibc!

TMP=${TMP:-/tmp}
mkdir -p $TMP

# This function fixes a doinst.sh file for x86_64.
# With thanks to Fred Emmott.
fix_doinst() {
  if [ "$LIBDIRSUFFIX" = "" ]; then
    return;
  fi;
  if [ "$MULTILIB" = "--enable-multilib" ]; then
    # Save a copy of this to append the 32-bit links later.
    cp -a install/doinst.sh install/doinst32.sh
  fi
  # Fix "( cd usr/lib ;" occurrences
  sed -i "s#lib ;#lib${LIBDIRSUFFIX} ;#" install/doinst.sh
  # Fix "lib/" occurrences
  sed -i "s#lib/#lib${LIBDIRSUFFIX}/#g" install/doinst.sh
  # Fix "( cd lib" occurrences
  sed -i "s#( cd lib\$#( cd lib${LIBDIRSUFFIX}#" install/doinst.sh
  if [ "$SLACKWARE_ARCH" = "x86_64" ]; then
    sed -i 's#ld-linux.so.2#ld-linux-x86-64.so.2#' install/doinst.sh
  fi
  if [ "$MULTILIB" = "--enable-multilib" ]; then
    echo "# Add 32-bit library links for multilib:"  >> install/doinst.sh
    cat install/doinst32.sh | grep -e '^( cd lib ' -e '^( cd usr/lib ' >> install/doinst.sh
    rm -f install/doinst32.sh
  fi
}

# This is a patch function to put all glibc patches in the build script
# up near the top.
apply_patches() {
  # Use old-style locale directories rather than a single (and strangely
  # formatted) /usr/lib/locale/locale-archive file:
  zcat $CWD/glibc.locale.no-archive.diff.gz | patch -p1 --verbose || exit 1
  # Support ru_RU.CP1251 locale:
  zcat $CWD/glibc.ru_RU.CP1251.diff.gz | patch -p1 --verbose || exit 1
  # Don't use AM/PM format for date(1). That's just plain crazy.
  zcat $CWD/glibc-2.32.en_US.no.am.pm.date.format.diff.gz | patch -p1 --verbose || exit 1
  # Other regression fixes from git:
  for git_patch in $CWD/patches/*.patch.gz ; do
    zcat $git_patch | patch -p1 --verbose || exit 1
  done
}

# This is going to be the initial $DESTDIR:
export PKG=$TMP/package-glibc-incoming-tree
PGLIBC=$TMP/package-glibc
PSOLIBS=$TMP/package-aaa_glibc-solibs
PI18N=$TMP/package-glibc-i18n
PPROFILE=$TMP/package-glibc-profile
PDEBUG=$TMP/package-glibc-debug

# Empty these locations first:
for dir in $PKG $PGLIBC $PSOLIBS $PZONE $PI18N $PPROFILE $PDEBUG ; do
  if [ -d $dir ]; then
    rm -rf $dir
  fi
  mkdir -p $dir
done
if [ -d $TMP/glibc-$VERSION ]; then
  rm -rf $TMP/glibc-$VERSION
fi

# Create an incoming directory structure for glibc to be built into:
mkdir -p $PKG/lib${LIBDIRSUFFIX}
mkdir -p $PKG/sbin
mkdir -p $PKG/usr/bin
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
mkdir -p $PKG/usr/sbin
mkdir -p $PKG/usr/include
mkdir -p $PKG/usr/doc
mkdir -p $PKG/usr/man
mkdir -p $PKG/usr/share
mkdir -p $PKG/var/db/nscd
mkdir -p $PKG/var/run/nscd
if [ "$MULTILIB" = "--enable-multilib" ]; then
  mkdir -p $PKG/lib
  mkdir -p $PKG/usr/lib
fi

# Begin extract/compile:
cd $TMP
rm -rf glibc-$CVSVER
echo "Extracting $CWD/glibc-$CVSVER.tar.?z..."
tar xf $CWD/glibc-$CVSVER.tar.xz \
  || tar xf $CWD/glibc-$CVSVER.tar.lz \
  || tar xf $CWD/glibc-$CVSVER.tar.gz
cd glibc-$CVSVER

# Apply patches; exit if any fail.
apply_patches
if [ ! $? = 0 ]; then
  exit 1
fi

# Clean up leftover CVS directories:
find . -type d -name CVS -exec rm -r {} \+ 2> /dev/null

chown -R root:root .
find . \
  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  -exec chmod 755 {} \+ -o \
  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  -exec chmod 644 {} \+

# Main function to build glibc:
build_glibc() {
  CFLAGS="-g $OPTIMIZ" \
  CXXFLAGS="-g $OPTIMIZ" \
  ../configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --enable-kernel=4.4 \
    --with-headers=/usr/include \
    --enable-add-ons \
    --enable-multi-arch \
    --enable-profile \
    $DISABLE_NSCD \
    $WERROR \
    --infodir=/usr/info \
    --mandir=/usr/man \
    --with-tls \
    --with-__thread \
    --without-cvs \
    $TARGET-slackware-linux || exit 1
  make $NUMJOBS || exit 1
  make $NUMJOBS install install_root=$PKG || exit 1
  # Don't use this, as it makes the i18n package WAY bigger:
  #make localedata/install-locale-files DESTDIR=$PKG || exit 1
  # This is ugly run in parallel, and seems to hang at the end. But it actually
  # completes much faster. :)
  make $NUMJOBS localedata/install-locales install_root=$PKG DESTDIR=$PKG || exit 1
}

# If this is a multilib build, then build the 32-bit binaries first so that the
# 64-bit stuff will overwrite it later where appropriate:
if [ "$MULTILIB" = "--enable-multilib" ]; then
  echo "BUILDING DAS 32-BiT NPTL GLIBC"
  (
    MYRET=0
    mkdir build-glibc-compat32-$VERSION
    cd build-glibc-compat32-$VERSION || exit 1
    export BUILD_ARCH=$TARGET
    export TARGET=$TARGET32
    export LIBDIRSUFFIX=
    export CC="gcc -m32"
    export CXX="g++ -m32"
    export OPTIMIZ="${X86FLAGS32}"
    build_glibc || exit 1
    MYRET=$(( $MYRET + $? ))
    # Build and install libxcrypt:
    pushd $CWD
    ARCH=$TARGET LIBDIRSUFFIX=$LIBDIRSUFFIX SLKCFLAGS=$OPTIMIZ ./libxcrypt.build || exit 1
    MYRET=$(( $MYRET + $? ))
    popd
    exit $MYRET
  ) || exit $?
fi

# Now do the main build:
mkdir build-glibc-$VERSION
cd build-glibc-$VERSION
echo "BUILDING DAS NPTL GLIBC"
build_glibc || exit 1

# Build and install libxcrypt:
pushd $CWD
ARCH=$SLACKWARE_ARCH LIBDIRSUFFIX=$LIBDIRSUFFIX SLKCFLAGS=$OPTIMIZ ./libxcrypt.build || exit 1
popd

# We've always had an sln symlink in /bin, so let's make sure it
# remains there so as not to break any scripts that might need it:
mkdir -p $PKG/bin
( cd $PKG/bin ; ln -sf /sbin/sln sln )

# The prevailing standard seems to be putting unstripped libraries in
# /usr/lib/debug/ and stripping the debugging symbols from all the other
# libraries.
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/debug
cp -a $PKG/lib${LIBDIRSUFFIX}/l*.so* $PKG/usr/lib${LIBDIRSUFFIX}/debug
cp -a $PKG/usr/lib${LIBDIRSUFFIX}/*.a $PKG/usr/lib${LIBDIRSUFFIX}/debug
# Don't need debug+profile:
( cd $PKG/usr/lib${LIBDIRSUFFIX}/debug ; rm -f *_p.* )
if [ "$MULTILIB" = "--enable-multilib" ]; then
  mkdir -p $PKG/usr/lib/debug
  cp -a $PKG/lib/l*.so* $PKG/usr/lib/debug
  cp -a $PKG/usr/lib/*.a $PKG/usr/lib/debug
  # Don't need debug+profile:
  ( cd $PKG/usr/lib/debug ; rm -f *_p.* )
fi
# NOTE:  Is there really a reason for the glibc-debug package?
# If you're debugging glibc, you can also compile it, right?
## COMMENTED OUT:  There's no reason for profile libs to include -g information.
## Put back unstripped profiling libraries:
#mv $PKG/usr/lib${LIBDIRSUFFIX}/debug/*_p.a $PKG/usr/lib${LIBDIRSUFFIX}
# It might be best to put the unstripped and profiling libraries in glibc-debug and glibc-profile.

# I don't think "strip -g" causes the pthread problems.  It's --strip-unneeded that does.
strip -g $PKG/usr/lib${LIBDIRSUFFIX}/lib*.a
if [ "$MULTILIB" = "--enable-multilib" ]; then
  strip -g $PKG/usr/lib/lib*.a
fi

# Remove the rquota.x and rquota.h include files, as they are provided by
# the quota package:
rm -f $PKG/usr/include/rpcsvc/rquota.{h,x}

# Back to the sources dir to add some files/docs:
cd $TMP/glibc-$CVSVER

# We'll automatically install the config file for the Name Server Cache Daemon.
# Perhaps this should also have some commented-out startup code in rc.inet2...
mkdir -p $PKG/etc
cat nscd/nscd.conf > $PKG/etc/nscd.conf.new

# Install docs:
( mkdir -p $PKG/usr/doc/glibc-$VERSION
  cp -a \
    CONTRIBUTED-BY* COPYING* INSTALL* LICENSES* MAINTAINERS* NEWS* README* SECURITY* SHARED-FILES* \
    $PKG/usr/doc/glibc-$VERSION
)

# Trim the NEWS file to omit ancient history:
if [ -r NEWS ]; then
  DOCSDIR=$(echo $PKG/usr/doc/glibc-$VERSION)
  cat NEWS | head -n 1000 > $DOCSDIR/NEWS
  touch -r NEWS $DOCSDIR/NEWS
fi

# Strip most binaries:
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip -g 2> /dev/null
)

# Compress manual pages:
find $PKG/usr/man -type f -exec gzip -9 {} \+
for i in $( find $PKG/usr/man -type l ) ; do
  ln -s $( readlink $i ).gz $i.gz
  rm $i
done

# Compress info files, if any:
if [ -d $PKG/usr/info ]; then
  ( cd $PKG/usr/info
    rm -f dir
    gzip -9 *
  )
fi

# This is junk:
rm $PKG/etc/ld.so.cache

# Remove any stray .orig files:
( cd $PKG
  find . -name "*.orig" -exec rm {} \+
)

##################################
# OK, time to make some packages #
##################################

# glibc-profile:
cd $PPROFILE
mkdir -p usr/lib${LIBDIRSUFFIX}
# Might as well just grab these with 'mv' to simplify things later:
mv $PKG/usr/lib${LIBDIRSUFFIX}/lib*_p.a usr/lib${LIBDIRSUFFIX}
# Profile libs should be stripped. Use the debug libs to debug...
( cd usr/lib${LIBDIRSUFFIX} ; strip -g *.a )
if [ "$MULTILIB" = "--enable-multilib" ]; then
  # Might as well just grab these with 'mv' to simplify things later:
  mv $PKG/usr/lib/lib*_p.a usr/lib
  # Profile libs should be stripped. Use the debug libs to debug...
  ( cd usr/lib ; strip -g *.a )
fi
mkdir install
cp -a $CWD/slack-desc.glibc-profile install/slack-desc
makepkg -l y -c n $TMP/glibc-profile-${VERSION}${VERTAG}-$SLACKWARE_ARCH-${BUILD}${TAG}.txz

# THIS IS NO LONGER PACKAGED (or is it?  might be better to let it be made, and then ship it or not...)
# glibc-debug:
cd $PDEBUG
mkdir -p usr/lib${LIBDIRSUFFIX}
# Might as well just grab these with 'mv' to simplify things later:
mv $PKG/usr/lib${LIBDIRSUFFIX}/debug usr/lib${LIBDIRSUFFIX}
mkdir install
cp -a $CWD/slack-desc.glibc-debug install/slack-desc
if [ "$MULTILIB" = "--enable-multilib" ]; then
  mkdir -p usr/lib
  # Might as well just grab these with 'mv' to simplify things later:
  mv $PKG/usr/lib/debug usr/lib
fi
## Don't package this:
#makepkg -l y -c n $TMP/glibc-debug-${VERSION}${VERTAG}-$SLACKWARE_ARCH-${BUILD}${TAG}.txz
## INSTEAD, NUKE THESE LIBS
#rm -rf $PKG/usr/lib${LIBDIRSUFFIX}/debug

# glibc-i18n:
cd $PI18N
mkdir -p usr/share/{i18n,locale}
mv $PKG/usr/share/i18n/* usr/share/i18n
mv $PKG/usr/share/locale/* usr/share/locale
mkdir -p usr/lib${LIBDIRSUFFIX}/locale
mv $PKG/usr/lib${LIBDIRSUFFIX}/locale/* usr/lib${LIBDIRSUFFIX}/locale
# Leave copies of the C, POSIX, and en_US locales in the main glibc package:
cp -a usr/lib${LIBDIRSUFFIX}/locale/{C,en_US}* $PKG/usr/lib${LIBDIRSUFFIX}/locale
mkdir -p $PKG/usr/share/i18n/locales
cp -a usr/share/i18n/locales/{C,POSIX,en_US} $PKG/usr/share/i18n/locales
if [ "$MULTILIB" = "--enable-multilib" ]; then
  mkdir -p usr/lib/locale
  mv $PKG/usr/lib/locale/* usr/lib/locale
  # Leave copies of the C, POSIX, and en_US locales in the main glibc package:
  cp -a usr/lib/locale/{C,en_US}* $PKG/usr/lib/locale
fi
mkdir install
cp -a $CWD/slack-desc.glibc-i18n install/slack-desc
makepkg -l y -c n $TMP/glibc-i18n-${VERSION}${VERTAG}-$SLACKWARE_ARCH-${BUILD}${TAG}.txz

# aaa_glibc-solibs:
cd $PSOLIBS
mkdir -p etc/profile.d
cp -a $CWD/profile.d/* etc/profile.d
chown -R root:root etc
chmod 755 etc/profile.d/*
mkdir -p lib${LIBDIRSUFFIX}
cp -a $PKG/lib${LIBDIRSUFFIX}/* lib${LIBDIRSUFFIX}
( cd lib${LIBDIRSUFFIX}
  mkdir incoming
  mv *so* incoming
  mv incoming/libmemusage.so .
  # Beginning with glibc-2.34, shared objects are using their ABI sonames
  # directly, which is frankly, a terrible idea. It might help other package
  # managers, but doesn't do us any favors where we already had a system for
  # dealing with upgrades (and downgrades!). We'll change these libraries to
  # use the versioned naming system of glibc-2.33 and earlier so that we don't
  # have to handle these files differently and so that it's easy to see what
  # version of glibc is in use at a glance.
  cd incoming
  # First do the new libxcrypt links (a little bit differently):
  for cryptlib in libcrypt.so.* ; do
    CRYPTSO=$(echo $cryptlib | cut -f 3 -d .)
    mv $cryptlib libcrypt${CRYPTSO}-${VERSION}.so
  done
  for library in *.so.* ; do
    mv $library $(echo $library | cut -f 1 -d .)-${VERSION}.so
  done
  # This one is a special case. We don't want an $ARCH embedded in the
  # filename. It prevents using the same install scripts on all $ARCH
  # and does no good since we'll never have multiple $ARCH libraries
  # installed in the same directory anyway. So give it the previous name
  # format:
  mv ld-linux*-${VERSION}.so ld-${VERSION}.so
)
if [ "$MULTILIB" = "--enable-multilib" ]; then
  # We don't need to use an incoming directory here.
  mkdir -p lib
  cp -a $PKG/lib/* lib
  ( cd lib
    for cryptlib in libcrypt.so.* ; do
      CRYPTSO=$(echo $cryptlib | cut -f 3 -d .)
      mv $cryptlib libcrypt${CRYPTSO}-${VERSION}.so
    done
    for library in *.so.* ; do
      mv $library $(echo $library | cut -f 1 -d .)-${VERSION}.so
    done
  )
fi
mkdir -p usr
cp -a $PKG/usr/bin usr
mv usr/bin/ldd .
rm usr/bin/*
mv ldd usr/bin
mkdir -p usr/lib${LIBDIRSUFFIX}
# The gconv directory has a lot of stuff, but including it here will save some problems.
# Seems standard elsewhere.
cp -a $PKG/usr/lib${LIBDIRSUFFIX}/gconv usr/lib${LIBDIRSUFFIX}
if [ "$MULTILIB" = "--enable-multilib" ]; then
  mkdir -p usr/lib
  cp -a $PKG/usr/lib/gconv usr/lib
fi
mkdir -p usr/libexec
cp -a $PKG/usr/libexec/pt_chown usr/libexec
# Same usr.bin deal:
cp -a $PKG/sbin .
mv sbin/ldconfig .
rm sbin/*
mv ldconfig sbin
mkdir install
cp -a $CWD/slack-desc.aaa_glibc-solibs install/slack-desc
cp -a $CWD/doinst.sh-aaa_glibc-solibs install/doinst.sh
# Fix specific versioning for the symlink creation script. This part of the
# script would only be used in the case where there is no ldconfig on the
# running system that's used to install the package. That should never be the
# case, but we'll leave the code in place anyway just in case.
sed -i "s/@@VERSION@@/$VERSION/g" install/doinst.sh
# Call the function to fix doinst.sh where $LIBDIRSUFFIX is needed:
fix_doinst
# Only scrub the links in /lib{,64} that will be created by ldconfig:
find lib${LIBDIRSUFFIX} -type l -exec rm {} \+
if [ "$MULTILIB" = "--enable-multilib" ]; then
  find lib -type l -exec rm {} \+
fi
# Build the package:
makepkg -l y -c n $TMP/aaa_glibc-solibs-${VERSION}${VERTAG}-$SLACKWARE_ARCH-${BUILD}${TAG}.txz

# And finally, the complete "all-in-one" glibc package is created
# from whatever was leftover:
cd $PGLIBC
mv $PKG/* .
mkdir -p etc/profile.d
cp -a $CWD/profile.d/* etc/profile.d
chown -R root:root etc
chmod 755 etc/profile.d/*
# Only scrub the links in /lib{,64} that will be created by ldconfig:
find lib${LIBDIRSUFFIX} -type l -exec rm {} \+
if [ "$MULTILIB" = "--enable-multilib" ]; then
  find lib -type l -exec rm {} \+
fi
mkdir install
cp -a $CWD/slack-desc.glibc install/slack-desc
cp -a $CWD/doinst.sh-glibc install/doinst.sh
# Fix specific versioning for the symlink creation script. This part of the
# script would only be used in the case where there is no ldconfig on the
# running system that's used to install the package. That should never be the
# case, but we'll leave the code in place anyway just in case.
sed -i "s/@@VERSION@@/$VERSION/g" install/doinst.sh
# Call the function to fix doinst.sh where $LIBDIRSUFFIX is needed:
fix_doinst
( cd lib${LIBDIRSUFFIX}
  mkdir incoming
  mv *so* incoming
  mv incoming/libmemusage.so .
  # Beginning with glibc-2.34, shared objects are using their ABI sonames
  # directly, which is frankly, a terrible idea. It might help other package
  # managers, but doesn't do us any favors where we already had a system for
  # dealing with upgrades (and downgrades!). We'll change these libraries to
  # use the versioned naming system of glibc-2.33 and earlier so that we don't
  # have to handle these files differently and so that it's easy to see what
  # version of glibc is in use at a glance.
  cd incoming
  # First do the new libxcrypt links (a little bit differently):
  for cryptlib in libcrypt.so.* ; do
    CRYPTSO=$(echo $cryptlib | cut -f 3 -d .)
    mv $cryptlib libcrypt${CRYPTSO}-${VERSION}.so
  done
  for library in *.so.* ; do
    mv $library $(echo $library | cut -f 1 -d .)-${VERSION}.so
  done
  # This one is a special case. We don't want an $ARCH embedded in the
  # filename. It prevents using the same install scripts on all $ARCH
  # and does no good since we'll never have multiple $ARCH libraries
  # installed in the same directory anyway. So give it the previous name
  # format:
  mv ld-linux*-${VERSION}.so ld-${VERSION}.so
)
if [ "$MULTILIB" = "--enable-multilib" ]; then
  # We don't need to use an incoming directory here.
  mkdir -p lib
  cp -a $PKG/lib/* lib
  ( cd lib
    for cryptlib in libcrypt.so.* ; do
      CRYPTSO=$(echo $cryptlib | cut -f 3 -d .)
      mv $cryptlib libcrypt${CRYPTSO}-${VERSION}.so
    done
    for library in *.so.* ; do
      mv $library $(echo $library | cut -f 1 -d .)-${VERSION}.so
    done
  )
fi
# Build the package:
/sbin/makepkg -l y -c n $TMP/glibc-${VERSION}${VERTAG}-$SLACKWARE_ARCH-${BUILD}${TAG}.txz

# Done!
echo
echo "glibc packages built in $TMP!"