mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 23:12:44 +01:00
* A function to build libraries.
* The linker can link against libraries. * C flags can be passed to the C compiler.
This commit is contained in:
parent
5d48dd6912
commit
17e20716c0
5 changed files with 43 additions and 11 deletions
11
lib/link.sh
11
lib/link.sh
|
|
@ -1,12 +1,19 @@
|
|||
. $stdenv/setup
|
||||
|
||||
objs=
|
||||
for i in "$objects"; do
|
||||
for i in $objects; do
|
||||
obj=$(echo $i/*.o)
|
||||
objs="$objs $obj"
|
||||
done
|
||||
|
||||
libs=
|
||||
for i in $libraries; do
|
||||
lib=$(echo $i/*.a)
|
||||
name=$(echo $(basename $lib) | sed -e 's/^lib//' -e 's/.a$//')
|
||||
libs="$libs -L$(dirname $lib) -l$name"
|
||||
done
|
||||
|
||||
echo "linking object files into \`$programName'..."
|
||||
|
||||
mkdir $out
|
||||
gcc -o $out/$programName $objs
|
||||
gcc -o $out/$programName $objs $libs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue