@@ -1,6 +1,7 @@
11{ stdenv, lib, fetchgit, fetchFromGitHub, gyp, readline, python, which, icu
22, patchelf, coreutils
33, doCheck ? false
4+, static ? false
45}:
56
67assert readline != null;
@@ -15,6 +16,7 @@ let
1516 else "ia32";
1617 git_url = "https://chromium.googlesource.com";
1718 clangFlag = if stdenv.isDarwin then "1" else "0";
19+ sharedFlag = if static then "static_library" else "shared_library";
1820
1921 deps = {
2022 "build" = fetchgit {
@@ -143,7 +145,7 @@ stdenv.mkDerivation rec {
143145 -Dclang=${clangFlag} \
144146 -Dv8_enable_i18n_support=1 \
145147 -Duse_system_icu=1 \
146− -Dcomponent=shared_library \
148+ -Dcomponent=${sharedFlag} \
147149 -Dconsole=readline \
148150 -Dv8_target_arch=${arch} \
149151 -Dv8_use_external_startup_data=0
@@ -170,7 +172,8 @@ stdenv.mkDerivation rec {
170172 installPhase = ''
171173 install -vD out/Release/d8 "$out/bin/d8"
172174 install -vD out/Release/mksnapshot "$out/bin/mksnapshot"
173− ${if stdenv.isDarwin then ''
175+ ${if static then ""
176+ else if stdenv.isDarwin then ''
174177 install -vD out/Release/lib.target/libv8.dylib "$out/lib/libv8.dylib"
175178 install_name_tool -change /usr/local/lib/libv8.dylib $out/lib/libv8.dylib -change /usr/lib/libgcc_s.1.dylib ${stdenv.cc.cc.lib}/lib/libgcc_s.1.dylib $out/bin/d8
176179 install_name_tool -id $out/lib/libv8.dylib -change /usr/lib/libgcc_s.1.dylib ${stdenv.cc.cc.lib}/lib/libgcc_s.1.dylib $out/lib/libv8.dylib
@@ -180,6 +183,7 @@ stdenv.mkDerivation rec {
180183 mkdir -p "$out/include"
181184 cp -vr include/*.h "$out/include"
182185 cp -vr include/libplatform "$out/include"
186+ mkdir -p "$out/lib"
183187 cp -v out/Release/*.a "$out/lib"
184188 '';
185189