root/trunk/m2/m2_sun.r

Revision 244, 7.0 kB (checked in by krobillard, 2 years ago)

m2 - Added lines to link statically with Qt on Solaris.

Line 
1REBOL [
2    Title: "m2 Solaris-g++ template"
3]
4
5
6sun:  func [blk] [do blk]
7unix: func [blk] [do blk]
8
9eol: "^/"
10
11dist_files: function [] [str obj] [
12    str: make string! 64
13
14    obj: []
15    foreach t m2/targets [ append obj t/objdir ]
16    obj: intersect obj obj   ; Removes duplicates.
17    append str obj
18
19    foreach t m2/targets [ append str t/dist ]
20    str
21]
22
23generate_makefile: does [
24    foreach t m2/targets [
25        ;probe t
26
27        ; make_obj_rule must be called before we write DIST_FILES since
28        ; it finds the header dependencies.
29        t/built_obj_rule: t/make_obj_rule
30    ]
31
32    emit do_tags copy gnu_header
33
34    emit "^/#------ Target settings"
35    foreach t m2/targets [ emit "^/^/" t/macro_text ]
36
37    emit [ {^/ARCHIVE = } m2/project_version {^/DIST_FILES = \^/} ]
38    if not empty? m2/distribution_files [
39        emit expand_list_gnu/part m2/distribution_files
40    ]
41    emit expand_list_gnu m2/header_files_used
42
43    emit "^/^/#------ Build rules^/^/all:"
44    foreach t m2/targets [ emit [ " " t/output_file ] ]
45    emit eol
46
47    foreach t m2/targets [ emit " " t/rule_text ]
48
49    emit [ "^/^/" do_tags copy gnu_other_rules ]
50
51    foreach t m2/targets [ emit t/clean ]
52
53    emit "^/^/#------ Compile rules^/^/"
54    foreach t m2/targets [
55        emit t/built_obj_rule
56        if t/cfg/qt [ emit t/moc_rule ]
57    ]
58
59    emit "^/#EOF^/"
60]
61
62
63qt-includes: context [
64   gui:     does [ include_from {$(QTDIR)/include/QtGui} ]
65   network: does [ include_from {$(QTDIR)/include/QtNetwork} ]
66   opengl:  does [ include_from {$(QTDIR)/include/QtOpenGL} ]
67   xml:     does [ include_from {$(QTDIR)/include/QtXml} ]
68   svg:     does [ include_from {$(QTDIR)/include/QtSvg} ]
69   sql:     does [ include_from {$(QTDIR)/include/QtSql} ]
70   support: does [ include_from {$(QTDIR)/include/Qt3Support}
71                   cxxflags {-DQT3_SUPPORT} ]
72]
73
74qt-libraries: context [
75   core:    { QtCore}
76   gui:     { QtGui}
77   network: { QtNetwork}
78   opengl:  { QtOpenGL}
79   xml:     { QtXml}
80   svg:     { QtSvg}
81   sql:     { QtSql}
82   support: { Qt3Support}
83]
84
85qt-debug-libraries: context [
86   core:    { QtCore_debug}
87   gui:     { QtGui_debug}
88   network: { QtNetwork_debug}
89   opengl:  { QtOpenGL_debug}
90   xml:     { QtXml_debug}
91   svg:     { QtSvg_debug}
92   sql:     { QtSql_debug}
93   support: { Qt3Support_debug}
94]
95
96
97exe_target: make m2/target_env
98[
99    ; built_obj_rule exists only to hold the output make_obj_rule
100    built_obj_rule: none
101
102    obj_macro: none
103
104    config:
105    [
106        obj_macro: rejoin [ "$(" uppercase name "_OBJECTS)" ]
107
108        cflags {-pipe}
109
110        if cfg/warn [
111            cflags {-Wall -W}
112        ]
113
114        if cfg/debug [
115            cflags {-g -DDEBUG}
116        ]
117
118        if cfg/release [
119            cflags {-O3 -DNDEBUG}
120        ]
121
122        if cfg/opengl [
123            libs {GL GLU}
124            ;libs_from %/usr/X/lib {glut Xi}
125            ;libs {glut Xi Xmu}
126        ]
127
128        if cfg/qt [
129            either cfg/qt = 3 [
130                include_from {$(QTDIR)/include}
131            ][
132                include_from {$(QTDIR)/include}
133                include_from {$(QTDIR)/include/QtCore}
134                do bind cfg/qt in qt-includes 'gui
135            ]
136            if cfg/release [
137                cxxflags {-DQT_NO_DEBUG}
138            ]
139        ]
140
141        if cfg/x11 [
142            include_from {/usr/X/include}
143            libs_from %/usr/X/lib {Xext X11}
144        ]
145    ]
146
147    configure: does [
148        output_file: rejoin [ output_dir name ]
149        do config
150        if cfg/qt [
151            either cfg/qt = 3 [
152                ;libs_from %"$(QTDIR)/lib" {qt-mt}
153
154                ; Linking statically requires more libs.
155                libs_from %"$(QTDIR)/lib" {qt}
156                libs_from %/usr/X/lib {SM Xext X11 ICE}
157                libs {dl}
158            ][
159                append qt4-libs: copy cfg/qt 'core
160               
161                libs_from %"$(QTDIR)/lib"
162                    rejoin bind qt4-libs either cfg/debug
163                            [in qt-debug-libraries 'gui]
164                            [in qt-libraries 'gui]
165
166                ; Linking statically requires more libs.
167                libs_from %/usr/X/lib {SM Xi Xext X11 ICE}
168                libs_from %/usr/sfw/lib {freetype}
169                libs {pthread dl rt z}
170            ]
171        ]
172    ]
173
174    macro_text: func []
175    [
176        emit [
177            uc_name "_CFLAGS   = " menv_cflags " " gnu_string "-D" defines eol
178            uc_name "_CXXFLAGS = $(" uc_name "_CFLAGS) " menv_cxxflags eol
179            uc_name "_INCPATH  = " gnu_string "-I" include_paths eol
180            uc_name "_LFLAGS   = " menv_lflags eol
181            uc_name "_LIBS     = " gnu_string "-L" link_paths " "
182                              gnu_string "-l" link_libs eol
183        ]
184
185        ;if cfg/qt [
186        ;    emit [
187        ;        uc_name "_SRCMOC  = " expand_list_gnu srcmoc_files eol
188        ;        uc_name "_OBJMOC  = " expand_list_gnu objmoc_files eol
189        ;    ]
190        ;]
191
192        emit [
193            ;uc_name "_HEADERS  = " expand_list_gnu header_files eol
194            uc_name "_SOURCES  = " expand_list_gnu source_files eol
195            uc_name "_OBJECTS  = " expand_list_gnu object_files eol
196        ]
197    ]
198
199    clean: does [ rejoin [ "^(tab)-rm -f " output_file " " obj_macro eol ] ]
200    ; TODO: if cfg/qt [ "rm -f $(_SRCMOC)" ]
201
202    dist: func [] [
203        rejoin [" $(" uc_name "_SOURCES)" ]
204    ]
205
206    rule_text: func []
207    [
208        emit [ eol output_file ": " obj_macro m2/local_libs link_libs
209            {^/^(tab)$(}
210                either link_cxx ["LINK_CXX"]["LINK"]
211                {) -o $@ $(} uc_name {_LFLAGS) } obj_macro
212            { $(} uc_name {_LIBS)} eol
213        ]
214    ]
215]
216
217
218lib_target: make exe_target [
219    configure: does [
220        output_file: rejoin [ output_dir "lib" name ".a" ]
221        do config
222    ]
223
224    rule_text: function [] []
225    [
226        emit [ eol output_file ": " obj_macro
227            "^/^(tab)ar rc $@ " obj_macro " $(" uppercase name "_LFLAGS)"
228            "^/^(tab)ranlib $@^/"
229        ]
230    ]
231]
232
233
234shlib_target: make exe_target [
235    configure: does [
236        output_file: rejoin [ output_dir "lib" name ".so" ]
237        do config
238        cflags {-fPIC}
239        lflags {-shared}
240    ]
241]
242
243
244gnu_header:
245{#----------------------------------------------------------------------------
246# Makefile for GNU make
247# Generated by m2 at <now>
248# Project: <m2/project_name>
249#----------------------------------------------------------------------------
250
251
252#------ Compiler and tools
253
254CC       = gcc
255CXX      = g++
256LINK     = gcc
257LINK_CXX = g++
258TAR      = tar -cf
259GZIP     = gzip -9f
260MOC      = $(QTDIR)/bin/moc
261
262}
263;#------ Project-wide settings
264
265
266gnu_other_rules:
267{<m2/makefile>: <project_file>
268^(tab)m2 <project_file>
269
270.PHONY: dist
271dist:
272^(tab)$(TAR) $(ARCHIVE).tar --exclude CVS --exclude .svn --exclude *.o <project_file> <dist_files> $(DIST_FILES)
273^(tab)mkdir /tmp/$(ARCHIVE)
274^(tab)tar -C /tmp/$(ARCHIVE) -xf $(ARCHIVE).tar
275^(tab)tar -C /tmp -cf $(ARCHIVE).tar $(ARCHIVE)
276^(tab)rm -rf /tmp/$(ARCHIVE)
277^(tab)$(GZIP) $(ARCHIVE).tar
278
279.PHONY: clean
280clean:
281^(tab)-rm -f core
282}
283
284
285;EOF
Note: See TracBrowser for help on using the browser.