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