Gordons Projects

--> Projects Top-Level GIT

Updates to the build process
[wiringPi] / wiringPi / Makefile
1 # ;
2 # Makefile:
3 #       wiringPi - Wiring Compatable library for the Raspberry Pi
4 #
5 #       Copyright (c) 2012 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 DYN_VERS_MAJ=2
25 DYN_VERS_MIN=0
26
27 VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN)
28 DESTDIR=/usr
29 PREFIX=/local
30
31 STATIC=libwiringPi.a
32 DYNAMIC=libwiringPi.so.$(VERSION)
33
34 #DEBUG  = -g -O0
35 DEBUG   = -O2
36 CC      = gcc
37 INCLUDE = -I.
38 DEFS    = -D_GNU_SOURCE
39 CFLAGS  = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
40
41 LIBS    =
42
43 # Should not alter anything below this line
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 OBJ     =       $(SRC:.c=.o)
62
63 all:            $(DYNAMIC)
64
65 static:         $(STATIC)
66
67 $(STATIC):      $(OBJ)
68         @echo "[Link (Static)]"
69         @ar rcs $(STATIC) $(OBJ)
70         @ranlib $(STATIC)
71 #       @size   $(STATIC)
72
73 $(DYNAMIC):     $(OBJ)
74         @echo "[Link (Dynamic)]"
75         @$(CC) -shared -Wl,-soname,libwiringPi.so -o libwiringPi.so.$(VERSION) -lpthread $(OBJ)
76
77 .c.o:
78         @echo [Compile] $<
79         @$(CC) -c $(CFLAGS) $< -o $@
80
81 .PHONY: clean
82 clean:
83         @echo "[Clean]"
84         @rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*
85
86 .PHONY: tags
87 tags:   $(SRC)
88         @echo [ctags]
89         @ctags $(SRC)
90
91
92 .PHONY: install-headers
93 install-headers:
94         @echo "[Install Headers]"
95         @install -m 0755 -d                     $(DESTDIR)$(PREFIX)/include
96         @install -m 0644 wiringPi.h             $(DESTDIR)$(PREFIX)/include
97         @install -m 0644 wiringSerial.h         $(DESTDIR)$(PREFIX)/include
98         @install -m 0644 wiringShift.h          $(DESTDIR)$(PREFIX)/include
99         @install -m 0644 softPwm.h              $(DESTDIR)$(PREFIX)/include
100         @install -m 0644 softTone.h             $(DESTDIR)$(PREFIX)/include
101         @install -m 0644 wiringPiSPI.h          $(DESTDIR)$(PREFIX)/include
102         @install -m 0644 wiringPiI2C.h          $(DESTDIR)$(PREFIX)/include
103         @install -m 0644 drcSerial.h            $(DESTDIR)$(PREFIX)/include
104         @install -m 0644 mcp23008.h             $(DESTDIR)$(PREFIX)/include
105         @install -m 0644 mcp23016.h             $(DESTDIR)$(PREFIX)/include
106         @install -m 0644 mcp23017.h             $(DESTDIR)$(PREFIX)/include
107         @install -m 0644 mcp23s08.h             $(DESTDIR)$(PREFIX)/include
108         @install -m 0644 mcp23s17.h             $(DESTDIR)$(PREFIX)/include
109         @install -m 0644 max31855.h             $(DESTDIR)$(PREFIX)/include
110         @install -m 0644 max5322.h              $(DESTDIR)$(PREFIX)/include
111         @install -m 0644 mcp3002.h              $(DESTDIR)$(PREFIX)/include
112         @install -m 0644 mcp3004.h              $(DESTDIR)$(PREFIX)/include
113         @install -m 0644 mcp4802.h              $(DESTDIR)$(PREFIX)/include
114         @install -m 0644 mcp3422.h              $(DESTDIR)$(PREFIX)/include
115         @install -m 0644 sr595.h                $(DESTDIR)$(PREFIX)/include
116         @install -m 0644 pcf8574.h              $(DESTDIR)$(PREFIX)/include
117         @install -m 0644 pcf8591.h              $(DESTDIR)$(PREFIX)/include
118         @install -m 0644 sn3218.h               $(DESTDIR)$(PREFIX)/include
119         @install -m 0644 wpiExtensions.h        $(DESTDIR)$(PREFIX)/include
120
121 .PHONY: install
122 install:        $(DYNAMIC) install-headers
123         @echo "[Install Dynamic Lib]"
124         @install -m 0755 -d                                             $(DESTDIR)$(PREFIX)/lib
125         @install -m 0755 libwiringPi.so.$(VERSION)                      $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
126         @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)       $(DESTDIR)/lib/libwiringPi.so
127         @ldconfig
128
129 .PHONY: install-static
130 install-static: $(STATIC) install-headers
131         @echo "[Install Static Lib]"
132         @install -m 0755 -d                     $(DESTDIR)$(PREFIX)/lib
133         @install -m 0755 libwiringPi.a          $(DESTDIR)$(PREFIX)/lib
134
135 .PHONY: uninstall
136 uninstall:
137         @echo "[UnInstall]"
138         @rm -f $(DESTDIR)$(PREFIX)/include/wiringPi.h
139         @rm -f $(DESTDIR)$(PREFIX)/include/wiringSerial.h
140         @rm -f $(DESTDIR)$(PREFIX)/include/wiringShift.h
141         @rm -f $(DESTDIR)$(PREFIX)/include/softPwm.h
142         @rm -f $(DESTDIR)$(PREFIX)/include/softTone.h
143         @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiSPI.h
144         @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiI2C.h
145         @rm -f $(DESTDIR)$(PREFIX)/include/drcSerial.h
146         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23008.h
147         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23016.h
148         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23017.h
149         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s08.h
150         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s17.h
151         @rm -f $(DESTDIR)$(PREFIX)/include/max31855.h
152         @rm -f $(DESTDIR)$(PREFIX)/include/max5322.h
153         @rm -f $(DESTDIR)$(PREFIX)/include/mcp3002.h
154         @rm -f $(DESTDIR)$(PREFIX)/include/mcp3004.h
155         @rm -f $(DESTDIR)$(PREFIX)/include/mcp4802.h
156         @rm -f $(DESTDIR)$(PREFIX)/include/mcp3422.h
157         @rm -f $(DESTDIR)$(PREFIX)/include/sr595.h
158         @rm -f $(DESTDIR)$(PREFIX)/include/pcf8574.h
159         @rm -f $(DESTDIR)$(PREFIX)/include/pcf8591.h
160         @rm -f $(DESTDIR)$(PREFIX)/include/sn3218.h
161         @rm -f $(DESTDIR)$(PREFIX)/includewpiExtensions.h
162         @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.*
163         @ldconfig
164
165
166 .PHONY: depend
167 depend:
168         makedepend -Y $(SRC) $(SRC_I2C)
169
170 # DO NOT DELETE
171
172 wiringPi.o: softPwm.h softTone.h wiringPi.h
173 wiringSerial.o: wiringSerial.h
174 wiringShift.o: wiringPi.h wiringShift.h
175 piHiPri.o: wiringPi.h
176 piThread.o: wiringPi.h
177 wiringPiSPI.o: wiringPi.h wiringPiSPI.h
178 wiringPiI2C.o: wiringPi.h wiringPiI2C.h
179 softPwm.o: wiringPi.h softPwm.h
180 softTone.o: wiringPi.h softTone.h
181 mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h
182 mcp23016.o: wiringPi.h wiringPiI2C.h mcp23016.h mcp23016reg.h
183 mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h
184 mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h
185 mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h
186 sr595.o: wiringPi.h sr595.h
187 pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h
188 pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h
189 mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h
190 mcp3004.o: wiringPi.h wiringPiSPI.h mcp3004.h
191 mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h
192 mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h
193 max31855.o: wiringPi.h wiringPiSPI.h max31855.h
194 max5322.o: wiringPi.h wiringPiSPI.h max5322.h
195 sn3218.o: wiringPi.h wiringPiI2C.h sn3218.h
196 drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h
197 wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h
198 wpiExtensions.o: mcp23s17.h sr595.h pcf8591.h pcf8574.h max31855.h max5322.h
199 wpiExtensions.o: mcp3002.h mcp3004.h mcp4802.h mcp3422.h sn3218.h drcSerial.h
200 wpiExtensions.o: wpiExtensions.h