Gordons Projects

--> Projects Top-Level GIT

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