-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
60 lines (45 loc) · 1.79 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
CC=gcc
CFLAGS=-Wall -Wextra -std=c11
LDFLAGS = -ljpeg -lSDL2 -lm
SRC_DIR=source
BUILD_DIR=build
BIN_DIR=bin
COMMON_DIR=$(BUILD_DIR)/common
FEMBNG_DIR=$(BUILD_DIR)/fembng
FEMBNGAPP_DIR=$(BUILD_DIR)/fembngapp
# Create build directories if they don't exist
$(shell mkdir -p $(BIN_DIR) $(COMMON_DIR) $(FEMBNG_DIR) $(FEMBNGAPP_DIR))
# Common source files
SRCS_COMMON=$(wildcard $(SRC_DIR)/common/*.c)
OBJS_COMMON=$(patsubst $(SRC_DIR)/common/%.c, $(COMMON_DIR)/%.o, $(SRCS_COMMON))
# Source files for fembng
SRCS_FEMBNG=$(wildcard $(SRC_DIR)/fembng/*.c)
OBJS_FEMBNG=$(patsubst $(SRC_DIR)/fembng/%.c, $(FEMBNG_DIR)/%.o, $(SRCS_FEMBNG))
TARGET_FEMBNG=$(BIN_DIR)/fembng
# Source files for fembngapp
SRCS_FEMBNGAPP=$(wildcard $(SRC_DIR)/fembngapp/*.c)
OBJS_FEMBNGAPP=$(patsubst $(SRC_DIR)/fembngapp/%.c, $(FEMBNGAPP_DIR)/%.o, $(SRCS_FEMBNGAPP))
TARGET_FEMBNGAPP=$(BIN_DIR)/fembngapp
all: $(TARGET_FEMBNG) $(TARGET_FEMBNGAPP)
# Compile common source files
$(COMMON_DIR)/%.o: $(SRC_DIR)/common/%.c
$(CC) $(CFLAGS) -c -o $@ $<
# Compile fembng
$(TARGET_FEMBNG): $(OBJS_COMMON) $(OBJS_FEMBNG)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(FEMBNG_DIR)/%.o: $(SRC_DIR)/fembng/%.c
$(CC) $(CFLAGS) -c -o $@ $<
# Compile fembngapp
$(TARGET_FEMBNGAPP): $(OBJS_COMMON) $(OBJS_FEMBNGAPP)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(FEMBNGAPP_DIR)/%.o: $(SRC_DIR)/fembngapp/%.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -rf $(BUILD_DIR)/*.o $(BUILD_DIR)/common/*.o $(BUILD_DIR)/fembng/*.o $(BUILD_DIR)/fembngapp/*.o $(TARGET_FEMBNG) $(TARGET_FEMBNGAPP)
test: all
./$(TARGET_FEMBNG) -w 5000 -h 5000 -o test1
./$(TARGET_FEMBNGAPP) ./test1.femboy
check: clean all
valgrind ./$(TARGET_FEMBNG) -w 5000 -h 5000 -o test1
valgrind ./$(TARGET_FEMBNG) -c ./test.jpg -o testjpg
./$(TARGET_FEMBNGAPP) ./test1.femboy & ./$(TARGET_FEMBNGAPP) ./testjpg.femboy