Experimental support for native Pdf rendering
[texmacs.git] / src / src / makefile.in
blob2ef4d8181f5dba50029b52ca07cf4cb3ca1307b3
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' ' ')
14 vpath %.c $(shell find . -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
16 ###############################################################################
17 # Configuration variables
18 ###############################################################################
20 tmsrc = @tmsrc@
21 SO_SUFFIX= @CONFIG_SO@
22 CONFIG_OS= @CONFIG_OS@
24 CC = @CC@
25 CXX = @CXX@
26 CXXWARNING = @CONFIG_CXXWARNING@
27 CXXTEMPLATE = @CONFIG_CXXTEMPLATE@
28 CXXOPTIMIZE = @CONFIG_CXXOPTIMIZE@ @CONFIG_CXXDIALECT@
29 CXXDEBUG = @CONFIG_CXXDEBUG@
30 CXXFLAGS = $(CXXWARNING) $(CXXTEMPLATE) $(CXXOPTIMIZE) $(CXXDEBUG) @CONFIG_CXXFLAGS@ @CXXFLAGS@
31 CPPFLAGS = @CPPFLAGS@ @QT_CPPFLAGS@ -D@CONFIG_GUI_DEFINE@
32 CXXX11 = @X11_CFLAGS@
33 CXXCOCOA = @COCOA_CFLAGS@
34 CXXQT = @QT_CXXFLAGS@
35 CXXGUI = $(CXX@CONFIG_GUI@)
36 CXXAXEL = @AXEL_CFLAGS@
37 CXXCAIRO = @CAIRO_CFLAGS@
38 CXXIMLIB2 = @IMLIB2_CFLAGS@
39 CXXFREETYPE = @FREETYPE_CFLAGS@
40 CXXICONV = @ICONV_CFLAGS@
41 CXXGUILE = @GUILE_CFLAGS@
42 LD = @CXX@
43 LDFLAGS = @LDFLAGS@ @CONFIG_BFLAGS@ @QT_LDFLAGS@
44 LDRT = @CONFIG_LDRT@
45 LDSTATIC = @CONFIG_BSTATIC@
46 LDSHARED = @CONFIG_BSHARED@
47 LDPATH = @CONFIG_BPATH@
48 LDDL = @CONFIG_BDL@
49 LDX11 = @X11_LDFLAGS@
50 LDCOCOA = @COCOA_LDFLAGS@
51 LDQT = @QT_LIBS@
52 LDGUI = $(LD@CONFIG_GUI@)
53 LDAXEL = @AXEL_LDFLAGS@
54 LDCAIRO = @CAIRO_LDFLAGS@
55 LDIMLIB2 = @IMLIB2_LDFLAGS@
56 LDFREETYPE = @FREETYPE_LDFLAGS@
57 LDICONV = @ICONV_LDFLAGS@
58 LDGUILE = @GUILE_LDFLAGS@
59 AR = ar
60 ARFLAGS = -r
61 RM = rm -f
62 CP = cp -r -f
63 GLUE = cd Guile/Glue; ./build-glue
64 TOUCH = touch
65 MOC = @MOC@
66 MOCFLAGS = @QT_CPPFLAGS@
68 ###############################################################################
69 # Source files
70 ###############################################################################
72 # The following definition are used to locate source files by name in
73 # the main TeXmacs source package.
75 # Get the file name of each source file. The files are grouped
76 # according to the compilation options they require and group they
77 # belong to (in aggregate compilation).
79 # The enclosing makefile must have a "vpath %.cpp" directive to allow
80 # make to find the sources files given only their file name.
82 findsrc_in = \
83 $(foreach dir,$(patsubst %,$(1)/%,$(2)),\
84 $(notdir $(wildcard $(dir)/*.cpp $(dir)/*/*.cpp)))
85 findsrc = $(call findsrc_in,$(1),*)
86 findm_in = \
87 $(foreach dir,$(patsubst %,$(1)/%,$(2)),\
88 $(notdir $(wildcard $(dir)/*.m $(dir)/*/*.m)))
89 findmm_in = \
90 $(foreach dir,$(patsubst %,$(1)/%,$(2)),\
91 $(notdir $(wildcard $(dir)/*.mm $(dir)/*/*.mm)))
92 findc_in = \
93 $(foreach dir,$(patsubst %,$(1)/%,$(2)),\
94 $(notdir $(wildcard $(dir)/*.c)))
96 kernel_src := $(call findsrc,Kernel)
97 system_src := $(call findsrc,System)
98 data_src := $(call findsrc,Data)
99 graphics_src := $(call findsrc,Graphics)
100 plugins_src := $(call findsrc_in,Plugins,Bibtex Freetype Cairo Imlib2 \
101 Ispell Metafont Openssl @CONFIG_PDF@)
102 plugins_c_src:= $(call findc_in,Plugins,@CONFIG_PDF@)
103 x11_src := $(call findsrc_in,Plugins,@CONFIG_X11@)
104 cocoa_m_src := $(call findm_in,Plugins,@CONFIG_COCOA@)
105 cocoa_mm_src := $(call findmm_in,Plugins,@CONFIG_COCOA@ @CONFIG_MACOS@)
106 os_src := $(call findsrc_in,Plugins,@CONFIG_OS_COMPAT@)
107 qt_src := $(call findsrc_in,Plugins,@CONFIG_QT@)
108 gs_src := $(call findsrc_in,Plugins,@CONFIG_GS@)
109 style_src := $(call findsrc_in,Style,@CONFIG_EXPERIMENTAL@)
110 typeset_src := $(call findsrc,Typeset)
111 edit_src := $(call findsrc,Edit)
112 texmacs_src := $(call findsrc,Texmacs)
113 guile_src := $(call findsrc_in,Guile,Scheme) glue_all.cpp
115 # Each makefile will have its own Deps directory. Okay that is a bit
116 # inefficient, but that is much simpler to maintain.
118 # The enclosing makefile should accumulate a dependences file name in
119 # $(deps) and define an rule without command for every source file it
120 # compiles.
122 make_cpp_deps = $(patsubst %.cpp,Deps/%.d,$(notdir $(1)))
123 make_c_deps = $(patsubst %.c,Deps/%.d,$(notdir $(1)))
124 make_m_deps = $(patsubst %.m,Deps/%.d,$(notdir $(1)))
125 make_mm_deps = $(patsubst %.mm,Deps/%.d,$(notdir $(1)))
127 texmacs_cpp_deps := $(call make_cpp_deps,$(system_src) $(kernel_src) $(data_src)\
128 $(edit_src) $(guile_src) $(graphics_src)\
129 $(plugins_src) $(x11_src) $(texmacs_src)\
130 $(typeset_src) $(style_src) $(qt_src) $(gs_src) $(os_src))
131 texmacs_m_deps += $(call make_m_deps,$(cocoa_m_src))
132 texmacs_mm_deps += $(call make_mm_deps,$(cocoa_mm_src))
133 texmacs_c_deps += $(call make_c_deps,$(plugins_c_src))
135 deps += $(texmacs_cpp_deps) $(texmacs_c_deps) $(texmacs_m_deps) $(texmacs_mm_deps)
137 ###############################################################################
138 # Include files
139 ###############################################################################
141 incl_flags = $(patsubst %,-I%,$(1))
143 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)
144 kernel_incl := $(system_incl)
145 data_incl := $(system_incl)
146 graphics_incl := $(system_incl)
147 plugins_incl := $(system_incl)
148 x11_incl := $(system_incl)
149 cocoa_incl := $(system_incl)
150 os_incl := $(system_incl)
151 qt_incl := $(system_incl)
152 gs_incl := $(system_incl)
153 style_incl := $(system_incl) $(call incl_flags,Style/Memorizer Style/Environment Style/Evaluate)
154 typeset_incl := $(system_incl) $(call incl_flags,Typeset Typeset/Bridge Typeset/Concat Typeset/Page Edit)
155 guile_incl := $(typeset_incl) $(call incl_flags,Plugins Texmacs)
156 edit_incl := $(guile_incl) $(call incl_flags,Edit/Editor Edit/Interface Edit/Modify)
157 texmacs_incl := $(guile_incl)
159 ###############################################################################
160 # MOC files
161 ###############################################################################
163 # moc source files are generated for each header present in $(qt_moc) and
164 # put in the Plugins/Qt directory
166 ifeq "@CONFIG_QT@" ""
167 qt_moc :=
168 else
169 qt_moc := QTMStyle.hpp QTMGuiHelper.hpp QTMInteractiveInputHelper.hpp QTMMenuHelper.hpp QTMWidget.hpp QTMWindow.hpp QTMScrollView.hpp QTMPipeLink.hpp QTMFileDialog.hpp
170 endif
172 qt_moc_src = $(patsubst %.hpp, moc_%.cpp,$(qt_moc))
173 qt_moc_paths = $(patsubst %,./Plugins/Qt/%,$(qt_moc_src))
176 $(qt_moc_paths): ./Plugins/Qt/moc_%.cpp: ./Plugins/Qt/%.hpp
177 $(MOC) $(MOCFLAGS) $< -o $@
179 ###############################################################################
180 # Dependencies
181 ###############################################################################
183 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)
185 deps_flags = $(deps_incl)\
186 $(CPPFLAGS) $(CXXAXEL) $(CXXCAIRO) $(CXXIMLIB2) $(CXXFREETYPE) $(CXXICONV) $(CXXGUILE) \
187 -I$(tmsrc)/include $(CXXGUI)
188 # we should use -I- to separate local includes from system includes, but
189 # headers of guile 1.6.0 use includes in quotes with names relative to the
190 # current directory, and that feature is disable by -I-.
192 $(texmacs_cpp_deps): Deps/%.d: %.cpp
193 $(texmacs_m_deps): Deps/%.d: %.m
194 $(texmacs_mm_deps): Deps/%.d: %.mm
196 $(deps):
197 @ echo "make deps: $@"
198 @ set -e; $(CXX) -M $(deps_flags) $< \
199 | sed 's|\($*\)\.o[ :]*|Objects/\1.o $@ : |g' > $@; \
200 [ -s $@ ] || $(RM) $@
202 # To avoid unneeded processing, the Deps will not be included (and thus
203 # remade if needed) unless the "deps" target has been previously made,
204 # by hand.
206 deps: $(deps)
207 $(TOUCH) Deps/stamp
209 .PHONY: deps
211 ifeq ($(shell test -f Deps/stamp && echo yes || echo no),yes)
212 include $(deps)
213 endif
215 ###############################################################################
216 # Object files
217 ###############################################################################
219 makeobj = $(patsubst %.cpp,Objects/%.o,$(1))
220 makeobj_m = $(patsubst %.m,Objects/%.o,$(1))
221 makeobj_mm = $(patsubst %.mm,Objects/%.o,$(1))
222 makeobj_c = $(patsubst %.c,Objects/%.o,$(1))
224 system_obj := $(call makeobj,$(system_src))
225 kernel_obj := $(call makeobj,$(kernel_src))
226 data_obj := $(call makeobj,$(data_src))
227 edit_obj := $(call makeobj,$(edit_src))
228 guile_obj := $(call makeobj,$(guile_src))
229 graphics_obj := $(call makeobj,$(graphics_src))
230 x11_obj := $(call makeobj,$(x11_src))
231 cocoa_m_obj := $(call makeobj_m,$(cocoa_m_src))
232 cocoa_mm_obj := $(call makeobj_mm,$(cocoa_mm_src))
233 os_obj := $(call makeobj,$(os_src))
234 moc_obj := $(call makeobj,$(qt_moc_src))
235 qt_obj := $(filter-out $(moc_obj), $(call makeobj,$(qt_src)))
236 gs_obj := $(call makeobj,$(gs_src))
237 plugins_obj := $(call makeobj,$(plugins_src))
238 plugins_c_obj:= $(call makeobj_c,$(plugins_c_src))
239 texmacs_obj := $(call makeobj,$(texmacs_src))
240 typeset_obj := $(call makeobj,$(typeset_src))
241 style_obj := $(call makeobj,$(style_src))
243 # To enforce some degree of modularity, each object file must be
244 # compiled with only a specific set of include flags. To achieve that,
245 # we must disable the default (implicit) compilation rule and define
246 # an appropriate rule for each object file.
249 %.o: %.cpp # Disable implicit compilation rule
250 %.o: %.c # Disable implicit compilation rule
252 cxx_flags = $(strip $(CXX) $(1) -c $< -o $@)
253 cxx_incl = $(call cxx_flags,$(1) \
254 $(CXXAXEL) $(CXXCAIRO) $(CXXIMLIB2) $(CXXFREETYPE) $(CXXICONV) \
255 $(CXXGUILE) $(CPPFLAGS) $(CXXFLAGS))
256 cc_flags = $(strip $(CC) $(1) -c $< -o $@)
257 cc_incl = $(call cc_flags,$(1) \
258 $(CPPFLAGS) $(CXXFLAGS))
260 $(system_obj): Objects/%.o: %.cpp
261 $(call cxx_incl,$(system_incl) -I$(tmsrc)/include)
262 $(kernel_obj): Objects/%.o: %.cpp
263 $(call cxx_incl,$(kernel_incl))
264 $(data_obj): Objects/%.o: %.cpp
265 $(call cxx_incl,$(data_incl) -I$(tmsrc)/include)
266 $(edit_obj): Objects/%.o: %.cpp
267 $(call cxx_incl,$(edit_incl))
268 $(guile_obj): Objects/%.o: %.cpp
269 $(call cxx_incl,$(guile_incl))
270 $(graphics_obj): Objects/%.o: %.cpp
271 $(call cxx_incl,$(graphics_incl))
272 $(plugins_obj): Objects/%.o: %.cpp
273 $(call cxx_incl,$(plugins_incl))
274 $(plugins_c_obj): Objects/%.o: %.c
275 $(call cc_incl,$(plugins_incl))
276 $(x11_obj): Objects/%.o: %.cpp
277 $(call cxx_incl,$(x11_incl) $(CXXX11))
278 $(os_obj): Objects/%.o: %.cpp
279 $(call cxx_incl,$(os_incl))
280 $(qt_obj): Objects/%.o: %.cpp
281 $(call cxx_incl,$(qt_incl) $(CXXQT))
282 $(moc_obj): Objects/%.o: ./Plugins/Qt/%.cpp
283 $(call cxx_incl,$(qt_incl) $(CXXQT))
284 $(gs_obj): Objects/%.o: %.cpp
285 $(call cxx_incl,$(gs_incl))
286 $(cocoa_m_obj): Objects/%.o: %.m
287 $(call cxx_incl,$(cocoa_incl) $(CXXCOCOA))
288 $(cocoa_mm_obj): Objects/%.o: %.mm
289 $(call cxx_incl,$(cocoa_incl) $(CXXCOCOA))
290 $(texmacs_obj): Objects/%.o: %.cpp
291 $(call cxx_incl,$(texmacs_incl))
292 $(typeset_obj): Objects/%.o: %.cpp
293 $(call cxx_incl,$(typeset_incl))
294 $(style_obj): Objects/%.o: %.cpp
295 $(call cxx_incl,$(style_incl))
297 ###############################################################################
298 # Make editor
299 ###############################################################################
301 # Linking rules
303 # The link_bin function uses different flags depending on the value
304 # of the $(link) option, and on the host type. Its parameter must be a
305 # sequence of options for the compiler control which libraries to link
306 # with and where to find them.
308 # It should be used as the body of rules whose target are executable
309 # binaries and the prerequisites are the object files being linked in
310 # the target.
312 ifeq "$(link)" "shared"
313 ifeq "$(CONFIG_OS)" "DEC"
314 link_bin = $(strip $(LD) $(LDFLAGS) -lstdc++ $(LDSHARED) $^ $(1) -o $@)
315 else
316 link_bin = $(strip $(LD) $(LDFLAGS) $(LDSHARED) $^ $(1) -o $@)
317 endif
318 endif
319 ifeq "$(link)" "static"
320 ifeq "$(CONFIG_OS)" "DEC"
321 link_bin = $(strip $(LD) $(LDFLAGS) $^ $(LDSTATIC) $(1) -lstdc++ -o $@)
322 else
323 link_bin = $(strip $(LD) $(LDFLAGS) $^ $(LDSTATIC) $(1) -o $@)
324 endif
325 endif
327 # Compilation of objects
329 # The 'uses' function must be used as a prerequisite of a link rule
330 # (whose body is a link_bin function call). It takes a number of
331 # module names in parameters.
333 uses = $(sort $(foreach use,$(patsubst %,uses_%,$(1)),$($(use))))
335 uses_system := $(system_obj)
336 uses_kernel := $(kernel_obj)
337 uses_data := $(data_obj)
338 uses_graphics := $(graphics_obj)
339 uses_plugins := $(plugins_obj) $(plugins_c_obj)
340 uses_x11 := $(x11_obj)
341 uses_os := $(os_obj)
342 uses_qt := $(qt_obj) $(moc_obj)
343 uses_gs := $(gs_obj)
344 uses_cocoa := $(cocoa_m_obj) $(cocoa_mm_obj)
345 uses_typeset := $(typeset_obj)
346 uses_style := $(style_obj)
347 uses_edit := $(edit_obj)
348 uses_glue := $(guile_obj)
349 uses_texmacs := $(texmacs_obj)
351 # Compilation rules
353 TEXMACS_objects := $(strip $(call uses,system kernel data graphics\
354 plugins x11 os qt gs cocoa style typeset edit glue texmacs))
356 link_options:=-L$(tmsrc)/lib $(LDRT) -lm $(LDPATH) $(LDGUI) $(LDGUILE) \
357 $(LDAXEL) $(LDCAIRO) $(LDIMLIB2) $(LDFREETYPE) $(LDICONV) $(LDDL)
359 $(tmsrc)/bin/texmacs.bin: Objects/texmacs-$(link).bin
360 $(CP) $^ $@
362 Objects/texmacs-$(link).bin: $(TEXMACS_objects)
363 $(call link_bin,$(link_options))
365 all: $(tmsrc)/bin/texmacs.bin
367 .PHONY: all $(tmsrc)/bin/texmacs.bin
369 ###############################################################################
370 # Interface for Guile
371 ###############################################################################
373 # Compilation of glue
375 # When dependences are generated, the glue code can be rebuilt
376 # automatically, but only if there is an appropriate rule for
377 # regenerating the glue source from the scheme documents.
379 Guile/Glue/glue_%.cpp: Guile/Glue/build-glue-%.scm
380 $(MAKE) GLUE
382 gluesrc = Guile/Glue
384 GLUE: $(gluesrc)/glue_basic.cpp $(gluesrc)/glue_editor.cpp $(gluesrc)/glue_server.cpp
386 .PHONY: GLUE
388 $(gluesrc)/glue_basic.cpp: $(gluesrc)/build-glue.scm
389 $(gluesrc)/glue_editor.cpp: $(gluesrc)/build-glue.scm
390 $(gluesrc)/glue_server.cpp: $(gluesrc)/build-glue.scm
392 $(gluesrc)/glue_basic.cpp: $(gluesrc)/build-glue-basic.scm
393 $(GLUE) build-glue-basic.scm glue_basic.cpp
395 $(gluesrc)/glue_editor.cpp: $(gluesrc)/build-glue-editor.scm
396 $(GLUE) build-glue-editor.scm glue_editor.cpp
398 $(gluesrc)/glue_server.cpp: $(gluesrc)/build-glue-server.scm
399 $(GLUE) build-glue-server.scm glue_server.cpp
401 ###############################################################################
402 # Cleaning and backup
403 ###############################################################################
405 DISTR:
406 $(RM) Deps/*.*
407 $(RM) Deps/stamp
409 CLEAN: DISTR
410 $(RM) Objects/*.o
411 $(RM) Plugins/Qt/moc_*.cpp
413 clean: CLEAN
415 maintainer-clean: CLEAN
416 $(RM) Objects/*.*
418 PHONY: DISTR CLEAN clean maintainer-clean