Repository: spack/spack

Issue:
tophat: build error
Summary: I am getting an error message when building tophat v2.1.1 that seems a bit strange to me.

### Expected Result

clean build
```
==> libsigsegv is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libsigsegv-2.11-ej4dtzvxydoockkjzgltuwbncl3qxcfx
==> m4 is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/m4-1.4.18-hnrf4xgkkkxxlojbhjmk7ktfh4ubxoiu
==> pkgconf is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/pkgconf-1.4.0-5orwkhqi6i42pmyxjubzqecgauyt5m53
==> ncurses is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/ncurses-6.0-tymhqxlvcy5eduud5ijnohpkuinoi7n4
==> readline is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/readline-7.0-6a33hh42gihqevhhwm7ddsklhu7xwkgk
==> gdbm is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/gdbm-1.14.1-nu73hb3bwwumnr5pe7n2ovwpvn3lj32c
==> perl is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/perl-5.24.1-hyqxea7h2rxfs2ttqf3irt2ebd2v7trx
==> autoconf is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/autoconf-2.69-qeckaewd7y2r32gevcgri3nkihu5jwjl
==> automake is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/automake-1.15.1-vmtyzl2ksbqod7v5hh3hrf24lcn7u7cm
==> bzip2 is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/bzip2-1.0.6-egkg2fbrcljkai2d23pgrq7wzeg2k5p5
==> zlib is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/zlib-1.2.11-euf4keckd7zopxedqa5pp37smh4v2aa4
==> boost is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/boost-1.63.0-qn7eohmlu7in7mxuvnlexd5jd5nsnwiw
==> intel-tbb is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/intel-tbb-2018.2-5m5j2t2tjmtvctu735trdii4p6zgladf
==> openssl is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/openssl-1.0.2n-b2pwlezjpb63d4lvpnb6hppps7qw4cap
==> sqlite is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/sqlite-3.18.0-ss65uo3pidaok5xk6ggbrastms2ludx4
==> python is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/python-2.7.13-7c6oeana5b37cz62oxrsfzvnrmaxejjm
==> bowtie2 is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/bowtie2-2.3.0-n7meksodlwwsisku3kgyrsp6i2muud2w
==> libtool is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libtool-2.4.6-vwgxyfslc5ia6zlesisvn2e3mwvpduaz
==> Installing tophat
==> Fetching MIRROR_DIR/mirror/tophat/tophat-2.1.1.tar.gz
==> Staging archive: WORKING_DIR/var/spack/stage/tophat-2.1.1-hfre5ftljlya2rcpykr6rksjltlibut7/v2.1.1.tar.gz
==> Created stage in WORKING_DIR/var/spack/stage/tophat-2.1.1-hfre5ftljlya2rcpykr6rksjltlibut7
==> No patches needed for tophat
==> Building tophat [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed tophat
  Fetch: 0.04s.  Build: 1m 41.22s.  Total: 1m 41.26s.
[+] WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/tophat-2.1.1-hfre5ftljlya2rcpykr6rksjltlibut7
```

### Actual Result
```
==> libsigsegv is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libsigsegv-2.11-ej4dtzvxydoockkjzgltuwbncl3qxcfx
==> m4 is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/m4-1.4.18-hnrf4xgkkkxxlojbhjmk7ktfh4ubxoiu
==> pkgconf is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/pkgconf-1.4.0-5orwkhqi6i42pmyxjubzqecgauyt5m53
==> ncurses is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/ncurses-6.0-tymhqxlvcy5eduud5ijnohpkuinoi7n4
==> readline is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/readline-7.0-6a33hh42gihqevhhwm7ddsklhu7xwkgk
==> gdbm is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/gdbm-1.14.1-nu73hb3bwwumnr5pe7n2ovwpvn3lj32c
==> perl is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/perl-5.24.1-hyqxea7h2rxfs2ttqf3irt2ebd2v7trx
==> autoconf is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/autoconf-2.69-qeckaewd7y2r32gevcgri3nkihu5jwjl
==> automake is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/automake-1.16.1-2vuoeb2m3uan3kw2sodpnuuqfe2og6dg
==> bzip2 is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/bzip2-1.0.6-egkg2fbrcljkai2d23pgrq7wzeg2k5p5
==> zlib is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/zlib-1.2.11-euf4keckd7zopxedqa5pp37smh4v2aa4
==> boost is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/boost-1.63.0-qn7eohmlu7in7mxuvnlexd5jd5nsnwiw
==> intel-tbb is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/intel-tbb-2018.2-5m5j2t2tjmtvctu735trdii4p6zgladf
==> openssl is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/openssl-1.0.2n-b2pwlezjpb63d4lvpnb6hppps7qw4cap
==> sqlite is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/sqlite-3.18.0-ss65uo3pidaok5xk6ggbrastms2ludx4
==> python is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/python-2.7.13-52dgd34kwi53hcwhmkggokoplqxzzmfp
==> bowtie2 is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/bowtie2-2.3.0-5de2lkd5d2hlgs5w6hpaqcfyh2ryfbc6
==> libtool is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libtool-2.4.6-vwgxyfslc5ia6zlesisvn2e3mwvpduaz
==> xz is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/xz-5.2.3-ehlxwhosxgdfbduwx3nk5zzxmo4qhmaq
==> htslib is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/htslib-1.6-awaj7rgiodnj7bqnqv3reut4wp765ryk
==> samtools is already installed in WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/samtools-1.6-tif7gm6nzido4g5pgwbbdu45dm7lyiij
==> Installing tophat
==> Fetching file://MIRROR_DIR/mirror/tophat/tophat-2.1.1.tar.gz
==> Staging archive: WORKING_DIR/var/spack/stage/tophat-2.1.1-dw5nauo4swl52tqp44hc4oxqufbscm3s/v2.1.1.tar.gz
==> Created stage in WORKING_DIR/var/spack/stage/tophat-2.1.1-dw5nauo4swl52tqp44hc4oxqufbscm3s
==> No patches needed for tophat
==> Building tophat [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'

==> Error: ProcessError: Command exited with status 2:
    'make'

11 errors found in build log:
     31     autoreconf: running: WORKING_DIR/opt/spack/linux-centos7-x8
            6_64/gcc-5.4.0/autoconf-2.69-qeckaewd7y2r32gevcgri3nkihu5jwjl/bin/a
            utoconf --include=WORKING_DIR/opt/spack/linux-centos7-x86_6
            4/gcc-5.4.0/pkgconf-1.4.0-5orwkhqi6i42pmyxjubzqecgauyt5m53/share/ac
            local --force
     32     fatal: Not a git repository (or any of the parent directories): .gi
            t
     33     autoreconf: running: WORKING_DIR/opt/spack/linux-centos7-x8
            6_64/gcc-5.4.0/autoconf-2.69-qeckaewd7y2r32gevcgri3nkihu5jwjl/bin/a
            utoheader --include=WORKING_DIR/opt/spack/linux-centos7-x86
            _64/gcc-5.4.0/pkgconf-1.4.0-5orwkhqi6i42pmyxjubzqecgauyt5m53/share/
            aclocal --force
     34     fatal: Not a git repository (or any of the parent directories): .gi
            t
     35     autoreconf: running: automake --add-missing --copy --force-missing
     36     fatal: Not a git repository (or any of the parent directories): .gi
            t
  >> 37     configure.ac:20: installing './ar-lib'
  >> 38     configure.ac:20: installing './compile'
  >> 39     configure.ac:74: installing './config.guess'
  >> 40     configure.ac:74: installing './config.sub'
  >> 41     configure.ac:8: installing './install-sh'
  >> 42     configure.ac:8: installing './missing'
     43     src/Makefile.am: installing './depcomp'
     44     autoreconf: Leaving directory `.'
     45     ==> Executing phase: 'configure'
     46     ==> 'WORKING_DIR/var/spack/stage/tophat-2.1.1-dw5nauo4swl52
            tqp44hc4oxqufbscm3s/tophat-2.1.1/configure' '--prefix=WORKING_DIR
            ck/wip/opt/spack/linux-centos7-x86_64/gcc-5.4.0/tophat-2.1.1-dw5nau
            o4swl52tqp44hc4oxqufbscm3s' '--with-boost=WORKING_DIR/opt/s
            pack/linux-centos7-x86_64/gcc-5.4.0/boost-1.63.0-qn7eohmlu7in7mxuvn
            lexd5jd5nsnwiw'
     47     checking for a BSD-compatible install... /usr/bin/install -c
     48     checking whether build environment is sane... yes

     ...

     252    gcc -c -g -Wall -O2  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -
            D_USE_KNETFILE -D_CURSES_LIB=0 -I. phase.c -o phase.o
     253    gcc -c -g -Wall -O2  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -
            D_USE_KNETFILE -D_CURSES_LIB=0 -I. bam2depth.c -o bam2depth.o
     254    gcc -g -Wall -O2  -o samtools_0.1.18 bam_tview.o bam_plcmd.o sam_vi
            ew.o bam_rmdup.o bam_rmdupse.o bam_mate.o bam_stat.o bam_color.o ba
            mtk.o kaln.o bam2bcf.o bam2bcf_indel.o errmod.o sample.o cut_target
            .o phase.o bam2depth.o -Lbcftools  libbam.a -lbcf -lm -lz #-lcurses
     255    make[3]: Leaving directory `/tmp/peetsv/spack-stage/spack-stage-f1X
            t85/tophat-2.1.1/src/samtools-0.1.18'
     256    WORKING_DIR/lib/spack/env/gcc/gcc  -Wall -Wno-strict-aliasi
            ng -g -gdwarf-2 -Wuninitialized  -O3  -DNDEBUG  -L./samtools-0.1.18
             -LWORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-5.4.0/boo
            st-1.63.0-qn7eohmlu7in7mxuvnlexd5jd5nsnwiw/lib  -o samtools_0.1.18
              -lz
     257    /lib/../lib64/crt1.o: In function `_start':
  >> 258    (.text+0x20): undefined reference to `main'
  >> 259    collect2: error: ld returned 1 exit status
  >> 260    make[2]: *** [samtools_0.1.18] Error 1
     261    make[2]: Leaving directory `/tmp/peetsv/spack-stage/spack-stage-f1X
            t85/tophat-2.1.1/src'
  >> 262    make[1]: *** [all-recursive] Error 1
     263    make[1]: Leaving directory `/tmp/peetsv/spack-stage/spack-stage-f1X
            t85/tophat-2.1.1'
  >> 264    make: *** [all] Error 2

See build log for details:
  WORKING_DIR/var/spack/stage/tophat-2.1.1-dw5nauo4swl52tqp44hc4oxqufbscm3s/tophat-2.1.1/spack-build.out
```
This suggests a dependency issue with samtools, though when I added the dependency to the tophat package.py and rebuilding, the same error was recreated.

### Steps to reproduce the issue

```console
$ spack install tophat
```

### Information on your system
linux-centos7-x86_64/gcc-5.4.0


Discussion:
What's changed between the clean build you quote and the problematic one?

The one that failed seems to have a dependency on samtools (one of the output lines says that it's "already installed") but the clean build does not.

TopHat 2.0.13 vendored it's own copy of samtools, perhaps you're running into a conflict?

Turns out the difference was automake@1.15.1 to automake@1.16.1

PR soon.
@peetsv +1 on the list of people that were hit by this :sob: 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/tophat/package.py b/var/spack/repos/builtin/packages/tophat/package.py
--- a/var/spack/repos/builtin/packages/tophat/package.py
+++ b/var/spack/repos/builtin/packages/tophat/package.py
@@ -31,10 +31,15 @@ class Tophat(AutotoolsPackage):
     homepage = "http://ccb.jhu.edu/software/tophat/index.shtml"
     url      = "https://github.com/infphilo/tophat/archive/v2.1.1.tar.gz"
 
+    version('2.1.2', 'db844fd7f53c519e716cd6222e6195b2')
     version('2.1.1', 'ffd18de2f893a95eb7e9d0c5283d241f')
 
     depends_on('autoconf', type='build')
-    depends_on('automake', type='build')
+    # 2.1.1 only builds with automake@1.15.1.  There's a patch here:
+    # https://github.com/spack/spack/pull/8244, which was incorporated
+    # upstream in 2.1.2, which is known to build with 1.16.1 and 1.15.1.
+    depends_on('automake',                        type='build')
+    depends_on('automake@1.15.1', when='@:2.1.1', type='build')
     depends_on('libtool',  type='build')
     depends_on('m4',       type='build')
 


Test patch: