Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. VERSION=$(shell cat ../VERSION)
  24. DESTDIR=/usr
  25. PREFIX=/local
  26. ifneq ($V,1)
  27. Q ?= @
  28. endif
  29. STATIC=libwiringPiDev.a
  30. DYNAMIC=libwiringPiDev.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 = ds1302.c maxdetect.c piNes.c \
  40. gertboard.c piFace.c \
  41. lcd128x64.c lcd.c \
  42. piGlow.c
  43. OBJ = $(SRC:.c=.o)
  44. HEADERS = ds1302.h gertboard.h lcd128x64.h lcd.h maxdetect.h piFace.h piGlow.h piNes.h
  45. all: $(DYNAMIC)
  46. static: $(STATIC)
  47. $(STATIC): $(OBJ)
  48. $Q echo "[Link (Static)]"
  49. $Q ar rcs $(STATIC) $(OBJ)
  50. $Q ranlib $(STATIC)
  51. # @size $(STATIC)
  52. $(DYNAMIC): $(OBJ)
  53. $Q echo "[Link (Dynamic)]"
  54. $Q $(CC) -shared -Wl,-soname,libwiringPiDev.so -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ)
  55. .c.o:
  56. $Q echo [Compile] $<
  57. $Q $(CC) -c $(CFLAGS) $< -o $@
  58. .PHONY: clean
  59. clean:
  60. $Q echo "[Clean]"
  61. $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.*
  62. .PHONY: tags
  63. tags: $(SRC)
  64. $Q echo [ctags]
  65. $Q ctags $(SRC)
  66. .PHONY: install
  67. install: $(DYNAMIC)
  68. $Q echo "[Install Headers]"
  69. $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
  70. $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
  71. $Q echo "[Install Dynamic Lib]"
  72. $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
  73. $Q install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)
  74. $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so
  75. $Q ldconfig
  76. .PHONY: install-static
  77. install-static: $(STATIC)
  78. $Q echo "[Install Headers]"
  79. $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
  80. $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
  81. $Q echo "[Install Static Lib]"
  82. $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
  83. $Q install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib
  84. .PHONY: install-deb
  85. install-deb: $(DYNAMIC)
  86. $Q echo "[Install Headers: deb]"
  87. $Q install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/include
  88. $Q install -m 0644 $(HEADERS) ~/wiringPi/debian-template/wiringPi/usr/include
  89. $Q echo "[Install Dynamic Lib: deb]"
  90. install -m 0755 -d ~/wiringPi/debian-template/wiringPi/usr/lib
  91. install -m 0755 libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION)
  92. ln -sf ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) ~/wiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so
  93. .PHONY: uninstall
  94. uninstall:
  95. $Q echo "[UnInstall]"
  96. $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
  97. $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPiDev.*
  98. $Q ldconfig
  99. .PHONY: depend
  100. depend:
  101. makedepend -Y $(SRC)
  102. # DO NOT DELETE
  103. ds1302.o: ds1302.h
  104. maxdetect.o: maxdetect.h
  105. piNes.o: piNes.h
  106. gertboard.o: gertboard.h
  107. piFace.o: piFace.h
  108. lcd128x64.o: font.h lcd128x64.h
  109. lcd.o: lcd.h
  110. piGlow.o: piGlow.h