/
distr_Makefile
212 lines (163 loc) · 7.32 KB
/
distr_Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# See the file INSTALL for detailed instructions
# the following line avoids trouble on some systems (GNU make does this anyway)
SHELL = /bin/sh
INSTALL = /usr/bin/install
# You may edit the INSTALLDIR and BINDIR variables
# INSTALLDIR is where the executables Fokko, atlas, and the messages directory
# will be moved after successfull compilation
# BINDIR is where a symbolic link to the 'Fokko' executable will be created,
# and shell script executing 'atlas' will be placed; provided this directory
# is in the search path, you can then call Fokko, atlas, from anywhere
# However when BINDIR is INSTALLDIR one cannot have those shell scripts since
# they would be at the same place as the executable to call; since both default
# to the current directory, you are advised to set at least BINDIR explicitly.
# INSTALLDIR only needs to be changed if the current directory is temporary
# In a single-user situation, you might want something like this:
# INSTALLDIR := /home/ducloux/atlas
# BINDIR := /home/ducloux/bin
# In a multi-user situation, you might want this (requires root privilege):
# INSTALLDIR := /usr/local/atlas
# BINDIR := /usr/local/bin
# The default: use current directoty for both
INSTALLDIR := $(shell pwd)
BINDIR := $(shell pwd)
version := $(shell ./getversion.pl)
messagedir := $(INSTALLDIR)/messages/
# Fokko_dirs contains subdirectories of 'atlas/sources' needed for 'Fokko'
# atlas_dirs are where the object files for atlas are situated
Fokko_dirs := utilities structure gkmod io error interface test
atlas_dirs := utilities structure gkmod io error interpreter
# Fokko_sources contains a list of the source files (i.e., the .cpp files)
Fokko_sources := $(wildcard $(Fokko_dirs:%=sources/%/*.cpp))
# there is one .o file for each .cpp file, in the same directory
Fokko_objects := $(Fokko_sources:%.cpp=%.o)
# headers are searched in the all directories containing source files
Fokko_includes := $(addprefix -Isources/,$(Fokko_dirs))
atlas_includes := $(addprefix -Isources/,$(atlas_dirs))
interpreter_objects := $(patsubst %.cpp,%.o, \
$(wildcard sources/interpreter/*.cpp)) sources/interpreter/parser.tab.o
non_atlas_objects := sources/io/interactive%.o \
sources/interface/%.o sources/test/%.o \
sources/io/poset.o sources/utilities/abelian.o sources/gkmod/kgp.o
atlas_objects := $(interpreter_objects) \
$(filter-out $(non_atlas_objects),$(Fokko_objects))
objects := $(Fokko_objects) $(interpreter_objects)
# compiler flags
# whenever changing the setting of these flags, do 'make clean' first
# the following are predefined flavors for the compiler flags:
# normal (nflags)
# optimizing (oflags)
# development with debugging (gflags)
nflags := -Wall -DNDEBUG
oflags := -Wall -O3 -DNDEBUG
gflags := -Wall -ggdb
# these flags are necessary for compilation, the -c should not be altered
CXXFLAGS = -c $(CXXFLAVOR)
# additional flags specific for Fokko and atlas
Fokko_flags = $(Fokko_includes)
atlas_flags = -Wno-parentheses $(atlas_includes)
# to select another flavor, set optimize=false or (stronger) debug=true
# when calling make (as in "make optimize=false") or set CXXFLAVOR as an
# environment variable (only the first flavor set in above list takes effect)
# alternatively, you can do "make CXXFLAVOR='explicit options'" to specify
ifeq ($(optimize),false)
CXXFLAVOR := $(nflags)
else
ifeq ($(debug),true)
CXXFLAVOR := $(gflags)
else # use value from environment or command line, or default to optimising
CXXFLAVOR ?= $(oflags)
endif
endif
# suppress readline by setting readline=false
# and/or make more verbose by setting verbose=true
ifeq ($(readline),false)
CXXFLAVOR += -DNREADLINE
rl_libs =
else
rl_libs ?= -lreadline
endif
# To override this define and export a shell variable 'rl_libs', for instance
# for readline on the Mac give the command: make rl_libs="-lreadline.5 -lcurses"
# Any value of LDFLAGS set in the environment is also included in $(LDFLAGS)
ifdef LDFLAGS
LDFLAGS := $(LDFLAGS) $(rl_libs)
else
LDFLAGS := $(rl_libs)
endif
ifeq ($(verbose),true)
Fokko_flags += -DVERBOSE
endif
# the compiler to use, including language switch
# some C++11 support needed (rvalue references, shared_ptr) but g++-4.4 suffices
CXX = g++ -std=c++0x
CXXVERSION := $(shell $(CXX) -dumpversion)
CXXVERSIONOLD := $(shell expr `echo $(CXXVERSION) | cut -f1-2 -d.` \< 4.8)
CXXVERSIONVERYOLD := $(shell expr `echo $(CXXVERSION) | cut -f1-2 -d.` \< 4.6)
ifeq "$(CXXVERSIONOLD)" "1"
CXXFLAVOR += -Dincompletecpp11
endif
ifeq "$(CXXVERSIONVERYOLD)" "1"
CXXFLAVOR += -Dnoexcept= -Dconstexpr= -Dnullptr=0
endif
# RULES follow below
# This target causes failed actions to clean up their (corrupted) target
.DELETE_ON_ERROR:
# we use no suffix rules
.SUFFIXES:
.PHONY: all install version
# The default target is 'all', which builds the executable 'Fokko', and 'atlas'
all: Fokko atlas
# the following dependency forces emptymode.cpp to be recompiled whenever any
# of the object files changes; this guarantees that the date in the version
# string it prints will be that of the last recompilation.
sources/interface/emptymode.o: $(Fokko_sources)
Fokko: $(Fokko_objects)
$(CXX) -o Fokko $(Fokko_objects) $(LDFLAGS)
atlas: $(atlas_objects)
$(CXX) -o atlas $(atlas_objects) $(LDFLAGS)
# Rules with two colons are static pattern rules: they are like implicit
# rules, but only apply to the files listed before the first colon
$(filter-out sources/interface/io.o,$(Fokko_objects)) : %.o : %.cpp
$(CXX) $(CXXFLAGS) $(Fokko_flags) -o $*.o $*.cpp
# the $(messagedir) variable is only needed for the compilation of io.cpp
sources/interface/io.o : sources/interface/io.cpp
$(CXX) $(CXXFLAGS) $(Fokko_flags) -DMESSAGE_DIR_MACRO=\"$(messagedir)\" -o $@ $<
# for the interpreter replace $(Fokko_flags) by $(atlas_flags)
$(filter-out sources/interpreter/parser.tab.o,$(interpreter_objects)) :\
%.o : %.cpp
$(CXX) $(CXXFLAGS) $(atlas_flags) -o $*.o $*.cpp
# bison produces a file with extension .c, nonetheless it too needs $(CXX)
sources/interpreter/parser.tab.o: \
sources/interpreter/parser.tab.c sources/interpreter/parsetree.h
$(CXX) $(CXXFLAGS) $(atlas_flags) -o $@ $<
install: Fokko atlas
ifneq ($(INSTALLDIR),$(shell pwd))
@echo "Installing directories and files in $(INSTALLDIR)"
$(INSTALL) -d $(INSTALLDIR)/messages $(INSTALLDIR)/atlas-scripts
$(INSTALL) -m 644 LICENSE COPYRIGHT README $(INSTALLDIR)
$(INSTALL) -p Fokko atlas $(INSTALLDIR)
$(INSTALL) -m 644 messages/*.help $(INSTALLDIR)/messages/
$(INSTALL) -m 644 messages/intro_mess $(INSTALLDIR)/messages/
$(INSTALL) -m 644 atlas-scripts/* $(INSTALLDIR)/atlas-scripts/
endif
ifneq ($(BINDIR),$(INSTALLDIR))
ifneq ($(BINDIR),$(shell pwd))
$(INSTALL) -d $(BINDIR)
@if test -h $(BINDIR)/Fokko; then rm -f $(BINDIR)/Fokko; fi
@if test -e $(BINDIR)/atlas; then rm -f $(BINDIR)/atlas; fi
ln -s $(INSTALLDIR)/Fokko $(BINDIR)/Fokko # make symbolic link
# whenever BINDIR is not INSTALLDIR, we can put a shell script as bin/atlas
# which ensures the search path will be properly set (no compiled-in path here)
(echo '#!/bin/sh'; echo '$(INSTALLDIR)/atlas --path=$(INSTALLDIR)/atlas-scripts basic.at "$$@"') >$(BINDIR)/atlas; chmod a+x $(BINDIR)/atlas
endif
endif
version:
@echo $(version)
.PHONY: mostlyclean clean showobjects
mostlyclean:
$(RM) -f $(objects)
clean: mostlyclean
$(RM) -f Fokko atlas
# distribution version of Fokko uses a frozen set of dependencies
include dependencies