about summary refs log tree commit diff
path: root/pkgs/development/compilers/tinycc/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/tinycc/default.nix')
-rw-r--r--pkgs/development/compilers/tinycc/default.nix62
1 files changed, 33 insertions, 29 deletions
diff --git a/pkgs/development/compilers/tinycc/default.nix b/pkgs/development/compilers/tinycc/default.nix
index 906df89b2117..a848accf1666 100644
--- a/pkgs/development/compilers/tinycc/default.nix
+++ b/pkgs/development/compilers/tinycc/default.nix
@@ -1,20 +1,16 @@
 { lib
-, stdenv
-, fetchFromRepoOrCz
 , copyPkgconfigItems
+, fetchFromRepoOrCz
 , makePkgconfigItem
 , perl
+, stdenv
 , texinfo
 , which
 }:
 
-let
-  # avoid "malformed 32-bit x.y.z" error on mac when using clang
-  isCleanVer = version: builtins.match "^[0-9]\\.+[0-9]+\\.[0-9]+" version != null;
-in
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "tcc";
-  version = "unstable-2022-07-15";
+  version = "0.9.27-unstable-2022-07-15";
 
   src = fetchFromRepoOrCz {
     repo = "tinycc";
@@ -22,6 +18,8 @@ stdenv.mkDerivation rec {
     hash = "sha256-jY0P2GErmo//YBaz6u4/jj/voOE3C2JaIDRmo0orXN8=";
   };
 
+  outputs = [ "out" "info" "man" ];
+
   nativeBuildInputs = [
     copyPkgconfigItems
     perl
@@ -29,23 +27,27 @@ stdenv.mkDerivation rec {
     which
   ];
 
-  pkgconfigItems = [
-    (makePkgconfigItem rec {
+  strictDeps = true;
+
+  pkgconfigItems = let
+    libtcc-pcitem = {
       name = "libtcc";
-      inherit version;
-      cflags = [ "-I${variables.includedir}" ];
+      inherit (finalAttrs) version;
+      cflags = [ "-I${libtcc-pcitem.variables.includedir}" ];
       libs = [
-        "-L${variables.libdir}"
-        "-Wl,--rpath ${variables.libdir}"
+        "-L${libtcc-pcitem.variables.libdir}"
+        "-Wl,--rpath ${libtcc-pcitem.variables.libdir}"
         "-ltcc"
       ];
-      variables = rec {
+      variables = {
         prefix = "${placeholder "out"}";
-        includedir = "${prefix}/include";
-        libdir = "${prefix}/lib";
+        includedir = "${placeholder "dev"}/include";
+        libdir = "${placeholder "lib"}/lib";
       };
       description = "Tiny C compiler backend";
-    })
+    };
+  in [
+    (makePkgconfigItem libtcc-pcitem)
   ];
 
   postPatch = ''
@@ -64,17 +66,19 @@ stdenv.mkDerivation rec {
     "--config-musl"
   ];
 
-  preConfigure = ''
+  preConfigure = let
+    # To avoid "malformed 32-bit x.y.z" error on mac when using clang
+    versionIsClean = version:
+      builtins.match "^[0-9]\\.+[0-9]+\\.[0-9]+" version != null;
+  in ''
     ${
-      if stdenv.isDarwin && ! isCleanVer version
+      if stdenv.isDarwin && ! versionIsClean finalAttrs.version
       then "echo 'not overwriting VERSION since it would upset ld'"
-      else "echo ${version} > VERSION"
+      else "echo ${finalAttrs.version} > VERSION"
     }
     configureFlagsArray+=("--elfinterp=$(< $NIX_CC/nix-support/dynamic-linker)")
   '';
 
-  outputs = [ "out" "info" "man" ];
-
   # Test segfault for static build
   doCheck = !stdenv.hostPlatform.isStatic;
 
@@ -84,7 +88,7 @@ stdenv.mkDerivation rec {
     rm tests/tests2/{108,114}*
   '';
 
-  meta = with lib; {
+  meta = {
     homepage = "https://repo.or.cz/tinycc.git";
     description = "Small, fast, and embeddable C compiler and interpreter";
     longDescription = ''
@@ -108,13 +112,13 @@ stdenv.mkDerivation rec {
 
       With libtcc, you can use TCC as a backend for dynamic code generation.
     '';
-    license = licenses.lgpl21Only;
-    maintainers = with maintainers; [ joachifm AndersonTorres ];
-    platforms = platforms.unix;
+    license = with lib.licenses; [ lgpl21Only ];
+    mainProgram = "tcc";
+    maintainers = with lib.maintainers; [ joachifm AndersonTorres ];
+    platforms = lib.platforms.unix;
     # https://www.mail-archive.com/tinycc-devel@nongnu.org/msg10199.html
     broken = stdenv.isDarwin && stdenv.isAarch64;
   };
-}
+})
 # TODO: more multiple outputs
 # TODO: self-compilation
-# TODO: provide expression for stable release