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)
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',
37 def makelib(bld
,*k
,**kw
):
38 kw
['includes'] = ['.', 'src', 'src/xutf8/headers' ]
39 kw
['cflags'] = [ '-fPIC' ]
40 kw
['cxxflags'] = [ '-fPIC' ]
41 kw
['defines'] = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ]
42 kw
['vnum'] = API_VERSION
43 kw
['install_path'] = '${LIBDIR}'
44 kw
['features' ] = 'c cxx cxxstlib'
45 kw
['name'] = kw
['target'] + '_static'
47 kw
['features' ] = 'c cxx cxxshlib'
48 kw
['name'] = kw
['target'] + '_shared'
52 def run_ldconfig(ctx
):
53 if (ctx
.cmd
== 'install'
54 and not ctx
.env
['RAN_LDCONFIG']
56 and not os
.environ
.get('DESTDIR')):
58 Logs
.info("Waf: Running `/sbin/ldconfig %s'" % ctx
.env
['LIBDIR'])
59 subprocess
.call(['/sbin/ldconfig', ctx
.env
['LIBDIR']])
60 ctx
.env
['RAN_LDCONFIG'] = True
65 opt
.load('compiler_c')
66 opt
.load('compiler_cxx')
69 opt
.add_option('--enable-debug', action
='store_true', default
=False, dest
='debug',
70 help='Build for debugging')
71 opt
.add_option('--enable-gl', action
='store_true', default
=False, dest
='USE_GL',
72 help='Build with OpenGL extension library')
73 opt
.add_option('--enable-test', action
='store_true', default
=False, dest
='ENABLE_TEST',
74 help='Build test programs')
77 conf
.load('compiler_c')
78 conf
.load('compiler_cxx')
80 # conf.load('ntk_fluid')
82 conf
.env
.append_value('CFLAGS', ['-Wall'])
83 # conf.env.append_value('CXXFLAGS',['-Wall','-fno-exceptions', '-fno-rtti'])
84 conf
.env
.append_value('CXXFLAGS', ['-Wall'])
86 conf
.check_cfg(package
='x11', uselib_store
='X11', args
="--cflags --libs",
89 conf
.check_cfg(package
='fontconfig', uselib_store
='FONTCONFIG', args
="--cflags --libs",
92 conf
.check_cfg(package
='xft', uselib_store
='XFT', args
="--cflags --libs",
95 conf
.check_cfg(package
='cairo', uselib_store
='CAIRO', args
="--cflags --libs",
96 atleast_version
='1.10.0', mandatory
=True)
99 conf
.check(header_name
='unistd.h', define_name
='HAVE_UNISTD_H', mandatory
=False)
100 conf
.check(header_name
='pthread.h', define_name
='HAVE_PTHREAD_H', mandatory
=False)
101 conf
.check(header_name
='dirent.h', define_name
='HAVE_DIRENT_H', mandatory
=False)
102 conf
.check(header_name
='string.h', define_name
='HAVE_STRINGS_H', mandatory
=False)
103 conf
.check(header_name
='locale.h', define_name
='HAVE_LOCALE_H', mandatory
=False)
104 conf
.check(header_name
='sys/select.h', define_name
='HAVE_SYS_SELECT_H', mandatory
=False)
105 conf
.check(header_name
='dlfcn.h', define_name
='HAVE_DLFCN_H', mandatory
=False)
106 conf
.check(header_name
='sys/stdtypes.h', define_name
='HAVE_SYS_STDTYPES_H', mandatory
=False)
107 conf
.check(header_name
='pthread.h', define_name
='HAVE_PTHREAD', mandatory
=True)
108 conf
.check(header_name
='png.h', define_name
='HAVE_PNG_H', mandatory
=False)
110 conf
.check(features
='c cprogram',
111 fragment
='#include <pthread.h>\nint main ( int argc, const char **argv ) { return PTHREAD_MUTEX_RECURSIVE; }\n',
113 define_name
='HAVE_PTHREAD_MUTEX_RECURSIVE', mandatory
=False,
114 msg
='Checking for PTHREAD_MUTEX_RECURSIVE')
115 # conf.check(function_name='jpeg_CreateCompress', header_name='jpeglib.h', use='jpeg', define_name='HAVE_LIBJPEG', mandatory=False)
117 if Options
.options
.ENABLE_TEST
:
118 conf
.env
.ENABLE_TEST
= True
120 conf
.env
.BUNDLED
= []
122 conf
.env
['LIB_PTHREAD'] = ['pthread']
123 conf
.env
['LIB_DL'] = ['dl']
124 conf
.env
['LIB_M'] = ['m']
126 conf
.env
.BUNDLED
= []
128 conf
.check(function_name
='strtoll', header_name
="stdlib.h", define_name
='HAVE_STRTOLL', mandatory
=False)
129 conf
.check(function_name
='scandir', header_name
="dirent.h", define_name
='HAVE_SCANDIR', mandatory
=False)
131 conf
.check(lib
='jpeg', uselib_store
='LIBJPEG', mandatory
=True )
132 conf
.check_cfg(package
='libpng', uselib_store
='LIBPNG', args
="--cflags --libs",
134 conf
.check_cfg(package
='zlib', uselib_store
='LIBZ', args
="--cflags --libs",
138 if Options
.options
.USE_GL
:
139 conf
.env
.append_value( 'USE_GL', '1' )
140 conf
.check_cfg(package
='glu', uselib_store
='GL', args
="--cflags --libs",
142 conf
.define('HAVE_GL', 1 )
143 conf
.check(header_name
='GL/glu.h', define_name
='HAVE_GL_GLU_H')
145 # FIXME: HAVE_LONG_LONG
147 optimization_flags
= [
149 "-fomit-frame-pointer",
151 # "-fstrength-reduce",
161 if Options
.options
.debug
:
162 print('Building for debugging')
163 conf
.env
.append_value('CFLAGS', debug_flags
)
164 conf
.env
.append_value('CXXFLAGS', debug_flags
)
166 print('Building for performance')
167 conf
.env
.append_value('CFLAGS', optimization_flags
)
168 conf
.env
.append_value('CXXFLAGS', optimization_flags
)
169 conf
.define( 'NDEBUG', 1 )
171 conf
.env
.append_value('CFLAGS', CFLAGS
)
172 conf
.env
.append_value('CXXFLAGS', CFLAGS
)
174 if sys
.platform
== 'darwin':
175 conf
.define( '__APPLE__', 1 )
176 if sys
.platform
== 'win32':
177 conf
.define( 'WIN32', 1 )
179 conf
.define( 'HAVE_X11', 1 )
180 conf
.define( 'USE_X11', 1 )
182 conf
.define( 'USE_POLL', 1 )
183 conf
.define( 'USE_XFT', 1 )
184 conf
.define( 'BORDER_WIDTH', 1 )
186 conf
.define( 'HAVE_SCANDIR_POSIX', 1 )
187 conf
.define( 'HAVE_STRCASECMP', 1 )
188 conf
.define( 'HAVE_VSNPRINTF', 1 )
189 conf
.define( 'HAVE_SNPRINTF', 1 )
190 conf
.define( 'HAVE_STRTOLL', 1 )
192 conf
.define( 'HAVE_DLSYM', 1 )
195 # FIXME: use tests for these
197 conf
.define( 'U16', 'unsigned short', quote
=False )
198 conf
.define( 'U32', 'unsined', quote
=False )
199 conf
.define( 'U64', 'unsigned long', quote
=False )
201 conf
.define( 'WORDS_BIGENDIAN', 0 )
203 conf
.define('VERSION', PACKAGE_VERSION
)
204 conf
.define('FLTK_DOCDIR', conf
.env
.DOCDIR
);
205 # conf.define('SYSTEM_PATH', string.join( [ conf.env.DATADIR, APPNAME ], '/' ) )
206 # conf.define('DOCUMENT_PATH', conf.env.DOCDIR )
207 # conf.define('PIXMAP_PATH', string.join( [ conf.env.DATADIR, APPNAME ], '/' ) )
209 conf
.write_config_header('config.h', remove
=False)
211 for i
in conf
.env
.BUNDLED
:
222 bld
.makelib( source
= '''
223 src/Fl_Cairo_Graphics_Driver.cxx
229 src/Fl_Browser_load.cxx
233 src/Fl_Check_Browser.cxx
234 src/Fl_Check_Button.cxx
236 src/Fl_Color_Chooser.cxx
241 src/Fl_Double_Window.cxx
242 src/Fl_File_Browser.cxx
243 src/Fl_File_Chooser.cxx
244 src/Fl_File_Chooser2.cxx
246 src/Fl_File_Input.cxx
252 src/Fl_Light_Button.cxx
256 src/Fl_Sys_Menu_Bar.cxx
257 src/Fl_Menu_Button.cxx
258 src/Fl_Menu_Window.cxx
260 src/Fl_Menu_global.cxx
261 src/Fl_Multi_Label.cxx
262 src/Fl_Native_File_Chooser.cxx
263 src/Fl_Overlay_Window.cxx
265 src/Fl_Paged_Device.cxx
268 src/Fl_Positioner.cxx
269 src/Fl_Preferences.cxx
272 src/Fl_Repeat_Button.cxx
273 src/Fl_Return_Button.cxx
274 src/Fl_Round_Button.cxx
277 src/Fl_Shared_Image.cxx
278 src/Fl_Single_Window.cxx
283 src/Fl_Text_Buffer.cxx
284 src/Fl_Text_Display.cxx
285 src/Fl_Text_Editor.cxx
287 src/Fl_Tiled_Image.cxx
290 src/Fl_Tree_Item_Array.cxx
291 src/Fl_Tree_Prefs.cxx
294 src/Fl_Value_Input.cxx
295 src/Fl_Value_Output.cxx
296 src/Fl_Value_Slider.cxx
299 src/Fl_Window_fullscreen.cxx
300 src/Fl_Window_hotspot.cxx
301 src/Fl_Window_iconize.cxx
311 src/Fl_get_system_colors.cxx
314 src/Fl_own_colormap.cxx
317 src/filename_absolute.cxx
318 src/filename_expand.cxx
320 src/filename_isdir.cxx
321 src/filename_list.cxx
322 src/filename_match.cxx
323 src/filename_setext.cxx
331 src/fl_diamond_box.cxx
335 src/fl_draw_image.cxx
336 src/fl_draw_pixmap.cxx
337 src/fl_encoding_latin1.cxx
338 src/fl_encoding_mac_roman.cxx
339 src/fl_engraved_label.cxx
343 src/fl_line_style.cxx
347 src/fl_read_image.cxx
350 src/fl_rounded_box.cxx
353 src/fl_scroll_area.cxx
354 src/fl_shadow_box.cxx
356 src/fl_show_colormap.cxx
362 src/Fl_Theme_Chooser.cxx
366 src/Crystal_Theme.cxx
373 src/xutf8/is_right2left.c
374 src/xutf8/is_spacing.c
375 src/xutf8/keysym2Ucs.c
376 src/xutf8/utf8Input.c
377 src/xutf8/utf8Utils.c
383 uselib
= [ 'X11', 'FONTCONFIG', 'XFT', 'CAIRO', 'DL', 'M', 'PTHREAD' ] )
385 bld
.makelib( source
= '''
386 src/fl_images_core.cxx
388 src/Fl_File_Icon2.cxx
390 src/Fl_Help_Dialog.cxx
391 src/Fl_JPEG_Image.cxx
395 target
= 'ntk_images',
396 uselib
= [ 'LIBJPEG', 'LIBPNG', 'LIBZ', 'DL', 'M', 'PTHREAD' ] )
403 src/glut_compatability.cxx
406 src/Fl_Gl_Device_Plugin.cxx
407 src/Fl_Gl_Overlay.cxx
411 uselib
= [ 'X11', 'DL', 'M', 'PTHREAD', 'GL'] )
413 bld( features
= 'subst',
414 source
= 'ntk.pc.in',
417 install_path
= '${LIBDIR}/pkgconfig',
418 CFLAGS
= ' '.join( CFLAGS
),
420 PREFIX
= bld
.env
.PREFIX
)
422 bld( features
= 'subst',
423 source
= 'ntk_images.pc.in',
424 target
= 'ntk_images.pc',
426 install_path
= '${LIBDIR}/pkgconfig',
427 CFLAGS
= ' '.join( CFLAGS
),
429 PREFIX
= bld
.env
.PREFIX
)
431 bld( features
= 'subst',
432 source
= 'ntk_gl.pc.in',
433 target
= 'ntk_gl.pc',
435 install_path
= '${LIBDIR}/pkgconfig',
436 CFLAGS
= ' '.join( CFLAGS
),
438 PREFIX
= bld
.env
.PREFIX
)
440 bld( features
= 'subst',
441 source
= 'ntk-uninstalled.pc.in',
442 target
= 'ntk-uninstalled.pc',
444 CFLAGS
= ' '.join( CFLAGS
),
446 BUILD
= os
.getcwd() + '/' + out
)
448 bld( features
= 'subst',
449 source
= 'ntk_images.pc.in',
450 target
= 'ntk_images-uninstalled.pc',
453 CFLAGS
= ' '.join( CFLAGS
),
454 BUILD
= os
.getcwd() + '/' + out
)
457 bld( features
= 'subst',
458 source
= 'ntk_gl.pc.in',
459 target
= 'ntk_gl-uninstalled.pc',
462 CFLAGS
= ' '.join( CFLAGS
),
463 BUILD
= os
.getcwd() + '/' + out
)
467 source
= 'src/ntk-chtheme.cxx',
468 target
= 'ntk-chtheme',
470 use
= ['ntk_images_shared', 'ntk_shared'],
471 install_path
= "${BINDIR}" )
473 # bld( features = 'subst',
474 # source = 'ntk-config.in',
475 # target = '../ntk-config',
478 # # VERSION = VERSION,
479 # FL_MAJOR_VERSION = FL_MAJOR_VERSION,
480 # FL_MINOR_VERSION = FL_MINOR_VERSION,
481 # FL_PATCH_VERSION = FL_PATCH_VERSION,
482 # preifx = bld.env.PREFIX,
483 # exec_prefix = bld.env.EXECPREFIX,
484 # bindir = bld.env.BINDIR,
485 # includedir = bld.env.INCLUDEDIR,
486 # libdir = bld.env.LIBDIR,
487 # srcdir = os.getcwd() + '/' + out,
488 # CC = bld.env.CC[0],
489 # CXX = bld.env.CXX[0],
490 # CFLAGS = string.join( bld.env.CFLAGS, ' ' ),
491 # CXXFLAGS = string.join( bld.env.CXXFLAGS, ' ' ),
492 # LDFLAGS = bld.env.LDFLAGS,
493 # CAIROLIBS = '-lcairo',
495 # install_path = '${BINDIR}' )
497 for i
in bld
.env
.BUNDLED
:
503 # 'PREFIX': bld.env.PREFIX,
504 # 'EXEC_PREFIX' : bld.env.EXEC_PREFIX,
505 # 'BINDIR' : bld.env.BINDIR,
506 # 'INCLUDEDIR' : bld.env.INCLUDEDIR,
507 # 'LIBDIR' : bld.env.LIBDIR,
508 # 'SRCDIR' : bld.env.SRCDIR } )
511 start_dir
= bld
.path
.find_dir( 'FL' )
513 bld
.install_files( bld
.env
.INCLUDEDIR
+ '/ntk/FL', start_dir
.ant_glob('*.H *.h'),
514 cwd
=start_dir
, relative_trick
=True)
516 bld
.add_post_fun( run_ldconfig
)
518 # bld.install_files( string.join( [ '${DATADIR}/doc', APPNAME ], '/' ), bld.path.ant_glob( 'doc/*.html doc/*.png' ) )