Repository: spack/spack

Issue:
Centos 7 libjson-c build failure
Build failure
``` bash
==> Installing libjson-c
==> Using cached archive: spack/var/spack/cache/libjson-c/libjson-c-0.11.tar.gz
==> Staging archive: spack/var/spack/stage/libjson-c-0.11-6kxjkfdqpwot5vdijbs6ueuwwdjncues/json-c-0.11.tar.gz
==> Created stage in spack/var/spack/stage/libjson-c-0.11-6kxjkfdqpwot5vdijbs6ueuwwdjncues
==> Ran patch() for libjson-c
==> Building libjson-c [AutotoolsPackage]
==> Executing phase : 'autoreconf'
==> Executing phase : 'configure'
==> Error: ProcessError: Command exited with status 1:
    'spack/var/spack/stage/libjson-c-0.11-6kxjkfdqpwot5vdijbs6ueuwwdjncues/json-c-0.11/configure' '--prefix=spack/opt/spack/linux-centos7-x86_64/gcc-4.8.5/libjson-c-0.11-6kxjkfdqpwot5vdijbs6ueuwwdjncues'
spack/lib/spack/spack/build_systems/autotools.py:266, in configure:
     258      def configure(self, spec, prefix):
     259          """Runs configure with the arguments specified in
     260          :py:meth:`~.AutotoolsPackage.configure_args`
     261          and an appropriately set prefix.
     262          """
     263          options = ['--prefix={0}'.format(prefix)] + self.configure_args()
     264
     265          with working_dir(self.build_directory, create=True):
  >> 266              inspect.getmodule(self).configure(*options)

See build log for details:
  spack-stage-yggXWT/json-c-0.11/spack-build.out
 ```

Logs
``` bash
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
configure: error: source directory already configured; run "make distclean" there first
```

```make distclean``` isn't portable in this case because the Makefile was configured to use /bin/ksh, which isn't installed on many systems.

I could work around it with ```rm config.status``` which will cause configure to lose its state and re-run.


Discussion:
The latest release of `libjson-c` doesn't seem to have this problem. I'll put out a PR to add this new version.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/flux/package.py b/var/spack/repos/builtin/packages/flux/package.py
--- a/var/spack/repos/builtin/packages/flux/package.py
+++ b/var/spack/repos/builtin/packages/flux/package.py
@@ -44,7 +44,7 @@ class Flux(AutotoolsPackage):
     depends_on("hwloc")
     depends_on("lua@5.1:5.1.99")
     depends_on("munge")
-    depends_on("libjson-c")
+    depends_on("json-c")
     depends_on("libxslt")
     depends_on("python")
     depends_on("py-cffi", type=('build', 'run'))
diff --git a/var/spack/repos/builtin/packages/libjson-c/package.py b/var/spack/repos/builtin/packages/json-c/package.py
similarity index 86%
rename from var/spack/repos/builtin/packages/libjson-c/package.py
rename to var/spack/repos/builtin/packages/json-c/package.py
--- a/var/spack/repos/builtin/packages/libjson-c/package.py
+++ b/var/spack/repos/builtin/packages/json-c/package.py
@@ -25,11 +25,12 @@
 from spack import *
 
 
-class LibjsonC(AutotoolsPackage):
-    """ A JSON implementation in C """
+class JsonC(AutotoolsPackage):
+    """A JSON implementation in C."""
     homepage = "https://github.com/json-c/json-c/wiki"
-    url      = "https://s3.amazonaws.com/json-c_releases/releases/json-c-0.11.tar.gz"
+    url      = "https://s3.amazonaws.com/json-c_releases/releases/json-c-0.12.1.tar.gz"
 
-    parallel = False
+    version('0.12.1', '55f7853f7d8cf664554ce3fa71bf1c7d')
+    version('0.11',   'aa02367d2f7a830bf1e3376f77881e98')
 
-    version('0.11', 'aa02367d2f7a830bf1e3376f77881e98')
+    parallel = False
diff --git a/var/spack/repos/builtin/packages/libhio/package.py b/var/spack/repos/builtin/packages/libhio/package.py
--- a/var/spack/repos/builtin/packages/libhio/package.py
+++ b/var/spack/repos/builtin/packages/libhio/package.py
@@ -35,6 +35,6 @@ class Libhio(AutotoolsPackage):
 
     version('1.3.0.1', 'c073541de8dd70aeb8878bd00d6d877f')
 
-    depends_on("libjson-c")
+    depends_on("json-c")
     depends_on("bzip2")
     depends_on("pkg-config", type="build")


Test patch: