Debian Codegraph @

src/GNUmakefile

raw ◀ ▶
Source reconstructed at patch state 0 of 3 — not the installed (fully patched) source.
3 Debian patches touch this file
1 #
2 # Trigger Rally GNUmakefile for Linux users
3 #
4
5 # standard GNU and custom variables
6 DISTNAME := trigger-rally
7 DISTVER := 0.6.6.1
8 DISTDIR := $(DISTNAME)-$(DISTVER)
9 DISTARC := $(DISTDIR).tar.gz
10 TR_EXENAME := trigger-rally
11 TR_CFGNAME := trigger-rally.config.defs
12 TR_BINDIR := ../bin
13 TR_DATADIR := ../data
14 TR_DOCDIR := ../doc
15 TR_EXEFILE := $(TR_BINDIR)/$(TR_EXENAME)
16 TR_CFGFILE := $(TR_BINDIR)/$(TR_CFGNAME)
17 TR_DATAFILES := $(shell cd $(TR_DATADIR); find * -type f)
18 TR_DOCFILES := $(shell cd $(TR_DOCDIR); find * -type f)
19 PROJDIRS := PEngine PSim Trigger
20 SRCFILES := $(sort $(shell find $(PROJDIRS) -type f -name "*.cpp"))
21 OBJFILES := $(patsubst %.cpp, %.o, $(SRCFILES))
22 DEPFILES := $(patsubst %.cpp, %.d, $(SRCFILES))
23 WARNINGS ?= -Wall -Wextra -pedantic
24 OPTIMS ?= -march=native -mtune=native -Ofast
25 DMACROS := -DNDEBUG -DUNIX -DPACKAGE_VERSION=\"$(DISTVER)\"
26 INCDIRS := -I'./include'
27 CXXFLAGS += -std=c++11 $(WARNINGS) $(OPTIMS)
28 CPPFLAGS += $(DMACROS) $(INCDIRS)
29 EXTRA_LIBS := -lSDL2main -lGL -lGLU -lGLEW -lSDL2 -lSDL2_image -lphysfs -lopenal -lalut -lpthread -ltinyxml2
30 LDFLAGS += $(EXTRA_LIBS)
31 INSTALL_PROGRAM := install --mode=0755
32 INSTALL_DATA := install --mode=0644
33
34 # standard GNU directories
35 prefix ?= /usr/local
36 exec_prefix ?= $(prefix)
37 bindir := $(exec_prefix)/games
38 datarootdir := $(prefix)/share
39 datadir := $(datarootdir)/games
40 docdir := $(datarootdir)/doc/$(DISTNAME)
41
42 #
43 # phony targets, whose names aren't names of resulting files
44 #
45 # NOTE that several "standard" targets are missing; here
46 # `all` is `build` because I always felt "all" was a bad name,
47 # while the others I had either no time or no incentive to implement
48 #
49 .PHONY: build printvars install uninstall installdirs dist clean
50
51 # builds the executable
52 build: printvars $(TR_EXEFILE)
53
54 #
55 # prints the variables that the user can change;
56 # if VAR is in the list, then the user can change it by running:
57 #
58 # VAR="new value" make [target]
59 #
60 # examples:
61 # OPTIMS="-O0 -g" make
62 # prefix="/usr" exec_prefix="/usr" make install
63 #
64 printvars:
65 @printf "\ncurrent values of user-set variables:\n"
66 @printf "\tDESTDIR ?= %s\n" "$(DESTDIR)"
67 @printf "\tprefix ?= %s\n" "$(prefix)"
68 @printf "\texec_prefix ?= %s\n" "$(exec_prefix)"
69 @printf "\tOPTIMS ?= %s\n" "$(OPTIMS)"
70 @printf "\tWARNINGS ?= %s\n" "$(WARNINGS)"
71 @printf "\n"
72 @printf "resulting values of build variables:\n"
73 @printf "\tCXXFLAGS += %s\n" "$(CXXFLAGS)"
74 @printf "\tCPPFLAGS += %s\n" "$(CPPFLAGS)"
75 @printf "\tLDFLAGS += %s\n" "$(LDFLAGS)"
76 @printf "\n"
77
78 # installs the software (executable, data files and documentation)
79 install: installdirs build
80 @printf "\ninstall [%s] begin\n" "$(DISTNAME)"
81 @$(INSTALL_PROGRAM) "$(TR_EXEFILE)" "$(DESTDIR)$(bindir)"
82 @$(INSTALL_DATA) "$(TR_CFGFILE)" "$(DESTDIR)$(bindir)"
83 @for file in $(TR_DATAFILES); do \
84 $(INSTALL_DATA) -D "$(TR_DATADIR)/$$file" "$(DESTDIR)$(datadir)/$(DISTNAME)/$$file"; \
85 done
86 @for file in $(TR_DOCFILES); do \
87 $(INSTALL_DATA) -D "$(TR_DOCDIR)/$$file" "$(DESTDIR)$(docdir)/$$file"; \
88 done
89 @printf "install [%s] end\n\n" "$(DISTNAME)"
90
91 # deletes the software (executable, data files and documentation)
92 uninstall:
93 -@$(RM) --verbose "$(DESTDIR)$(bindir)/$(TR_EXENAME)"
94 -@$(RM) --verbose "$(DESTDIR)$(bindir)/$(TR_CFGNAME)"
95 -@$(RM) --verbose --recursive "$(DESTDIR)$(datadir)/$(DISTNAME)"
96 -@$(RM) --verbose --recursive "$(DESTDIR)$(docdir)"
97
98 # creates the installation directories if they do not exist
99 installdirs:
100 @printf "\nmkdir\t[installation directories]\n"
101 @mkdir --mode=0755 --parents \
102 "$(DESTDIR)$(bindir)" \
103 "$(DESTDIR)$(datadir)/$(DISTNAME)" \
104 "$(DESTDIR)$(docdir)"
105
106 #
107 # creates a zipped tarball for redistribution
108 #
109 # NOTE that this fails if the directory we're in isn't named $(DISTDIR) however
110 # this is by design: it's meant to enforce directory naming consistency and
111 # awareness of the $(DISTVER) variable, which you must update for each release!
112 #
113 dist: clean
114 @printf "\ntar -> \"../../%s\"\n" "$(DISTARC)"
115 @cd ../..; \
116 tar --owner=root --group=root --create --file="$(DISTARC)" --auto-compress "$(DISTDIR)"
117 @printf "md5sum -> \"../../%s.md5\"\n\n" "$(DISTARC)"
118 @cd ../..; \
119 md5sum "$(DISTARC)" > "$(DISTARC).md5"
120
121 # links the object files into the executable, which it then strips
122 $(TR_EXEFILE): $(OBJFILES)
123 @printf "%s" $(CXX)
124 @for file in $(OBJFILES); do \
125 printf "\t%s\n" $$file; \
126 done
127 @printf "\t-> %s\n" $@
128 @$(CXX) -o $@ $(OBJFILES) $(LDFLAGS)
129 @printf "strip\t%s\n" $@
130 @strip $@
131
132 #
133 # removes object files, dependency files, executable and
134 # backup files (such as "func.cpp~")
135 #
136 clean:
137 -@$(RM) --verbose \
138 $(OBJFILES) \
139 $(DEPFILES) \
140 $(TR_EXEFILE) \
141 $(shell find -type f -name "*~")
142
143 #
144 # includes dependency files; these files are needed to speed up
145 # the build process by excluding the compilation of object files
146 # which are already up-to-date
147 #
148 -include $(DEPFILES)
149
150 #
151 # compiles source files to object files
152 #
153 # GNUmakefile was added as a dependency in order to trigger a rebuild
154 # if this makefile is edited
155 #
156 %.o: %.cpp GNUmakefile
157 @printf "%s\t%s -> %s\n" $(CXX) $< $@
158 @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MP -c $< -o $@