2023-09-28 15:09:26 +02:00
|
|
|
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
|
2004-03-11 18:26:14 +01:00
|
|
|
set -x
|
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
export NIX_DEBUG=1
|
|
|
|
|
2005-12-05 15:11:09 +01:00
|
|
|
source $stdenv/setup
|
2004-03-08 17:02:46 +01:00
|
|
|
|
2004-03-12 12:12:18 +01:00
|
|
|
export NIX_ENFORCE_PURITY=1
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
mkdir $out
|
|
|
|
mkdir $out/bin
|
|
|
|
|
|
|
|
cat > hello.c <<EOF
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char * * argv)
|
|
|
|
{
|
|
|
|
printf("Hello World!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2004-03-08 19:29:08 +01:00
|
|
|
#gcc -I/nix/store/foo -I /nix/store/foo -I/usr/lib -I /usr/lib hello.c -o $out/bin/hello
|
2004-03-12 12:12:18 +01:00
|
|
|
gcc -I`pwd` -L /nix/store/abcd/lib -isystem /usr/lib hello.c -o $out/bin/hello
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
$out/bin/hello
|
|
|
|
|
|
|
|
cat > hello2.cc <<EOF
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
int main(int argc, char * * argv)
|
|
|
|
{
|
|
|
|
std::cout << "Hello World!\n";
|
|
|
|
std::cout << VALUE << std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
g++ hello2.cc -o $out/bin/hello2 -DVALUE="1 + 2 * 3"
|
|
|
|
|
|
|
|
$out/bin/hello2
|
|
|
|
|
2004-03-30 14:46:52 +02:00
|
|
|
ld -v
|