Builder (hcbuild)

Project build system that reads .prj configuration files and orchestrates compilation, assembly, and linking in one command. The project file path is used as the base directory for all relative source file paths.

Command Line

hcbuild [options] <project.prj> <command> [config]
ArgumentDescription
<project.prj>Path to the project configuration file (required)
<command>make to build, clean to remove output files (required)
[config]Link configuration name. Default: release. Allows multiple [link:NAME] sections.

Command-Line Options

OptionDescription
--sdk-path <dir>Base directory for all tools (compiler, assembler, linker, librarian). Overrides HC_SDK_PATH and sdk_path in [config].
--asm-path <dir>Assembler directory (defaults to sdk_path).
--link-path <dir>Linker directory (defaults to sdk_path).
--lib-path <dir>Librarian directory (defaults to sdk_path).
--output-dir <dir>Output directory for all generated files. Overrides HC_OUTPUT_DIR and output_dir in [config].
-I <dir>Add include path (for B language #include). Repeatable.
--verbose, -vPrint each tool invocation before executing.
--dumpGenerate .dump assembly listing files alongside .obj files.
--keepKeep intermediate .__s files (normally deleted after assembly).
--help, -hShow help message.

Environment Variables

VariableDescription
HC_SDK_PATHBase directory for all tools. Overridden by --sdk-path.
HC_OUTPUT_DIROutput directory. Overridden by --output-dir.

Build Order

When make is executed, hcbuild processes the project in this order:

  1. Collect objects from [lib:start] and [libs:start] (linked first)
  2. Compile and assemble source files from all [files:*] sections
  3. Collect objects from [lib] and [libs] (linked after user objects)
  4. Invoke the linker with all collected objects

.prj File Format — Complete Reference

The project file uses an INI-like syntax. Lines starting with ; or # are comments. Section headers use square brackets. Keys can have values after =, or stand alone (no = needed for source file entries). Values may be quoted with double quotes.

1. [config] — Global Settings

Optional section. All keys are optional.

KeyValuesDescription
sdk_pathPath stringBase directory where hcbcomp-*, hcasm-*, hclink-*, and hclib are located.
output_dirPath stringDirectory for all output files. If not set, output goes next to the .prj file.
verboseyes, true, 1, enablePrint each tool command before executing.
dumpyes, true, 1, enableGenerate .dump assembly listing files.
keepyes, true, 1, enableKeep intermediate .__s files after assembly.
[config]
sdk_path = ../../bin
verbose = yes
keep = true

2. [files:ARCH] — Source Files

Lists source files for a specific target architecture. Each line is a filename (no = value). The architecture determines which compiler and assembler are used. Multiple [files:ARCH] sections can coexist in one project.

ArchitectureCompilerAssemblerUse Case
z80hcbcomp-z80hcasm-z80Z80 / CP/M, MSX-DOS
8086hcbcomp-8086hcasm-80868086 / MS-DOS COM (near pointers)
8086exehcbcomp-8086exehcasm-80868086 / MS-DOS EXE (far pointers, MZ format)
8080hcbcomp-8080hcasm-80808080 / CP/M
8085hcbcomp-8085hcasm-80858085 / CP/M

Supported Source File Extensions

ExtensionStep 1Step 2Notes
.b, .BCompile to .__sAssemble to .objB language source. Uses hcbcomp-ARCH.
.s, .SAssemble to .objAssembly source. Uses hcasm-ARCH.
.objPassed directly to linkerPre-compiled object file.
[files:z80]
main.b
utils.s
startup.obj

[files:8086]
portable.b

3. [libs] and [lib] — Library Files

Lists library (.lib) and object (.obj) files to link. [libs] and [lib] are equivalent — both are linked after all source files have been compiled and assembled.

[libs]
../../libs/z80-cpm-b.lib
extra/mylib.lib

4. [libs:start] and [lib:start] — Startup Objects

Libraries and objects linked before user source files. Use this for startup code (_start). The linker ensures the object containing _start is placed first.

[libs:start]
start.obj
crt.lib

5. [link:NAME] — Link Configuration

Defines how to produce the final executable. NAME is the configuration name (e.g., release, debug). Pass the name as the third argument to hcbuild. If only one [link:*] section exists, it is used regardless of name.

KeyDefaultDescription
formatbinOutput format. bin = flat binary (COM/ROM), mz = MZ EXE (MS-DOS segmented), rex = REX relocatable, lib = librarian output (produces .lib using hclib).
filenamea.outOutput file name. Relative paths are resolved from the output_dir or project directory.
text(none)Text section start address (hex or decimal). Typical CP/M .COM: 0x100. ROM images may use 0x0000 or 0x4000.
data(none)Data section start address. If omitted, data follows immediately after text.
bss(none)BSS section start address. If omitted, BSS follows immediately after data.
align(none)Section alignment in bytes. Ensures each section starts at a multiple of this value.
stack4096Stack size in bytes. Only meaningful for format = mz. The stack is placed at the end of the BSS section.
symbols(none)If set, generates a symbol table file listing all labels with addresses. Format: $ADDR NAME [TYPE file.obj].
; CP/M .COM target
[link:release]
format = bin
text = 0x100
filename = program.com
symbols = program.sym

; MS-DOS .EXE target
[link:msdos]
format = mz
stack = 1024
filename = program.exe

; ROM image target
[link:rom]
format = bin
text = 0x4000
bss = 0xC000
filename = firmware.bin

6. [blang:include_path] — B Compiler Include Paths

Additional include directories passed to the B compiler via -I. Each line is a path. These paths are used for #include resolution in .b source files.

[blang:include_path]
../include
../lib/common

Complete Example

A multi-target project building for both Z80/CP/M and 8086/MS-DOS EXE:

; game.prj — Retro game for Z80 CP/M and 8086 MS-DOS
[config]
sdk_path = ../../bin
verbose = yes

[files:z80]
main.b
sound.b
gfx.b
cp/m_wrapper.s

[files:8086exe]
main.b
sound.b
gfx.b
dos_wrapper.s

[libs]
../../libs/z80-cpm-b.lib

[libs:start]
startup.obj

[link:cpm]
format = bin
text = 0x100
filename = GAME.COM

[link:dos]
format = mz
stack = 4096
filename = GAME.EXE

Build commands:

hcbuild game.prj make cpm      # build CP/M version
hcbuild game.prj make dos      # build MS-DOS EXE version
hcbuild game.prj clean         # remove all outputs

[Quick Start] · [Linker] · [B Compiler] © 2025-2026 HC SDK