undar-lang/src/Makefile

40 lines
730 B
Makefile

# Compiler and flags
CC = gcc
CFLAGS += -std=c89 -g -Wall -Wextra -Werror -Wno-unused-parameter
LDFLAGS +=
LDLIBS +=
# Source and build configuration
SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)
EXEC = zre
# Phony targets
.PHONY: all clean test install
# Default target
all: $(EXEC)
# Main build rule
$(EXEC): $(OBJ)
$(CC) $(LDFLAGS) $(OBJ) $(LDLIBS) -o $@
# Pattern rule for object files
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Test target with dependency
test: $(EXEC)
@echo "Running tests..."
./$(EXEC)
@echo "Tests completed successfully."
# Clean build artifacts
clean:
$(RM) $(OBJ) $(EXEC)
# Install target (example)
install: $(EXEC)
install -d $(DESTDIR)/usr/local/bin
install $(EXEC) $(DESTDIR)/usr/local/bin/