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. See the Portability page for more details.
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 new languages can be done easily.

The language of a source file in ${SRCS} is determined by its file extension. Refer to the current build.prog.mk and build.lib.mk 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 build.prog.mk 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:

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

A minimal hello.c might look like:

  
  #include <stdio.h>
  
  int
  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 configure.in with the following:


# Example BSDBuild configure script
# ex: syn=bsdbuild

package("hello")
version("1.0")

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

require(cc)
check_header(stdio.h)

if [ "${enable_warnings}" = "yes" ]; then
  c_option(-Wall)
  c_option(-Werror)
  c_option(-Wmissing-prototypes)
fi

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


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

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

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

Yes, by including only build.subdir.mk, and setting the targets explicitely:

  
  TOP=	.
  
  SUBDIR= dir1 \
          dir2
  
  all: all-subdir
  install: install-subdir
  deinstall: deinstall-subdir
  clean: clean-subdir
  cleandir: cleandir-subdir
  depend: depend-subdir
  
  include ${TOP}/mk/build.subdir.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:

Makefile.config
config.log
config.status
configure.lua
.depend

# If configure uses c_incdir():
config/

# If configure uses config_script():
myprogram-config

# If configure uses pkgconfig_mod():
myprogram.pc

*.so
*.so.*
*.dll
*.exe
*.o
*.obj
*.res
*.lib
*.a
*.la
*.lo
*.dSYM
*.lnk
*.err
*.exp
*.map
*.orig
*~
*.swp
*.tmp
*.rej

Csoft.net ElectronTubeStore