-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
41 lines (31 loc) · 960 Bytes
/
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
DIR_OBJ = ./lib
DIR_BIN = ./bin
DIR_Config = ./lib/Config
DIR_Examples = ./examples
OBJ_C = $(wildcard ${DIR_OBJ}/*.c ${DIR_Examples}/*.c ${DIR_Config}/*.c)
OBJ_O = $(patsubst %.c,${DIR_BIN}/%.o,$(notdir ${OBJ_C}))
TARGET = main
#BIN_TARGET = ${DIR_BIN}/${TARGET}
CC = gcc
DEBUG = -g -O0 -Wall
CFLAGS += $(DEBUG)
# USELIB = USE_BCM2835_LIB
# USELIB = USE_WIRINGPI_LIB
USELIB = USE_DEV_LIB
DEBUG = -D $(USELIB)
ifeq ($(USELIB), USE_BCM2835_LIB)
LIB = -lbcm2835 -lm
else ifeq ($(USELIB), USE_WIRINGPI_LIB)
LIB = -lwiringPi -lm
endif
${TARGET}:${OBJ_O}
$(CC) $(CFLAGS) $(OBJ_O) -o $@ $(LIB)
${DIR_BIN}/%.o : $(DIR_Examples)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LIB) -I $(DIR_OBJ) -I $(DIR_Config)
${DIR_BIN}/%.o : $(DIR_OBJ)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LIB) -I $(DIR_Config)
${DIR_BIN}/%.o : $(DIR_Config)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LIB)
clean :
rm $(DIR_BIN)/*.*
rm $(TARGET)