-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
68 lines (56 loc) · 1.61 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
# Variables to override
#
# CC C compiler
# CROSSCOMPILE crosscompiler prefix, if any
# CFLAGS compiler flags for compiling all C files
# LDFLAGS linker flags for linking all binaries
# Initialize some variables if not set
LDFLAGS ?=
CC ?= $(CROSSCOMPILE)-gcc
CFLAGS := $(CFLAGS) -std=gnu99 -O2 -Wall
# Check that we're on a supported build platform
ifeq ($(CROSSCOMPILE),)
# Not crosscompiling, so check that we're on Linux.
ifneq ($(shell uname -s),Linux)
$(warning dht only works on Linux on a Raspberry Pi. Crosscompilation)
$(warning is supported by defining at least $$CROSSCOMPILE and $$MIX_TARGET.)
$(warning See Makefile for details. If using Nerves, this should be done automatically.)
$(warning )
$(warning Skipping C compilation unless targets explicitly passed to make.)
DEFAULT_TARGETS = priv
endif
endif
DEFAULT_TARGETS ?= priv priv/dht
ifeq ($(CI),true)
$(warning CI build)
DEFAULT_TARGETS = priv
endif
# Raspberry Platform
CFLAGS := $(CFLAGS) -D$(MIX_TARGET)
ifeq ($(MIX_TARGET),rpi)
SRC = $(wildcard src/*.c src/rpi/*.c)
endif
ifeq ($(MIX_TARGET),rpi0)
SRC = $(wildcard src/*.c src/rpi0/*.c)
endif
ifeq ($(MIX_TARGET),rpi2)
SRC = $(wildcard src/*.c src/rpi2/*.c)
endif
ifeq ($(MIX_TARGET),rpi3)
SRC = $(wildcard src/*.c src/rpi2/*.c)
endif
ifeq ($(MIX_TARGET),rpi4)
SRC = $(wildcard src/*.c src/rpi2/*.c)
endif
SRC ?=
OBJ=$(SRC:.c=.o)
.PHONY: all clean
all: $(DEFAULT_TARGETS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
priv:
mkdir -p priv
priv/dht: $(OBJ)
$(CC) $^ $(LDFLAGS) -o $@
clean:
rm -f priv/dht $(OBJ)