Apache-2.0 licensed
Maintained by [email protected]
This version can be pinned in stack with:shake-language-c-0.8.4@sha256:5a8aa565f010a3f87d41664a451dff83f31acd28c722f528c1538cf19d83aa5d,3030


Hackage version 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.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


  • 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.