BSDBuild Logo

How portable is BSDBuild?
BSDBuild is portable to many operating systems including most flavors of Unix, MacOS and Windows. It requires a standard make utility (such as GNU make or BSD make), a Bourne shell and the commands test, echo and sed.
Are there security considerations in BSDBuild?

Security, ease of testing and debuggability has always been a consideration in the design of BSDBuild.

  • BSDBuild configure scripts are simpler than autoconf scripts. They do not use shell functions or complicated tricks in general. They use a minimal number of commands (mainly test, echo and sed).
  • BSDBuild configure scripts may be easily regenerated by running mkconfigure. In a ports/packages setting, maintainers only need to review and use BSDBuild to regenerate (or diff against) configure as part of the packaging process.
  • The config.log generated by BSDBuild configure scripts contains a copy of all of the tests performed. Each test can be manually replayed by copy/pasting the relevant config.log fragment to the shell.
  • With BSDBuild's make libraries, the make install target is guaranteed to only perform basic file installations (e.g., running install). It will never trigger any type of compilation or last-minute generation process. By design, make install never implies make all.
Which languages are supported?
At this time, executables and libraries can be compiled from sources in Ada, C, C++, Objective C, assembler, Lex and Yacc. Adding support for more languages is straightforward.

The language of a source file in a ${SRCS} lists is determined by its file extension. Refer to the current and manual pages for the complete list.
Is cross-compilation supported?
Yes, you can pass --host to any BSDBuild ./configure script and it will arrange for cross-compilation to the given target. BSDBuild also provides special support for the cc65 compiler to 65(C)02 based platforms and emscripten for compiling to WebAssembly.
Do you have a template for a BSDBuild project?

The following should allow you to compile a "Hello world" program in C.

First, create a directory for the project and use the mkify prog command to create a copy of the files required by the module:

  $ mkdir hello
  $ cd hello
  $ mkify prog
  Installing in mk: ...
  Installing scripts: ...

mkify should create a subdirectory mk and an empty Makefile. Open up the Makefile in an editor and add the directives:

  PROG= hello
  SRCS= hello.c
  include ${TOP}/mk/

A minimal hello.c might look like:

  #include <stdio.h>
  main(int argc, char *argv[])
      printf("Hello, world!\n");
      return (0);

Now you can run make depend for the first time to generate dependencies:

  $ touch .depend
  $ make depend

Finally, compile the program with make:

  $ make
  cc -O2 -pipe -o hello.o -c hello.c

  $ ./hello
  Hello, world!

Next, you might want to add a configure script. Create a file called with the following:

# Example BSDBuild configure script.
# ex:syn=bsdbuild


register("--some-option", "An example option")
register("--enable-warnings", "Enable compiler warnings")


if [ "${enable_warnings}" = "yes" ]; then

# Write definitions to a config/ directory?

# Write definitions to a single config.h file?

To compile to a POSIX-style configure script, use the mkconfigure command:

  $ cat | mkconfigure > configure
  $ chmod 755 configure
How do I produce a single library from source files located in different subdirectories?

You can create a standard makefile and use relative path names in ${SRCS}, for example:

  TOP=	.
  LIB=	mylib
  SRCS=	source1.c \
        subdir1/source2.c \
  include ${TOP}/Makefile.config
  include ${TOP}/mk/
Can I create a Makefile in a directory without any sources?

Yes, by including only, and setting the targets explicitely:

  TOP=	.
  SUBDIR= dir1 \
  all: all-subdir
  install: install-subdir
  deinstall: deinstall-subdir
  clean: clean-subdir
  cleandir: cleandir-subdir
  depend: depend-subdir
  include ${TOP}/mk/
Is profiling supported?

Yes, you can set ${GMONOUT} to the desired output filename and then invoke:

  $ make ${GMONOUT}
What is a good ".gitignore" file for a project that uses BSDBuild?

To ignore files generated by make depend and configure:


# If configure uses c_incdir_config():

# If configure uses c_include_config():

# If configure uses config_script():

# If configure uses pkgconfig_mod():

*.rej ElectronTubeStore