-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (67 loc) · 1.88 KB
/
Copy pathMakefile
File metadata and controls
81 lines (67 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Image Editor Makefile
# Supports both Windows (MSYS2/MinGW) and Linux
# Compiler settings
CXX = g++
CXXFLAGS = -std=c++17 -Wall -Wextra -O2
LDFLAGS =
# Windows-specific settings
ifeq ($(OS),Windows_NT)
LDFLAGS += -lws2_32
EXECUTABLE = image_editor.exe
RM = del /Q
MKDIR = mkdir
SEP = \\
else
EXECUTABLE = image_editor
RM = rm -f
MKDIR = mkdir -p
SEP = /
endif
# Directories
SRCDIR = src
BUILDDIR = build
OBJDIR = $(BUILDDIR)$(SEP)obj
# Source files
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
OBJECTS = $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
# Default target
all: $(BUILDDIR)/$(EXECUTABLE)
# Create build directory
$(OBJDIR):
$(MKDIR) $(OBJDIR)
# Compile object files
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Link executable
$(BUILDDIR)/$(EXECUTABLE): $(OBJECTS)
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
# Clean build files
clean:
ifeq ($(OS),Windows_NT)
if exist $(BUILDDIR) rmdir /s /q $(BUILDDIR)
else
$(RM) -r $(BUILDDIR)
endif
# Run the application
run: $(BUILDDIR)/$(EXECUTABLE)
cd $(BUILDDIR) && ./$(EXECUTABLE)
# Install dependencies (Windows with MSYS2)
install-deps-windows:
@echo "Make sure you have MSYS2 installed and run:"
@echo "pacman -S mingw-w64-x86_64-gcc"
@echo "pacman -S mingw-w64-x86_64-make"
# Install dependencies (Linux)
install-deps-linux:
@echo "Installing dependencies for Linux..."
sudo apt-get update
sudo apt-get install build-essential g++
# Help
help:
@echo "Available targets:"
@echo " all - Build the image editor application"
@echo " clean - Remove build files"
@echo " run - Build and run the application"
@echo " install-deps-windows - Show Windows dependency installation instructions"
@echo " install-deps-linux - Install Linux dependencies"
@echo " help - Show this help message"
.PHONY: all clean run install-deps-windows install-deps-linux help