Gordons Projects

--> Projects Top-Level GIT

0a1283fdd69b94c545eb9ede867f75c2ef92d471
[wiringPi] / wiringPi / Makefile
1 #
2 # Makefile:
3 #       wiringPi - Wiring Compatable library for the Raspberry Pi
4 #
5 #       Copyright (c) 2012-2015 Gordon Henderson
6 #################################################################################
7 # This file is part of wiringPi:
8 #       https://projects.drogon.net/raspberry-pi/wiringpi/
9 #
10 #    wiringPi is free software: you can redistribute it and/or modify
11 #    it under the terms of the GNU Lesser General Public License as published by
12 #    the Free Software Foundation, either version 3 of the License, or
13 #    (at your option) any later version.
14 #
15 #    wiringPi is distributed in the hope that it will be useful,
16 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 #    GNU Lesser General Public License for more details.
19 #
20 #    You should have received a copy of the GNU Lesser General Public License
21 #    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
22 #################################################################################
23
24 VERSION=$(shell cat ../VERSION)
25 DESTDIR?=/usr
26 PREFIX?=/local
27
28 LDCONFIG?=ldconfig
29
30 ifneq ($V,1)
31 Q ?= @
32 endif
33
34 STATIC=libwiringPi.a
35 DYNAMIC=libwiringPi.so.$(VERSION)
36
37 #DEBUG  = -g -O0
38 DEBUG   = -O2
39 CC      = gcc
40 INCLUDE = -I.
41 DEFS    = -D_GNU_SOURCE
42 CFLAGS  = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC
43
44 LIBS    = -lm -lpthread -lrt
45
46 ###############################################################################
47
48 SRC     =       wiringPi.c                                              \
49                 wiringSerial.c wiringShift.c                            \
50                 piHiPri.c piThread.c                                    \
51                 wiringPiSPI.c wiringPiI2C.c                             \
52                 softPwm.c softTone.c                                    \
53                 mcp23008.c mcp23016.c mcp23017.c                        \
54                 mcp23s08.c mcp23s17.c                                   \
55                 sr595.c                                                 \
56                 pcf8574.c pcf8591.c                                     \
57                 mcp3002.c mcp3004.c mcp4802.c mcp3422.c                 \
58                 max31855.c max5322.c ads1115.c                          \
59                 sn3218.c                                                \
60                 bmp180.c htu21d.c ds18b20.c rht03.c                     \
61                 drcSerial.c drcNet.c                                    \
62                 pseudoPins.c                                            \
63                 wpiExtensions.c
64
65 HEADERS =       $(shell ls *.h)
66
67 OBJ     =       $(SRC:.c=.o)
68
69 all:            $(DYNAMIC)
70
71 static:         $(STATIC)
72
73 $(STATIC):      $(OBJ)
74         $Q echo "[Link (Static)]"
75         $Q ar rcs $(STATIC) $(OBJ)
76         $Q ranlib $(STATIC)
77 #       @size   $(STATIC)
78
79 $(DYNAMIC):     $(OBJ)
80         $Q echo "[Link (Dynamic)]"
81         $Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) $(LIBS) $(OBJ)
82
83 .c.o:
84         $Q echo [Compile] $<
85         $Q $(CC) -c $(CFLAGS) $< -o $@
86
87
88 .PHONY: clean
89 clean:
90         $Q echo "[Clean]"
91         $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*
92
93 .PHONY: tags
94 tags:   $(SRC)
95         $Q echo [ctags]
96         $Q ctags $(SRC)
97
98
99 .PHONY: install
100 install:        $(DYNAMIC)
101         $Q echo "[Install Headers]"
102         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/include
103         $Q install -m 0644 $(HEADERS)                                   $(DESTDIR)$(PREFIX)/include
104         $Q echo "[Install Dynamic Lib]"
105         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/lib
106         $Q install -m 0755 libwiringPi.so.$(VERSION)                    $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
107         $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)     $(DESTDIR)/lib/libwiringPi.so
108         $Q $(LDCONFIG)
109
110 .PHONY: install-static
111 install-static: $(STATIC)
112         $Q echo "[Install Headers]"
113         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/include
114         $Q install -m 0644 $(HEADERS)                                   $(DESTDIR)$(PREFIX)/include
115         $Q echo "[Install Static Lib]"
116         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/lib
117         $Q install -m 0755 libwiringPi.a                                        $(DESTDIR)$(PREFIX)/lib
118
119 .PHONY: install-deb
120 install-deb:    $(DYNAMIC)
121         $Q echo "[Install Headers: deb]"
122         $Q install -m 0755 -d                                                   ~/wiringPi/debian-template/wiringPi/usr/include
123         $Q install -m 0644 $(HEADERS)                                           ~/wiringPi/debian-template/wiringPi/usr/include
124         $Q echo "[Install Dynamic Lib: deb]"
125         install -m 0755 -d                                                      ~/wiringPi/debian-template/wiringPi/usr/lib
126         install -m 0755 libwiringPi.so.$(VERSION)                               ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION)
127         ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION)    ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so
128
129 .PHONY: uninstall
130 uninstall:
131         $Q echo "[UnInstall]"
132         $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
133         $Q cd $(DESTDIR)$(PREFIX)/lib/     && rm -f libwiringPi.*
134         $Q $(LDCONFIG)
135
136
137 .PHONY: depend
138 depend:
139         makedepend -Y $(SRC) $(SRC_I2C)
140
141 # DO NOT DELETE
142
143 wiringPi.o: softPwm.h softTone.h wiringPi.h ../version.h
144 wiringSerial.o: wiringSerial.h
145 wiringShift.o: wiringPi.h wiringShift.h
146 piHiPri.o: wiringPi.h
147 piThread.o: wiringPi.h
148 wiringPiSPI.o: wiringPi.h wiringPiSPI.h
149 wiringPiI2C.o: wiringPi.h wiringPiI2C.h
150 softPwm.o: wiringPi.h softPwm.h
151 softTone.o: wiringPi.h softTone.h
152 mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h
153 mcp23016.o: wiringPi.h wiringPiI2C.h mcp23016.h mcp23016reg.h
154 mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h
155 mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h
156 mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h
157 sr595.o: wiringPi.h sr595.h
158 pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h
159 pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h
160 mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h
161 mcp3004.o: wiringPi.h wiringPiSPI.h mcp3004.h
162 mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h
163 mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h
164 max31855.o: wiringPi.h wiringPiSPI.h max31855.h
165 max5322.o: wiringPi.h wiringPiSPI.h max5322.h
166 ads1115.o: wiringPi.h wiringPiI2C.h ads1115.h
167 sn3218.o: wiringPi.h wiringPiI2C.h sn3218.h
168 bmp180.o: wiringPi.h wiringPiI2C.h bmp180.h
169 htu21d.o: wiringPi.h wiringPiI2C.h htu21d.h
170 ds18b20.o: wiringPi.h ds18b20.h
171 drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h
172 pseudoPins.o: wiringPi.h pseudoPins.h
173 wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h
174 wpiExtensions.o: mcp23s17.h sr595.h pcf8574.h pcf8591.h mcp3002.h mcp3004.h
175 wpiExtensions.o: mcp4802.h mcp3422.h max31855.h max5322.h ads1115.h sn3218.h
176 wpiExtensions.o: drcSerial.h pseudoPins.h bmp180.h htu21d.h ds18b20.h
177 wpiExtensions.o: wpiExtensions.h