chiark / gitweb /
d62b5324e0640384b7fb063fa5e085cb1efa36ec
[wiringPi.git] / devLib / Makefile
1 #
2 # Makefile:
3 #       wiringPi device - 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=libwiringPiDev.a
29 DYNAMIC=libwiringPiDev.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     =       ds1302.c maxdetect.c  piNes.c           \
43                 gertboard.c piFace.c                    \
44                 lcd128x64.c lcd.c                       \
45                 piGlow.c
46
47 OBJ     =       $(SRC:.c=.o)
48
49 HEADERS =       ds1302.h gertboard.h  lcd128x64.h  lcd.h  maxdetect.h piFace.h  piGlow.h  piNes.h
50
51 all:            $(DYNAMIC)
52
53 static:         $(STATIC)
54
55 $(STATIC):      $(OBJ)
56         @echo "[Link (Static)]"
57         @ar rcs $(STATIC) $(OBJ)
58         @ranlib $(STATIC)
59 #       @size   $(STATIC)
60
61 $(DYNAMIC):     $(OBJ)
62         @echo "[Link (Dynamic)]"
63         @$(CC) -shared -Wl,-soname,libwiringPiDev.so -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ)
64
65 .c.o:
66         @echo [Compile] $<
67         @$(CC) -c $(CFLAGS) $< -o $@
68
69 .PHONY: clean
70 clean:
71         @echo "[Clean]"
72         @rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.*
73
74 .PHONY: tags
75 tags:   $(SRC)
76         @echo [ctags]
77         @ctags $(SRC)
78
79
80 .PHONY: install
81 install:        $(DYNAMIC)
82         @echo "[Install Headers]"
83         @install -m 0755 -d                                             $(DESTDIR)$(PREFIX)/include
84         @install -m 0644 $(HEADERS)                                     $(DESTDIR)$(PREFIX)/include
85         @echo "[Install Dynamic Lib]"
86         @install -m 0755 -d                                             $(DESTDIR)$(PREFIX)/lib
87         @install -m 0755 libwiringPiDev.so.$(VERSION)                   $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)
88         @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)    $(DESTDIR)/lib/libwiringPiDev.so
89         @ldconfig
90
91 .PHONY: install-static
92 install-static: $(STATIC)
93         @echo "[Install Headers]"
94         @install -m 0755 -d                                             $(DESTDIR)$(PREFIX)/include
95         @install -m 0644 $(HEADERS)                                     $(DESTDIR)$(PREFIX)/include
96         @echo "[Install Static Lib]"
97         @install -m 0755 -d                                             $(DESTDIR)$(PREFIX)/lib
98         @install -m 0755 libwiringPiDev.a                               $(DESTDIR)$(PREFIX)/lib
99
100 .PHONY: install-deb
101 install-deb:    $(DYNAMIC)
102         @echo "[Install Headers: deb]"
103         @install -m 0755 -d                                                     ~/wiringPi/debian/wiringPi/usr/include
104         @install -m 0644 $(HEADERS)                                             ~/wiringPi/debian/wiringPi/usr/include
105         @echo "[Install Dynamic Lib: deb]"
106         install -m 0755 -d                                                      ~/wiringPi/debian/wiringPi/usr/lib
107         install -m 0755 libwiringPiDev.so.$(VERSION)                            ~/wiringPi/debian/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION)
108         ln -sf ~/wiringPi/debian/wiringPi/usr/lib/libwiringPi.so.$(VERSION)     ~/wiringPi/debian/wiringPi/usr/lib/libwiringPiDev.so
109
110 .PHONY: uninstall
111 uninstall:
112         @echo "[UnInstall]"
113         @cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
114         @cd $(DESTDIR)$(PREFIX)/lib/     && rm -f libwiringPiDev.*
115         @ldconfig
116
117
118 .PHONY: depend
119 depend:
120         makedepend -Y $(SRC)
121
122 # DO NOT DELETE
123
124 ds1302.o: ds1302.h
125 maxdetect.o: maxdetect.h
126 piNes.o: piNes.h
127 gertboard.o: gertboard.h
128 piFace.o: piFace.h
129 lcd128x64.o: font.h lcd128x64.h
130 lcd.o: lcd.h
131 piGlow.o: piGlow.h