-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
44 lines (32 loc) · 957 Bytes
/
makefile
File metadata and controls
44 lines (32 loc) · 957 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
# Compiler to use
CC = gcc
# Compiler flags
CFLAGS = -Wall -Iinclude -O3 -s
# Directories
SRC_DIR = src
BUILD_DIR = build
# Source files
SRCS = $(wildcard $(SRC_DIR)/*.c)
# Object files
OBJS = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRCS))
# Target executable
TARGET = murpkg
# Default target
all: $(BUILD_DIR) $(TARGET)
# Rule to create the build directory if it doesn't exist
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Rule to link the object files into the final executable
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^
# Rule to compile the source files into object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
# Install target to install the executable to /usr/bin
install: $(TARGET)
install -Dm 0755 $(TARGET) $(DESTDIR)/usr/local/bin/$(TARGET)
install -Dm 0755 printsrcinfo $(DESTDIR)/usr/local/bin/printsrcinfo
# Clean target to remove generated files
clean:
rm -rf $(BUILD_DIR)/* $(TARGET)
.PHONY: all clean