Utilities for cross-compiling with Shake

Version on this page:0.10.1
LTS Haskell 22.22:0.12.0
Stackage Nightly 2023-12-26:0.12.0
Latest on Hackage:0.12.0

See all snapshots shake-language-c appears in

Apache-2.0 licensed
Maintained by [email protected]
This version can be pinned in stack with:shake-language-c-0.10.1@sha256:13460f56735c4d0306211019ca3d95180b49d0b9cdca980da03d2097b5cda9bf,3031


Hackage version Stackage LTS Stackage Nightly Build Status

shake-language-c is a cross-platform build system based on the Shake Haskell library. The focus is on cross-compilation of C, C++ and Objective C source code to various target platforms. Currently supported target platforms are iOS, Android NDK, Google Portable Native Client, MacOS X, Linux and Windows (MinGW). Supported host platforms are MacOS X, Linux and Windows.


Please see the package documentation. Feel free to open an issue or send a pull request if there’s anything missing that you want to see covered.


Here’s an iOS example that compiles all .cpp files in the src directory. The resulting static library libexample.a can then be used e.g. from an XCode project.

import Control.Applicative
import Control.Arrow
import Development.Shake
import Development.Shake.FilePath
import Development.Shake.Language.C
import qualified Development.Shake.Language.C.Target.OSX as OSX

main :: IO ()
main = shakeArgs shakeOptions { shakeFiles = "build/" } $ do
  let target = OSX.iPhoneOS (Arm Armv7s)
      toolChain = OSX.toolChain
                    <$> OSX.getSDKRoot
                    <*> (maximum <$> OSX.getPlatformVersions (targetPlatform target))
                    <*> pure target

  lib <- staticLibrary toolChain
          ("build" </> toBuildPrefix target </> "libexample.a")
          (return $
               append compilerFlags [(Just Cpp, ["-std=c++11"])]
           >>> append compilerFlags [(Nothing, ["-O3"])]
           >>> append userIncludes ["include"] )
          (getDirectoryFiles "" ["src//*.cpp"])

  want [lib]

A more complex build script is used by the Methcla sound engine library. It defines Shake rules for building the library on various platforms and also exports functions for transparently including the library into other build systems. The build script makes extensive use of Shake configuration files.


Changelog for shake-language-c


  • Add support for Linux ARMv7


  • Add mkConfig function that caches dependencies


  • Fix host architecture detection on Windows 10


  • Add support for the Android arm64-v8a target architecture and drop support for specifying the toolchain version; this API breaking change requires a minimum Android NDK revision 11c


  • Fix Windows host target
  • Get host architecture from environment on Windows


  • Allow to set linker command via LD environment variable


  • Fix compiler and linker commands for Clang toolchain on Linux


  • Use -I compiler flag for the userIncludes of BuildFlags and -isystem for systemIncludes; semantics should be as before for gcc and clang but -isystem suppresses warnings in system headers


  • Refactor NMF file creation in NaCl module


  • Fix compilation error with GHC 7.10 in test suite (#25)


  • Add arm64 ARM version
  • Add support for arm64 to OSX toolchains
  • Fix compilation error with GHC 7.10 (#25)


  • Fix Android toolchain definition for x86 architecture


  • Fix bug in Development.Shake.Language.C.Target.OSX: getPlatformVersionsWithRoot works correctly now with SDK directories without version number, as introduced by Xcode 6


Bug fix release.


Bug fix release.



  • Add Data.Default.Class.Default instances for some data types; add dependency on package data-default-class.


  • Don’t export the entire module Development.Shake.Language.C.ToolChain from Development.Shake.Language.C; expose Development.Shake.Language.C.ToolChain for toolchain writers.
  • Export Development.Shake.Language.C.Language.Language from Development.Shake.Language.C.BuildFlags instead of Development.Shake.Language.C.
  • Export Development.Shake.Language.C.Rules from Development.Shake.Language.C; hide Development.Shake.Language.C.Rules in Cabal file.
  • Android: Add libcxxabi include directory instead of gabi++ to include path when compiling with libcxx. Fixes error: no member named '__cxa_demangle' in namespace '__cxxabiv1'.


  • Remove libppapi, libppapi_cpp, libnacl_io, libppapi_simple from Development.Shake.Language.C.Target.NaCl.
  • Remove Development.Shake.Language.C.Target.archString.


First released version.