chiark / gitweb /
Makefiles: Honour WIRINGPI_SUDO=0
[wiringPi.git] / gpio / Makefile
1 #
2 # Makefile:
3 #       The gpio command:
4 #         A swiss-army knige of GPIO shenanigans.
5 #       https://projects.drogon.net/wiring-pi
6 #
7 #       Copyright (c) 2012-2015 Gordon Henderson
8 #################################################################################
9 # This file is part of wiringPi:
10 #       Wiring Compatable library for the Raspberry Pi
11 #
12 #    wiringPi is free software: you can redistribute it and/or modify
13 #    it under the terms of the GNU Lesser General Public License as published by
14 #    the Free Software Foundation, either version 3 of the License, or
15 #    (at your option) any later version.
16 #
17 #    wiringPi is distributed in the hope that it will be useful,
18 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
19 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 #    GNU Lesser General Public License for more details.
21 #
22 #    You should have received a copy of the GNU Lesser General Public License
23 #    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
24 #################################################################################
25
26 DESTDIR?=/usr
27 PREFIX?=/local
28
29 ifneq ($V,1)
30 Q ?= @
31 endif
32
33 #DEBUG  = -g -O0
34 DEBUG   = -O2
35 CC      = gcc
36 INCLUDE = -I$(DESTDIR)$(PREFIX)/include
37 CFLAGS  = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
38
39 LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
40 LIBS    = -lwiringPi -lwiringPiDev -lpthread -lm
41
42 # May not need to  alter anything below this line
43 ###############################################################################
44
45 SRC     =       gpio.c readall.c pins.c
46
47 OBJ     =       $(SRC:.c=.o)
48
49 all:            gpio
50
51 version.h:      ../VERSION
52         ./newVersion
53
54 gpio:   $(OBJ)
55         $Q echo [Link]
56         $Q $(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBS)
57
58 .c.o:
59         $Q echo [Compile] $<
60         $Q $(CC) -c $(CFLAGS) $< -o $@
61
62 .PHONY: clean
63 clean:
64         $Q echo "[Clean]"
65         $Q rm -f $(OBJ) gpio *~ core tags *.bak
66
67 .PHONY: tags
68 tags:   $(SRC)
69         $Q echo [ctags]
70         $Q ctags $(SRC)
71
72 .PHONY: install
73 install: gpio
74         $Q echo "[Install]"
75         $Q cp gpio              $(DESTDIR)$(PREFIX)/bin
76 ifneq ($(WIRINGPI_SUID),0)
77         $Q chown root.root      $(DESTDIR)$(PREFIX)/bin/gpio
78         $Q chmod 4755           $(DESTDIR)$(PREFIX)/bin/gpio
79 endif
80         $Q mkdir -p             $(DESTDIR)$(PREFIX)/man/man1
81         $Q cp gpio.1            $(DESTDIR)$(PREFIX)/man/man1
82
83 .PHONY: install-deb
84 install-deb:    gpio
85         $Q echo "[Install: deb]"
86         $Q install -m 0755 -d                                                   ~/wiringPi/debian-template/wiringPi/usr/bin
87         $Q install -m 0755 gpio                                                 ~/wiringPi/debian-template/wiringPi/usr/bin
88
89 .PHONY: uninstall
90 uninstall:
91         $Q echo "[UnInstall]"
92         $Q rm -f $(DESTDIR)$(PREFIX)/bin/gpio
93         $Q rm -f $(DESTDIR)$(PREFIX)/man/man1/gpio.1
94
95 .PHONY: depend
96 depend:
97         makedepend -Y $(SRC)
98
99 # DO NOT DELETE