Elliott Hughes | d173c99 | 2019-01-10 14:51:35 -0800 | [diff] [blame] | 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 | |
| 8 | AR = ar |
| 9 | ARFLAGS = cr |
| 10 | RM = rm -f |
| 11 | RANLIB = ranlib |
| 12 | MKDIR = mkdir -p |
| 13 | CXXFLAGS = -fPIC |
| 14 | |
| 15 | INSTALL = install |
| 16 | INSTALL_PROGRAM = $(INSTALL) |
| 17 | INSTALL_DATA = $(INSTALL) -m 644 |
| 18 | |
| 19 | prefix = /usr/local |
| 20 | bindir = $(prefix)/bin |
| 21 | libdir = $(prefix)/lib |
| 22 | includedir = $(prefix)/include |
| 23 | |
Narayan Kamath | 74c03bb | 2017-12-22 10:59:43 +0000 | [diff] [blame] | 24 | all: xmltest staticlib |
| 25 | |
| 26 | rebuild: clean all |
| 27 | |
| 28 | xmltest: xmltest.cpp libtinyxml2.a |
| 29 | |
| 30 | effc: |
| 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 | |
| 37 | clean: |
Elliott Hughes | d173c99 | 2019-01-10 14:51:35 -0800 | [diff] [blame] | 38 | -$(RM) *.o xmltest libtinyxml2.a |
| 39 | |
| 40 | # Standard GNU target |
| 41 | distclean: |
| 42 | -$(RM) *.o xmltest libtinyxml2.a |
| 43 | |
Narayan Kamath | 74c03bb | 2017-12-22 10:59:43 +0000 | [diff] [blame] | 44 | test: clean xmltest |
| 45 | ./xmltest |
| 46 | |
Elliott Hughes | d173c99 | 2019-01-10 14:51:35 -0800 | [diff] [blame] | 47 | # Standard GNU target |
| 48 | check: clean xmltest |
| 49 | ./xmltest |
| 50 | |
Narayan Kamath | 74c03bb | 2017-12-22 10:59:43 +0000 | [diff] [blame] | 51 | staticlib: libtinyxml2.a |
| 52 | |
| 53 | libtinyxml2.a: tinyxml2.o |
Elliott Hughes | d173c99 | 2019-01-10 14:51:35 -0800 | [diff] [blame] | 54 | $(AR) $(ARFLAGS) $@ $^ |
| 55 | $(RANLIB) $@ |
| 56 | |
Narayan Kamath | 74c03bb | 2017-12-22 10:59:43 +0000 | [diff] [blame] | 57 | tinyxml2.o: tinyxml2.cpp tinyxml2.h |
| 58 | |
Elliott Hughes | d173c99 | 2019-01-10 14:51:35 -0800 | [diff] [blame] | 59 | directories: |
| 60 | $(MKDIR) $(DESTDIR)$(prefix) |
| 61 | $(MKDIR) $(DESTDIR)$(bindir) |
| 62 | $(MKDIR) $(DESTDIR)$(libdir) |
| 63 | $(MKDIR) $(DESTDIR)$(includedir) |
| 64 | |
| 65 | # Standard GNU target. |
| 66 | install: 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 |
| 72 | uninstall: |
| 73 | $(RM) $(DESTDIR)$(bindir)/xmltest |
| 74 | $(RM) $(DESTDIR)$(includedir)/tinyxml2.h |
| 75 | $(RM) $(DESTDIR)$(libdir)/libtinyxml2.a |