Repository: spack/spack

Issue:
Installation issue: sed
### Steps to reproduce the issue

```console
$ spack spec -I <spec>
Input spec
--------------------------------
 -   sed

Concretized
--------------------------------
[+]  sed@4.8%gcc@7.5.0 arch=linux-ubuntu18.04-westmere
```


### Error message

<details><summary>Error message</summary><pre>
==> sed: Executing phase: 'autoreconf'
==> sed: Executing phase: 'configure'
==> [2022-05-24-15:46:43.352706] '/tmp/pnanda/spack-stage/spack-stage-sed-4.8-pivv4eqxcciuvtoq3kh44ltwzslfo2dn/
spack-src/configure' '--prefix=/home/pnanda/spack/opt/spack/linux-ubuntu18.04-westmere/gcc-7.5.0/sed-4.8-pivv4e
qxcciuvtoq3kh44ltwzslfo2dn'
checking for a BSD-compatible install... /usr/bin/install -c
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating po/Makefile.in
config.status: creating gnulib-tests/Makefile
config.status: creating config.h
config.status: linking /tmp/pnanda/spack-stage/spack-stage-sed-4.8-pivv4eqxcciuvtoq3kh44ltwzslfo2dn/spack-src/GNUmakefile to GNUmakefile
config.status: executing depfiles commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
==> sed: Executing phase: 'build'
==> [2022-05-24-15:47:06.752714] 'make' '-j12' 'V=1'
make: GNUmakefile: Too many levels of symbolic links
make: stat: GNUmakefile: Too many levels of symbolic links
make: *** No rule to make target 'GNUmakefile'.  Stop.
</pre></details>


### Information on your system

* **Spack:** 0.18.0.dev0 (f2a81af70e1d70828a579ea325a0699d89c7a420)
* **Python:** 3.6.9                                                                                            
* **Platform:** linux-ubuntu18.04-westmere                                                                     
* **Concretizer:** clingo

### Additional information

* [spack-build-out.txt](https://github.com/spack/spack/files/8765833/spack-build-out.txt)
* [spack-build-env.txt](https://github.com/spack/spack/files/8765838/spack-build-env.txt)
* [config.log](https://github.com/spack/spack/files/8765840/config.log)

Searching the previous spack issues for the make error "Too many levels of symbolic links", I was able to find a previous bug fix https://github.com/spack/spack/pull/3543/files and can similarly fix the issue by adding the line a single line specifying the build directory:

```diff
diff --git a/var/spack/repos/builtin/packages/sed/package.py b/var/spack/repos/builtin/packages/sed/package.py
index 12f190e604..6bd6d11e23 100644
--- a/var/spack/repos/builtin/packages/sed/package.py
+++ b/var/spack/repos/builtin/packages/sed/package.py
@@ -16,6 +16,8 @@ class Sed(AutotoolsPackage, GNUMirrorPackage):
     version('4.8', sha256='f79b0cfea71b37a8eeec8490db6c5f7ae7719c35587f21edb0617f370eeff633')
     version('4.2.2', sha256='f048d1838da284c8bc9753e4506b85a1e0cc1ea8999d36f6995bcb9460cddbd7')
 
+    build_directory = 'spack-build'
+
     executables = ['^sed$']
 
     def url_for_version(self, version):
```

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
I encountered this as well on macOS due to https://github.com/spack/spack/pull/30714 . I will submit a patch.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/sed/package.py b/var/spack/repos/builtin/packages/sed/package.py
--- a/var/spack/repos/builtin/packages/sed/package.py
+++ b/var/spack/repos/builtin/packages/sed/package.py
@@ -16,6 +16,9 @@ class Sed(AutotoolsPackage, GNUMirrorPackage):
     version('4.8', sha256='f79b0cfea71b37a8eeec8490db6c5f7ae7719c35587f21edb0617f370eeff633')
     version('4.2.2', sha256='f048d1838da284c8bc9753e4506b85a1e0cc1ea8999d36f6995bcb9460cddbd7')
 
+    # Avoid symlinking GNUMakefile to GNUMakefile
+    build_directory = 'spack-build'
+
     executables = ['^sed$']
 
     def url_for_version(self, version):


Test patch: