nd100x

ND100X Project

Build System Overview

This project uses CMake as its build system. The structure is modular, with core libraries and frontends built separately.

Project Structure

Building the Project

Prerequisites

Building on Linux/macOS

# Configure and build in debug mode
./build.sh

# Build in release mode
./build.sh --release

# Build WebAssembly version
./build.sh --wasm

# Specify custom build directory
./build.sh --build-dir my_build

# Specify custom installation prefix
./build.sh --install-prefix ~/local

Building on Windows

# Configure and build in debug mode
build.bat

# Build in release mode
build.bat --release

# Build WebAssembly version
build.bat --wasm

# Specify custom build directory
build.bat --build-dir my_build

# Specify custom installation prefix
build.bat --install-prefix "C:\Program Files\ND100X"

Manual CMake Build

# Create a build directory
mkdir build && cd build

# Configure
cmake ..

# Build
cmake --build .

# Install
cmake --install .

CMake Structure

The project uses a modern CMake approach with proper target-based dependency management:

  1. Each module is built as a standalone library
  2. Dependencies are expressed using target_link_libraries
  3. Include directories are properly scoped with PUBLIC/PRIVATE visibility
  4. Platform-specific code is conditionally included
  5. WebAssembly builds use Emscripten-specific configurations

Debugger Support

The debugger is only available on Linux and Windows builds. It uses the DAP (Debug Adapter Protocol) from external/libdap. The preprocessor symbol WITH_DEBUGGER is defined when the debugger is available.

Out-of-Source Builds

The build system follows CMake best practices for out-of-source builds:

Building ND100X

This project provides two build systems:

  1. Original Makefile-based build system
  2. New CMake-based build system

Makefile-based Build System

Using Make

A Makefile is included to simplify the process if you prefer using make.

Prerequisites

Building with Make

Use “make help” to list the options


$make help

ND100X Makefile Help
-------------------------------------------------------------------------------
Targets:
  all (default) - Same as 'debug'
  debug         - Build debug version
  release       - Build release version
  sanitize      - Build with address sanitizer
  wasm          - Build WebAssembly version
                  (Requires Emscripten SDK, run in browser via HTTP server)
  dap-tools     - Build with DAP tools (dap_debugger and dap_mock_server)
                  (Only available on Linux/Windows with libdap)
  clean         - Remove build directories
  install       - Install the build
  run           - Build and run nd100x (uses defaults below)
  help          - Show this help

Run options (environment variables):
  BOOT_TYPE=smd|floppy|bpun|aout|bp   Boot type (default: smd)
  IMAGE_FILE=path                     Image file to load
  START_ADDR=0                        Start address (default: 0)
  VERBOSE=1                           Enable verbose output
  DEBUGGER=1                          Enable DAP debugger
  DISASM=1                            Enable disassembly output

Platform-specific features:
  Linux/Windows: WITH_DEBUGGER is automatically set for cpu/debugger
                 This enables Debug Adapter Protocol (DAP) support
  WebAssembly:   Debugger is disabled, optimized for browser performance

WebAssembly options:
  The wasm target builds a browser-compatible version of the emulator.
  After building, serve the build_wasm/bin directory via HTTP
  and open index.html in a browser.

Example:
  BOOT_TYPE=floppy IMAGE_FILE=FLOPPY.IMG make run

This Makefile is a wrapper around CMake. If you prefer, you can use CMake directly:
  ./build.sh          - For more build options  
  1. For debug build (default):
    make debug
    
  2. For release build:
    make release
    
  3. For build with sanitizers:
    make sanitize
    

The build system supports three different build types:

CMake-based Build System

Prerequisites

Building with CMake

  1. Create a build directory:
    mkdir -p build
    
  2. Configure the project:
    cd build
    cmake ..
    
  3. Build the project:
    cmake --build .
    
  4. Install (optional):
    cmake --install .
    # Or to specify an installation prefix:
    cmake --install . --prefix /path/to/install
    

Build Script

For convenience, a build script is provided that handles common build configurations:

# Configure and build in debug mode
./build.sh

# Build in release mode
./build.sh --release

# Build WebAssembly version
./build.sh --wasm

# Specify custom build directory
./build.sh --build-dir my_build

# Specify custom installation prefix
./build.sh --install-prefix ~/local

# Build with DAP test tools (dap_debugger, dap_mock_server)
./build.sh --with-dap-tools

Building on Windows

On Windows, you can use the provided batch file:

# Configure and build in debug mode
build.bat

# Build in release mode
build.bat --release

# Specify custom build directory
build.bat --build-dir my_build

# Specify custom installation prefix
build.bat --install-prefix "C:\Program Files\ND100X"

# Build with DAP test tools
build.bat --with-dap-tools

Building for WebAssembly

To build for WebAssembly, you need to have Emscripten SDK installed and activated:

# Using emcmake directly
mkdir -p build_wasm
emcmake cmake -B build_wasm -S .
cmake --build build_wasm

# Or using the build script
./build.sh --wasm

Building DAP Test Tools

By default, the DAP (Debug Adapter Protocol) test tools (dap_debugger and dap_mock_server) are not built to reduce compilation time and dependencies. If you need these tools for development or testing, you can enable them:

# Using CMake directly
cmake -B build -S . -DBUILD_DAP_TOOLS=ON
cmake --build build

# Or using the build script
./build.sh --with-dap-tools

CMake Structure

The project uses a modern CMake approach:

  1. Each module is built as a standalone library
  2. Dependencies are expressed using target_link_libraries
  3. Include directories are properly scoped with PUBLIC/PRIVATE visibility
  4. Platform-specific code is conditionally included
  5. WebAssembly builds use Emscripten-specific configurations

Debugger Support

The debugger is only available on Linux and Windows builds. It uses the DAP (Debug Adapter Protocol) from external/libdap. The preprocessor symbol WITH_DEBUGGER is defined when the debugger is available.

CMake Generated Files

The build system respects the existing code structure and uses the mkptypes tool to generate prototype headers, just like the original Makefile system.