-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (36 loc) · 820 Bytes
/
Copy pathMakefile
File metadata and controls
51 lines (36 loc) · 820 Bytes
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
# Makefile for the project
# Compiler
CC = gcc
# Compiler flags
CFLAGS = -Wall -g
# Linker flags
LDFLAGS = -lm
# Source files directory
SRCDIR = src
# Object files directory
OBJDIR = obj
# Executable name
TARGET = main
# Source files
SRC = $(SRCDIR)/calc_coordinate.c $(SRCDIR)/calc_surface.c $(SRCDIR)/main.c
# Object files
OBJ = $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
# Include directories
INCLUDES = -I$(SRCDIR)
# Create object directory if not exists
$(shell mkdir -p $(OBJDIR))
# Default target
all: $(TARGET)
# Build target
$(TARGET): $(OBJ)
@echo "Linking..."
$(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $@
# Build object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@echo "Compiling $<..."
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# Clean target
clean:
rm -rf $(OBJDIR) $(TARGET)
# Phony targets
.PHONY: all clean