Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #
  2. # Makefile for QR Code generator (C++)
  3. #
  4. # Copyright (c) Project Nayuki. (MIT License)
  5. # https://www.nayuki.io/page/qr-code-generator-library
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy of
  8. # this software and associated documentation files (the "Software"), to deal in
  9. # the Software without restriction, including without limitation the rights to
  10. # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  11. # the Software, and to permit persons to whom the Software is furnished to do so,
  12. # subject to the following conditions:
  13. # - The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. # - The Software is provided "as is", without warranty of any kind, express or
  16. # implied, including but not limited to the warranties of merchantability,
  17. # fitness for a particular purpose and noninfringement. In no event shall the
  18. # authors or copyright holders be liable for any claim, damages or other
  19. # liability, whether in an action of contract, tort or otherwise, arising from,
  20. # out of or in connection with the Software or the use or other dealings in the
  21. # Software.
  22. #
  23. # ---- Configuration options ----
  24. # External/implicit variables:
  25. # - CXX: The C++ compiler, such as g++ or clang++.
  26. # - CXXFLAGS: Any extra user-specified compiler flags (can be blank).
  27. # Recommended compiler flags:
  28. CXXFLAGS += -std=c++11 -O
  29. # Extra flags for diagnostics:
  30. # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
  31. # ---- Controlling make ----
  32. # Clear default suffix rules
  33. .SUFFIXES:
  34. # Don't delete object files
  35. .SECONDARY:
  36. # Stuff concerning goals
  37. .DEFAULT_GOAL = all
  38. .PHONY: all clean
  39. # ---- Targets to build ----
  40. LIB = qrcodegencpp
  41. LIBFILE = lib$(LIB).a
  42. LIBOBJ = qrcodegen.o
  43. MAINS = QrCodeGeneratorDemo
  44. # Build all binaries
  45. all: $(LIBFILE) $(MAINS)
  46. # Delete build output
  47. clean:
  48. rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
  49. rm -rf .deps
  50. # Executable files
  51. %: %.o $(LIBFILE)
  52. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -L . -l $(LIB)
  53. # The library
  54. $(LIBFILE): $(LIBOBJ)
  55. $(AR) -crs $@ -- $^
  56. # Object files
  57. %.o: %.cpp .deps/timestamp
  58. $(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
  59. # Have a place to store header dependencies automatically generated by compiler
  60. .deps/timestamp:
  61. mkdir -p .deps
  62. touch .deps/timestamp
  63. # Make use of said dependencies if available
  64. -include .deps/*.d