Fl_Tiled_Image: Start tiling at 0,0--don't try to center image.
[ntk.git] / wscript
blob0b25ec5eff322d1f643d4fcd8dda5d7832d9a130
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='0'
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',
34 '-D_GNU_SOURCE' ]
36 @conf
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'
46 bld.shlib(*k,**kw)
47 kw['features' ] = 'c cxx cxxshlib'
48 kw['name'] = kw['target'] + '_shared'
49 bld.stlib(*k,**kw)
51 # from autowaf
52 def run_ldconfig(ctx):
53 if (ctx.cmd == 'install'
54 and not ctx.env['RAN_LDCONFIG']
55 and ctx.env['LIBDIR']
56 and not os.environ.get('DESTDIR')):
57 try:
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
61 except:
62 pass
64 def options(opt):
65 opt.load('compiler_c')
66 opt.load('compiler_cxx')
67 opt.load('gnu_dirs')
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')
76 def configure(conf):
77 conf.load('compiler_c')
78 conf.load('compiler_cxx')
79 conf.load('gnu_dirs')
80 # conf.load('ntk_fluid')
81 conf.line_just = 52
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",
87 mandatory=True)
89 conf.check_cfg(package='fontconfig', uselib_store='FONTCONFIG', args="--cflags --libs",
90 mandatory=True)
92 conf.check_cfg(package='xft', uselib_store='XFT', args="--cflags --libs",
93 mandatory=True)
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',
112 execute = False,
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",
133 mandatory=True)
134 conf.check_cfg(package='zlib', uselib_store='LIBZ', args="--cflags --libs",
135 mandatory=True)
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",
141 mandatory=True)
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 = [
148 "-O3",
149 "-fomit-frame-pointer",
150 "-ffast-math",
151 # "-fstrength-reduce",
152 "-pipe"
155 debug_flags = [
156 '-g',
157 '-O0' ]
159 print('---')
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 )
165 else:
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 )
178 else:
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 )
194 # print conf.env
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:
212 conf.recurse(i)
214 for i in children:
215 conf.recurse(i)
218 print('')
220 def build(bld):
222 bld.makelib( source = '''
223 src/Fl_Cairo_Graphics_Driver.cxx
224 src/Fl.cxx
225 src/Fl_Adjuster.cxx
226 src/Fl_Bitmap.cxx
227 src/Fl_Browser.cxx
228 src/Fl_Browser_.cxx
229 src/Fl_Browser_load.cxx
230 src/Fl_Box.cxx
231 src/Fl_Button.cxx
232 src/Fl_Chart.cxx
233 src/Fl_Check_Browser.cxx
234 src/Fl_Check_Button.cxx
235 src/Fl_Choice.cxx
236 src/Fl_Color_Chooser.cxx
237 src/Fl_Counter.cxx
238 src/Fl_Dial.cxx
239 src/Fl_Dial_Base.cxx
240 src/Fl_Device.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
245 src/Fl_File_Icon.cxx
246 src/Fl_File_Input.cxx
247 src/Fl_Group.cxx
248 src/Fl_Help_View.cxx
249 src/Fl_Image.cxx
250 src/Fl_Input.cxx
251 src/Fl_Input_.cxx
252 src/Fl_Light_Button.cxx
253 src/Fl_Menu.cxx
254 src/Fl_Menu_.cxx
255 src/Fl_Menu_Bar.cxx
256 src/Fl_Sys_Menu_Bar.cxx
257 src/Fl_Menu_Button.cxx
258 src/Fl_Menu_Window.cxx
259 src/Fl_Menu_add.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
264 src/Fl_Pack.cxx
265 src/Fl_Paged_Device.cxx
266 src/Fl_Panzoomer.cxx
267 src/Fl_Pixmap.cxx
268 src/Fl_Positioner.cxx
269 src/Fl_Preferences.cxx
270 src/Fl_Printer.cxx
271 src/Fl_Progress.cxx
272 src/Fl_Repeat_Button.cxx
273 src/Fl_Return_Button.cxx
274 src/Fl_Round_Button.cxx
275 src/Fl_Scroll.cxx
276 src/Fl_Scrollbar.cxx
277 src/Fl_Shared_Image.cxx
278 src/Fl_Single_Window.cxx
279 src/Fl_Slider.cxx
280 src/Fl_Table.cxx
281 src/Fl_Table_Row.cxx
282 src/Fl_Tabs.cxx
283 src/Fl_Text_Buffer.cxx
284 src/Fl_Text_Display.cxx
285 src/Fl_Text_Editor.cxx
286 src/Fl_Tile.cxx
287 src/Fl_Tiled_Image.cxx
288 src/Fl_Tree.cxx
289 src/Fl_Tree_Item.cxx
290 src/Fl_Tree_Item_Array.cxx
291 src/Fl_Tree_Prefs.cxx
292 src/Fl_Tooltip.cxx
293 src/Fl_Valuator.cxx
294 src/Fl_Value_Input.cxx
295 src/Fl_Value_Output.cxx
296 src/Fl_Value_Slider.cxx
297 src/Fl_Widget.cxx
298 src/Fl_Window.cxx
299 src/Fl_Window_fullscreen.cxx
300 src/Fl_Window_hotspot.cxx
301 src/Fl_Window_iconize.cxx
302 src/Fl_Wizard.cxx
303 src/Fl_XBM_Image.cxx
304 src/Fl_XPM_Image.cxx
305 src/Fl_abort.cxx
306 src/Fl_add_idle.cxx
307 src/Fl_arg.cxx
308 src/Fl_compose.cxx
309 src/Fl_display.cxx
310 src/Fl_get_key.cxx
311 src/Fl_get_system_colors.cxx
312 src/Fl_grab.cxx
313 src/Fl_lock.cxx
314 src/Fl_own_colormap.cxx
315 src/Fl_visual.cxx
316 src/Fl_x.cxx
317 src/filename_absolute.cxx
318 src/filename_expand.cxx
319 src/filename_ext.cxx
320 src/filename_isdir.cxx
321 src/filename_list.cxx
322 src/filename_match.cxx
323 src/filename_setext.cxx
324 src/fl_arc.cxx
325 src/fl_arci.cxx
326 src/fl_ask.cxx
327 src/fl_boxtype.cxx
328 src/fl_color.cxx
329 src/fl_cursor.cxx
330 src/fl_curve.cxx
331 src/fl_diamond_box.cxx
332 src/fl_dnd.cxx
333 src/fl_draw.cxx
334 src/Fl_Cairo.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
340 src/fl_file_dir.cxx
341 src/fl_font.cxx
342 src/fl_labeltype.cxx
343 src/fl_line_style.cxx
344 src/fl_open_uri.cxx
345 src/fl_oval_box.cxx
346 src/fl_overlay.cxx
347 src/fl_read_image.cxx
348 src/fl_rect.cxx
349 src/fl_round_box.cxx
350 src/fl_rounded_box.cxx
351 src/fl_set_font.cxx
352 src/fl_set_fonts.cxx
353 src/fl_scroll_area.cxx
354 src/fl_shadow_box.cxx
355 src/fl_shortcut.cxx
356 src/fl_show_colormap.cxx
357 src/fl_symbols.cxx
358 src/fl_vertex.cxx
359 src/screen_xywh.cxx
360 src/fl_utf8.cxx
361 src/Fl_Theme.cxx
362 src/Fl_Theme_Chooser.cxx
363 src/Cairo_Theme.cxx
364 src/Gleam_Theme.cxx
365 src/Clean_Theme.cxx
366 src/Crystal_Theme.cxx
367 src/Vector_Theme.cxx
368 src/themes.cxx
369 src/ps_image.cxx
370 src/fl_utf.c
371 src/vsnprintf.c
372 src/xutf8/case.c
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
378 src/xutf8/utf8Wrap.c
379 src/numericsort.c
380 src/flstring.c
381 ''',
382 target = 'ntk',
383 uselib = [ 'X11', 'FONTCONFIG', 'XFT', 'CAIRO', 'DL', 'M', 'PTHREAD' ] )
385 bld.makelib( source = '''
386 src/fl_images_core.cxx
387 src/Fl_BMP_Image.cxx
388 src/Fl_File_Icon2.cxx
389 src/Fl_GIF_Image.cxx
390 src/Fl_Help_Dialog.cxx
391 src/Fl_JPEG_Image.cxx
392 src/Fl_PNG_Image.cxx
393 src/Fl_PNM_Image.cxx
394 ''',
395 target = 'ntk_images',
396 uselib = [ 'LIBJPEG', 'LIBPNG', 'LIBZ', 'DL', 'M', 'PTHREAD' ] )
398 if bld.env.USE_GL:
399 bld.makelib(
400 source = '''
401 src/gl_draw.cxx
402 src/gl_start.cxx
403 src/glut_compatability.cxx
404 src/glut_font.cxx
405 src/Fl_Gl_Choice.cxx
406 src/Fl_Gl_Device_Plugin.cxx
407 src/Fl_Gl_Overlay.cxx
408 src/Fl_Gl_Window.cxx
409 ''',
410 target = 'ntk_gl',
411 uselib = [ 'X11', 'DL', 'M', 'PTHREAD', 'GL'] )
413 bld( features = 'subst',
414 source = 'ntk.pc.in',
415 target = 'ntk.pc',
416 encoding = 'utf8',
417 install_path = '${LIBDIR}/pkgconfig',
418 CFLAGS = ' '.join( CFLAGS ),
419 VERSION = VERSION,
420 PREFIX = bld.env.PREFIX )
422 bld( features = 'subst',
423 source = 'ntk_images.pc.in',
424 target = 'ntk_images.pc',
425 encoding = 'utf8',
426 install_path = '${LIBDIR}/pkgconfig',
427 CFLAGS = ' '.join( CFLAGS ),
428 VERSION = VERSION,
429 PREFIX = bld.env.PREFIX )
431 bld( features = 'subst',
432 source = 'ntk_gl.pc.in',
433 target = 'ntk_gl.pc',
434 encoding = 'utf8',
435 install_path = '${LIBDIR}/pkgconfig',
436 CFLAGS = ' '.join( CFLAGS ),
437 VERSION = VERSION,
438 PREFIX = bld.env.PREFIX )
440 bld( features = 'subst',
441 source = 'ntk-uninstalled.pc.in',
442 target = 'ntk-uninstalled.pc',
443 encoding = 'utf8',
444 CFLAGS = ' '.join( CFLAGS ),
445 VERSION = VERSION,
446 BUILD = os.getcwd() + '/' + out )
448 bld( features = 'subst',
449 source = 'ntk_images.pc.in',
450 target = 'ntk_images-uninstalled.pc',
451 encoding = 'utf8',
452 VERSION = VERSION,
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',
460 encoding = 'utf8',
461 VERSION = VERSION,
462 CFLAGS = ' '.join( CFLAGS ),
463 BUILD = os.getcwd() + '/' + out )
466 bld.program(
467 source = 'src/ntk-chtheme.cxx',
468 target = 'ntk-chtheme',
469 includes = [ '.' ],
470 use = ['ntk_images_shared', 'ntk_shared'],
471 install_path = "${BINDIR}" )
473 # bld( features = 'subst',
474 # source = 'ntk-config.in',
475 # target = '../ntk-config',
476 # mode = 0777,
477 # encoding = 'utf8',
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:
498 bld.recurse(i)
500 for i in children:
501 bld.recurse(i)
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' ) )