# Building Octave with MATLAB Compatibility Enhancements

## Prerequisites

- C++ compiler (GCC 7+ or Clang 10+)
- Fortran compiler (gfortran)
- Development tools (autoconf, automake, libtool, make)
- BLAS and LAPACK libraries (OpenBLAS recommended for performance)

## Installing OpenBLAS (Recommended for Performance)

### Ubuntu/Debian
```bash
sudo apt-get install libopenblas-dev
```

### macOS (Homebrew)
```bash
brew install openblas
```

### From Source
```bash
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make
sudo make install
```

## Building Octave

### Basic Build with OpenBLAS

```bash
./bootstrap
./configure --with-blas=openblas --with-lapack=openblas --prefix=/usr/local/octave-custom
make -j$(nproc)
make check
sudo make install
```

### Performance Build Options

For optimal performance, use:

```bash
./configure \
  --with-blas=openblas \
  --with-lapack=openblas \
  --enable-64 \
  --enable-shared \
  --prefix=/usr/local/octave-custom
```

### Minimal Lite Build (for distribution)

```bash
./configure \
  --with-blas=openblas \
  --with-lapack=openblas \
  --disable-gui \
  --disable-docs \
  --disable-java \
  --prefix=/usr/local/octave-lite
```

## Testing

After building, run the test suite:

```bash
make check
```

Or run specific compatibility tests:

```bash
cd test
octave --eval "run('matlab-compat/minimal-release.tst')"
```

## Troubleshooting

### OpenBLAS not found
- Ensure OpenBLAS is installed: `pkg-config --modversion openblas`
- Specify path: `./configure --with-blas=/usr/local/lib/libopenblas.a`

### Build errors
- Ensure all dependencies are installed
- Check compiler version compatibility
- Review configure output for missing libraries

