I had been messing around with ninja/meson since that is what gnome/gtk uses and ended up with something below. It seems to work with the tbamud code I'm working on currently but has mysql that is not on stock. I haven't tested all the steps from scratch to make sure they were copied right though. I've only used it on ubuntu. It is very basic and probably needs a lot of work but here is what it looks like:
meson.build
Code:
# Project definition
project('tbaMUD', 'c', version: '1.0')
# Option to enable profiling
profile = get_option('profile') ? ['-pg'] : []
# Compiler flags and options
cflags = ['-Wall', '-Wno-char-subscripts', '-Wno-unused-but-set-variable', '-I/usr/include/mysql']
# MySQL dependency
mysql_dep = dependency('mysqlclient', required: true)
# Get the C compiler
cc = meson.get_compiler('c')
# Add the crypt library
crypt_dep = cc.find_library('crypt', required: true)
# Declare a custom dependency that includes compiler flags and the MySQL and Crypt dependencies
global_deps = declare_dependency(
compile_args: cflags + profile,
dependencies: [mysql_dep, crypt_dep]
)
# Add the subdirectory where the source files are
subdir('src')
# Utilities
# subdir('util')
# Create the executable (no path specified here) (if you want /usr/local/bin)
# executable('circle', src_files, dependencies: global_deps, install: true, install_dir: join_paths(get_option('prefix'), 'bin'))
# Create the executable in the root directory and install it into the 'bin' directory
executable('circle', src_files, dependencies: global_deps, install: true, install_dir: 'bin')
cat meson_options.txt
Code:
option('profile', type : 'boolean', value : false, description : 'Enable profiling')
cat src/meson.build
Code:
# Source files in the src directory
src_files = files(
'act.comm.c', 'act.informative.c', 'act.item.c', 'act.movement.c', 'act.offensive.c',
'act.other.c', 'act.social.c', 'act.wizard.c', 'aedit.c', 'arena.c', 'asciimap.c',
'ban.c', 'boards.c', 'bsd-snprintf.c', 'castle.c', 'cedit.c', 'clan.c', 'clanedit.c',
'class.c', 'comm.c', 'config.c', 'constants.c', 'db.c', 'dg_comm.c', 'dg_db_scripts.c',
'dg_event.c', 'dg_handler.c', 'dg_misc.c', 'dg_mobcmd.c', 'dg_objcmd.c', 'dg_olc.c',
'dg_scripts.c', 'dg_triggers.c', 'dg_variables.c', 'dg_wldcmd.c', 'feats.c', 'fight.c',
'genmob.c', 'genobj.c', 'genolc.c', 'genqst.c', 'genshp.c', 'genwld.c', 'genzon.c',
'graph.c', 'handler.c', 'hedit.c', 'house.c', 'ibt.c', 'improved-edit.c', 'interpreter.c',
'limits.c', 'lists.c', 'magic.c', 'mail.c', 'medit.c', 'memorization.c', 'mobact.c',
'modify.c', 'msgedit.c', 'mud_event.c', 'mysql_db.c', 'mysql_players.c', 'oasis.c',
'oasis_copy.c', 'oasis_delete.c', 'oasis_list.c', 'objsave.c', 'oedit.c', 'players.c',
'prefedit.c', 'protocol.c', 'qedit.c', 'quest.c', 'random.c', 'redit.c', 'sedit.c',
'shop.c', 'spec_assign.c', 'spec_procs.c', 'spell_parser.c', 'spells.c', 'statedit.c',
'strife_quest.c', 'tedit.c', 'utils.c', 'weather.c', 'zedit.c', 'zmalloc.c'
)
- **Meson** (build system)
- **Ninja** (build backend)
- **GCC** (C compiler)
- **MySQL Client Libraries**
- **Crypt Library** (for password encryption)
You can install the required packages on a Debian-based system (e.g., Ubuntu) using:
sudo apt update
sudo apt install meson ninja-build gcc libmysqlclient-dev libcrypt-dev
## Compilation and Installation Steps
Follow the steps below to compile and install the project locally.
### Step 1: Configure the Build Directory
First, configure Meson to use the root of the project as the installation prefix:
meson setup builddir --prefix=$PWD
This command sets up the build directory and ensures that the compiled binary will be installed in the local `bin/` directory inside the project.
### Step 2: Compile the Project
To compile the project, run the following command:
meson compile -C builddir
This will compile the source files and generate the necessary binaries.
### Step 3: Install the Executables
After the project is compiled, install the `circle` executable (and any other required binaries) to the `bin/` directory in the project:
meson install -C builddir
The `circle` executable and other utility programs will be installed into `bin/`.
### Step 4: Run the Project
To run the `circle` executable, use the following command:
./bin/circle
This will launch the tbaMUD server.
## Cleaning the Build
If you want to clean the build directory, you can remove the `builddir` directory:
rm -rf builddir
Then, you can reconfigure and rebuild by repeating the steps above.