-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (60 loc) · 1.58 KB
/
Makefile
File metadata and controls
78 lines (60 loc) · 1.58 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
76
77
78
APP = itpu
SRCEXT = c
SRCDIR = src
OBJDIR = obj
BINDIR = build
SRCS := $(shell find $(SRCDIR) -name '*.$(SRCEXT)')
SRCDIRS := $(shell find . -name '*.$(SRCEXT)' -exec dirname {} \; | uniq)
OBJS := $(patsubst %.$(SRCEXT),$(OBJDIR)/%.o,$(SRCS))
DEBUG = -g
# maybe INCLUDES = -I../nmealib/include/nmea
INCLUDES = -I./nmealib/include -I./include
# CFLAGS = -Wall -ped6antic -c $(DEBUG) $(INCLUDES)
CFLAGS = $(INCLUDES) -Wall -c $(DEBUG)
#Its a static library so maybe different l-option? <-- check
LDFLAGS = -lncurses -L./nmealib/lib -lnmea -lm -pthread
ifeq ($(SRCEXT), cpp)
CC = $(CXX)
# else
# CFLAGS += -std=gnu99
endif
.PHONY: all clean distclean
all: $(BINDIR)/$(APP)
$(BINDIR)/$(APP): buildrepo $(OBJS)
@echo "Building NMEA-Library"
@cd nmealib; make
@echo "done"
@mkdir -p `dirname $@`
@echo "Linking $@..."
@echo $(CC) $(OBJS) $(LDFLAGS) -o $@
@$(CC) $(OBJS) $(LDFLAGS) -o $@
$(OBJDIR)/%.o: %.$(SRCEXT)
@echo "Generating dependencies for $<..."
@$(call make-depend,$<,$@,$(subst .o,.d,$@))
@echo "Compiling $<..."
@echo $(CC) $(CFLAGS) $< -o $@
@$(CC) $(CFLAGS) $< -o $@
clean:
@echo "Cleaning itpu..."
@$(RM) -r $(OBJDIR)
@$(RM) -r $(BINDIR)
distclean: clean
@echo "Cleaning NMEA-lib..."
@cd nmealib; make clean;
buildrepo:
@$(call make-repo)
define make-repo
for dir in $(SRCDIRS); \
do \
mkdir -p $(OBJDIR)/$$dir; \
done
endef
# usage: $(call make-depend,source-file,object-file,depend-file)
define make-depend
$(CC) -MM \
-MF $3 \
-MP \
-MT $2 \
$(CFLAGS) \
$1
endef