Ultra-small and simple micro-embedded Linux command set
MiniBox is not a fork of BusyBox or ToyBox; it is entirely written from scratch. Inspired by the "small and simple is beautiful" philosophy of Thompson and Ritchie, MiniBox embodies a minimalistic approach that aligns with its name.
MiniBox is a collection of ultra-miniature C utilities comparable to the full-sized GNU Coreutils. The key difference is that MiniBox utilities omit uncommon options and prioritize size over features. Each utility can be compiled standalone, separate from the MiniBox suite.
Why choose MiniBox? Here are some reasons:
- Extremely Small: MiniBox comes in under 60KB.
- Blazingly Fast: It is 7.3x faster than BusyBox and 3.1x faster than ToyBox.
- Simple Source Code: The code is easy to understand with zero bloat.
- Universal libc Support: Compatible with dietlibc, uclibc, musl, glibc, etc.
- No Dependencies: Except for libc, MiniBox requires no external dependencies.
- Standalone Utilities: Each utility can be compiled independently (see Standalone Compilation).
Follow these simple steps to build MiniBox:
-
Configure:
- Run
./configure
(no options) to configure the build. - To compile all commands, you can use
yes | ./configure
.
- Run
-
Compile:
- Run
make
.
- Run
-
Install:
- Run
make install
to install MiniBox toinstall_dir
.
- Run
- Remove compiled objects: Run
make distclean
. - Uninstall: Since files are copied to
install_dir
, you can't uninstall traditionally, but you can clean up withmake distclean
.
If you need to edit any code after running ./configure
, you must first run:
make distclean
- OR
./scripts/toggle_ifdef.sh -D
(recommended)
This will remove the #ifdef
statements from the source files so that everything compiles without running ./configure
.
To compile a utility standalone:
-
Clean Up:
- If you've already run
./configure
ormake
, runmake distclean
or./scripts/toggle_ifdef.sh -D
.
- If you've already run
-
Edit the Source:
- Remove
#include "minibox.h"
and replace it with the necessary headers and function definitions (or copy the source to your home directory before modifying).
- Remove
-
Add a Main Function:
- Your main function should look like this:
int main(int argc, char *argv[]) {
return example(argc, argv);
}
-
Handle the VERSION Macro:
- Either add
#define VERSION <some_random_chars>
or removeVERSION
and the corresponding%s
in the printf statement.
- Either add
-
Handle Reusable Functions:
- If your program uses functions from
libmb
, either copy the code fromlibmb/<function_name>.c
into your program or compilelibmb
and link it with-Llibmb -lmb
.
- If your program uses functions from
-
Compile:
- Use
gcc -flto -o <utility> <utility>.c
. You can add additional compilation flags as needed.
- Use
-
Optional: Static Compilation:
- To compile statically, use
gcc -static -flto -o <utility> <utility>.c -lc
. If compilation fails, ensure that all necessary libraries are included.
- To compile statically, use
If you want to contribute or add your own utilities:
-
Create the Source File:
- Create the source file (e.g.,
src/example.c
).
- Create the source file (e.g.,
-
Include Headers:
- Include
#include "minibox.h"
in your source file. - If your program has multiple functions, also include
#include "utils.h"
.
- Include
-
Define Functions:
- Add the function definitions to
minibox.h
:
- Add the function definitions to
int example(int argc, char *argv[]);
-
Implement the Program:
- Implement the program in
src/example.c
. Manual option parsing is required (do not usegetopt
).
- Implement the program in
-
Update the Commands Table:
- Add your program to the commands table in
src/minibox.c
:
- Add your program to the commands table in
Command commands[] = {
#ifdef CONFIG_EXAMPLE
{"example", example},
#endif
};
-
Edit the Makefile:
- Add your program to the
PROGS
variable in the Makefile.
- Add your program to the
-
Test:
- Run
./configure
and select your program for compilation.
- Run