blob: 5989b95d9b681eaf2970787a7a9f2de04f89c4cb [file] [log] [blame]
Elliott Hughesd173c992019-01-10 14:51:35 -08001# For GNU conventions and targets see https://www.gnu.org/prep/standards/standards.html
2# Using GNU standards makes it easier for some users to keep doing what they are used to.
3
4# 'mkdir -p' is non-portable, but it is widely supported. A portable solution
5# is elusive due to race conditions on testing the directory and creating it.
6# Anemic toolchain users can sidestep the problem using MKDIR="mkdir".
7
8AR = ar
9ARFLAGS = cr
10RM = rm -f
11RANLIB = ranlib
12MKDIR = mkdir -p
13CXXFLAGS = -fPIC
14
15INSTALL = install
16INSTALL_PROGRAM = $(INSTALL)
17INSTALL_DATA = $(INSTALL) -m 644
18
19prefix = /usr/local
20bindir = $(prefix)/bin
21libdir = $(prefix)/lib
22includedir = $(prefix)/include
23
Narayan Kamath74c03bb2017-12-22 10:59:43 +000024all: xmltest staticlib
25
26rebuild: clean all
27
28xmltest: xmltest.cpp libtinyxml2.a
29
30effc:
31 gcc -Werror -Wall -Wextra -Wshadow -Wpedantic -Wformat-nonliteral \
32 -Wformat-security -Wswitch-default -Wuninitialized -Wundef \
33 -Wpointer-arith -Woverloaded-virtual -Wctor-dtor-privacy \
34 -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo \
35 -Wno-unused-parameter -Weffc++ xmltest.cpp tinyxml2.cpp -o xmltest
36
37clean:
Elliott Hughesd173c992019-01-10 14:51:35 -080038 -$(RM) *.o xmltest libtinyxml2.a
39
40# Standard GNU target
41distclean:
42 -$(RM) *.o xmltest libtinyxml2.a
43
Narayan Kamath74c03bb2017-12-22 10:59:43 +000044test: clean xmltest
45 ./xmltest
46
Elliott Hughesd173c992019-01-10 14:51:35 -080047# Standard GNU target
48check: clean xmltest
49 ./xmltest
50
Narayan Kamath74c03bb2017-12-22 10:59:43 +000051staticlib: libtinyxml2.a
52
53libtinyxml2.a: tinyxml2.o
Elliott Hughesd173c992019-01-10 14:51:35 -080054 $(AR) $(ARFLAGS) $@ $^
55 $(RANLIB) $@
56
Narayan Kamath74c03bb2017-12-22 10:59:43 +000057tinyxml2.o: tinyxml2.cpp tinyxml2.h
58
Elliott Hughesd173c992019-01-10 14:51:35 -080059directories:
60 $(MKDIR) $(DESTDIR)$(prefix)
61 $(MKDIR) $(DESTDIR)$(bindir)
62 $(MKDIR) $(DESTDIR)$(libdir)
63 $(MKDIR) $(DESTDIR)$(includedir)
64
65# Standard GNU target.
66install: xmltest staticlib directories
67 $(INSTALL_PROGRAM) xmltest $(DESTDIR)$(bindir)/xmltest
68 $(INSTALL_DATA) tinyxml2.h $(DESTDIR)$(includedir)/tinyxml2.h
69 $(INSTALL_DATA) libtinyxml2.a $(DESTDIR)$(libdir)/libtinyxml2.a
70
71# Standard GNU target
72uninstall:
73 $(RM) $(DESTDIR)$(bindir)/xmltest
74 $(RM) $(DESTDIR)$(includedir)/tinyxml2.h
75 $(RM) $(DESTDIR)$(libdir)/libtinyxml2.a