chiark / gitweb /
Makefiles: Honour LDCONFIG from the environment
[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 LDCONFIG?=ldconfig
29
30 ifneq ($V,1)
31 Q ?= @
32 endif
33
34 STATIC=libwiringPiDev.a
35 DYNAMIC=libwiringPiDev.so.$(VERSION)
36
37 #DEBUG  = -g -O0
38 DEBUG   = -O2
39 CC      = gcc
40 INCLUDE = -I.
41 DEFS    = -D_GNU_SOURCE
42 CFLAGS  = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
43
44 LIBS    =
45
46 ###############################################################################
47
48 SRC     =       ds1302.c maxdetect.c  piNes.c           \
49                 gertboard.c piFace.c                    \
50                 lcd128x64.c lcd.c                       \
51                 piGlow.c
52
53 OBJ     =       $(SRC:.c=.o)
54
55 HEADERS =       ds1302.h gertboard.h  lcd128x64.h  lcd.h  maxdetect.h piFace.h  piGlow.h  piNes.h
56
57 all:            $(DYNAMIC)
58
59 static:         $(STATIC)
60
61 $(STATIC):      $(OBJ)
62         $Q echo "[Link (Static)]"
63         $Q ar rcs $(STATIC) $(OBJ)
64         $Q ranlib $(STATIC)
65 #       @size   $(STATIC)
66
67 $(DYNAMIC):     $(OBJ)
68         $Q echo "[Link (Dynamic)]"
69         $Q $(CC) -shared -Wl,-soname,libwiringPiDev.so -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ)
70
71 .c.o:
72         $Q echo [Compile] $<
73         $Q $(CC) -c $(CFLAGS) $< -o $@
74
75 .PHONY: clean
76 clean:
77         $Q echo "[Clean]"
78         $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.*
79
80 .PHONY: tags
81 tags:   $(SRC)
82         $Q echo [ctags]
83         $Q ctags $(SRC)
84
85
86 .PHONY: install
87 install:        $(DYNAMIC)
88         $Q echo "[Install Headers]"
89         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/include
90         $Q install -m 0644 $(HEADERS)                                   $(DESTDIR)$(PREFIX)/include
91         $Q echo "[Install Dynamic Lib]"
92         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/lib
93         $Q install -m 0755 libwiringPiDev.so.$(VERSION)                 $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)
94         $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)  $(DESTDIR)/lib/libwiringPiDev.so
95         $Q $(LDCONFIG)
96
97 .PHONY: install-static
98 install-static: $(STATIC)
99         $Q echo "[Install Headers]"
100         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/include
101         $Q install -m 0644 $(HEADERS)                                   $(DESTDIR)$(PREFIX)/include
102         $Q echo "[Install Static Lib]"
103         $Q install -m 0755 -d                                           $(DESTDIR)$(PREFIX)/lib
104         $Q install -m 0755 libwiringPiDev.a                             $(DESTDIR)$(PREFIX)/lib
105
106 .PHONY: install-deb
107 install-deb:    $(DYNAMIC)
108         $Q echo "[Install Headers: deb]"
109         $Q install -m 0755 -d                                                   ~/wiringPi/debian-template/wiringPi/usr/include
110         $Q install -m 0644 $(HEADERS)                                           ~/wiringPi/debian-template/wiringPi/usr/include
111         $Q echo "[Install Dynamic Lib: deb]"
112         install -m 0755 -d                                                      ~/wiringPi/debian-template/wiringPi/usr/lib
113         install -m 0755 libwiringPiDev.so.$(VERSION)                            ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION)
114         ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so
115
116 .PHONY: uninstall
117 uninstall:
118         $Q echo "[UnInstall]"
119         $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
120         $Q cd $(DESTDIR)$(PREFIX)/lib/     && rm -f libwiringPiDev.*
121         $Q $(LDCONFIG)
122
123
124 .PHONY: depend
125 depend:
126         makedepend -Y $(SRC)
127
128 # DO NOT DELETE
129
130 ds1302.o: ds1302.h
131 maxdetect.o: maxdetect.h
132 piNes.o: piNes.h
133 gertboard.o: gertboard.h
134 piFace.o: piFace.h
135 lcd128x64.o: font.h lcd128x64.h
136 lcd.o: lcd.h
137 piGlow.o: piGlow.h