haskell/cabal — pull request #2053 by RyanGlScott (2014-08-24 17:11:23+00:00)
Title: Accommodate network/network-uri split

This adds the necessary flags and CPP logic to allow `cabal-install` to use the `network-uri` package (since it was split off recently from `network`). I suppose this would be a temporary workaround to allow `cabal-install` to build until issue #2033 is resolved.

The one thing I'm not quite happy about with this commit is the CPP macro logic that `Distribution.Client.BuildReports.Upload` uses to check if `network-uri` or `network` (and if the latter, which version) is installed. I wanted to do something like this:

```haskell
#if defined(VERSION_network_uri) || MIN_VERSION_network(2,4,0)
return $ relativeTo rel uri
#else
relativeTo rel uri
#endif
```

But that won't work, since if `network-uri` is installed, then `MIN_VERSION_network` won't be defined in `cabal_macros.h`, causing the build to fail with `error: missing binary operator before token "("`. The workaround I used was:

```haskell
#if defined(VERSION_network_uri)
return $ relativeTo rel uri
#elif defined(VERSION_network)
#if MIN_VERSION_network(2,4,0)
return $ relativeTo rel uri
#else
relativeTo rel uri
#endif
#endif
```

but I feel like this could be made cleaner with some CPP wizardry.