1# 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 24all: 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: 38 -$(RM) *.o xmltest libtinyxml2.a 39 40# Standard GNU target 41distclean: 42 -$(RM) *.o xmltest libtinyxml2.a 43 44test: clean xmltest 45 ./xmltest 46 47# Standard GNU target 48check: clean xmltest 49 ./xmltest 50 51staticlib: libtinyxml2.a 52 53libtinyxml2.a: tinyxml2.o 54 $(AR) $(ARFLAGS) $@ $^ 55 $(RANLIB) $@ 56 57tinyxml2.o: tinyxml2.cpp tinyxml2.h 58 59directories: 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 76