-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
203 lines (175 loc) · 5.92 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#
# Set CROSS_PREFIX to prepend to all compiler tools at once for easier
# cross-compilation.
CROSS_PREFIX =
CC = $(CROSS_PREFIX)gcc
AR = $(CROSS_PREFIX)ar
RANLIB = $(CROSS_PREFIX)ranlib
SIZE = $(CROSS_PREFIX)size
STRIP = $(CROSS_PREFIX)strip
SHLIB = $(CC) -shared
STRIPLIB = $(STRIP) --strip-unneeded
PYTHON ?= python3
SOVERSION = 1
prefix ?= /usr/local
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
includedir ?= $(prefix)/include
libdir ?= $(prefix)/lib
mandir ?= $(prefix)/man
CFLAGS += -O3 -Wall -pthread -fpic $(CPPFLAGS)
#CFLAGS += -O0 -g -Wall -pthread -fpic
# -Wunused-local-typedefs -Wunused-macros -fno-common
LIB_LGPIO = liblgpio.so
LIB_RGPIO = librgpio.so
OBJ_LGPIO = \
lgCtx.o \
lgDbg.o \
lgErr.o \
lgGpio.o \
lgHdl.o \
lgI2C.o \
lgNotify.o \
lgPthAlerts.o \
lgPthTx.o \
lgSerial.o \
lgSPI.o \
lgThread.o \
lgUtil.o \
OBJ_RGPIO = \
rgpio.o \
lgCfg.o \
lgErr.o \
lgDbg.o \
lgMD5.o \
OBJ_RGPIOD = \
lgCfg.o \
lgCmd.o \
lgExec.o \
lgFile.o \
lgMD5.o \
lgPthSocket.o \
lgScript.o \
OBJ_RGS = \
lgCmd.o \
lgCfg.o \
lgDbg.o \
lgErr.o \
lgMD5.o \
DOCS = \
DOC/src/defs/rgs.def \
DOC/src/defs/rgpiod.def \
DOC/src/defs/permits.def \
DOC/src/defs/scripts.def \
lgpio.h \
rgpio.h \
LIB = $(LIB_LGPIO) $(LIB_RGPIO)
ALL = $(LIB) rgpiod rgs DOC/.docs
LINK_LGPIO = -L. -llgpio -pthread -lrt
LINK_RGPIO = -L. -lrgpio -pthread -lrt
all: $(ALL)
lib: $(LIB)
rgpio.o: rgpio.c lgpio.h lgCmd.h rgpio.h
$(CC) $(CFLAGS) -c -o rgpio.o rgpio.c
rgpiod: rgpiod.o $(OBJ_RGPIOD) $(LIB_LGPIO)
$(CC) $(LDFLAGS) -o rgpiod rgpiod.o $(OBJ_RGPIOD) $(LINK_LGPIO)
$(STRIP) rgpiod
rgs: rgs.o $(OBJ_RGS)
$(CC) $(LDFLAGS) -o rgs rgs.o $(OBJ_RGS)
$(STRIP) rgs
DOC/.docs: $(DOCS)
@[ -d "DOC" ] && cd DOC && ./cdoc || echo "*** No DOC directory ***"
touch DOC/.docs
clean:
rm -f *.o *.i *.s *~ $(ALL) *.so.$(SOVERSION)
ifeq ($(DESTDIR),)
PYBUILDARGS =
PYINSTALLARGS =
else
PYBUILDARGS = --include-dirs=$(DESTDIR)$(includedir) --library-dirs=$(DESTDIR)$(libdir)
PYINSTALLARGS = --root=$(DESTDIR)
endif
html: $(ALL)
@[ -d "DOC" ] && cd DOC && ./makedoc || echo "*** No DOC directory ***"
install: $(ALL)
@install -m 0755 -d $(DESTDIR)$(includedir)
install -m 0644 lgpio.h $(DESTDIR)$(includedir)
install -m 0644 rgpio.h $(DESTDIR)$(includedir)
@install -m 0755 -d $(DESTDIR)$(libdir)
install -m 0755 liblgpio.so.$(SOVERSION) $(DESTDIR)$(libdir)
install -m 0755 librgpio.so.$(SOVERSION) $(DESTDIR)$(libdir)
@cd $(DESTDIR)$(libdir) && ln -fs liblgpio.so.$(SOVERSION) liblgpio.so
@cd $(DESTDIR)$(libdir) && ln -fs librgpio.so.$(SOVERSION) librgpio.so
@install -m 0755 -d $(DESTDIR)$(bindir)
install -m 0755 rgpiod $(DESTDIR)$(bindir)
install -m 0755 rgs $(DESTDIR)$(bindir)
@install -m 0755 -d $(DESTDIR)$(mandir)/man1
install -m 0644 rgpiod.1 $(DESTDIR)$(mandir)/man1
install -m 0644 rgs.1 $(DESTDIR)$(mandir)/man1
@install -m 0755 -d $(DESTDIR)$(mandir)/man3
install -m 0644 lgpio.3 $(DESTDIR)$(mandir)/man3
install -m 0644 rgpio.3 $(DESTDIR)$(mandir)/man3
ifeq ($(DESTDIR),)
ldconfig
endif
@if which $(PYTHON); then cd PY_RGPIO && $(PYTHON) setup.py -q install $(PYINSTALLARGS) || echo "*** install of Python3 rgpio.py failed ***"; fi
@if which swig $(PYTHON); then \
cd PY_LGPIO && \
$(PYTHON) setup.py build_ext $(PYBUILDARGS) && \
$(PYTHON) setup.py -q install $(PYINSTALLARGS) || \
echo "*** install of Python3 lgpio.py failed ***"; \
fi
uninstall:
rm -f $(DESTDIR)$(includedir)/lgpio.h
rm -f $(DESTDIR)$(includedir)/rgpio.h
rm -f $(DESTDIR)$(libdir)/liblgpio.so
rm -f $(DESTDIR)$(libdir)/librgpio.so
rm -f $(DESTDIR)$(libdir)/liblgpio.so.$(SOVERSION)
rm -f $(DESTDIR)$(libdir)/librgpio.so.$(SOVERSION)
rm -f $(DESTDIR)$(bindir)/rgpiod
rm -f $(DESTDIR)$(bindir)/rgs
rm -f $(DESTDIR)$(mandir)/man1/rgpiod.1
rm -f $(DESTDIR)$(mandir)/man1/rgs.1
rm -f $(DESTDIR)$(mandir)/man3/lgpio.3
rm -f $(DESTDIR)$(mandir)/man3/rgpio.3
ifeq ($(DESTDIR),)
ldconfig
endif
$(LIB_LGPIO): $(OBJ_LGPIO)
$(SHLIB) -pthread $(LDFLAGS) -Wl,-soname,$(LIB_LGPIO).$(SOVERSION) -o $(LIB_LGPIO).$(SOVERSION) $(OBJ_LGPIO)
ln -fs $(LIB_LGPIO).$(SOVERSION) $(LIB_LGPIO)
$(STRIPLIB) $(LIB_LGPIO)
$(SIZE) $(LIB_LGPIO)
$(LIB_RGPIO): $(OBJ_RGPIO)
$(SHLIB) -pthread $(LDFLAGS) -Wl,-soname,$(LIB_RGPIO).$(SOVERSION) -o $(LIB_RGPIO).$(SOVERSION) $(OBJ_RGPIO)
ln -fs $(LIB_RGPIO).$(SOVERSION) $(LIB_RGPIO)
$(STRIPLIB) $(LIB_RGPIO)
$(SIZE) $(LIB_RGPIO)
# generated using gcc -MM *.c
lgCfg.o: lgCfg.c lgCfg.h
lgCmd.o: lgCmd.c lgpio.h rgpiod.h lgCmd.h lgDbg.h
lgCtx.o: lgCtx.c lgpio.h lgDbg.h lgCtx.h
lgDbg.o: lgDbg.c lgpio.h lgDbg.h
lgErr.o: lgErr.c lgpio.h
lgExec.o: lgExec.c lgpio.h rgpiod.h lgCmd.h lgCfg.h lgCtx.h lgDbg.h \
lgHdl.h lgMD5.h
lgFile.o: lgFile.c lgpio.h rgpiod.h lgCmd.h lgDbg.h lgHdl.h
lgGpio.o: lgGpio.c lgpio.h lgDbg.h lgGpio.h lgHdl.h lgPthAlerts.h \
lgPthTx.h
lgHdl.o: lgHdl.c lgpio.h lgCtx.h lgDbg.h lgHdl.h
lgI2C.o: lgI2C.c lgpio.h lgDbg.h lgHdl.h
lgMD5.o: lgMD5.c lgpio.h lgMD5.h lgCfg.h
lgNotify.o: lgNotify.c lgpio.h lgDbg.h lgHdl.h
lgPthAlerts.o: lgPthAlerts.c lgDbg.h lgHdl.h lgpio.h lgGpio.h \
lgPthAlerts.h
lgPthSocket.o: lgPthSocket.c lgpio.h rgpiod.h lgCmd.h lgCtx.h lgDbg.h \
lgHdl.h
lgPthTx.o: lgPthTx.c lgDbg.h lgHdl.h lgpio.h lgPthTx.h lgGpio.h
lgScript.o: lgScript.c lgpio.h rgpiod.h lgCmd.h lgCtx.h lgDbg.h lgHdl.h
lgSerial.o: lgSerial.c lgpio.h lgDbg.h lgHdl.h
lgSPI.o: lgSPI.c lgpio.h lgDbg.h lgHdl.h
lgThread.o: lgThread.c lgpio.h lgDbg.h
lgUtil.o: lgUtil.c lgpio.h lgDbg.h
rgpio.o: rgpio.c rgpiod.h lgCmd.h lgpio.h rgpio.h lgCfg.h lgDbg.h lgMD5.h
rgpiod.o: rgpiod.c lgpio.h rgpiod.h lgCmd.h lgDbg.h
rgs.o: rgs.c lgpio.h rgpiod.h lgCmd.h lgDbg.h lgMD5.h