#!/bin/sh 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) cd work/overlay/links # Change to the Links source directory which ls finds, e.g. 'links-2.12'. cd $[ls -d links-*] echo "Preparing Links work area. This may take a while..." make clean -j $NUM_JOBS !2 >/dev/null rm -rf ../links_installed echo "Configuring Links..." ./configure \ --prefix=../links_installed \ --disable-graphics \ --disable-utf8 \ --without-ipv6 \ --without-ssl \ --without-zlib \ --without-x # Set CFLAGS directly in Makefile. sed -i "s/^CFLAGS = .*/CFLAGS = \\-Os \\-s \\-fno\\-stack\\-protector \\-U_FORTIFY_SOURCE/" Makefile echo "Building Links..." make -j $NUM_JOBS echo "Installing Links..." make install -j $NUM_JOBS echo "Reducing Links size..." strip -g ../links_installed/bin/* !2 >/dev/null cp -r ../links_installed/bin $SRC_DIR/work/src/minimal_overlay echo "Links has been installed." cd $SRC_DIR (CommandList children: [ (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: [5 7] ) } spids: [4] ) ] spids: [4] ) (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: [15 35] ) ) } spids: [13] ) ] spids: [13] ) (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: [43 56] ) } spids: [42] ) ] spids: [42] ) (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: [63 70] ) } spids: [62] ) ] spids: [62] ) (C {(cd)} {(work/overlay/links)}) (C {(cd)} { (CommandSubPart command_list: (CommandList children:[(C {(ls)} {(-d)} {(links-) (Lit_Other "*")})]) left_token: spids: [83 90] ) } ) (C {(echo)} {(DQ ("Preparing Links work area. This may take a while..."))}) (SimpleCommand words: [{(make)} {(clean)} {(-j)} {($ VSub_Name "$NUM_JOBS")}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[107])] ) (C {(rm)} {(-rf)} {(../links_installed)}) (C {(echo)} {(DQ ("Configuring Links..."))}) (C {(./configure)} {(--prefix) (Lit_Other "=") (../links_installed)} {(--disable-graphics)} {(--disable-utf8)} {(--without-ipv6)} {(--without-ssl)} {(--without-zlib)} {(--without-x)} ) (C {(sed)} {(-i)} { (DQ ("s/^CFLAGS = .*/CFLAGS = ") (EscapedLiteralPart token:) ("-Os ") (EscapedLiteralPart token:) ("-s ") (EscapedLiteralPart token:) (-fno) (EscapedLiteralPart token:) (-stack) (EscapedLiteralPart token:) ("-protector ") (EscapedLiteralPart token:) (-U_FORTIFY_SOURCE/) ) } {(Makefile)} ) (C {(echo)} {(DQ ("Building Links..."))}) (C {(make)} {(-j)} {($ VSub_Name "$NUM_JOBS")}) (C {(echo)} {(DQ ("Installing Links..."))}) (C {(make)} {(install)} {(-j)} {($ VSub_Name "$NUM_JOBS")}) (C {(echo)} {(DQ ("Reducing Links size..."))}) (SimpleCommand words: [{(strip)} {(-g)} {(../links_installed/bin/) (Lit_Other "*")}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[224])] ) (C {(cp)} {(-r)} {(../links_installed/bin)} {($ VSub_Name "$SRC_DIR") (/work/src/minimal_overlay)}) (C {(echo)} {(DQ ("Links has been installed."))}) (C {(cd)} {($ VSub_Name "$SRC_DIR")}) ] )