-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (59 loc) · 1.41 KB
/
Copy pathMakefile
File metadata and controls
76 lines (59 loc) · 1.41 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# Software License Agreement (BSD License)
#
# Copyright (c) 2017, DUKELEC, Inc.
# All rights reserved.
#
# Author: Duke Fong <d@d-l.io>
#
INCLUDES = \
cdnet/parser \
cdnet/core \
cdnet/utils \
cdnet/dev \
cdnet/arch/pc \
ip \
tun \
usr
C_SOURCES = \
usr/main.c \
usr/cd_args.c \
cdnet/parser/cdnet.c \
cdnet/parser/cdnet_l0.c \
cdnet/parser/cdnet_l1.c \
cdnet/dev/cdbus_uart.c \
cdnet/arch/pc/arch_wrapper.c \
cdnet/utils/cd_list.c \
cdnet/utils/modbus_crc.c \
cdnet/utils/hex_dump.c \
dev_wrapper/cdbus_tty_wrapper.c \
dev_wrapper/linux_dev_wrapper.c \
ip/ip_cdnet_conversion.c \
ip/ip_checksum.c \
tun/tun.c
GIT_VERSION := $(shell git describe --dirty --always --tags)
CC = gcc
BUILD_DIR = build
TARGET = cdnet_tun
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
I_INCLUDES = $(foreach includedir,$(INCLUDES),-I$(includedir))
CFLAGS = $(I_INCLUDES) -DSW_VER=\"$(GIT_VERSION)\"
LDFLAGS =
ifeq ($(USE_SPI),1)
C_SOURCES += dev_wrapper/cdctl_spi_wrapper.c \
cdnet/dev/cdctl_pll_cal.c \
cdnet/dev/cdctl.c
LDFLAGS += -lgpiod
CFLAGS += -DUSE_SPI
endif
DEPS = $(foreach includedir,$(INCLUDES),$(wildcard $(includedir)/*.h))
$(BUILD_DIR)/%.o: %.c $(DEPS) Makefile | $(BUILD_DIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJECTS)
$(CC) -o $@ $^ $(LDFLAGS)
$(BUILD_DIR):
mkdir $@
.PHONY: clean
clean:
rm -rf $(BUILD_DIR) $(TARGET)