I was wondering what the preferred way of building software in the BSDs is and if they are actively using and encouraging the use of GNU autotools.

I found the following section about GNU autoconf in the OpenBSD Handbook:

autoconf is a gnu tool that is supposed to help in writing portable programs. It is often used together with automake (portable makefiles) and libtool (portable shared libraries).

Those tools do not work all that well, and often create specific challenges in porting software to OpenBSD.

This seems not very encouraging. Does OpenBSD have its own autotools-like programs? Are you supposed to write the configure scripts yourself? I see that for example OpenSSH is using autoconf.

FreeBSD has a neutral section in its Handbook, but it is still in the "Special Considerations" section:

The various GNU autotools provide an abstraction mechanism for building a piece of software over a wide variety of operating systems and machine architectures. [...]

  • Do you create an own program? If yes and the program isn't too big and complex you can create a Makefile by hand. I think it's a simpliest solution. Or your program is Qt-based, you can use qmake. – uzsolt Mar 25 '14 at 15:45
  • This is more a general question of mine. I use Linux and have successfully used autotools for some projects, but I have also heard many people talking bad about autotools. I know and have used cmake, (s)cons, GYP, waf and many more. As people from BSD tend to avoid GNU tools, I thought maybe they have a better solution for the problem. – user846 Mar 26 '14 at 9:56
  • Many people are talking bad about many things but as far as I know noone came out with a full featured autotools replacement. I personally feel cmake is rather awkward and doesn't fit the autotools configure/Makefile standards nor improve on it. – Pavel Šimerda Sep 20 '14 at 19:21

Typically, if you're targeting a specific BSD version, you'd use that BSD's make (sometimes known as bmake, bsdmake or pmake). This has various predefined rule sets for particular kinds of targets you'd like to build.

For example, on NetBSD bsd.prog.mk is typically used for building a program; you simply declare the program's name and source files, and it automatically invokes the compiler and linker with the correct settings. This would also allow your program to be integrated into build.sh (the NetBSD program to build the entire operating system from source), as it will automatically pick up things like DESTDIR and cross-compilation settings, without you having to do anything special. There are similar rule files for building libraries and so on.

The main roadblock to using this everywhere is that this seems to be pretty unportable. See also this discussion about the advantages and disadvantages of BSD make.

| improve this answer | |

I have seen that if OpenBSD uses one of my programs in the base system, they may ignore the configure script:

Then again, they may not. It depends on who did the work:

  • lynx (apparently used the configure script, though some patches removed configure checks...)

The configure script is tolerated in the ports area however. It has been quite a while since I saw a port maintainer constructing a makefile just because they disapproved of autoconf.

| improve this answer | |

Not sure there is any "officially BSD preferred" way, but my preferred method is cmake. While it's name is misleading as it performs the configure step and generates make files, it doesn't replace make or gmake. It can generate unix makefiles as well as xcode, qtcreator, visual studio, borland and many other project files.

Cmake's syntax is clear and easy to understand. It also provides a cli and a gui app that can be used to adjust configuration options, which I think is easier than adding a list of items after a configure command.

| improve this answer | |
  • 2
    downvoted because while this is a nice review of your favourite build system, it doens't answer the question. – strugee Mar 25 '14 at 16:00
  • 1
    Well he asked preferred and it is my preferred way. I see more projects using it, so it is becoming more preferred by more people. I'm not sure of any "officially BSD preferred" way. – sambler Mar 26 '14 at 17:49
  • 2
    he asked preferred by OpenBSD. you answered preferred by you. therein lies the distinction. if you know that OpenBSD has no such preference, say that there is no answer - don't fill it in with opinion. – strugee Mar 27 '14 at 3:02
  • Same as @strugee – enedil Mar 27 '14 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy