-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
78 lines (60 loc) · 1.26 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
ifeq ($(OS), Windows_NT)
RM := del
MD := mkdir
CP := copy
SP := \\
else
RM := rm -fr
MD := mkdir -p
CP := cp
SP := /
endif
CC = gcc
AR = gcc
CFLAGS = -Wall -g
CFLAGS += -std=c99
CFLAGS += -O3
TARGET := ks
OBJ_DIR := obj
OUT_DIR := out
SRC_DIR := source
CMD_DIR := command
KSL_DIR := kserial
MAIN = main.c
SRC = serial.c \
kString.c \
kFile.c \
kLogger.c
CMD = kCommand.c \
kCommandHelp.c \
kCommandTarget.c \
kCommandTwi.c
KSL = kSerial.c
SRCS := $(MAIN) \
$(SRC) \
$(CMD) \
$(KSL)
INCS := -I $(SRC_DIR) \
-I $(CMD_DIR) \
-I $(KSL_DIR)
OBJS := $(MAIN:%.c=$(OBJ_DIR)$(SP)%.o) \
$(SRC:%.c=$(OBJ_DIR)$(SP)%.o) \
$(CMD:%.c=$(OBJ_DIR)$(SP)%.o) \
$(KSL:%.c=$(OBJ_DIR)$(SP)%.o)
$(TARGET): $(OBJS)
$(CC) -o $(OUT_DIR)$(SP)$(TARGET) $(OBJS) $(INCS)
@echo build program ... done ($(TARGET).exe)
$(OBJ_DIR)$(SP)%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@ $(INCS)
$(OBJ_DIR)$(SP)%.o: $(SRC_DIR)$(SP)%.c
$(CC) $(CFLAGS) -c $< -o $@ $(INCS)
$(OBJ_DIR)$(SP)%.o: $(CMD_DIR)$(SP)%.c
$(CC) $(CFLAGS) -c $< -o $@ $(INCS)
$(OBJ_DIR)$(SP)%.o: $(KSL_DIR)$(SP)%.c
$(CC) $(CFLAGS) -c $< -o $@ $(INCS)
.PHONY: clean
clean:
@if not exist $(OBJ_DIR) ($(MD) $(OBJ_DIR))
@if not exist $(OUT_DIR) ($(MD) $(OUT_DIR))
$(RM) $(OBJ_DIR)$(SP)*.o
$(RM) $(OUT_DIR)$(SP)*.exe