[LLVMdev] Building LLVM with cmake on FreeBSD

Chuck Robey
Mon, 25 May 2009 19:58:27 -0000

Paul Melis wrote:
> Hi,
>
> Óscar Fuentes wrote:
>> Chuck Robey <chuckr at telenix.org> writes:
>>
>>
>>>> Just checked that the makefiles generated by cmake work with
`make' on
>>>> FreeBSD 7.2 x86. The build fails while building `opt'
because libdl is
>>>> missing.
>>>>
>>> They absolutely do work, even on FreeBSD-current( I run that here),
>>> but not using the native make (the one built as part of "make
world"
>>> which is a direct descendant of "pmake".  You have to use
the GNU
>>> make,

Both BSD Make and GNU make run on FreeBSD (as long as you do install GNU Make,
because it's not part of the base install, however 90% of folks will install
it.
 They coexist with no problem.

>>>
>> Uh? My FreeBSD installment has `make' and no `gmake'.
`make' is indeed
>> BSD make.

In your FreeBSD system, do an "ls -d /var/db/pkg/gmake*" and see if
any
directory shows up.  If it does, then the only argument you can have is what
name you installed it under, not whether it's there or not, it is.  GNU
Make,
and NOT BSD Make, will respond to the -v parameter with version info.  BSD make
won't do that.

>>
>> So, to recap, right now LLVM svn builds fine on FreeBSD 7.2 using BSD
>> `make' with the makefiles generated by cmake.
>>
> I quickly browsed the CMake 2.6.2 source and their does not seem to be a
> special case for BSD in the makefile generator code.
> It seems that the makefiles generated by cmake use the subset of
> features that is shared by BSD make and GNU make
> (http://www.cmake.org/pipermail/cmake/2004-March/004881.html), so
> building with either BSD make or GNU make should work.
>
> However, I also noticed that KDE4 uses CMake these days and on a page
> (http://techbase.kde.org/Getting_Started/Build/KDE4/FreeBSD) that
> describes building on FreeBSD it says "Sometimes, building with *make*
> can fail on some modules. You should try using *gmake* instead." So
> perhaps YMMV...

Let me explain a bit.  Things that are part of FreeBSD ports are built using
whatever build tool is called for, but if it's brought in as part of the
FreeBSD
base code (as I expect llvm will be) then there will be additional Makefiles
provided by FreeBSD programmers (in separate directories, they won't
interfere
or overwrite the Makefiles that come with llvm, they'll just use source
pathing
to refer to the source files, and force the build to be run via BSD Make) so
that the build can be guided by the BSD Make.  Unless you understand how Make
works (and this feature works for both GNU Make and BSD Make, if under different
names, the GNU Make folks call this VPATH) then you might not even realize that
BSD Make is in control.  I would.

There is already a llvm *port*, it's using whatever is native to llvm, it
looks
like CMake is provided, but GNU Make compatible Makefiles (via configure) are
being used.  I looked at the Makefiles being produced, they're not bmake
compatible.  I don't care what they claim, look at the actual Makefiles
being
produced.

I already gave you a couple of very easy to spot sentinels, ways you can
absolutely prove the code is or is not GNU Make(gmake), or BSD Make (bmake):
look for the conditionals, they don't look alike, and they aren't cross
compatible.  One obvious example is the gmake uses "ifeq" there bmake
uses ".if
(var1==var2)".  If you spot a "ifeq" then you can argue that
it's bmake all you
want, you'd still be wrong.  I don't know CMake all that well, I believe
it can
generate gmake compatible Makefiles, but if it puts something like
"ifeq" into
the Makefiles it produces, then don't believe the documentation that says
it's
cross compatible with BSD, it won't be, the ifeq constructs are clear
evidence.

It's NOT possible to make a single Makefile, one that has conditionals in
it, be
compatible with both bmake and gmake, because their conditionals don't look
alike.  It's possible to produce a bmake or gmake compatible makefile, but I
haven't seen any project do that, actually.  Certainly, you can write (for
the
autoconf) a Makefile.in that would be compatible with bmake, but I never saw
that actually done, have you?