wct-configure-for-nix.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 usage () {
4  cat <<EOF
5 Configure WCT source to build against Nix-provided packages.
6 
7 You must already have sourced
8 
9  $HOME/.nix-profile/etc/profile.d/nix.sh
10 
11 or equivalent.
12 
13 This script should be kept in the "waftools" git submodule of WCT.
14 But, it may be run from anywhwere:
15 
16  ./waftools/wct-configure-for-nix.sh [<path-to-install>]
17 
18  - <path-to-install> :: optional location for installing WCT. It
19  defaults to installing into the view.
20 
21 Note: this assumes a Nix profile exists. New packages will be added.
22 
23 EOF
24  exit 1
25 }
26 
27 topdir=$(dirname $(dirname $(readlink -f $BASH_SOURCE)))
28 inst="${1:-$topdir/install-nix}"
29 echo "Will 'wcb install' to $inst"
30 
31 if [ -z "$NIX_PATH" ] ; then
32  echo "Nix not yet configured."
33  nixsh="$HOME/.nix-profile/etc/profile.d/nix.sh"
34  if [ -f "$nixsh"] ; then
35  echo "source $nixsh"
36  else
37  echo "... and no nix profile even."
38  fi
39  exit 1
40 fi
41 
42 view="$(dirname $(dirname $(which root-config)))"
43 if [ -z "$view" -o ! -d "$view" ] ; then
44  echo "Fail to find nix profile directory: $view"
45  exit 1
46 fi
47 
48 assure_packages () {
49  echo "Assuring packages. This may take some time"
50  # To get "dev" outputs from multi-ouput packages requires some hoop jumping
51  for devpkg in fftwFloat boost zlib
52  do
53  echo "Assuring dev package: $pkg"
54  echo
55  nix-env -i -E '_: with import <nixpkgs> {}; let newmeta = ( '$devpkg'.meta // { outputsToInstall = ["out" "dev"]; } ); in '$devpkg' // { meta = newmeta; }' || exit 1
56  echo
57  done
58  for pkg in gcc python jsonnet jsoncpp eigen root tbb
59  do
60  echo "Assuring package: $pkg"
61  echo
62  nix-env -iA nixpkgs.$pkg
63  echo
64  done
65 }
66 # assure_packages
67 
68 
69 # fixme: would like to test clang too...
70 export CC=`which gcc`
71 export CXX=`which g++`
72 
73 # needed to shut up eigen 3.2.10
74 export CXXFLAGS='-Wno-misleading-indentation -Wno-int-in-bool-context -Wvla'
75 
76 "$topdir/wcb" \
77  configure \
78  --with-jsoncpp="$view" \
79  --with-jsonnet="$view" \
80  --with-eigen-include="$view/include/eigen3" \
81  --with-fftw="$view" \
82  --with-zlib="$view" \
83  --with-root="$view" \
84  --boost-includes="$view/include" \
85  --boost-libs="$view/lib" \
86  --boost-mt \
87  --with-tbb=$view \
88  --prefix="$inst"
89 
90 
91 #
92 
93