Update Makefile
Update for better understating the progress stage
This commit is contained in:
34
Makefile
34
Makefile
@@ -1,5 +1,12 @@
|
|||||||
# Makefile for HTTP Server
|
# Makefile for HTTP Server
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
GREEN := \033[1;32m
|
||||||
|
YELLOW := \033[1;33m
|
||||||
|
RED := \033[1;31m
|
||||||
|
BLUE := \033[1;34m
|
||||||
|
NC := \033[0m
|
||||||
|
|
||||||
# Compiler and flags
|
# Compiler and flags
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra -O2 -D_GNU_SOURCE
|
CFLAGS = -Wall -Wextra -O2 -D_GNU_SOURCE
|
||||||
@@ -17,29 +24,44 @@ HEADERS = server_config.h
|
|||||||
# Include directories
|
# Include directories
|
||||||
INCLUDES = -I/usr/include/cjson
|
INCLUDES = -I/usr/include/cjson
|
||||||
|
|
||||||
|
# Count total number of source files
|
||||||
|
TOTAL_FILES := $(words $(SRCS))
|
||||||
|
CURRENT_FILE = 0
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
@echo "$(GREEN)Build complete! ✓$(NC)"
|
||||||
|
|
||||||
# Linking
|
# Linking
|
||||||
$(TARGET): $(OBJS)
|
$(TARGET): $(OBJS)
|
||||||
$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS) $(LIBS)
|
@echo "$(BLUE)Linking...$(NC)"
|
||||||
|
@$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS) $(LIBS) \
|
||||||
|
|| (echo "$(RED)Linking failed ✗$(NC)" && exit 1)
|
||||||
|
@echo "$(GREEN)Linking successful ✓$(NC)"
|
||||||
|
|
||||||
# Compilation
|
# Compilation with progress
|
||||||
%.o: %.c $(HEADERS)
|
%.o: %.c $(HEADERS)
|
||||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
@$(eval CURRENT_FILE=$(shell echo $$(($(CURRENT_FILE)+1))))
|
||||||
|
@echo "$(YELLOW)Building [$$(( $(CURRENT_FILE) * 100 / $(TOTAL_FILES) ))%] $<$(NC)"
|
||||||
|
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ \
|
||||||
|
|| (echo "$(RED)Compilation failed for $< ✗$(NC)" && exit 1)
|
||||||
|
|
||||||
# Clean build files
|
# Clean build files
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) $(TARGET)
|
@echo "$(BLUE)Cleaning build files...$(NC)"
|
||||||
|
@rm -f $(OBJS) $(TARGET)
|
||||||
|
@echo "$(GREEN)Clean complete ✓$(NC)"
|
||||||
|
|
||||||
# Install dependencies (for Debian/Ubuntu/Raspberry Pi OS)
|
# Install dependencies (for Debian/Ubuntu/Raspberry Pi OS)
|
||||||
install-deps:
|
install-deps:
|
||||||
sudo apt-get update
|
@echo "$(BLUE)Installing dependencies...$(NC)"
|
||||||
sudo apt-get install -y \
|
@sudo apt-get update
|
||||||
|
@sudo apt-get install -y \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
libcjson-dev \
|
libcjson-dev \
|
||||||
libmagic-dev \
|
libmagic-dev \
|
||||||
build-essential
|
build-essential
|
||||||
|
@echo "$(GREEN)Dependencies installed ✓$(NC)"
|
||||||
|
|
||||||
# Debug build
|
# Debug build
|
||||||
debug: CFLAGS += -g -DDEBUG
|
debug: CFLAGS += -g -DDEBUG
|
||||||
|
|||||||
Reference in New Issue
Block a user