-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (49 loc) · 1.66 KB
/
Makefile
File metadata and controls
62 lines (49 loc) · 1.66 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
# ***************************************************************************************
# Project: CLI Calculator Project
# File: Makefile
# Date: 2024-07-24
# Author: Navid Dezashibi
# Contact: navid@dezashibi.com
# Website: https://www.dezashibi.com | https://github.com/dezashibi
# License:
# Please refer to the LICENSE file in the repository or website for more information
# about the licensing of this work. If you have any questions or concerns,
# please feel free to contact me at the email address provided above.
# ***************************************************************************************
# * Description: Read the readme file for more information
# ***************************************************************************************
# Compiler to use
CC = gcc
# Compiler flags
CFLAGS = -Wall -Wextra -pedantic
# Executable name
TARGET = calc.exe
# Directories
SRCDIR = src
OBJDIR = obj
BUILDDIR = build
# Source files
SRCS = $(wildcard $(SRCDIR)/*.c)
# Object files
OBJS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRCS))
# Default target
all: $(BUILDDIR)/$(TARGET)
# Run the target
run: $(BUILDDIR)/$(TARGET)
./$(BUILDDIR)/$(TARGET) add 1 2 3
run_input: $(BUILDDIR)/$(TARGET)
./$(BUILDDIR)/$(TARGET) f input.clc
# Rule to link the object files and create the executable
$(BUILDDIR)/$(TARGET): $(OBJS)
mkdir -p $(BUILDDIR)
$(CC) $(CFLAGS) -o $@ $(OBJS)
# Rule to compile source files into object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
# Clean up the build files
clean:
rm -f $(BUILDDIR)/$(TARGET) $(OBJS)
rm -rf $(OBJDIR) $(BUILDDIR)
# Phony targets
.PHONY: all clean