• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
24
25# ---- Configuration options ----
26
27# External/implicit variables:
28# - CXX: The C++ compiler, such as g++ or clang++.
29# - CXXFLAGS: Any extra user-specified compiler flags (can be blank).
30
31# Recommended compiler flags:
32CXXFLAGS += -std=c++11 -O
33
34# Extra flags for diagnostics:
35# CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
36
37
38# ---- Controlling make ----
39
40# Clear default suffix rules
41.SUFFIXES:
42
43# Don't delete object files
44.SECONDARY:
45
46# Stuff concerning goals
47.DEFAULT_GOAL = all
48.PHONY: all clean
49
50
51# ---- Targets to build ----
52
53LIB = qrcodegencpp
54LIBFILE = lib$(LIB).a
55LIBOBJ = qrcodegen.o
56MAINS = QrCodeGeneratorDemo
57
58# Build all binaries
59all: $(LIBFILE) $(MAINS)
60
61# Delete build output
62clean:
63	rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
64	rm -rf .deps
65
66# Executable files
67%: %.o $(LIBFILE)
68	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -L . -l $(LIB)
69
70# The library
71$(LIBFILE): $(LIBOBJ)
72	$(AR) -crs $@ -- $^
73
74# Object files
75%.o: %.cpp .deps/timestamp
76	$(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
77
78# Have a place to store header dependencies automatically generated by compiler
79.deps/timestamp:
80	mkdir -p .deps
81	touch .deps/timestamp
82
83# Make use of said dependencies if available
84-include .deps/*.d
85