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