-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathMakefile
53 lines (39 loc) · 1.21 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
PYTHON = python
CC = $(CROSS)gcc
AR = $(CROSS)ar
VERSION=$(shell head -n 1 VERSION)
INCDIR = include
CFLAGS = -Wall -I$(INCDIR) -Wextra -g -fPIC -DLIBI2C_VERSION="$(VERSION)"
LDSHFLAGS = -rdynamic -shared
ARFLAGS = rcv
CODE_STYLE = astyle --align-pointer=name --align-reference=name --suffix=none --break-blocks --pad-oper --pad-header --break-blocks --keep-one-line-blocks --indent-switches --indent=spaces
SOURCES=$(filter-out src/pyi2c.c, $(wildcard src/*.c))
HEADERS=$(wildcard $(INCDIR)/i2c/*.h)
OBJECTS=$(SOURCES:.c=.o)
TARGETS = libi2c.a libi2c.so pylibi2c.so
.PHONY:all clean example test install help style
.SILENT: clean
all:$(TARGETS) example
clean:
make -C example clean
find . -name "*.o" | xargs rm -f
$(RM) *.o *.so *~ a.out depend $(TARGETS) build -rf
help:
$(PYTHON) help.py
test:
$(PYTHON) -m unittest discover tests
style:
@find -regex '.*/.*\.\(c\|cpp\|h\)$$' | xargs $(CODE_STYLE)
install:
$(PYTHON) setup.py install
example:$(TARGETS)
make -C $@
libi2c.a:$(OBJECTS)
$(AR) $(ARFLAGS) $@ $^
libi2c.so:$(OBJECTS)
$(CC) $(LDSHFLAGS) -o $@ $^
pylibi2c.so:$(OBJECTS)
$(PYTHON) setup.py build_ext --inplace
depend:$(SOURCES) $(HEADERS) src/pyi2c.c
$(CC) $(CFLAGS) -MM $^ > $@
-include depend