#!/bin/sh echo "*** BUILD GLIBC BEGIN ***" global SRC_DIR := $[pwd] # Read the 'JOB_FACTOR' property from '.config' global JOB_FACTOR := $[grep -i ^JOB_FACTOR .config | cut -f2 -d'=] # Find the number of available CPU cores. global NUM_CORES := $[grep ^processor /proc/cpuinfo | wc -l] # Calculate the number of 'make' jobs to be used later. global NUM_JOBS := $(NUM_CORES * JOB_FACTOR) # Save the kernel installation directory. global KERNEL_INSTALLED := "$SRC_DIR/work/kernel/kernel_installed" cd work/glibc # Find the glibc source directory, e.g. 'glibc-2.23' and remember it. cd $[ls -d glibc-*] global GLIBC_SRC := $[pwd] cd .. # Prepare the work area, e.g. 'work/glibc/glibc_objects'. echo "Preparing glibc object area. This may take a while..." rm -rf glibc_objects mkdir glibc_objects # Prepare the install area, e.g. 'work/glibc/glibc_installed'. echo "Preparing glibc install area. This may take a while..." rm -rf glibc_installed mkdir glibc_installed global GLIBC_INSTALLED := "$[pwd]/glibc_installed" # All glibc work is done from the working area. cd glibc_objects # glibc is configured to use the root folder (--prefix=) and as result all # libraries will be installed in '/lib'. Note that on 64-bit machines BusyBox # will be linked with the libraries in '/lib' while the Linux loader is expected # to be in '/lib64'. Kernel headers are taken from our already prepared kernel # header area (see xx_build_kernel.sh). Packages 'gd' and 'selinux' are disabled # for better build compatibility with the host system. echo "Configuring glibc..." $GLIBC_SRC/configure \ --prefix= \ --with-headers=$KERNEL_INSTALLED/include \ --without-gd \ --without-selinux \ --disable-werror \ CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE" # Compile glibc with optimization for "parallel jobs" = "number of processors". echo "Building glibc..." make -j $NUM_JOBS # Install glibc in the installation area, e.g. 'work/glibc/glibc_installed'. echo "Installing glibc..." make install \ DESTDIR=$GLIBC_INSTALLED \ -j $NUM_JOBS cd $SRC_DIR echo "*** BUILD GLIBC END ***" (CommandList children: [ (C {(echo)} {(DQ ("*** BUILD GLIBC BEGIN ***"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SRC_DIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [12 14] ) } spids: [11] ) ] spids: [11] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:JOB_FACTOR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(grep)} {(-i)} {(Lit_Other "^") (JOB_FACTOR)} {(.config)}) (C {(cut)} {(-f2)} {(-d) (SQ <"=">)}) ] negated: False ) ] ) left_token: spids: [22 42] ) ) } spids: [20] ) ] spids: [20] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NUM_CORES) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(grep)} {(Lit_Other "^") (processor)} {(/proc/cpuinfo)}) (C {(wc)} {(-l)}) ] negated: False ) ] ) left_token: spids: [50 63] ) } spids: [49] ) ] spids: [49] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NUM_JOBS) op: Equal rhs: { (ArithSubPart anode: (ArithBinary op_id: Arith_Star left: (ArithVarRef name:NUM_CORES) right: (ArithVarRef name:JOB_FACTOR) ) spids: [70 77] ) } spids: [69] ) ] spids: [69] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KERNEL_INSTALLED) op: Equal rhs: {($ VSub_Name "$SRC_DIR") (/work/kernel/kernel_installed)} spids: [83] ) ] spids: [83] ) (C {(cd)} {(work/glibc)}) (C {(cd)} { (CommandSubPart command_list: (CommandList children:[(C {(ls)} {(-d)} {(glibc-) (Lit_Other "*")})]) left_token: spids: [98 105] ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GLIBC_SRC) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [108 110] ) } spids: [107] ) ] spids: [107] ) (C {(cd)} {(..)}) (C {(echo)} {(DQ ("Preparing glibc object area. This may take a while..."))}) (C {(rm)} {(-rf)} {(glibc_objects)}) (C {(mkdir)} {(glibc_objects)}) (C {(echo)} {(DQ ("Preparing glibc install area. This may take a while..."))}) (C {(rm)} {(-rf)} {(glibc_installed)}) (C {(mkdir)} {(glibc_installed)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GLIBC_INSTALLED) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [157 159] ) (/glibc_installed) } spids: [156] ) ] spids: [156] ) (C {(cd)} {(glibc_objects)}) (C {(echo)} {(DQ ("Configuring glibc..."))}) (C {($ VSub_Name "$GLIBC_SRC") (/configure)} {(--prefix) (Lit_Other "=")} {(--with-headers) (Lit_Other "=") ($ VSub_Name "$KERNEL_INSTALLED") (/include)} {(--without-gd)} {(--without-selinux)} {(--disable-werror)} {(Lit_VarLike "CFLAGS=") (DQ ("-Os -s -fno-stack-protector -U_FORTIFY_SOURCE"))} ) (C {(echo)} {(DQ ("Building glibc..."))}) (C {(make)} {(-j)} {($ VSub_Name "$NUM_JOBS")}) (C {(echo)} {(DQ ("Installing glibc..."))}) (C {(make)} {(install)} {(Lit_VarLike "DESTDIR=") ($ VSub_Name "$GLIBC_INSTALLED")} {(-j)} {($ VSub_Name "$NUM_JOBS")} ) (C {(cd)} {($ VSub_Name "$SRC_DIR")}) (C {(echo)} {(DQ ("*** BUILD GLIBC END ***"))}) ] )