3 import waflib
.Options
as Options
4 from waflib
.Configure
import conf
5 from waflib
import Logs
10 # Version of this package (even if built as a child)
14 FL_PATCH_VERSION
='1000'
16 PACKAGE_VERSION
= FL_MAJOR_VERSION
+ '.' + FL_MINOR_VERSION
+ '.' + FL_PATCH_VERSION
18 API_VERSION
= FL_MAJOR_VERSION
+ '.' + FL_MINOR_VERSION
20 # Variables for 'waf dist'
22 VERSION
= PACKAGE_VERSION
28 children
= [ 'fluid', 'test' ]
31 CFLAGS
= [ '-pthread',
32 '-D_LARGEFILE64_SOURCE',
33 '-D_FILE_OFFSET_BITS=64' ]
36 def makelib(bld
,*k
,**kw
):
37 kw
['includes'] = ['.', 'src', 'src/xutf8/headers' ]
38 kw
['cflags'] = [ '-fPIC' ]
39 kw
['cxxflags'] = [ '-fPIC' ]
40 kw
['defines'] = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ]
41 kw
['vnum'] = PACKAGE_VERSION
42 kw
['install_path'] = '${LIBDIR}'
43 kw
['features' ] = 'c cxx cxxstlib'
44 kw
['name'] = kw
['target'] + '_static'
46 kw
['features' ] = 'c cxx cxxshlib'
47 kw
['name'] = kw
['target'] + '_shared'
51 def run_ldconfig(ctx
):
52 if (ctx
.cmd
== 'install'
53 and not ctx
.env
['RAN_LDCONFIG']
55 and not os
.environ
.get('DESTDIR')):
57 Logs
.info("Waf: Running `/sbin/ldconfig %s'" % ctx
.env
['LIBDIR'])
58 subprocess
.call(['/sbin/ldconfig', ctx
.env
['LIBDIR']])
59 ctx
.env
['RAN_LDCONFIG'] = True
64 opt
.load('compiler_c')
65 opt
.load('compiler_cxx')
68 opt
.add_option('--enable-debug', action
='store_true', default
=False, dest
='debug',
69 help='Build for debugging')
70 opt
.add_option('--enable-gl', action
='store_true', default
=False, dest
='USE_GL',
71 help='Build with OpenGL extension library')
72 opt
.add_option('--enable-test', action
='store_true', default
=False, dest
='ENABLE_TEST',
73 help='Build test programs')
76 conf
.load('compiler_c')
77 conf
.load('compiler_cxx')
79 # conf.load('ntk_fluid')
81 conf
.env
.append_value('CFLAGS', ['-Wall'])
82 # conf.env.append_value('CXXFLAGS',['-Wall','-fno-exceptions', '-fno-rtti'])
83 conf
.env
.append_value('CXXFLAGS', ['-Wall'])
85 conf
.check_cfg(package
='x11', uselib_store
='X11', args
="--cflags --libs",
88 conf
.check_cfg(package
='fontconfig', uselib_store
='FONTCONFIG', args
="--cflags --libs",
91 conf
.check_cfg(package
='xft', uselib_store
='XFT', args
="--cflags --libs",
94 conf
.check_cfg(package
='cairo', uselib_store
='CAIRO', args
="--cflags --libs",
95 atleast_version
='1.10.0', mandatory
=True)
98 conf
.check(header_name
='unistd.h', define_name
='HAVE_UNISTD_H', mandatory
=False)
99 conf
.check(header_name
='pthread.h', define_name
='HAVE_PTHREAD_H', mandatory
=False)
100 conf
.check(header_name
='dirent.h', define_name
='HAVE_DIRENT_H', mandatory
=False)
101 conf
.check(header_name
='string.h', define_name
='HAVE_STRINGS_H', mandatory
=False)
102 conf
.check(header_name
='locale.h', define_name
='HAVE_LOCALE_H', mandatory
=False)
103 conf
.check(header_name
='sys/select.h', define_name
='HAVE_SYS_SELECT_H', mandatory
=False)
104 conf
.check(header_name
='dlfcn.h', define_name
='HAVE_DLFCN_H', mandatory
=False)
105 conf
.check(header_name
='sys/stdtypes.h', define_name
='HAVE_SYS_STDTYPES_H', mandatory
=False)
106 conf
.check(header_name
='pthread.h', define_name
='HAVE_PTHREAD', mandatory
=True)
107 conf
.check(header_name
='png.h', define_name
='HAVE_PNG_H', mandatory
=False)
109 conf
.check(features
='c cprogram',
110 fragment
='#include <pthread.h>\nint main ( int argc, const char **argv ) { return PTHREAD_MUTEX_RECURSIVE; }\n',
112 define_name
='HAVE_PTHREAD_MUTEX_RECURSIVE', mandatory
=False,
113 msg
='Checking for PTHREAD_MUTEX_RECURSIVE')
114 # conf.check(function_name='jpeg_CreateCompress', header_name='jpeglib.h', use='jpeg', define_name='HAVE_LIBJPEG', mandatory=False)
116 if Options
.options
.ENABLE_TEST
:
117 conf
.env
.ENABLE_TEST
= True
119 conf
.env
.BUNDLED
= []
121 conf
.env
['LIB_PTHREAD'] = ['pthread']
122 conf
.env
['LIB_DL'] = ['dl']
123 conf
.env
['LIB_M'] = ['m']
125 conf
.env
.BUNDLED
= []
127 conf
.check(function_name
='strtoll', header_name
="stdlib.h", define_name
='HAVE_STRTOLL', mandatory
=False)
128 conf
.check(function_name
='scandir', header_name
="dirent.h", define_name
='HAVE_SCANDIR', mandatory
=False)
130 conf
.check(lib
='jpeg', uselib_store
='LIBJPEG', mandatory
=True )
131 conf
.check_cfg(package
='libpng', uselib_store
='LIBPNG', args
="--cflags --libs",
133 conf
.check_cfg(package
='zlib', uselib_store
='LIBZ', args
="--cflags --libs",
137 if Options
.options
.USE_GL
:
138 conf
.env
.append_value( 'USE_GL', '1' )
139 conf
.check_cfg(package
='glu', uselib_store
='GL', args
="--cflags --libs",
141 conf
.define('HAVE_GL', 1 )
142 conf
.check(header_name
='GL/glu.h', define_name
='HAVE_GL_GLU_H')
144 conf
.check( fragment
='#include <stdio.h>\n int main ( int argc, char **argv ) { printf("%u", (unsigned)sizeof(long long)); return 0; }',
146 define_name
='HAVE_LONG_LONG',
147 msg
='Checking for long long type',
151 if sys
.platform
== 'darwin':
152 conf
.define( '__APPLE__', 1 )
153 if sys
.platform
== 'win32':
154 conf
.define( 'WIN32', 1 )
156 conf
.define( 'HAVE_X11', 1 )
157 conf
.define( 'USE_X11', 1 )
158 conf
.define( 'USE_XFT', 1 )
160 conf
.define( 'USE_POLL', 1 )
161 conf
.define( 'BORDER_WIDTH', 1 )
163 conf
.define( 'HAVE_SCANDIR_POSIX', 1 )
165 conf
.check(function_name
='strcasecmp', header_name
="strings.h", define_name
='HAVE_STRCASECMP', mandatory
=False)
166 conf
.check(function_name
='snprintf', header_name
="stdio.h", define_name
='HAVE_SNPRINTF', mandatory
=False)
167 conf
.check(function_name
='vsnprintf', header_name
=['stdio.h','stdarg.h'], define_name
='HAVE_SNPRINTF', mandatory
=False)
169 conf
.define( 'HAVE_DLSYM', 1 )
173 conf
.check( fragment
='#include <stdio.h>\n int main ( int argc, char **argv ) { printf("%u", (unsigned)sizeof(short)); return 0; }',
177 define_name
='SIZEOF_SHORT',
178 msg
='Checking sizeof short',
181 conf
.check( fragment
='#include <stdio.h>\n int main ( int argc, char **argv ) { printf("%u", (unsigned)sizeof(int)); return 0; }',
185 msg
='Checking sizeof int',
186 define_name
='SIZEOF_INT', mandatory
=True );
188 conf
.check( fragment
='#include <stdio.h>\n int main ( int argc, char **argv ) { printf("%u", (unsigned)sizeof(long)); return 0; }',
192 msg
='Checking sizeof long',
193 define_name
='SIZEOF_LONG', mandatory
=True );
195 if int(conf
.get_define('SIZEOF_SHORT')) == 2:
196 conf
.define( 'U16', 'unsigned short', quote
=False )
198 if int(conf
.get_define('SIZEOF_INT')) == 4:
199 conf
.define( 'U32', 'unsigned int', quote
=False )
200 elif int(conf
.get_define('SIZEOF_LONG')) == 4:
201 conf
.define( 'U32', 'unsigned long', quote
=False )
203 if int(conf
.get_define('SIZEOF_INT')) == 8:
204 conf
.define( 'U64', 'unsigned int', quote
=False )
205 elif int(conf
.get_define('SIZEOF_LONG')) == 8:
206 conf
.define( 'U64', 'unsigned long', quote
=False )
208 # FIXME: use a test for this
209 conf
.define( 'WORDS_BIGENDIAN', 0 )
211 optimization_flags
= [
213 "-fomit-frame-pointer",
215 # "-fstrength-reduce",
225 print('Note: "not found" is OK for optional items.')
229 if Options
.options
.debug
:
230 print('Building for debugging')
231 conf
.env
.append_value('CFLAGS', debug_flags
)
232 conf
.env
.append_value('CXXFLAGS', debug_flags
)
234 print('Building for performance')
235 conf
.env
.append_value('CFLAGS', optimization_flags
)
236 conf
.env
.append_value('CXXFLAGS', optimization_flags
)
237 conf
.define( 'NDEBUG', 1 )
239 conf
.env
.append_value('CFLAGS', CFLAGS
)
240 conf
.env
.append_value('CXXFLAGS', CFLAGS
)
242 conf
.define('VERSION', PACKAGE_VERSION
)
243 conf
.define('FLTK_DOCDIR', conf
.env
.DOCDIR
);
244 # conf.define('SYSTEM_PATH', string.join( [ conf.env.DATADIR, APPNAME ], '/' ) )
245 # conf.define('DOCUMENT_PATH', conf.env.DOCDIR )
246 # conf.define('PIXMAP_PATH', string.join( [ conf.env.DATADIR, APPNAME ], '/' ) )
248 conf
.write_config_header('config.h', remove
=False)
250 for i
in conf
.env
.BUNDLED
:
261 bld
.makelib( source
= '''
262 src/Fl_Cairo_Graphics_Driver.cxx
268 src/Fl_Browser_load.cxx
272 src/Fl_Check_Browser.cxx
273 src/Fl_Check_Button.cxx
275 src/Fl_Color_Chooser.cxx
280 src/Fl_Double_Window.cxx
281 src/Fl_File_Browser.cxx
282 src/Fl_File_Chooser.cxx
283 src/Fl_File_Chooser2.cxx
285 src/Fl_File_Input.cxx
291 src/Fl_Light_Button.cxx
295 src/Fl_Sys_Menu_Bar.cxx
296 src/Fl_Menu_Button.cxx
297 src/Fl_Menu_Window.cxx
299 src/Fl_Menu_global.cxx
300 src/Fl_Multi_Label.cxx
301 src/Fl_Native_File_Chooser.cxx
302 src/Fl_Overlay_Window.cxx
304 src/Fl_Paged_Device.cxx
307 src/Fl_Positioner.cxx
308 src/Fl_Preferences.cxx
311 src/Fl_Repeat_Button.cxx
312 src/Fl_Return_Button.cxx
313 src/Fl_Round_Button.cxx
316 src/Fl_Shared_Image.cxx
317 src/Fl_Single_Window.cxx
322 src/Fl_Text_Buffer.cxx
323 src/Fl_Text_Display.cxx
324 src/Fl_Text_Editor.cxx
326 src/Fl_Tiled_Image.cxx
329 src/Fl_Tree_Item_Array.cxx
330 src/Fl_Tree_Prefs.cxx
333 src/Fl_Value_Input.cxx
334 src/Fl_Value_Output.cxx
335 src/Fl_Value_Slider.cxx
338 src/Fl_Window_fullscreen.cxx
339 src/Fl_Window_hotspot.cxx
340 src/Fl_Window_iconize.cxx
350 src/Fl_get_system_colors.cxx
353 src/Fl_own_colormap.cxx
356 src/filename_absolute.cxx
357 src/filename_expand.cxx
359 src/filename_isdir.cxx
360 src/filename_list.cxx
361 src/filename_match.cxx
362 src/filename_setext.cxx
370 src/fl_diamond_box.cxx
374 src/fl_draw_image.cxx
375 src/fl_draw_pixmap.cxx
376 src/fl_encoding_latin1.cxx
377 src/fl_encoding_mac_roman.cxx
378 src/fl_engraved_label.cxx
382 src/fl_line_style.cxx
386 src/fl_read_image.cxx
389 src/fl_rounded_box.cxx
392 src/fl_scroll_area.cxx
393 src/fl_shadow_box.cxx
395 src/fl_show_colormap.cxx
401 src/Fl_Theme_Chooser.cxx
405 src/Crystal_Theme.cxx
412 src/xutf8/is_right2left.c
413 src/xutf8/is_spacing.c
414 src/xutf8/keysym2Ucs.c
415 src/xutf8/utf8Input.c
416 src/xutf8/utf8Utils.c
422 uselib
= [ 'X11', 'FONTCONFIG', 'XFT', 'CAIRO', 'DL', 'M', 'PTHREAD' ] )
424 bld
.makelib( source
= '''
425 src/fl_images_core.cxx
427 src/Fl_File_Icon2.cxx
429 src/Fl_Help_Dialog.cxx
430 src/Fl_JPEG_Image.cxx
434 target
= 'ntk_images',
435 uselib
= [ 'LIBJPEG', 'LIBPNG', 'LIBZ', 'DL', 'M', 'PTHREAD' ] )
442 src/glut_compatability.cxx
445 src/Fl_Gl_Device_Plugin.cxx
446 src/Fl_Gl_Overlay.cxx
450 uselib
= [ 'X11', 'DL', 'M', 'PTHREAD', 'GL'] )
452 bld( features
= 'subst',
453 source
= 'ntk.pc.in',
456 install_path
= '${LIBDIR}/pkgconfig',
457 CFLAGS
= ' '.join( CFLAGS
),
459 PREFIX
= bld
.env
.PREFIX
)
461 bld( features
= 'subst',
462 source
= 'ntk_images.pc.in',
463 target
= 'ntk_images.pc',
465 install_path
= '${LIBDIR}/pkgconfig',
466 CFLAGS
= ' '.join( CFLAGS
),
468 PREFIX
= bld
.env
.PREFIX
)
470 bld( features
= 'subst',
471 source
= 'ntk_gl.pc.in',
472 target
= 'ntk_gl.pc',
474 install_path
= '${LIBDIR}/pkgconfig',
475 CFLAGS
= ' '.join( CFLAGS
),
477 PREFIX
= bld
.env
.PREFIX
)
479 bld( features
= 'subst',
480 source
= 'ntk-uninstalled.pc.in',
481 target
= 'ntk-uninstalled.pc',
483 CFLAGS
= ' '.join( CFLAGS
),
485 BUILD
= os
.getcwd() + '/' + out
)
487 bld( features
= 'subst',
488 source
= 'ntk_images.pc.in',
489 target
= 'ntk_images-uninstalled.pc',
492 CFLAGS
= ' '.join( CFLAGS
),
493 BUILD
= os
.getcwd() + '/' + out
)
496 bld( features
= 'subst',
497 source
= 'ntk_gl.pc.in',
498 target
= 'ntk_gl-uninstalled.pc',
501 CFLAGS
= ' '.join( CFLAGS
),
502 BUILD
= os
.getcwd() + '/' + out
)
506 source
= 'src/ntk-chtheme.cxx',
507 target
= 'ntk-chtheme',
509 use
= ['ntk_images_shared', 'ntk_shared'],
510 install_path
= "${BINDIR}" )
512 # bld( features = 'subst',
513 # source = 'ntk-config.in',
514 # target = '../ntk-config',
517 # # VERSION = VERSION,
518 # FL_MAJOR_VERSION = FL_MAJOR_VERSION,
519 # FL_MINOR_VERSION = FL_MINOR_VERSION,
520 # FL_PATCH_VERSION = FL_PATCH_VERSION,
521 # preifx = bld.env.PREFIX,
522 # exec_prefix = bld.env.EXECPREFIX,
523 # bindir = bld.env.BINDIR,
524 # includedir = bld.env.INCLUDEDIR,
525 # libdir = bld.env.LIBDIR,
526 # srcdir = os.getcwd() + '/' + out,
527 # CC = bld.env.CC[0],
528 # CXX = bld.env.CXX[0],
529 # CFLAGS = string.join( bld.env.CFLAGS, ' ' ),
530 # CXXFLAGS = string.join( bld.env.CXXFLAGS, ' ' ),
531 # LDFLAGS = bld.env.LDFLAGS,
532 # CAIROLIBS = '-lcairo',
534 # install_path = '${BINDIR}' )
536 for i
in bld
.env
.BUNDLED
:
542 # 'PREFIX': bld.env.PREFIX,
543 # 'EXEC_PREFIX' : bld.env.EXEC_PREFIX,
544 # 'BINDIR' : bld.env.BINDIR,
545 # 'INCLUDEDIR' : bld.env.INCLUDEDIR,
546 # 'LIBDIR' : bld.env.LIBDIR,
547 # 'SRCDIR' : bld.env.SRCDIR } )
550 start_dir
= bld
.path
.find_dir( 'FL' )
552 bld
.install_files( bld
.env
.INCLUDEDIR
+ '/ntk/FL', start_dir
.ant_glob('*.H *.h'),
553 cwd
=start_dir
, relative_trick
=True)
555 bld
.add_post_fun( run_ldconfig
)
557 # bld.install_files( string.join( [ '${DATADIR}/doc', APPNAME ], '/' ), bld.path.ant_glob( 'doc/*.html doc/*.png' ) )