Make.rules 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # build rules for linuxtv.org dvb-apps
  2. CC = arm-linux-gnueabi-gcc
  3. CFLAGS ?= -g -Wall -W -Wshadow -Wpointer-arith -Wstrict-prototypes
  4. ifneq ($(lib_name),)
  5. # additional rules for libraries
  6. CFLAGS_LIB ?= -fPIC
  7. CFLAGS += $(CFLAGS_LIB)
  8. libraries = $(lib_name).so $(lib_name).a
  9. .PHONY: library
  10. library: $(libraries)
  11. $(libraries): $(objects)
  12. endif
  13. prerequisites = $(subst .o,.d,$(objects)) $(addsuffix .d,$(binaries))
  14. .PHONY: clean install
  15. ifeq ($(static),1)
  16. LDFLAGS += -static
  17. endif
  18. prefix ?= /usr
  19. bindir ?= $(prefix)/bin
  20. includedir ?= $(prefix)/include
  21. libdir ?= $(prefix)/lib
  22. sharedir ?= $(prefix)/share
  23. ifneq ($(DESTDIR),)
  24. DESTDIR := $(DESTDIR)/
  25. endif
  26. ifeq ($(V),1)
  27. %.o: %.c
  28. $(CC) -c $(CPPFLAGS) $(CFLAGS) -MMD -o $@ $< $(filter-out %.h %.c,$^)
  29. %: %.o
  30. $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS)
  31. %: %.c
  32. $(CC) $(CPPFLAGS) $(CFLAGS) -MMD $(LDFLAGS) -o $@ $< $(filter-out %.h %.c,$^) $(LOADLIBES) $(LDLIBS)
  33. %.so:
  34. $(CC) -shared -o $@ $^
  35. %.a:
  36. $(AR) rcs $@ $^
  37. clean::
  38. $(RM) -f $(prerequisites) $(objects) $(libraries) $(binaries) $(removing) *~
  39. install::
  40. ifneq ($(includes),)
  41. mkdir -p $(DESTDIR)$(includedir)/$(lib_name)
  42. install -m 644 $(includes) $(DESTDIR)$(includedir)/$(lib_name)/
  43. endif
  44. ifneq ($(libraries),)
  45. mkdir -p $(DESTDIR)$(libdir)
  46. install -m 644 $(libraries) $(DESTDIR)$(libdir)/
  47. endif
  48. ifneq ($(inst_bin),)
  49. mkdir -p $(DESTDIR)$(bindir)
  50. install -m 755 $(inst_bin) $(DESTDIR)$(bindir)/
  51. endif
  52. else
  53. %.o: %.c
  54. @echo CC $@
  55. @$(CC) -c $(CPPFLAGS) $(CFLAGS) -MMD -o $@ $< $(filter-out %.h %.c,$^)
  56. %: %.o
  57. @echo CC $@
  58. @$(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS)
  59. %: %.c
  60. @echo CC $@
  61. @$(CC) $(CPPFLAGS) $(CFLAGS) -MMD $(LDFLAGS) -o $@ $< $(filter-out %.h %.c,$^) $(LOADLIBES) $(LDLIBS)
  62. %.so:
  63. @echo CC $@
  64. @$(CC) -shared -o $@ $^
  65. %.a:
  66. @echo AR $@
  67. @$(AR) rcs $@ $^
  68. clean::
  69. @echo cleaning
  70. @$(RM) -f $(prerequisites) $(objects) $(libraries) $(binaries) $(removing) *~
  71. install::
  72. ifneq ($(includes),)
  73. @echo installing headers
  74. @mkdir -p $(DESTDIR)$(includedir)/$(lib_name)
  75. @install -m 644 $(includes) $(DESTDIR)$(includedir)/$(lib_name)/
  76. endif
  77. ifneq ($(libraries),)
  78. @echo installing libraries
  79. @mkdir -p $(DESTDIR)$(libdir)
  80. @install -m 644 $(libraries) $(DESTDIR)$(libdir)/
  81. endif
  82. ifneq ($(inst_bin),)
  83. @echo installing binaries
  84. @mkdir -p $(DESTDIR)$(bindir)
  85. @install -m 755 $(inst_bin) $(DESTDIR)$(bindir)/
  86. endif
  87. endif
  88. -include $(prerequisites)