Makefile 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #
  2. # Makefile:
  3. # wiringPi - 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. VERSION=$(shell cat ../VERSION)
  24. DESTDIR=/usr
  25. PREFIX=/local
  26. ifneq ($V,1)
  27. Q ?= @
  28. endif
  29. STATIC=libwiringPi.a
  30. DYNAMIC=libwiringPi.so.$(VERSION)
  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. LIBS =
  38. ###############################################################################
  39. SRC = wiringPi.c \
  40. wiringSerial.c wiringShift.c \
  41. piHiPri.c piThread.c \
  42. wiringPiSPI.c wiringPiI2C.c \
  43. softPwm.c softTone.c \
  44. mcp23008.c mcp23016.c mcp23017.c \
  45. mcp23s08.c mcp23s17.c \
  46. sr595.c \
  47. pcf8574.c pcf8591.c \
  48. mcp3002.c mcp3004.c mcp4802.c mcp3422.c \
  49. max31855.c max5322.c \
  50. sn3218.c \
  51. drcSerial.c \
  52. wpiExtensions.c
  53. HEADERS = wiringPi.h \
  54. wiringSerial.h wiringShift.h \
  55. wiringPiSPI.h wiringPiI2C.h \
  56. softPwm.h softTone.h \
  57. mcp23008.h mcp23016.h mcp23017.h \
  58. mcp23s08.h mcp23s17.h \
  59. sr595.h \
  60. pcf8574.h pcf8591.h \
  61. mcp3002.h mcp3004.h mcp4802.h mcp3422.h \
  62. max31855.h max5322.h \
  63. sn3218.h \
  64. drcSerial.h \
  65. wpiExtensions.h
  66. OBJ = $(SRC:.c=.o)
  67. all: $(DYNAMIC)
  68. static: $(STATIC)
  69. $(STATIC): $(OBJ)
  70. $Q echo "[Link (Static)]"
  71. $Q ar rcs $(STATIC) $(OBJ)
  72. $Q ranlib $(STATIC)
  73. # @size $(STATIC)
  74. $(DYNAMIC): $(OBJ)
  75. $Q echo "[Link (Dynamic)]"
  76. $Q $(CC) -shared -Wl,-soname,libwiringPi.so -o libwiringPi.so.$(VERSION) -lpthread $(OBJ)
  77. .c.o:
  78. $Q echo [Compile] $<
  79. $Q $(CC) -c $(CFLAGS) $< -o $@
  80. .PHONY: clean
  81. clean:
  82. $Q echo "[Clean]"
  83. $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.*
  84. .PHONY: tags
  85. tags: $(SRC)
  86. $Q echo [ctags]
  87. $Q ctags $(SRC)
  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 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION)
  96. $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so
  97. $Q ldconfig
  98. .PHONY: install-static
  99. install-static: $(STATIC)
  100. $Q echo "[Install Headers]"
  101. $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
  102. $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
  103. $Q echo "[Install Static Lib]"
  104. $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
  105. $Q install -m 0755 libwiringPi.a $(DESTDIR)$(PREFIX)/lib
  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 libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION)
  114. ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so
  115. .PHONY: uninstall
  116. uninstall:
  117. $Q echo "[UnInstall]"
  118. $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
  119. $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPi.*
  120. $Q ldconfig
  121. .PHONY: depend
  122. depend:
  123. makedepend -Y $(SRC) $(SRC_I2C)
  124. # DO NOT DELETE
  125. wiringPi.o: softPwm.h softTone.h wiringPi.h
  126. wiringSerial.o: wiringSerial.h
  127. wiringShift.o: wiringPi.h wiringShift.h
  128. piHiPri.o: wiringPi.h
  129. piThread.o: wiringPi.h
  130. wiringPiSPI.o: wiringPi.h wiringPiSPI.h
  131. wiringPiI2C.o: wiringPi.h wiringPiI2C.h
  132. softPwm.o: wiringPi.h softPwm.h
  133. softTone.o: wiringPi.h softTone.h
  134. mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h
  135. mcp23016.o: wiringPi.h wiringPiI2C.h mcp23016.h mcp23016reg.h
  136. mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h
  137. mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h
  138. mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h
  139. sr595.o: wiringPi.h sr595.h
  140. pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h
  141. pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h
  142. mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h
  143. mcp3004.o: wiringPi.h wiringPiSPI.h mcp3004.h
  144. mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h
  145. mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h
  146. max31855.o: wiringPi.h wiringPiSPI.h max31855.h
  147. max5322.o: wiringPi.h wiringPiSPI.h max5322.h
  148. sn3218.o: wiringPi.h wiringPiI2C.h sn3218.h
  149. drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h
  150. wpiExtensions.o: wiringPi.h mcp23008.h mcp23016.h mcp23017.h mcp23s08.h
  151. wpiExtensions.o: mcp23s17.h sr595.h pcf8574.h pcf8591.h mcp3002.h mcp3004.h
  152. wpiExtensions.o: mcp4802.h mcp3422.h max31855.h max5322.h sn3218.h
  153. wpiExtensions.o: drcSerial.h wpiExtensions.h