-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
90 lines (64 loc) · 2.31 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
79
80
81
82
83
84
85
86
87
88
89
90
TARGET = FanControl
SRCDIR = src
OBJDIR = obj
BINDIR = .
#DEBUG = -g -O0
DEBUG = -O3
CC = gcc
INCLUDE = -I$(SRCDIR) -I./wiringPi/wiringPi/
CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
LDFLAGS = -L./wiringPi/wiringPi/
LDLIBS = -lwiringPi
DESTDIR = /usr
PREFIX = /local
###############################################################################
# May not need to alter anything below this line
###############################################################################
SRCS := $(foreach dir, $(SRCDIR), $(notdir $(wildcard $(dir)/*.c)))
INCLUDES := $(addprefix -include, $(addprefix $(SRCDIR)/, $(foreach dir, $(SRCDIR), $(notdir $(wildcard $(dir)/*.h)))))
OBJS := $(addprefix $(OBJDIR)/, $(patsubst %.c, %.o, $(SRCS)))
TBIN = $(addprefix $(BINDIR)/, $(TARGET))
DESTPATH = $(DESTDIR)$(PREFIX)
TINSTALL = $(addprefix $(DESTPATH)/bin/, $(TARGET))
SUBDIRS = $(SRCDIR) $(OBJDIR) $(BINDIR)
all: subdirs wiringPI $(TBIN)
@echo "Everything build! Have Fun with \""$(TBIN)"\" or \"make install\"!"
$(addprefix $(OBJDIR)/, %.o): $(addprefix $(SRCDIR)/, %.c)
@$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled \"$(<)\" -> \"$(@)\" successfully!"
$(TBIN): $(OBJS)
@$(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) $(INCLUDES) -o $(TBIN)
@echo "Linking \"$(TBIN)\" complete!"
.PHONY: subdirs
subdirs:
@for dir in $(SUBDIRS); do \
test -d $$dir || mkdir -p $$dir; \
done
.PHONY: install
install: all install-wiringPI
@sudo install -m 0775 -d $(DESTPATH)/bin
@sudo install -m 0755 -s -b $(TBIN) $(TINSTALL)
@echo "Installed \"$(TARGET)\" to \"$(TINSTALL)\" complete!"
.PHONY: clean
clean: clean-wiringPI
@$(RM) $(OBJS)
@echo "Cleaning up \"$(OBJDIR)\" complete!"
.PHONY: dist-clean
dist-clean: clean
@$(RM) $(TBIN)
@echo "Executable \"$(TBIN)\" removed!"
###############################################################################
# Handling wiringPi Makefile
###############################################################################
.PHONY: wiringPI
wiringPI:
@$(MAKE) -C ./wiringPi/wiringPi/ all
@echo "Making \"wiringPi2\" complete!"
.PHONY: clean-wiringPI
clean-wiringPI:
@$(MAKE) -C ./wiringPi/build xclean
@echo "Cleaning up \"wiringPi2\" complete!"
.PHONY: install-wiringPI
install-wiringPI:
./wiringPi/build
@echo "Installing \"wiringPi2\" complete!"