Tweak themes for more color consistency.
[ntk.git] / wscript
blob2b10dd893bc3c4919f8de328892d2e0688f89123
1 #!/usr/bin/env python
2 import subprocess
3 import waflib.Options as Options
4 from waflib.Configure import conf
5 from waflib import Logs
6 import string
7 import os
8 import sys
10 # Version of this package (even if built as a child)
12 FL_MAJOR_VERSION='1'
13 FL_MINOR_VERSION='3'
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'
21 APPNAME = 'ntk'
22 VERSION = PACKAGE_VERSION
24 # Mandatory variables
25 top = '.'
26 out = 'build'
28 children = [ 'fluid', 'test' ]
29 #children = []
31 CFLAGS = [ '-pthread',
32 '-D_LARGEFILE64_SOURCE',
33 '-D_FILE_OFFSET_BITS=64' ]
35 @conf
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'
45 bld.shlib(*k,**kw)
46 kw['features' ] = 'c cxx cxxshlib'
47 kw['name'] = kw['target'] + '_shared'
48 bld.stlib(*k,**kw)
50 # from autowaf
51 def run_ldconfig(ctx):
52 if (ctx.cmd == 'install'
53 and not ctx.env['RAN_LDCONFIG']
54 and ctx.env['LIBDIR']
55 and not os.environ.get('DESTDIR')):
56 try:
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
60 except:
61 pass
63 def options(opt):
64 opt.load('compiler_c')
65 opt.load('compiler_cxx')
66 opt.load('gnu_dirs')
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')
75 def configure(conf):
76 conf.load('compiler_c')
77 conf.load('compiler_cxx')
78 conf.load('gnu_dirs')
79 # conf.load('ntk_fluid')
80 conf.line_just = 52
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",
86 mandatory=True)
88 conf.check_cfg(package='fontconfig', uselib_store='FONTCONFIG', args="--cflags --libs",
89 mandatory=True)
91 conf.check_cfg(package='xft', uselib_store='XFT', args="--cflags --libs",
92 mandatory=True)
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',
111 execute = False,
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",
132 mandatory=True)
133 conf.check_cfg(package='zlib', uselib_store='LIBZ', args="--cflags --libs",
134 mandatory=True)
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",
140 mandatory=True)
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; }',
145 execute=False,
146 define_name='HAVE_LONG_LONG',
147 msg='Checking for long long type',
148 mandatory=False);
151 if sys.platform == 'darwin':
152 conf.define( '__APPLE__', 1 )
153 if sys.platform == 'win32':
154 conf.define( 'WIN32', 1 )
155 else:
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 )
171 # print conf.env
173 conf.check( fragment='#include <stdio.h>\n int main ( int argc, char **argv ) { printf("%u", (unsigned)sizeof(short)); return 0; }',
174 execute=True,
175 define_ret=True,
176 quote=False,
177 define_name='SIZEOF_SHORT',
178 msg='Checking sizeof short',
179 mandatory=True);
181 conf.check( fragment='#include <stdio.h>\n int main ( int argc, char **argv ) { printf("%u", (unsigned)sizeof(int)); return 0; }',
182 execute=True,
183 quote=False,
184 define_ret=True,
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; }',
189 quote=False,
190 execute=True,
191 define_ret=True,
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 = [
212 "-O3",
213 "-fomit-frame-pointer",
214 "-ffast-math",
215 # "-fstrength-reduce",
216 "-pipe"
219 debug_flags = [
220 '-g',
221 '-O0' ]
223 print('---')
225 print('Note: "not found" is OK for optional items.')
227 print('---')
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 )
233 else:
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:
251 conf.recurse(i)
253 for i in children:
254 conf.recurse(i)
257 print('')
259 def build(bld):
261 bld.makelib( source = '''
262 src/Fl_Cairo_Graphics_Driver.cxx
263 src/Fl.cxx
264 src/Fl_Adjuster.cxx
265 src/Fl_Bitmap.cxx
266 src/Fl_Browser.cxx
267 src/Fl_Browser_.cxx
268 src/Fl_Browser_load.cxx
269 src/Fl_Box.cxx
270 src/Fl_Button.cxx
271 src/Fl_Chart.cxx
272 src/Fl_Check_Browser.cxx
273 src/Fl_Check_Button.cxx
274 src/Fl_Choice.cxx
275 src/Fl_Color_Chooser.cxx
276 src/Fl_Counter.cxx
277 src/Fl_Dial.cxx
278 src/Fl_Dial_Base.cxx
279 src/Fl_Device.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
284 src/Fl_File_Icon.cxx
285 src/Fl_File_Input.cxx
286 src/Fl_Group.cxx
287 src/Fl_Help_View.cxx
288 src/Fl_Image.cxx
289 src/Fl_Input.cxx
290 src/Fl_Input_.cxx
291 src/Fl_Light_Button.cxx
292 src/Fl_Menu.cxx
293 src/Fl_Menu_.cxx
294 src/Fl_Menu_Bar.cxx
295 src/Fl_Sys_Menu_Bar.cxx
296 src/Fl_Menu_Button.cxx
297 src/Fl_Menu_Window.cxx
298 src/Fl_Menu_add.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
303 src/Fl_Pack.cxx
304 src/Fl_Paged_Device.cxx
305 src/Fl_Panzoomer.cxx
306 src/Fl_Pixmap.cxx
307 src/Fl_Positioner.cxx
308 src/Fl_Preferences.cxx
309 src/Fl_Printer.cxx
310 src/Fl_Progress.cxx
311 src/Fl_Repeat_Button.cxx
312 src/Fl_Return_Button.cxx
313 src/Fl_Round_Button.cxx
314 src/Fl_Scroll.cxx
315 src/Fl_Scrollbar.cxx
316 src/Fl_Shared_Image.cxx
317 src/Fl_Single_Window.cxx
318 src/Fl_Slider.cxx
319 src/Fl_Table.cxx
320 src/Fl_Table_Row.cxx
321 src/Fl_Tabs.cxx
322 src/Fl_Text_Buffer.cxx
323 src/Fl_Text_Display.cxx
324 src/Fl_Text_Editor.cxx
325 src/Fl_Tile.cxx
326 src/Fl_Tiled_Image.cxx
327 src/Fl_Tree.cxx
328 src/Fl_Tree_Item.cxx
329 src/Fl_Tree_Item_Array.cxx
330 src/Fl_Tree_Prefs.cxx
331 src/Fl_Tooltip.cxx
332 src/Fl_Valuator.cxx
333 src/Fl_Value_Input.cxx
334 src/Fl_Value_Output.cxx
335 src/Fl_Value_Slider.cxx
336 src/Fl_Widget.cxx
337 src/Fl_Window.cxx
338 src/Fl_Window_fullscreen.cxx
339 src/Fl_Window_hotspot.cxx
340 src/Fl_Window_iconize.cxx
341 src/Fl_Wizard.cxx
342 src/Fl_XBM_Image.cxx
343 src/Fl_XPM_Image.cxx
344 src/Fl_abort.cxx
345 src/Fl_add_idle.cxx
346 src/Fl_arg.cxx
347 src/Fl_compose.cxx
348 src/Fl_display.cxx
349 src/Fl_get_key.cxx
350 src/Fl_get_system_colors.cxx
351 src/Fl_grab.cxx
352 src/Fl_lock.cxx
353 src/Fl_own_colormap.cxx
354 src/Fl_visual.cxx
355 src/Fl_x.cxx
356 src/filename_absolute.cxx
357 src/filename_expand.cxx
358 src/filename_ext.cxx
359 src/filename_isdir.cxx
360 src/filename_list.cxx
361 src/filename_match.cxx
362 src/filename_setext.cxx
363 src/fl_arc.cxx
364 src/fl_arci.cxx
365 src/fl_ask.cxx
366 src/fl_boxtype.cxx
367 src/fl_color.cxx
368 src/fl_cursor.cxx
369 src/fl_curve.cxx
370 src/fl_diamond_box.cxx
371 src/fl_dnd.cxx
372 src/fl_draw.cxx
373 src/Fl_Cairo.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
379 src/fl_file_dir.cxx
380 src/fl_font.cxx
381 src/fl_labeltype.cxx
382 src/fl_line_style.cxx
383 src/fl_open_uri.cxx
384 src/fl_oval_box.cxx
385 src/fl_overlay.cxx
386 src/fl_read_image.cxx
387 src/fl_rect.cxx
388 src/fl_round_box.cxx
389 src/fl_rounded_box.cxx
390 src/fl_set_font.cxx
391 src/fl_set_fonts.cxx
392 src/fl_scroll_area.cxx
393 src/fl_shadow_box.cxx
394 src/fl_shortcut.cxx
395 src/fl_show_colormap.cxx
396 src/fl_symbols.cxx
397 src/fl_vertex.cxx
398 src/screen_xywh.cxx
399 src/fl_utf8.cxx
400 src/Fl_Theme.cxx
401 src/Fl_Theme_Chooser.cxx
402 src/Cairo_Theme.cxx
403 src/Gleam_Theme.cxx
404 src/Clean_Theme.cxx
405 src/Crystal_Theme.cxx
406 src/Vector_Theme.cxx
407 src/themes.cxx
408 src/ps_image.cxx
409 src/fl_utf.c
410 src/vsnprintf.c
411 src/xutf8/case.c
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
417 src/xutf8/utf8Wrap.c
418 src/numericsort.c
419 src/flstring.c
420 ''',
421 target = 'ntk',
422 uselib = [ 'X11', 'FONTCONFIG', 'XFT', 'CAIRO', 'DL', 'M', 'PTHREAD' ] )
424 bld.makelib( source = '''
425 src/fl_images_core.cxx
426 src/Fl_BMP_Image.cxx
427 src/Fl_File_Icon2.cxx
428 src/Fl_GIF_Image.cxx
429 src/Fl_Help_Dialog.cxx
430 src/Fl_JPEG_Image.cxx
431 src/Fl_PNG_Image.cxx
432 src/Fl_PNM_Image.cxx
433 ''',
434 target = 'ntk_images',
435 uselib = [ 'LIBJPEG', 'LIBPNG', 'LIBZ', 'DL', 'M', 'PTHREAD' ] )
437 if bld.env.USE_GL:
438 bld.makelib(
439 source = '''
440 src/gl_draw.cxx
441 src/gl_start.cxx
442 src/glut_compatability.cxx
443 src/glut_font.cxx
444 src/Fl_Gl_Choice.cxx
445 src/Fl_Gl_Device_Plugin.cxx
446 src/Fl_Gl_Overlay.cxx
447 src/Fl_Gl_Window.cxx
448 ''',
449 target = 'ntk_gl',
450 uselib = [ 'X11', 'DL', 'M', 'PTHREAD', 'GL'] )
452 bld( features = 'subst',
453 source = 'ntk.pc.in',
454 target = 'ntk.pc',
455 encoding = 'utf8',
456 install_path = '${LIBDIR}/pkgconfig',
457 CFLAGS = ' '.join( CFLAGS ),
458 VERSION = VERSION,
459 PREFIX = bld.env.PREFIX )
461 bld( features = 'subst',
462 source = 'ntk_images.pc.in',
463 target = 'ntk_images.pc',
464 encoding = 'utf8',
465 install_path = '${LIBDIR}/pkgconfig',
466 CFLAGS = ' '.join( CFLAGS ),
467 VERSION = VERSION,
468 PREFIX = bld.env.PREFIX )
470 bld( features = 'subst',
471 source = 'ntk_gl.pc.in',
472 target = 'ntk_gl.pc',
473 encoding = 'utf8',
474 install_path = '${LIBDIR}/pkgconfig',
475 CFLAGS = ' '.join( CFLAGS ),
476 VERSION = VERSION,
477 PREFIX = bld.env.PREFIX )
479 bld( features = 'subst',
480 source = 'ntk-uninstalled.pc.in',
481 target = 'ntk-uninstalled.pc',
482 encoding = 'utf8',
483 CFLAGS = ' '.join( CFLAGS ),
484 VERSION = VERSION,
485 BUILD = os.getcwd() + '/' + out )
487 bld( features = 'subst',
488 source = 'ntk_images.pc.in',
489 target = 'ntk_images-uninstalled.pc',
490 encoding = 'utf8',
491 VERSION = VERSION,
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',
499 encoding = 'utf8',
500 VERSION = VERSION,
501 CFLAGS = ' '.join( CFLAGS ),
502 BUILD = os.getcwd() + '/' + out )
505 bld.program(
506 source = 'src/ntk-chtheme.cxx',
507 target = 'ntk-chtheme',
508 includes = [ '.' ],
509 use = ['ntk_images_shared', 'ntk_shared'],
510 install_path = "${BINDIR}" )
512 # bld( features = 'subst',
513 # source = 'ntk-config.in',
514 # target = '../ntk-config',
515 # mode = 0777,
516 # encoding = 'utf8',
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:
537 bld.recurse(i)
539 for i in children:
540 bld.recurse(i)
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' ) )