-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
54 lines (40 loc) · 1.02 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
# General definitions
TARGET = edl_cli
CFLAGS = -Wall -g -Og
LDFLAGS = -lrt -lpthread
# Include OpenCCSDS sources
CCSDS_ROOT = OpenCCSDS
include $(CCSDS_ROOT)/ccsds.mk
# Define application sources
SRCDIR = src
EDL_INC = include
EDL_SRC = $(SRCDIR)/common.c \
$(SRCDIR)/client.c \
$(SRCDIR)/cmd.c \
$(SRCDIR)/file.c \
$(SRCDIR)/main.c
# All sources
INC := $(CCSDS_INC) $(EDL_INC)
CSRC := $(CCSDS_SRC) $(EDL_SRC)
# Output and dependency directories
BUILDDIR = build
DEPDIR := $(BUILDDIR)/.dep
VPATH := $(sort $(dir $(CSRC)))
OBJS := $(addprefix $(BUILDDIR)/, $(notdir $(CSRC:.c=.o)))
INCDIR := $(patsubst %,-I%,$(INC))
# Generate dependencies
CFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d
all: $(OBJS) $(TARGET)
$(OBJS): | $(BUILDDIR) $(DEPDIR)
$(BUILDDIR):
@mkdir -p $(BUILDDIR)
$(DEPDIR):
@mkdir -p $(DEPDIR)
$(OBJS): $(BUILDDIR)/%.o : %.c $(MAKEFILE_LIST)
$(CC) -c $(CFLAGS) -I. $(INCDIR) $< -o $@
$(TARGET): $(OBJS)
$(CC) $(OBJS) $(LDFLAGS) -o $@
clean:
@rm -rf $(BUILDDIR) $(TARGET)
print-%:
@echo '$*=$($*)'