Gordons Projects

--> Projects Top-Level GIT

6bbcc5d54e357928686de250bc01653258ec70ec
[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 -Winline $(INCLUDE) -pipe -fPIC
43
44 LIBS    =
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                                    \
59                 sn3218.c                                                \
60                 drcSerial.c                                             \
61                 wpiExtensions.c
62
63 HEADERS =       wiringPi.h                                              \
64                 wiringSerial.h wiringShift.h                            \
65                 wiringPiSPI.h wiringPiI2C.h                             \
66                 softPwm.h softTone.h                                    \
67                 mcp23008.h mcp23016.h mcp23017.h                        \
68                 mcp23s08.h mcp23s17.h                                   \
69                 sr595.h                                                 \
70                 pcf8574.h pcf8591.h                                     \
71                 mcp3002.h mcp3004.h mcp4802.h mcp3422.h                 \
72                 max31855.h max5322.h                                    \
73                 sn3218.h                                                \
74                 drcSerial.h                                             \
75                 wpiExtensions.h 
76
77
78 OBJ     =       $(SRC:.c=.o)
79
80 all:            $(DYNAMIC)
81
82 static:         $(STATIC)
83
84 $(STATIC):      $(OBJ)
85         $Q echo "[Link (Static)]"
86         $Q ar rcs $(STATIC) $(OBJ)
87         $Q ranlib $(STATIC)
88 #       @size   $(STATIC)
89
90 $(DYNAMIC):     $(OBJ)
91         $Q echo "[Link (Dynamic)]"
92         $Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) -lpthread $(OBJ)
93
94 .c.o:
95         $Q echo [Compile] $<
96         $Q $(CC) -c $(CFLAGS) $< -o $@
97
98
99 .PHONY: clean
100 clean:
101         $Q echo "[Clean]"
102         $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*
103
104 .PHONY: tags
105 tags:   $(SRC)
106         $Q echo [ctags]
107         $Q ctags $(SRC)
108
109
110 .PHONY: install
111 install:        $(DYNAMIC)
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 Dynamic Lib]"
116         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/lib
117         $Q install -m 0755 libwiringPi.so.$(VERSION)                    $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
118         $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)     $(DESTDIR)/lib/libwiringPi.so
119         $Q $(LDCONFIG)
120
121 .PHONY: install-static
122 install-static: $(STATIC)
123         $Q echo "[Install Headers]"
124         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/include
125         $Q install -m 0644 $(HEADERS)                                   $(DESTDIR)$(PREFIX)/include
126         $Q echo "[Install Static Lib]"
127         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/lib
128         $Q install -m 0755 libwiringPi.a                                        $(DESTDIR)$(PREFIX)/lib
129
130 .PHONY: install-deb
131 install-deb:    $(DYNAMIC)
132         $Q echo "[Install Headers: deb]"
133         $Q install -m 0755 -d                                                   ~/wiringPi/debian-template/wiringPi/usr/include
134         $Q install -m 0644 $(HEADERS)                                           ~/wiringPi/debian-template/wiringPi/usr/include
135         $Q echo "[Install Dynamic Lib: deb]"
136         install -m 0755 -d                                                      ~/wiringPi/debian-template/wiringPi/usr/lib
137         install -m 0755 libwiringPi.so.$(VERSION)                               ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION)
138         ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION)    ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so
139
140 .PHONY: uninstall
141 uninstall:
142         $Q echo "[UnInstall]"
143         $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
144         $Q cd $(DESTDIR)$(PREFIX)/lib/     && rm -f libwiringPi.*
145         $Q $(LDCONFIG)
146
147
148 .PHONY: depend
149 depend:
150         makedepend -Y $(SRC) $(SRC_I2C)
151
152 # DO NOT DELETE
153
154 wiringPi.o: softPwm.h softTone.h wiringPi.h
155 wiringSerial.o: wiringSerial.h
156 wiringShift.o: wiringPi.h wiringShift.h
157 piHiPri.o: wiringPi.h
158 piThread.o: wiringPi.h
159 wiringPiSPI.o: wiringPi.h wiringPiSPI.h
160 wiringPiI2C.o: wiringPi.h wiringPiI2C.h
161 softPwm.o: wiringPi.h softPwm.h
162 softTone.o: wiringPi.h softTone.h
163 mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h
164 mcp23016.o: wiringPi.h wiringPiI2C.h mcp23016.h mcp23016reg.h
165 mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h
166 mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h
167 mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h
168 sr595.o: wiringPi.h sr595.h
169 pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h
170 pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h
171 mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h
172 mcp3004.o: wiringPi.h wiringPiSPI.h mcp3004.h
173 mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h
174 mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h
175 max31855.o: wiringPi.h wiringPiSPI.h max31855.h
176 max5322.o: wiringPi.h wiringPiSPI.h max5322.h
177 sn3218.o: wiringPi.h wiringPiI2C.h sn3218.h
178 drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h
179 wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h
180 wpiExtensions.o: mcp23s17.h sr595.h pcf8574.h pcf8591.h mcp3002.h mcp3004.h
181 wpiExtensions.o: mcp4802.h mcp3422.h max31855.h max5322.h sn3218.h
182 wpiExtensions.o: drcSerial.h wpiExtensions.h