Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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-2016 Gordon Henderson
  8. #################################################################################
  9. # This file is part of wiringPi:
  10. # A "wiring" 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. DESTDIR?=/usr
  26. PREFIX?=/local
  27. ifneq ($V,1)
  28. Q ?= @
  29. endif
  30. #DEBUG = -g -O0
  31. DEBUG = -O2
  32. CC = gcc
  33. INCLUDE = -I$(DESTDIR)$(PREFIX)/include
  34. CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe
  35. LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
  36. LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt
  37. # May not need to alter anything below this line
  38. ###############################################################################
  39. SRC = gpio.c readall.c
  40. OBJ = $(SRC:.c=.o)
  41. all: gpio
  42. version.h: ../VERSION
  43. $Q echo Need to run newVersion above.
  44. gpio: $(OBJ)
  45. $Q echo [Link]
  46. $Q $(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBS)
  47. .c.o:
  48. $Q echo [Compile] $<
  49. $Q $(CC) -c $(CFLAGS) $< -o $@
  50. .PHONY: clean
  51. clean:
  52. $Q echo "[Clean]"
  53. $Q rm -f $(OBJ) gpio *~ core tags *.bak
  54. .PHONY: tags
  55. tags: $(SRC)
  56. $Q echo [ctags]
  57. $Q ctags $(SRC)
  58. .PHONY: install
  59. install: gpio
  60. $Q echo "[Install]"
  61. $Q cp gpio $(DESTDIR)$(PREFIX)/bin
  62. ifneq ($(WIRINGPI_SUID),0)
  63. $Q chown root.root $(DESTDIR)$(PREFIX)/bin/gpio
  64. $Q chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio
  65. endif
  66. $Q mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1
  67. $Q cp gpio.1 $(DESTDIR)$(PREFIX)/share/man/man1
  68. .PHONY: check-deb-destdir
  69. check-deb-destdir:
  70. ifndef DEB_DESTDIR
  71. $(error DEB_DESTDIR is undefined)
  72. endif
  73. .PHONY: install-deb
  74. install-deb: gpio check-deb-destdir
  75. $Q echo "[Install: deb]"
  76. $Q install -m 0755 -d $(DEB_DESTDIR)/usr/bin
  77. $Q install -m 0755 gpio $(DEB_DESTDIR)/usr/bin
  78. $Q install -m 0755 -d $(DEB_DESTDIR)/usr/share/man/man1
  79. $Q install -m 0644 gpio.1 $(DEB_DESTDIR)/usr/share/man/man1
  80. .PHONY: uninstall
  81. uninstall:
  82. $Q echo "[UnInstall]"
  83. $Q rm -f $(DESTDIR)$(PREFIX)/bin/gpio
  84. $Q rm -f $(DESTDIR)$(PREFIX)/share/man/man1/gpio.1
  85. .PHONY: depend
  86. depend:
  87. makedepend -Y $(SRC)
  88. # DO NOT DELETE
  89. gpio.o: ../version.h