~npisanti/rpiezos

rpiezos/Makefile -rw-r--r-- 1.2 KiB
e7ddea38Nicola Pisanti cleaning 3 months ago
                                                                                
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
# this is a lazy generic makefile 
# mostly from : 
# https://spin.atomicobject.com/2016/08/26/makefile-c-projects/

TARGET ?= bin/$(shell basename $(CURDIR))
SRC_DIRS ?= ./src
DESTDIR?=/usr/local/bin

CFLAGS += -std=c99 -pipe -finput-charset=UTF-8 -g -D_POSIX_C_SOURCE=200809L
CFLAGS += -Wall -Wwrite-strings 
CFLAGS += -Wconversion -Wshadow -Wstrict-prototypes
CFLAGS += -Werror=implicit-function-declaration -Werror=implicit-int
CFLAGS += -Werror=incompatible-pointer-types -Werror=int-conversion

# links for system libraries, for example liblo
CFLAGS += -llo

SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
OBJS := $(addsuffix .o,$(basename $(SRCS)))
DEPS := $(OBJS:.o=.d)

INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))

CFLAGS += $(INC_FLAGS) -MMD -MP

all: release

release: CFLAGS += -O3 -DNDEBUG
release: $(TARGET)

debug: CFLAGS += -DDEBUG -Wpedantic -Wextra 
debug: $(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LOADLIBES) $(LDLIBS)

-include $(DEPS)

install: all
	install -d $(DESTDIR)
	install $(TARGET) $(DESTDIR)

clean:
	$(RM) $(TARGET) $(OBJS) $(DEPS)

format:
	clang-format-8 -i $(SRCS)