chiark / gitweb /
wiringPi Version 2 - First commit (of v2)
[wiringPi.git] / 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 CFLAGS  = $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC
39
40 LIBS    =
41
42 # Should not alter anything below this line
43 ###############################################################################
44
45 SRC     =       wiringPi.c                                              \
46                 wiringSerial.c wiringShift.c                            \
47                 piHiPri.c piThread.c                                    \
48                 wiringPiSPI.c wiringPiI2C.c                             \
49                 softPwm.c softTone.c                                    \
50                 mcp23s08.c mcp23008.c                                   \
51                 mcp23s17.c mcp23017.c sr595.c pcf8574.c                 \
52                 mcp3002.c mcp4802.c mcp3422.c                           \
53                 drc.c
54
55 OBJ     =       $(SRC:.c=.o)
56
57 all:            $(DYNAMIC)
58
59 static:         $(STATIC)
60
61 $(STATIC):      $(OBJ)
62         @echo "[Link (Static)]"
63         @ar rcs $(STATIC) $(OBJ)
64         @ranlib $(STATIC)
65 #       @size   $(STATIC)
66
67 $(DYNAMIC):     $(OBJ)
68         @echo "[Link (Dynamic)]"
69         @$(CC) -shared -Wl,-soname,libwiringPi.so -o libwiringPi.so.$(VERSION) -lpthread $(OBJ)
70
71 .c.o:
72         @echo [Compile] $<
73         @$(CC) -c $(CFLAGS) $< -o $@
74
75 .PHONEY:        clean
76 clean:
77         @echo "[Clean]"
78         @rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*
79
80 .PHONEY:        tags
81 tags:   $(SRC)
82         @echo [ctags]
83         @ctags $(SRC)
84
85
86 .PHONEY:        install-headers
87 install-headers:
88         @echo "[Install Headers]"
89         @install -m 0755 -d                     $(DESTDIR)$(PREFIX)/include
90         @install -m 0644 wiringPi.h             $(DESTDIR)$(PREFIX)/include
91         @install -m 0644 wiringSerial.h         $(DESTDIR)$(PREFIX)/include
92         @install -m 0644 wiringShift.h          $(DESTDIR)$(PREFIX)/include
93         @install -m 0644 softPwm.h              $(DESTDIR)$(PREFIX)/include
94         @install -m 0644 softTone.h             $(DESTDIR)$(PREFIX)/include
95         @install -m 0644 wiringPiSPI.h          $(DESTDIR)$(PREFIX)/include
96         @install -m 0644 wiringPiI2C.h          $(DESTDIR)$(PREFIX)/include
97         @install -m 0644 mcp23008.h             $(DESTDIR)$(PREFIX)/include
98         @install -m 0644 mcp23017.h             $(DESTDIR)$(PREFIX)/include
99         @install -m 0644 mcp23s08.h             $(DESTDIR)$(PREFIX)/include
100         @install -m 0644 mcp23s17.h             $(DESTDIR)$(PREFIX)/include
101         @install -m 0644 mcp3002.h              $(DESTDIR)$(PREFIX)/include
102         @install -m 0644 mcp4802.h              $(DESTDIR)$(PREFIX)/include
103         @install -m 0644 mcp3422.h              $(DESTDIR)$(PREFIX)/include
104         @install -m 0644 sr595.h                $(DESTDIR)$(PREFIX)/include
105         @install -m 0644 pcf8574.h              $(DESTDIR)$(PREFIX)/include
106
107 .PHONEY:        install
108 install:        $(DYNAMIC) install-headers
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 .PHONEY:        install-static
116 install-static: $(STATIC) install-headers
117         @echo "[Install Static Lib]"
118         @install -m 0755 -d                     $(DESTDIR)$(PREFIX)/lib
119         @install -m 0755 libwiringPi.a          $(DESTDIR)$(PREFIX)/lib
120
121 .PHONEY:        uninstall
122 uninstall:
123         @echo "[UnInstall]"
124         @rm -f $(DESTDIR)$(PREFIX)/include/wiringPi.h
125         @rm -f $(DESTDIR)$(PREFIX)/include/wiringSerial.h
126         @rm -f $(DESTDIR)$(PREFIX)/include/wiringShift.h
127         @rm -f $(DESTDIR)$(PREFIX)/include/softPwm.h
128         @rm -f $(DESTDIR)$(PREFIX)/include/softTone.h
129         @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiSPI.h
130         @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiI2C.h
131         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23008.h
132         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23017.h
133         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s08.h
134         @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s17.h
135         @rm -f $(DESTDIR)$(PREFIX)/include/mcp3002.h
136         @rm -f $(DESTDIR)$(PREFIX)/include/mcp4802.h
137         @rm -f $(DESTDIR)$(PREFIX)/include/mcp3422.h
138         @rm -f $(DESTDIR)$(PREFIX)/include/sr595.h
139         @rm -f $(DESTDIR)$(PREFIX)/include/pcf8574.h
140         @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.*
141         @ldconfig
142
143
144 .PHONEY:        depend
145 depend:
146         makedepend -Y $(SRC) $(SRC_I2C)
147
148 # DO NOT DELETE
149
150 wiringPi.o: wiringPi.h
151 wiringSerial.o: wiringSerial.h
152 wiringShift.o: wiringPi.h wiringShift.h
153 piHiPri.o: wiringPi.h
154 piThread.o: wiringPi.h
155 wiringPiSPI.o: wiringPi.h wiringPiSPI.h
156 wiringPiI2C.o: wiringPi.h wiringPiI2C.h
157 softPwm.o: wiringPi.h softPwm.h
158 softTone.o: wiringPi.h softTone.h
159 mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h
160 mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h
161 mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h
162 mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h
163 sr595.o: wiringPi.h sr595.h
164 pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h
165 mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h
166 mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h
167 mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h
168 drc.o: wiringPi.h wiringSerial.h drc.h