๐Ÿ”— CAmalgamator

August 1, 2025 ยท View on GitHub

GitHub release (latest by date) GitHub GitHub Repo stars GitHub issues GitHub Downloads C Platform Build Status Code Quality Security Maintenance

A powerful C amalgamator CLI tool that combines multiple C files into a single file โœจ

Perfect for creating single-header libraries, distributing projects, and simplifying builds!


๐ŸŽฏ What is CAmalgamator? (Super Simple Explanation!)

Imagine you have a LEGO castle made of many pieces scattered around your room. ๐Ÿฐ

CAmalgamator is like a magic tool that:

  1. Finds all your LEGO pieces (C files) ๐Ÿ“ฆ
  2. Connects them together ๐Ÿ”—
  3. Gives you one complete castle (single C file) โœจ

๐Ÿ“š In Programming Terms:

If you have a C project with files like:

  • main.c (your main program)
  • helper.c (some useful functions)
  • math.c (math functions)
  • helper.h and math.h (header files)

CAmalgamator combines ALL of these into ONE single file! ๐ŸŽ‰

๐Ÿค” Why is this AMAZING for beginners?

โœ… SUPER EASY to Share

  • Before: "Hey, here are 20 files you need to compile my program..."
  • After: "Hey, here's 1 file - just compile and run!" ๐Ÿš€

โœ… NO Complex Build Systems

  • Before: Need Makefiles, CMake, or other scary build tools ๐Ÿ˜ฐ
  • After: Just gcc single_file.c -o my_program โœจ

โœ… Perfect for Learning

  • See exactly what code is included
  • No mysterious "where does this function come from?" moments
  • Easy to understand the entire program flow

โœ… Great for Competitions

  • Programming contests often want single files
  • Easy to submit to online judges
  • No dependency headaches

๐Ÿ“ฅ Download & Installation (Choose Your Adventure!)

๐Ÿšจ Total Beginner? Start with the "๐ŸŽฎ Super Easy Download" section below!

๐ŸŽฎ Super Easy Download (No Compilation Needed!)

Just want to use it RIGHT NOW? Download the ready-to-run version for your computer:

๐Ÿ–ฅ๏ธ Your Computer๏ฟฝ Download This๐Ÿƒโ€โ™‚๏ธ How to Use
๏ฟฝ LinuxCAmalgamator.outDownload โ†’ Make executable โ†’ Run!
๐ŸชŸ Windows (64-bit)CAmalgamator64.exeDownload โ†’ Double-click โ†’ Use!
๐ŸชŸ Windows (32-bit)CAmalgamatori32.exeDownload โ†’ Double-click โ†’ Use!

๐Ÿš€ Super Quick Installation (Copy & Paste!)

๐Ÿง Linux Users (Easiest Way Ever!):

# Just copy and paste this into your terminal!
curl -L https://github.com/OUIsolutions/CAmalgamator/releases/download/0.0.4/CAmalgamator.out -o CAmalgamator
chmod +x CAmalgamator

# Now you can use it like this:
./CAmalgamator --help

๐Ÿง Ubuntu/Debian Users (Even Easier!):

# Download the package
wget https://github.com/OUIsolutions/CAmalgamator/releases/download/0.0.4/CAmalgamator.deb

# Install it (you'll need to enter your password)
sudo dpkg -i CAmalgamator.deb

# Now it's installed system-wide! Use it anywhere:
CAmalgamator --help

๐Ÿง‘โ€๐Ÿ’ป Advanced Downloads (For Developers)

๐Ÿ“ File๐ŸŽฏ Best For๐Ÿ“ Description
๏ฟฝ๏ธ CAmalgamator.cDevelopers who want to compileComplete source code
๏ฟฝ CAmalgamatorApiOne.hUse in your C programsFull API library
๏ฟฝ CAmalgamatorApiNoDependenciesIncluded.hMinimal integrationLightweight version
๐Ÿ“ฆ CAmalgamator.rpmFedora/RHEL/CentOSRPM package

๐Ÿƒโ€โ™‚๏ธ Quick Start Guide (For Total Beginners!)

Don't panic! This is easier than making instant noodles! ๐Ÿœ

๐ŸŽฌ Step 1: Your First Amalgamation (The Basics)

Let's start with the simplest possible example:

# This is THE most basic command you'll ever need!
./CAmalgamator --file main.c --output combined.c

๐Ÿค” What just happened?

  • --file main.c โ†’ "Hey CAmalgamator, start with this file!"
  • --output combined.c โ†’ "Put the final result in this file!"

That's it! CAmalgamator will:

  1. ๐Ÿ” Look at main.c
  2. ๐Ÿ•ต๏ธโ€โ™‚๏ธ Find all the #include statements
  3. ๐Ÿ”— Follow each include and grab that code
  4. ๐Ÿ“ Put everything together in combined.c

๐ŸŽฌ Step 2: Real-World Example (Let's Do This Together!)

Imagine you have these files:

my_awesome_project/
โ”œโ”€โ”€ main.c              โ† Your main program
โ”œโ”€โ”€ calculator.h        โ† Calculator functions
โ”œโ”€โ”€ calculator.c        โ† Calculator implementation  
โ”œโ”€โ”€ helpers.h           โ† Helper functions
โ””โ”€โ”€ helpers.c           โ† Helper implementation

๐Ÿง‘โ€๐Ÿ’ป What's in each file:

main.c:

#include <stdio.h>
#include "calculator.h"
#include "helpers.h"

int main() {
    printf("Hello from my awesome program!\n");
    int result = add(5, 3);
    print_result(result);
    return 0;
}

calculator.h:

#ifndef CALCULATOR_H
#define CALCULATOR_H
int add(int a, int b);
int subtract(int a, int b);
#endif

calculator.c:

#include "calculator.h"
int add(int a, int b) { return a + b; }
int subtract(int a, int b) { return a - b; }

helpers.h:

#ifndef HELPERS_H  
#define HELPERS_H
void print_result(int result);
#endif

helpers.c:

#include <stdio.h>
#include "helpers.h"
void print_result(int result) {
    printf("The result is: %d\n", result);
}

๐Ÿš€ Now, let's combine everything:

./CAmalgamator --file main.c --output single_awesome_program.c

๐ŸŽ‰ BOOM! Now you have ONE file called single_awesome_program.c with EVERYTHING inside!

You can compile and run it with just:

gcc single_awesome_program.c -o my_program
./my_program

No more worrying about:

  • โŒ "Did I include all the files?"
  • โŒ "Why can't the compiler find my functions?"
  • โŒ "How do I link all these files together?"

๐ŸŽฌ Step 3: Test It Yourself!

Create a simple test:

  1. Create test_main.c:
#include <stdio.h>
#include "test_math.h"

int main() {
    printf("Testing CAmalgamator!\n");
    printf("2 + 3 = %d\n", simple_add(2, 3));
    return 0;
}
  1. Create test_math.h:
#ifndef TEST_MATH_H
#define TEST_MATH_H
int simple_add(int a, int b);
#endif
  1. Create test_math.c:
#include "test_math.h"
int simple_add(int a, int b) {
    return a + b;
}
  1. Run CAmalgamator:
./CAmalgamator --file test_main.c --output combined_test.c
  1. Compile and run:
gcc combined_test.c -o test_program
./test_program

Expected output:

Testing CAmalgamator!
2 + 3 = 5

๏ฟฝ Congratulations! You just used CAmalgamator successfully!


โš™๏ธ Command-Line Options (All the Cool Features!)

๐ŸŽฏ Beginner Tip: Start with just --file and --output. Learn the other options later!

๐Ÿ”ฅ Essential Options (You NEED These!)

๐Ÿท๏ธ Flag๐Ÿ“ What It Does๐Ÿšจ Required?๐Ÿ’ก Example
--file or --fThe starting file (where to begin)โœ… YES--file main.c
--output or --oWhere to save the resultโœ… YES--output combined.c

๐Ÿ›ก๏ธ Safety Options (Protect Yourself!)

๐Ÿท๏ธ Flag๐Ÿ“ What It Does๐Ÿ”ง Default๐Ÿ’ก When to Use
--maxbyteMax size in bytes100MBWhen you want to limit file size exactly
--maxmegaMax size in megabytes100MBEasier! --maxmega 50 for 50MB limit
--maxreqMax recursion depth1000If includes go too deep

๐ŸŽ›๏ธ Advanced Control Options (For Power Users!)

๐Ÿท๏ธ Flag๐Ÿ“ What It Does๐ŸŽฏ Perfect For๐Ÿ’ก Example
--nochange or --ncDon't replace these includesKeep system includes as-is--nochange stdio.h
--noinclude or --niSkip these files completelyExclude external libraries--noinclude dependencies/
--perpetual or --pAllow multiple inclusionsHeaders that can be included many times--perpetual common_macros.h

๐ŸŒŸ Real-World Examples:

๐Ÿฅ‡ Beginner Example:

# Just combine everything - simple!
./CAmalgamator --file src/main.c --output build/single_file.c

๐Ÿฅˆ Intermediate Example:

# Limit size and exclude system headers
./CAmalgamator --file main.c --output combined.c --maxmega 10 --nochange stdio.h

๐Ÿฅ‰ Advanced Example:

# Skip dependencies folder but allow perpetual includes
./CAmalgamator --file src/main.c --output release/final.c \
  --noinclude dependencies/ \
  --perpetual common_macros.h \
  --maxmega 50

๐Ÿšจ Common Beginner Mistakes (And How to Avoid Them!)

โŒ DON'T DO THIS:

# Missing required flags - this will fail!
./CAmalgamator main.c

โœ… DO THIS INSTEAD:

# Always include both --file and --output
./CAmalgamator --file main.c --output combined.c

โŒ DON'T DO THIS:

# Using same name for input and output - BAD!
./CAmalgamator --file main.c --output main.c

โœ… DO THIS INSTEAD:

# Use different names to avoid overwriting
./CAmalgamator --file main.c --output main_combined.c

๐Ÿง‘โ€๐Ÿ’ป API Usage (For Programmers Who Want to Integrate!)

๐ŸŽฏ Beginner Note: This section is for people who want to use CAmalgamator inside their own C programs. If you just want to use the command-line tool, you can skip this section!

๐Ÿš€ Quick Setup (Get the API Library)

Download the API header file:

# Get the complete API (easiest way)
curl -L https://github.com/OUIsolutions/CAmalgamator/releases/download/0.002/CAmalgamatorApiOne.h -o CAmalgamatorApiOne.h

๐ŸŽฌ Simple Example (Your First API Program!)

Create a file called my_amalgamator.c:

#include <stdio.h>
#include "CAmalgamatorApiOne.h"

int main() {
    // Initialize the amalgamator
    CAmalgamatorNamesapce amalgamator = newCAmalgamatorNamesapce();
    
    // Settings (you can change these!)
    const char *starting_file = "src/cli/main.c";  // Where to start
    int max_recursion = 1000;                      // How deep to go
    int max_size = amalgamator.ONE_MB * 10;        // Max 10MB output
    
    // Do the magic! โœจ
    CAmalgamatorErrorOrContent *result = amalgamator.generate_amalgamation_simple(
        starting_file,
        max_size,
        max_recursion
    );
    
    // Check if it worked
    if(result->error) {
        printf("โŒ Oops! Something went wrong: %s\n", result->error_msg);
        amalgamator.free_error_or_string(result);
        return 1;
    }
    
    // Success! Print the combined code
    printf("โœ… Success! Here's your combined code:\n\n%s", result->content);
    
    // Clean up memory (important!)
    amalgamator.free_error_or_string(result);
    
    printf("\n๐ŸŽ‰ All done!\n");
    return 0;
}

Compile and run:

gcc my_amalgamator.c -o my_amalgamator
./my_amalgamator

๐ŸŽ›๏ธ Advanced Example (With Custom Control!)

Want more control over what gets included? Here's how:

#include <stdio.h>
#include "CAmalgamatorApiOne.h"

CAmalgamatorNamesapce amalgamator;

// This function decides what to do with each file
short my_custom_callback(const char *filename, const char *include_name, void *args) {
    printf("๐Ÿ” Found: %s (included from %s)\n", include_name, filename);
    
    // You can add your own logic here!
    
    // For example, skip all .txt files:
    if (strstr(include_name, ".txt") != NULL) {
        printf("โญ๏ธ  Skipping .txt file: %s\n", include_name);
        return amalgamator.DONT_INCLUDE;
    }
    
    // Include everything else once
    return amalgamator.INCLUDE_ONCE;
}

int main() {
    amalgamator = newCAmalgamatorNamesapce();
    
    const char *starting_file = "src/cli/main.c";
    int max_recursion = 1000;
    int max_size = amalgamator.ONE_MB * 10;
    void *custom_args = NULL;  // You can pass custom data here
    
    // Use the custom callback for more control
    CAmalgamatorErrorOrContent *result = amalgamator.generate_amalgamation(
        starting_file,
        max_size,
        max_recursion,
        my_custom_callback,  // Our custom function!
        custom_args
    );
    
    if(result->error) {
        printf("โŒ Error: %s\n", result->error_msg);
        amalgamator.free_error_or_string(result);
        return 1;
    }
    
    printf("โœ… Success! Here's your custom amalgamation:\n\n%s", result->content);
    amalgamator.free_error_or_string(result);
    return 0;
}

๐ŸŽฏ Callback Return Values (What Each One Does)

When you use a custom callback, you can return different values to control behavior:

๐Ÿท๏ธ Namespace๐Ÿท๏ธ Pure Constant๐Ÿ“ What It Does๐Ÿ’ก When to Use
amalgamator.DONT_INCLUDECAMALGAMATOR_DONT_INCLUDESkip this file completelyExternal libraries you don't want
amalgamator.DONT_CHANGECAMALGAMATOR_DONT_CHANGEKeep the #include as-isSystem headers like <stdio.h>
amalgamator.INCLUDE_ONCECAMALGAMATOR_INCLUDE_ONCEInclude the file onceMost normal files
amalgamator.INCLUDE_PERPETUALCAMALGAMATOR_INCLUDE_PERPETUALInclude every time it's foundMacros that can be included multiple times

๐Ÿšจ Important Notes for Beginners:

  1. Always check for errors! The API can fail if files don't exist or are too big.
  2. Don't forget to free memory! Always call free_error_or_string() when done.
  3. Start simple! Use generate_amalgamation_simple() first, then try the advanced version.

๐Ÿ”จ Building from Scratch (For Advanced Users!)

๐ŸŽฏ Beginner Note: You don't need this section if you just downloaded the ready-made executables above! This is only for people who want to compile CAmalgamator themselves.

๐Ÿ“‹ Prerequisites (What You Need First)

You'll need these tools installed:

  1. ๐Ÿฆ„ Darwin Build System (Version 0.020+)
  2. ๐Ÿณ Docker OR ๐Ÿซ– Podman (for containerized builds)
  3. ๐Ÿง Linux Environment (recommended)

๐Ÿš€ One-Line Darwin Installation (Linux Only!)

# Install Darwin build system in one command
curl -L https://github.com/OUIsolutions/Darwin/releases/download/0.7.0/darwin.out -o darwin.out && sudo chmod +x darwin.out && sudo mv darwin.out /usr/bin/darwin

๐Ÿ“ Clone and Build

# 1. Clone the repository
git clone https://github.com/OUIsolutions/CAmalgamator.git
cd CAmalgamator

# 2. Build all variants (this will take a while!)
darwin run_blueprint build/ --mode folder amalgamation_build alpine_static_build windowsi32_build windowsi64_build rpm_static_build debian_static_build

๐ŸŽ‰ After building, you'll have:

  • Linux executables
  • Windows executables (32-bit and 64-bit)
  • RPM packages
  • DEB packages
  • Static builds
  • And more!

๐Ÿค” What Gets Built?

๐Ÿ—๏ธ Build Target๐Ÿ“ Description๐ŸŽฏ Output
amalgamation_buildSingle C file versionCAmalgamator.c
alpine_static_buildStatic Linux binaryLinux executable
windowsi32_build32-bit Windows.exe file
windowsi64_build64-bit Windows.exe file
rpm_static_buildRPM package.rpm file
debian_static_buildDebian package.deb file

๐Ÿšจ Troubleshooting Common Build Issues

โŒ "darwin: command not found"

  • Solution: Make sure Darwin is installed and in your PATH

โŒ "Docker/Podman not found"

  • Solution: Install Docker or Podman for containerized builds

โŒ "Permission denied"

  • Solution: Make sure you have execute permissions on build scripts

๐Ÿ†˜ Need Help? (We've Got You Covered!)

๐Ÿค Community Support

๐Ÿ“š Common Questions

Q: "Can I use this with C++?" A: CAmalgamator is designed for C, but it might work with simple C++ code. Try it and see!

Q: "What about very large projects?" A: Use the --maxmega flag to set size limits. For huge projects, consider breaking them into smaller parts first.

Q: "Can I exclude certain system headers?" A: Yes! Use --nochange to keep system includes like <stdio.h> as-is.

Q: "Is it safe to use in production?" A: Absolutely! Many developers use amalgamation for distribution. Just test thoroughly first.


๐ŸŽ‰ Success Stories & Use Cases

๐ŸŒŸ Perfect For:

  • ๐ŸŽ“ Students: Submit single-file assignments easily
  • ๐Ÿ† Competitive Programming: Many contests prefer single files
  • ๐Ÿ“ฆ Library Distribution: Create easy-to-use single-header libraries
  • ๐Ÿš€ Embedded Systems: Simplify builds for microcontrollers
  • ๐Ÿ“ฑ Mobile Development: Reduce complexity in mobile C libraries

๐Ÿ’ฌ What Users Say:

"CAmalgamator saved me hours of build configuration headaches!" - DevStudent2024

"Perfect for my competitive programming setup. One command and I'm ready to submit!" - CodeWarrior

"Made distributing my C library so much easier. My users love the single-header approach!" - LibraryMaker


๐ŸŒŸ Ready to Simplify Your C Development?

โฌ‡๏ธ Download Now | โญ Star on GitHub | ๐Ÿ› Report Issues

Made with โค๏ธ by OUIsolutions

Simplifying C development, one amalgamation at a time! โœจ