-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·61 lines (47 loc) · 1.57 KB
/
Makefile
File metadata and controls
executable file
·61 lines (47 loc) · 1.57 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
# Compiler
CC = gcc
# Directories
SRC = ./src
INCLUDE = ./include
BIN = ./bin
BUILD = ./build
HELPING_DIR := $(SRC)/helping
# Compiler flags
CFLAGS = -pthread -Wall -g3 -std=c99 -I$(INCLUDE)
# Source files in src/helping
HELPING_SRCS := $(wildcard $(HELPING_DIR)/*.c)
# Object files for helping
HELPING_OBJS := $(patsubst $(HELPING_DIR)/%.c,$(BUILD)/%.o,$(HELPING_SRCS))
# Create directories if they don't exist
.PHONY: directories
directories:
@mkdir -p $(BIN) $(BUILD)
# Rule to build object files from helping source files
$(BUILD)/%.o: $(HELPING_DIR)/%.c | directories
$(CC) $(CFLAGS) -c -o $@ $<
# Source files
COMMANDER_SOURCE := $(SRC)/jobCommander.c
EXECUTOR_SOURCE := $(SRC)/jobExecutorServer.c
PROGDELAY_SOURCE := $(SRC)/progDelay.c
# Object files
COMMANDER_OBJECT := $(BUILD)/jobCommander.o $(HELPING_OBJS)
EXECUTOR_OBJECT := $(BUILD)/jobExecutorServer.o $(HELPING_OBJS)
PROGDELAY_OBJECT := $(BUILD)/progDelay.o
# Rule to build object files from main source files
$(BUILD)/%.o: $(SRC)/%.c | directories
$(CC) $(CFLAGS) -c -o $@ $<
# Targets
all: directories $(BIN)/jobCommander $(BIN)/jobExecutorServer $(BIN)/progDelay
$(BIN)/jobCommander: $(COMMANDER_OBJECT)
$(CC) $(CFLAGS) -o $@ $^
$(BIN)/jobExecutorServer: $(EXECUTOR_OBJECT)
$(CC) $(CFLAGS) -o $@ $^
$(BIN)/progDelay: $(PROGDELAY_OBJECT)
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f $(BIN)/jobCommander $(BIN)/jobExecutorServer $(BIN)/progDelay $(BUILD)/*.o
help:
@echo "Available targets:"
@echo " all: Build all executables"
@echo " clean: Clean object files and executables"
@echo " help: Display this help message"