-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
61 lines (48 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
DESTDIR?=/usr
PREFIX?=/local
ifneq ($V,1)
Q ?= @
endif
RASP=$$(cat /proc/cpuinfo | grep Model | cut -d ":" -f 2 | grep Pi | cut -d "i" -f 2 | cut -d "M" -f 1 | tr -d ' ')
NUM:=$(shell echo $(RASP))
CC = gcc
ifeq ($(NUM),5)
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe -DRPI5
else
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe
endif
LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
LIBS = -lpthread -lrt -lm -lcrypt -lgpiod
SRC = src/fan.c src/comm.c src/rpi_gpio.c
OBJ = $(SRC:.c=.o)
all: fan
fan: $(OBJ)
$Q echo [Link]
$Q $(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBS)
.c.o:
$Q echo [Compile] $<
$Q $(CC) -c $(CFLAGS) $< -o $@
.PHONY: clean
clean:
$Q echo "[Clean]"
$Q rm -f $(OBJ) fan *~ core tags *.bak
.PHONY: test
test:
$Q echo "[TEEST]"
$Q echo "Raspberry Pi" $(NUM) "detected"
$Q echo "Compile flags:" $(CFLAGS)
.PHONY: install
install: fan
$Q echo "[Install]"
$Q cp fan $(DESTDIR)$(PREFIX)/bin
ifneq ($(WIRINGPI_SUID),0)
$Q chown root:root $(DESTDIR)$(PREFIX)/bin/fan
$Q chmod 4755 $(DESTDIR)$(PREFIX)/bin/fan
endif
# $Q mkdir -p $(DESTDIR)$(PREFIX)/man/man1
# $Q cp megaio.1 $(DESTDIR)$(PREFIX)/man/man1
.PHONY: uninstall
uninstall:
$Q echo "[UnInstall]"
$Q rm -f $(DESTDIR)$(PREFIX)/bin/fan
$Q rm -f $(DESTDIR)$(PREFIX)/man/man1/fan.1