Fix Xcode warnings, part I
[texmacs.git] / src / src / makefile.in
blob680a3e15c1d385aca2db38b6d0f661c445633017
2 ###############################################################################
3 # MODULE : main make file for TeXmacs source
4 # BY : Joris van der Hoeven, David Allouche
5 # COPYRIGHT : This software falls under the GNU general public license;
6 # see the file 'LICENSE', which is provided with this package.
7 ###############################################################################
9 default: all
11 vpath %.cpp $(shell find . -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
12 vpath %.m $(shell find . -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
13 vpath %.mm $(shell find . -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
15 ###############################################################################
16 # Configuration variables
17 ###############################################################################
19 tmsrc = @tmsrc@
20 SO_SUFFIX= @CONFIG_SO@
21 CONFIG_OS= @CONFIG_OS@
23 CXX = @CXX@
24 CXXWARNING = @CONFIG_CXXWARNING@
25 CXXTEMPLATE = @CONFIG_CXXTEMPLATE@
26 CXXOPTIMIZE = @CONFIG_CXXOPTIMIZE@ @CONFIG_CXXDIALECT@
27 CXXDEBUG = @CONFIG_CXXDEBUG@
28 CXXFLAGS = $(CXXWARNING) $(CXXTEMPLATE) $(CXXOPTIMIZE) $(CXXDEBUG) @CONFIG_CXXFLAGS@ @CXXFLAGS@
29 CPPFLAGS = @CPPFLAGS@ @QT_CPPFLAGS@ -D@CONFIG_GUI_DEFINE@
30 CXXX11 = @X11_CFLAGS@
31 CXXCOCOA = @COCOA_CFLAGS@
32 CXXQT = @QT_CXXFLAGS@
33 CXXGUI = $(CXX@CONFIG_GUI@)
34 CXXAXEL = @AXEL_CFLAGS@
35 CXXCAIRO = @CAIRO_CFLAGS@
36 CXXIMLIB2 = @IMLIB2_CFLAGS@
37 CXXFREETYPE = @FREETYPE_CFLAGS@
38 CXXICONV = @ICONV_CFLAGS@
39 CXXGUILE = @GUILE_CFLAGS@
40 LD = @CXX@
41 LDFLAGS = @LDFLAGS@ @CONFIG_BFLAGS@ @QT_LDFLAGS@
42 LDRT = @LDRT@
43 LDSTATIC = @CONFIG_BSTATIC@
44 LDSHARED = @CONFIG_BSHARED@
45 LDPATH = @CONFIG_BPATH@
46 LDDL = @CONFIG_BDL@
47 LDX11 = @X11_LDFLAGS@
48 LDCOCOA = @COCOA_LDFLAGS@
49 LDQT = @QT_LIBS@
50 LDGUI = $(LD@CONFIG_GUI@)
51 LDAXEL = @AXEL_LDFLAGS@
52 LDCAIRO = @CAIRO_LDFLAGS@
53 LDIMLIB2 = @IMLIB2_LDFLAGS@
54 LDFREETYPE = @FREETYPE_LDFLAGS@
55 LDICONV = @ICONV_LDFLAGS@
56 LDGUILE = @GUILE_LDFLAGS@
57 AR = ar
58 ARFLAGS = -r
59 RM = rm -f
60 CP = cp -r -f
61 GLUE = cd Guile/Glue; ./build-glue
62 TOUCH = touch
63 MOC = @MOC@
64 MOCFLAGS = @QT_CPPFLAGS@
66 ###############################################################################
67 # Source files
68 ###############################################################################
70 # The following definition are used to locate source files by name in
71 # the main TeXmacs source package.
73 # Get the file name of each source file. The files are grouped
74 # according to the compilation options they require and group they
75 # belong to (in aggregate compilation).
77 # The enclosing makefile must have a "vpath %.cpp" directive to allow
78 # make to find the sources files given only their file name.
80 findsrc_in = \
81 $(foreach dir,$(patsubst %,$(1)/%,$(2)),\
82 $(notdir $(wildcard $(dir)/*.cpp $(dir)/*/*.cpp)))
83 findsrc = $(call findsrc_in,$(1),*)
84 findm_in = \
85 $(foreach dir,$(patsubst %,$(1)/%,$(2)),\
86 $(notdir $(wildcard $(dir)/*.m $(dir)/*/*.m)))
87 findmm_in = \
88 $(foreach dir,$(patsubst %,$(1)/%,$(2)),\
89 $(notdir $(wildcard $(dir)/*.mm $(dir)/*/*.mm)))
91 kernel_src := $(call findsrc,Kernel)
92 system_src := $(call findsrc,System)
93 data_src := $(call findsrc,Data)
94 graphics_src := $(call findsrc,Graphics)
95 plugins_src := $(call findsrc_in,Plugins,Bibtex Freetype Cairo Imlib2 \
96 Ispell Metafont Openssl)
97 x11_src := $(call findsrc_in,Plugins,@CONFIG_X11@)
98 cocoa_m_src := $(call findm_in,Plugins,@CONFIG_COCOA@)
99 cocoa_mm_src := $(call findmm_in,Plugins,@CONFIG_COCOA@ @CONFIG_MACOS@)
100 os_src := $(call findsrc_in,Plugins,@CONFIG_OS_COMPAT@)
101 qt_src := $(call findsrc_in,Plugins,@CONFIG_QT@)
102 style_src := $(call findsrc_in,Style,@CONFIG_EXPERIMENTAL@)
103 typeset_src := $(call findsrc,Typeset)
104 edit_src := $(call findsrc,Edit)
105 texmacs_src := $(call findsrc,Texmacs)
106 guile_src := $(call findsrc_in,Guile,Scheme) glue_all.cpp
108 # Each makefile will have its own Deps directory. Okay that is a bit
109 # inefficient, but that is much simpler to maintain.
111 # The enclosing makefile should accumulate a dependences file name in
112 # $(deps) and define an rule without command for every source file it
113 # compiles.
115 make_cpp_deps = $(patsubst %.cpp,Deps/%.d,$(notdir $(1)))
116 make_m_deps = $(patsubst %.m,Deps/%.d,$(notdir $(1)))
117 make_mm_deps = $(patsubst %.mm,Deps/%.d,$(notdir $(1)))
119 texmacs_cpp_deps := $(call make_cpp_deps,$(system_src) $(kernel_src) $(data_src)\
120 $(edit_src) $(guile_src) $(graphics_src)\
121 $(plugins_src) $(x11_src) $(texmacs_src)\
122 $(typeset_src) $(style_src) $(qt_src) $(os_src))
123 texmacs_m_deps += $(call make_m_deps,$(cocoa_m_src))
124 texmacs_mm_deps += $(call make_mm_deps,$(cocoa_mm_src))
126 deps += $(texmacs_cpp_deps) $(texmacs_m_deps) $(texmacs_mm_deps)
128 ###############################################################################
129 # Include files
130 ###############################################################################
132 incl_flags = $(patsubst %,-I%,$(1))
134 system_incl := $(call incl_flags,System System/Boot System/Classes System/Files System/Link System/Misc System/Language Kernel/Abstractions Kernel/Containers Kernel/Types Data/Convert Data/Drd Data/History Data/Observers Data/String Data/Tmfs Data/Tree Guile Graphics/Bitmap_fonts Graphics/Fonts Graphics/Gui Graphics/Mathematics Graphics/Renderer Plugins)
135 kernel_incl := $(system_incl)
136 data_incl := $(system_incl)
137 graphics_incl := $(system_incl)
138 plugins_incl := $(system_incl)
139 x11_incl := $(system_incl)
140 cocoa_incl := $(system_incl)
141 os_incl := $(system_incl)
142 qt_incl := $(system_incl)
143 style_incl := $(system_incl) $(call incl_flags,Style/Memorizer Style/Environment Style/Evaluate)
144 typeset_incl := $(system_incl) $(call incl_flags,Typeset Typeset/Bridge Typeset/Concat Typeset/Page Edit)
145 guile_incl := $(typeset_incl) $(call incl_flags,Plugins Texmacs)
146 edit_incl := $(guile_incl) $(call incl_flags,Edit/Editor Edit/Interface Edit/Modify)
147 texmacs_incl := $(guile_incl)
149 ###############################################################################
150 # MOC files
151 ###############################################################################
153 # moc source files are generated for each header present in $(qt_moc) and
154 # put in the Plugins/Qt directory
156 ifeq "@CONFIG_QT@" ""
157 qt_moc :=
158 else
159 qt_moc := QTMStyle.hpp QTMGuiHelper.hpp QTMInteractiveInputHelper.hpp QTMMenuHelper.hpp QTMWidget.hpp QTMWindow.hpp QTMScrollView.hpp QTMPipeLink.hpp
160 endif
162 qt_moc_src = $(patsubst %.hpp, moc_%.cpp,$(qt_moc))
163 qt_moc_paths = $(patsubst %,./Plugins/Qt/%,$(qt_moc_src))
166 $(qt_moc_paths): ./Plugins/Qt/moc_%.cpp: ./Plugins/Qt/%.hpp
167 $(MOC) $(MOCFLAGS) $< -o $@
169 ###############################################################################
170 # Dependencies
171 ###############################################################################
173 deps_incl = $(call incl_flags,System System/Boot System/Classes System/Files System/Link System/Misc System/Language Kernel/Abstractions Kernel/Containers Kernel/Types Data/Convert Data/Drd Data/History Data/Observers Data/String Data/Tmfs Data/Tree Graphics Plugins Style/Environment Style/Evaluate Style/Memorizer Typeset Edit Texmacs Guile Graphics/Bitmap_fonts Graphics/Fonts Graphics/Gui Graphics/Mathematics Graphics/Renderer)
175 deps_flags = $(deps_incl)\
176 $(CPPFLAGS) $(CXXAXEL) $(CXXCAIRO) $(CXXIMLIB2) $(CXXFREETYPE) $(CXXICONV) $(CXXGUILE) \
177 -I$(tmsrc)/include $(CXXGUI)
178 # we should use -I- to separate local includes from system includes, but
179 # headers of guile 1.6.0 use includes in quotes with names relative to the
180 # current directory, and that feature is disable by -I-.
182 $(texmacs_cpp_deps): Deps/%.d: %.cpp
183 $(texmacs_m_deps): Deps/%.d: %.m
184 $(texmacs_mm_deps): Deps/%.d: %.mm
186 $(deps):
187 @ echo "make deps: $@"
188 @ set -e; $(CXX) -M $(deps_flags) $< \
189 | sed 's|\($*\)\.o[ :]*|Objects/\1.o $@ : |g' > $@; \
190 [ -s $@ ] || $(RM) $@
192 # To avoid unneeded processing, the Deps will not be included (and thus
193 # remade if needed) unless the "deps" target has been previously made,
194 # by hand.
196 deps: $(deps)
197 $(TOUCH) Deps/stamp
199 .PHONY: deps
201 ifeq ($(shell test -f Deps/stamp && echo yes || echo no),yes)
202 include $(deps)
203 endif
205 ###############################################################################
206 # Object files
207 ###############################################################################
209 makeobj = $(patsubst %.cpp,Objects/%.o,$(1))
210 makeobj_m = $(patsubst %.m,Objects/%.o,$(1))
211 makeobj_mm = $(patsubst %.mm,Objects/%.o,$(1))
213 system_obj := $(call makeobj,$(system_src))
214 kernel_obj := $(call makeobj,$(kernel_src))
215 data_obj := $(call makeobj,$(data_src))
216 edit_obj := $(call makeobj,$(edit_src))
217 guile_obj := $(call makeobj,$(guile_src))
218 graphics_obj := $(call makeobj,$(graphics_src))
219 x11_obj := $(call makeobj,$(x11_src))
220 cocoa_m_obj := $(call makeobj_m,$(cocoa_m_src))
221 cocoa_mm_obj := $(call makeobj_mm,$(cocoa_mm_src))
222 os_obj := $(call makeobj,$(os_src))
223 moc_obj := $(call makeobj,$(qt_moc_src))
224 qt_obj := $(filter-out $(moc_obj), $(call makeobj,$(qt_src)))
225 plugins_obj := $(call makeobj,$(plugins_src))
226 texmacs_obj := $(call makeobj,$(texmacs_src))
227 typeset_obj := $(call makeobj,$(typeset_src))
228 style_obj := $(call makeobj,$(style_src))
230 # To enforce some degree of modularity, each object file must be
231 # compiled with only a specific set of include flags. To achieve that,
232 # we must disable the default (implicit) compilation rule and define
233 # an appropriate rule for each object file.
236 %.o: %.cpp # Disable implicit compilation rule
238 cxx_flags = $(strip $(CXX) $(1) -c $< -o $@)
239 cxx_incl = $(call cxx_flags,$(1) \
240 $(CXXAXEL) $(CXXCAIRO) $(CXXIMLIB2) $(CXXFREETYPE) $(CXXICONV) \
241 $(CXXGUILE) $(CPPFLAGS) $(CXXFLAGS))
243 $(system_obj): Objects/%.o: %.cpp
244 $(call cxx_incl,$(system_incl) -I$(tmsrc)/include)
245 $(kernel_obj): Objects/%.o: %.cpp
246 $(call cxx_incl,$(kernel_incl))
247 $(data_obj): Objects/%.o: %.cpp
248 $(call cxx_incl,$(data_incl) -I$(tmsrc)/include)
249 $(edit_obj): Objects/%.o: %.cpp
250 $(call cxx_incl,$(edit_incl))
251 $(guile_obj): Objects/%.o: %.cpp
252 $(call cxx_incl,$(guile_incl))
253 $(graphics_obj): Objects/%.o: %.cpp
254 $(call cxx_incl,$(graphics_incl))
255 $(plugins_obj): Objects/%.o: %.cpp
256 $(call cxx_incl,$(plugins_incl))
257 $(x11_obj): Objects/%.o: %.cpp
258 $(call cxx_incl,$(x11_incl) $(CXXX11))
259 $(os_obj): Objects/%.o: %.cpp
260 $(call cxx_incl,$(os_incl))
261 $(qt_obj): Objects/%.o: %.cpp
262 $(call cxx_incl,$(qt_incl) $(CXXQT))
263 $(moc_obj): Objects/%.o: ./Plugins/Qt/%.cpp
264 $(call cxx_incl,$(qt_incl) $(CXXQT))
265 $(cocoa_m_obj): Objects/%.o: %.m
266 $(call cxx_incl,$(cocoa_incl) $(CXXCOCOA))
267 $(cocoa_mm_obj): Objects/%.o: %.mm
268 $(call cxx_incl,$(cocoa_incl) $(CXXCOCOA))
269 $(texmacs_obj): Objects/%.o: %.cpp
270 $(call cxx_incl,$(texmacs_incl))
271 $(typeset_obj): Objects/%.o: %.cpp
272 $(call cxx_incl,$(typeset_incl))
273 $(style_obj): Objects/%.o: %.cpp
274 $(call cxx_incl,$(style_incl))
276 ###############################################################################
277 # Make editor
278 ###############################################################################
280 # Linking rules
282 # The link_bin function uses different flags depending on the value
283 # of the $(link) option, and on the host type. Its parameter must be a
284 # sequence of options for the compiler control which libraries to link
285 # with and where to find them.
287 # It should be used as the body of rules whose target are executable
288 # binaries and the prerequisites are the object files being linked in
289 # the target.
291 ifeq "$(link)" "shared"
292 ifeq "$(CONFIG_OS)" "DEC"
293 link_bin = $(strip $(LD) $(LDFLAGS) -lstdc++ $(LDSHARED) $^ $(1) -o $@)
294 else
295 link_bin = $(strip $(LD) $(LDFLAGS) $(LDSHARED) $^ $(1) -o $@)
296 endif
297 endif
298 ifeq "$(link)" "static"
299 ifeq "$(CONFIG_OS)" "DEC"
300 link_bin = $(strip $(LD) $(LDFLAGS) $^ $(LDSTATIC) $(1) -lstdc++ -o $@)
301 else
302 link_bin = $(strip $(LD) $(LDFLAGS) $^ $(LDSTATIC) $(1) -o $@)
303 endif
304 endif
306 # Compilation of objects
308 # The 'uses' function must be used as a prerequisite of a link rule
309 # (whose body is a link_bin functian call). It takes a number of
310 # module names in parameters.
312 uses = $(sort $(foreach use,$(patsubst %,uses_%,$(1)),$($(use))))
314 uses_system := $(system_obj)
315 uses_kernel := $(kernel_obj)
316 uses_data := $(data_obj)
317 uses_graphics := $(graphics_obj)
318 uses_plugins := $(plugins_obj)
319 uses_x11 := $(x11_obj)
320 uses_os := $(os_obj)
321 uses_qt := $(qt_obj) $(moc_obj)
322 uses_cocoa := $(cocoa_m_obj) $(cocoa_mm_obj)
323 uses_typeset := $(typeset_obj)
324 uses_style := $(style_obj)
325 uses_edit := $(edit_obj)
326 uses_glue := $(guile_obj)
327 uses_texmacs := $(texmacs_obj)
329 # Compilation rules
331 TEXMACS_objects := $(strip $(call uses,system kernel data graphics\
332 plugins x11 os qt cocoa style typeset edit glue texmacs))
334 link_options:=-L$(tmsrc)/lib $(LDRT) -lm $(LDPATH) $(LDGUI) $(LDGUILE) \
335 $(LDAXEL) $(LDCAIRO) $(LDIMLIB2) $(LDFREETYPE) $(LDICONV) $(LDDL) -mwindows
337 $(tmsrc)/bin/texmacs.bin: Objects/texmacs-$(link).bin
338 $(CP) $^ $@
340 Objects/texmacs-$(link).bin: $(TEXMACS_objects)
341 $(call link_bin,$(link_options))
343 all: $(tmsrc)/bin/texmacs.bin
345 .PHONY: all $(tmsrc)/bin/texmacs.bin
347 ###############################################################################
348 # Interface for Guile
349 ###############################################################################
351 # Compilation of glue
353 # When dependences are generated, the glue code can be rebuilt
354 # automatically, but only if there is an appropriate rule for
355 # regenerating the glue source from the scheme documents.
357 Guile/Glue/glue_%.cpp: Guile/Glue/build-glue-%.scm
358 $(MAKE) GLUE
360 gluesrc = Guile/Glue
362 GLUE: $(gluesrc)/glue_basic.cpp $(gluesrc)/glue_editor.cpp $(gluesrc)/glue_server.cpp
364 .PHONY: GLUE
366 $(gluesrc)/glue_basic.cpp: $(gluesrc)/build-glue.scm
367 $(gluesrc)/glue_editor.cpp: $(gluesrc)/build-glue.scm
368 $(gluesrc)/glue_server.cpp: $(gluesrc)/build-glue.scm
370 $(gluesrc)/glue_basic.cpp: $(gluesrc)/build-glue-basic.scm
371 $(GLUE) build-glue-basic.scm glue_basic.cpp
373 $(gluesrc)/glue_editor.cpp: $(gluesrc)/build-glue-editor.scm
374 $(GLUE) build-glue-editor.scm glue_editor.cpp
376 $(gluesrc)/glue_server.cpp: $(gluesrc)/build-glue-server.scm
377 $(GLUE) build-glue-server.scm glue_server.cpp
379 ###############################################################################
380 # Cleaning and backup
381 ###############################################################################
383 DISTR:
384 $(RM) Deps/*.*
385 $(RM) Deps/stamp
387 CLEAN: DISTR
388 $(RM) Objects/*.o
389 $(RM) Plugins/Qt/moc_*.cpp
391 clean: CLEAN
393 maintainer-clean: CLEAN
394 $(RM) Objects/*.*
396 PHONY: DISTR CLEAN clean maintainer-clean