-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (32 loc) · 803 Bytes
/
Makefile
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
# Makefile
# Compiler
CC = gcc
# Compiler flags
CFLAGS = -Wall -Wextra
# Source directory
SRC_DIR = src
# Build directory for object files
BUILD_DIR = build
# Source files
SRCS = $(wildcard $(SRC_DIR)/*.c)
# Object files
OBJS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
# Target executable
TARGET = applyenv
.PHONY: test
test: $(TARGET)
@make $(TARGET)
@if [ $$? -eq 0 ]; then \
INTERPOLATION_TEST_VAR=Interpolated ./$(TARGET) --systemTest; \
fi
# Default target
all: $(TARGET)
# Rule for building the target executable
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
# Rule for compiling C source files into object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
# Clean rule to remove object files and the target executable
clean:
rm -f $(OBJS) $(TARGET)