fudging the top-level Makefile

Currently, to get LLVM to build "Apple-style," it's necessary to copy two files (utils/buildit/GNUmakefile and utils/buildit/build_llvm) into the top-level directory. This is generally a PITA inside of Apple. (I'll spare you the gory details. :slight_smile:

I'd like to fix this for Apple, and I want to avoid compromising anybody else's build system. I've never used CMAKE, so I would be very grateful if a Windows/CMAKE developer would look this over.

I'm proposing to rename the top-level Makefile to "Makefile.standard", and add a new, trivial top-level "Makefile" that detects the Apple build environment. Every Apple-style build happens in the presence of an environment variable named "$RC_ARCHS". If the magic $RC_ARCHS is detected, the new Makefile arranges for an Apple-style build. If the magic environment variable is absent, "Makefile.standard" is included, and everything proceeds as usual.

I've tested this by building LLVM on OS/X:
1) with a separate build directory, e.g. "cd llvm.obj ; ../llvm/configure ; make"
2) building inside the LLVM source directory, e.g. "cd llvm ; ./configure ; make"
3) Apple-style (too ugly and frightening to reproduce here :slight_smile:

I've also tested this by building LLVM on my home Linux system:
1) with a separate build directory, e.g. "cd llvm.obj ; ../llvm/configure ; make"
2) building inside the LLVM source directory, e.g. "cd llvm ; ./configure ; make"

Comments or suggestions (or better approaches) are greatly appreciated.

Here is the patch. I was obliged to change autoconf/configure.ac; I have omitted the corresponding diffs from the top-level configure shellscript for brevity:

llvmCore.diffs.txt (1.65 KB)

Makefile (467 Bytes)

Why not:

$ RC_ARCHS="x86" make
echo Apple Build.
Apple Build.
$ make
echo Standard Build
Standard Build
$ cat Makefile
ifneq ($(RC_ARCHS),)
include Makefile.apple
else
all:
  echo Standard Build
endif
mrs $ cat Makefile.apple
all:
  echo Apple Build.

It leaves Makefile mostly alone, all except for three lines at the top and one line at the end of it.

Stuart Hastings <stuart@apple.com> writes:

I'd like to fix this for Apple, and I want to avoid compromising
anybody else's build system. I've never used CMAKE, so I would be
very grateful if a Windows/CMAKE developer would look this over.

As the LLVM cmake build specification completely ignores the makefiles
provided with LLVM, no problem here.

Because the existing top-level Makefile includes "Makefile.config". In a normal build, the configure step creates "Makefile.config". "Apple-style" builds don't run the configure script (I have filed a bug about this :-).

stuart

? Only if you want it:

$ cat Makefile
ifdef FOO
include no_such_file
endif

all:
  echo ok
mrs $ make all
echo ok
ok

Absolutely. Third-party build systems should impact the public LLVM as little
as possible.

                                  -Dave

I don't think that solves the problem. If I elide both of the includes in the top-level Makefile, then I'm obliged to make the combined Makefile + included GNUmakefile coexist. I think it could be done, but I'd rather not. :slight_smile: The alternative is to wrap the entire body of the top-level Makefile in a conditional. IMHO this is uglier and more fragile than my original proposal, but it's still workable:

llvmCore.diffs.txt (2.06 KB)

Well, that is indeed what I had in mind. I'll leave it to others as to what version they prefer. I think it is advantageous to leave the Makefile in place at the expense of the 6 extra lines.