minimake/README.md
2026-06-19 11:11:29 +02:00

73 lines
1.5 KiB
Markdown

# Minimake
Minimake is a small project written in about a week in C99. Its goal was to reproduce the main features of the well known GNU Make utility.
> **Note** This is a school project, therefore it probably won't interest you if you are looking for something useful.
## Build
```sh
make
```
or even better
```sh
minimake
```
## How it works
If you're not familiar with Make, what it does is that it reads a file named
`Makefile` in the current directory which contains instructions to build a
project in the form of recipes. It includes support for variables, dependencies
, implicit rules and more.
Then depending on the user input it automatically executes a recipe with its dependencies.
Here is what a basic one can look like
```make
BENCH_FLAGS = --all
test_and_bench:
bash ./runtests.sh
bash ./runbenchs.sh $(BENCH_FLAGS)
```
But it will more realisticly look like that
```make
CC = gcc
CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla
LDFLAGS=
DBG_CFLAGS = -fsanitize=address -g
DBG_LDFLAGS= -fsanitize=address
SRC_DIR = src
LIB_SRCS = lines/lines.c hash_maps/hash_maps.c lists/lists.c files/files.c
MAIN_SRCS = main.c minimake.c
SRCS = $(MAIN_SRCS:%=$(SRC_DIR)/%) $(LIB_SRCS:%=$(SRC_DIR)/%)
OBJS = $(SRCS:.c=.o)
TARGET= minimake
DBG_TARGET = minimake-dbg
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
@echo $(OBJS)
debug: CFLAGS += $(DBG_CFLAGS)
debug: LDFLAGS += $(DBG_LDFLAGS)
debug: $(OBJS)
$(CC) -o $(DBG_TARGET) $^ $(LDFLAGS) $(LDLIBS)
check:
dash ./tests/run.sh
clean:
$(RM) $(TARGET)
$(RM) $(OBJS)
```