You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

547 lines
16KB

  1. #!/usr/bin/env python
  2. import subprocess
  3. import waflib.Options as Options
  4. import string
  5. import os
  6. import sys
  7. # Version of this package (even if built as a child)
  8. FL_MAJOR_VERSION='1'
  9. FL_MINOR_VERSION='3'
  10. FL_PATCH_VERSION='0'
  11. PACKAGE_VERSION = FL_MAJOR_VERSION + '.' + FL_MINOR_VERSION + '.' + FL_PATCH_VERSION
  12. API_VERSION = FL_MAJOR_VERSION + '.' + FL_MINOR_VERSION
  13. # Variables for 'waf dist'
  14. APPNAME = 'ntk'
  15. VERSION = PACKAGE_VERSION
  16. # Mandatory variables
  17. top = '.'
  18. out = 'build'
  19. children = [ 'fluid', 'test' ]
  20. #children = []
  21. CFLAGS = [ '-D_LARGEFILE_SOURCE', '-D_LARGEFILE64_SOURCE', '-D_THREAD_SAFE', '-D_REENTRANT' ]
  22. def options(opt):
  23. opt.load('compiler_c')
  24. opt.load('compiler_cxx')
  25. opt.load('gnu_dirs')
  26. opt.add_option('--enable-debug', action='store_true', default=False, dest='debug',
  27. help='Build for debugging')
  28. opt.add_option('--enable-gl', action='store_true', default=False, dest='USE_GL',
  29. help='Build with OpenGL extension library')
  30. opt.add_option('--enable-test', action='store_true', default=False, dest='ENABLE_TEST',
  31. help='Build test programs')
  32. def configure(conf):
  33. conf.load('compiler_c')
  34. conf.load('compiler_cxx')
  35. conf.load('gnu_dirs')
  36. # conf.load('ntk_fluid')
  37. conf.line_just = 52
  38. conf.env.append_value('CFLAGS', CFLAGS + ['-Wall'])
  39. # conf.env.append_value('CXXFLAGS',['-Wall','-fno-exceptions', '-fno-rtti'])
  40. conf.env.append_value('CXXFLAGS',CFLAGS + ['-Wall'])
  41. conf.check_cfg(package='x11', uselib_store='X11', args="--cflags --libs",
  42. mandatory=True)
  43. conf.check_cfg(package='xft', uselib_store='XFT', args="--cflags --libs",
  44. mandatory=True)
  45. conf.check_cfg(package='cairo', uselib_store='CAIRO', args="--cflags --libs",
  46. atleast_version='1.9.0', mandatory=True)
  47. conf.check_cfg(package='gl', uselib_store='GL', args="--cflags --libs",
  48. mandatory=False)
  49. conf.check(header_name='unistd.h', define_name='HAVE_UNISTD_H', mandatory=False)
  50. conf.check(header_name='pthread.h', define_name='HAVE_PTHREAD_H', mandatory=False)
  51. conf.check(header_name='dirent.h', define_name='HAVE_DIRENT_H', mandatory=False)
  52. conf.check(header_name='string.h', define_name='HAVE_STRINGS_H', mandatory=False)
  53. conf.check(header_name='locale.h', define_name='HAVE_LOCALE_H', mandatory=False)
  54. conf.check(header_name='sys/select.h', define_name='HAVE_SYS_SELECT_H', mandatory=False)
  55. conf.check(header_name='dlfcn.h', define_name='HAVE_DLFCN_H', mandatory=False)
  56. conf.check(header_name='sys/stdtypes.h', define_name='HAVE_SYS_STDTYPES_H', mandatory=False)
  57. conf.check(header_name='pthread.h', define_name='HAVE_PTHREAD', mandatory=True)
  58. conf.check(header_name='png.h', define_name='HAVE_PNG_H', mandatory=False)
  59. conf.check(features='c cprogram',
  60. fragment='#include <pthread.h>\nint main ( int argc, const char **argv ) { return PTHREAD_MUTEX_RECURSIVE; }\n',
  61. execute = False,
  62. define_name='HAVE_PTHREAD_MUTEX_RECURSIVE', mandatory=False,
  63. msg='Checking for PTHREAD_MUTEX_RECURSIVE')
  64. # conf.check(function_name='jpeg_CreateCompress', header_name='jpeglib.h', use='jpeg', define_name='HAVE_LIBJPEG', mandatory=False)
  65. if Options.options.ENABLE_TEST:
  66. conf.env.ENABLE_TEST = True
  67. conf.env.BUNDLED = []
  68. conf.check(function_name='strtoll', header_name="stdlib.h", define_name='HAVE_STRTOLL', mandatory=False)
  69. conf.check(function_name='scandir', header_name="dirent.h", define_name='HAVE_SCANDIR', mandatory=False)
  70. conf.check(lib='jpeg', uselib_store='LIBJPEG', mandatory=True )
  71. conf.check_cfg(package='libpng', uselib_store='LIBPNG', args="--cflags --libs",
  72. mandatory=True)
  73. conf.check_cfg(package='zlib', uselib_store='LIBZ', args="--cflags --libs",
  74. mandatory=True)
  75. if Options.options.USE_GL:
  76. conf.env.append_value( 'USE_GL', '1' )
  77. # FIXME: HAVE_LONG_LONG
  78. optimization_flags = [
  79. "-O3",
  80. "-fomit-frame-pointer",
  81. "-ffast-math",
  82. # "-fstrength-reduce",
  83. "-pipe"
  84. ]
  85. debug_flags = [
  86. '-g',
  87. '-O0' ]
  88. if Options.options.debug:
  89. print 'Building for debugging'
  90. conf.env.append_value('CFLAGS', debug_flags )
  91. conf.env.append_value('CXXFLAGS', debug_flags )
  92. else:
  93. print 'Building for performance'
  94. conf.env.append_value('CFLAGS', optimization_flags )
  95. conf.env.append_value('CXXFLAGS', optimization_flags )
  96. conf.define( 'NDEBUG', 1 )
  97. if sys.platform == 'darwin':
  98. conf.define( '__APPLE__', 1 )
  99. if sys.platform == 'win32':
  100. conf.define( 'WIN32', 1 )
  101. else:
  102. conf.define( 'HAVE_X11', 1 )
  103. conf.define( 'USE_X11', 1 )
  104. conf.define( 'USE_POLL', 1 )
  105. conf.define( 'USE_XFT', 1 )
  106. conf.define( 'BORDER_WIDTH', 1 )
  107. conf.define( 'HAVE_SCANDIR_POSIX', 1 )
  108. conf.define( 'HAVE_STRCASECMP', 1 )
  109. conf.define( 'HAVE_VSNPRINTF', 1 )
  110. conf.define( 'HAVE_SNPRINTF', 1 )
  111. conf.define( 'HAVE_STRTOLL', 1 )
  112. conf.define( 'HAVE_DLSYM', 1 )
  113. # print conf.env
  114. # FIXME: use tests for these
  115. conf.define( 'U16', 'unsigned short', quote=False )
  116. conf.define( 'U32', 'unsined', quote=False )
  117. conf.define( 'U64', 'unsigned long', quote=False )
  118. conf.define( 'WORDS_BIGENDIAN', 0 )
  119. conf.define('VERSION', PACKAGE_VERSION)
  120. conf.define('FLTK_DOCDIR', conf.env.DOCDIR );
  121. # conf.define('SYSTEM_PATH', string.join( [ conf.env.DATADIR, APPNAME ], '/' ) )
  122. # conf.define('DOCUMENT_PATH', conf.env.DOCDIR )
  123. # conf.define('PIXMAP_PATH', string.join( [ conf.env.DATADIR, APPNAME ], '/' ) )
  124. conf.write_config_header('config.h', remove=False)
  125. for i in conf.env.BUNDLED:
  126. conf.recurse(i)
  127. for i in children:
  128. conf.recurse(i)
  129. print('')
  130. def build(bld):
  131. # libs = 'LILV SUIL JACK SERD SRATOM LV2'
  132. libs = ''
  133. lib_source = '''
  134. src/Fl_Cairo_Graphics_Driver.cxx
  135. src/Fl.cxx
  136. src/Fl_Adjuster.cxx
  137. src/Fl_Bitmap.cxx
  138. src/Fl_Browser.cxx
  139. src/Fl_Browser_.cxx
  140. src/Fl_Browser_load.cxx
  141. src/Fl_Box.cxx
  142. src/Fl_Button.cxx
  143. src/Fl_Chart.cxx
  144. src/Fl_Check_Browser.cxx
  145. src/Fl_Check_Button.cxx
  146. src/Fl_Choice.cxx
  147. src/Fl_Color_Chooser.cxx
  148. src/Fl_Counter.cxx
  149. src/Fl_Dial.cxx
  150. src/Fl_Dial_Base.cxx
  151. src/Fl_Device.cxx
  152. src/Fl_Double_Window.cxx
  153. src/Fl_File_Browser.cxx
  154. src/Fl_File_Chooser.cxx
  155. src/Fl_File_Chooser2.cxx
  156. src/Fl_File_Icon.cxx
  157. src/Fl_File_Input.cxx
  158. src/Fl_Group.cxx
  159. src/Fl_Help_View.cxx
  160. src/Fl_Image.cxx
  161. src/Fl_Input.cxx
  162. src/Fl_Input_.cxx
  163. src/Fl_Light_Button.cxx
  164. src/Fl_Menu.cxx
  165. src/Fl_Menu_.cxx
  166. src/Fl_Menu_Bar.cxx
  167. src/Fl_Sys_Menu_Bar.cxx
  168. src/Fl_Menu_Button.cxx
  169. src/Fl_Menu_Window.cxx
  170. src/Fl_Menu_add.cxx
  171. src/Fl_Menu_global.cxx
  172. src/Fl_Multi_Label.cxx
  173. src/Fl_Native_File_Chooser.cxx
  174. src/Fl_Overlay_Window.cxx
  175. src/Fl_Pack.cxx
  176. src/Fl_Paged_Device.cxx
  177. src/Fl_Panzoomer.cxx
  178. src/Fl_Pixmap.cxx
  179. src/Fl_Positioner.cxx
  180. src/Fl_Preferences.cxx
  181. src/Fl_Printer.cxx
  182. src/Fl_Progress.cxx
  183. src/Fl_Repeat_Button.cxx
  184. src/Fl_Return_Button.cxx
  185. src/Fl_Round_Button.cxx
  186. src/Fl_Scroll.cxx
  187. src/Fl_Scrollbar.cxx
  188. src/Fl_Shared_Image.cxx
  189. src/Fl_Single_Window.cxx
  190. src/Fl_Slider.cxx
  191. src/Fl_Table.cxx
  192. src/Fl_Table_Row.cxx
  193. src/Fl_Tabs.cxx
  194. src/Fl_Text_Buffer.cxx
  195. src/Fl_Text_Display.cxx
  196. src/Fl_Text_Editor.cxx
  197. src/Fl_Tile.cxx
  198. src/Fl_Tiled_Image.cxx
  199. src/Fl_Tree.cxx
  200. src/Fl_Tree_Item.cxx
  201. src/Fl_Tree_Item_Array.cxx
  202. src/Fl_Tree_Prefs.cxx
  203. src/Fl_Tooltip.cxx
  204. src/Fl_Valuator.cxx
  205. src/Fl_Value_Input.cxx
  206. src/Fl_Value_Output.cxx
  207. src/Fl_Value_Slider.cxx
  208. src/Fl_Widget.cxx
  209. src/Fl_Window.cxx
  210. src/Fl_Window_fullscreen.cxx
  211. src/Fl_Window_hotspot.cxx
  212. src/Fl_Window_iconize.cxx
  213. src/Fl_Wizard.cxx
  214. src/Fl_XBM_Image.cxx
  215. src/Fl_XPM_Image.cxx
  216. src/Fl_abort.cxx
  217. src/Fl_add_idle.cxx
  218. src/Fl_arg.cxx
  219. src/Fl_compose.cxx
  220. src/Fl_display.cxx
  221. src/Fl_get_key.cxx
  222. src/Fl_get_system_colors.cxx
  223. src/Fl_grab.cxx
  224. src/Fl_lock.cxx
  225. src/Fl_own_colormap.cxx
  226. src/Fl_visual.cxx
  227. src/Fl_x.cxx
  228. src/filename_absolute.cxx
  229. src/filename_expand.cxx
  230. src/filename_ext.cxx
  231. src/filename_isdir.cxx
  232. src/filename_list.cxx
  233. src/filename_match.cxx
  234. src/filename_setext.cxx
  235. src/fl_arc.cxx
  236. src/fl_arci.cxx
  237. src/fl_ask.cxx
  238. src/fl_boxtype.cxx
  239. src/fl_color.cxx
  240. src/fl_cursor.cxx
  241. src/fl_curve.cxx
  242. src/fl_diamond_box.cxx
  243. src/fl_dnd.cxx
  244. src/fl_draw.cxx
  245. src/Fl_Cairo.cxx
  246. src/fl_draw_image.cxx
  247. src/fl_draw_pixmap.cxx
  248. src/fl_encoding_latin1.cxx
  249. src/fl_encoding_mac_roman.cxx
  250. src/fl_engraved_label.cxx
  251. src/fl_file_dir.cxx
  252. src/fl_font.cxx
  253. src/fl_labeltype.cxx
  254. src/fl_line_style.cxx
  255. src/fl_open_uri.cxx
  256. src/fl_oval_box.cxx
  257. src/fl_overlay.cxx
  258. src/fl_read_image.cxx
  259. src/fl_rect.cxx
  260. src/fl_round_box.cxx
  261. src/fl_rounded_box.cxx
  262. src/fl_set_font.cxx
  263. src/fl_set_fonts.cxx
  264. src/fl_scroll_area.cxx
  265. src/fl_shadow_box.cxx
  266. src/fl_shortcut.cxx
  267. src/fl_show_colormap.cxx
  268. src/fl_symbols.cxx
  269. src/fl_vertex.cxx
  270. src/screen_xywh.cxx
  271. src/fl_utf8.cxx
  272. src/Fl_Theme.cxx
  273. src/Fl_Theme_Chooser.cxx
  274. src/Cairo_Theme.cxx
  275. src/Gleam_Theme.cxx
  276. src/Clean_Theme.cxx
  277. src/Crystal_Theme.cxx
  278. src/Vector_Theme.cxx
  279. src/themes.cxx
  280. src/ps_image.cxx
  281. src/fl_utf.c
  282. src/vsnprintf.c
  283. src/xutf8/case.c
  284. src/xutf8/is_right2left.c
  285. src/xutf8/is_spacing.c
  286. src/xutf8/keysym2Ucs.c
  287. src/xutf8/utf8Input.c
  288. src/xutf8/utf8Utils.c
  289. src/xutf8/utf8Wrap.c
  290. src/numericsort.c
  291. src/flstring.c
  292. '''
  293. # conf.define( 'FL_LIBRARY', 1 )
  294. # conf.define( 'FL_INTERNALS', 1 )
  295. bld( source = lib_source,
  296. features = 'c cxx cxxshlib',
  297. vnum = API_VERSION,
  298. target = 'ntk',
  299. cflags = [ '-fPIC' ],
  300. cxxflags = [ '-fPIC' ],
  301. defines = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ],
  302. includes = ['.', 'src', 'FL' ],
  303. uselib = [ 'X11', 'XFT', 'CAIRO' ],
  304. install_path = '${LIBDIR}')
  305. bld( source = lib_source,
  306. vnum = API_VERSION,
  307. features = 'c cxx cxxstlib',
  308. cflags = [ '-fPIC' ],
  309. cxxflags = [ '-fPIC' ],
  310. defines = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ],
  311. target = 'ntk',
  312. includes = ['.', 'src', 'FL' ],
  313. uselib = [ 'X11', 'XFT', 'CAIRO' ],
  314. install_path = '${LIBDIR}')
  315. lib_images_source = '''
  316. src/fl_images_core.cxx
  317. src/Fl_BMP_Image.cxx
  318. src/Fl_File_Icon2.cxx
  319. src/Fl_GIF_Image.cxx
  320. src/Fl_Help_Dialog.cxx
  321. src/Fl_JPEG_Image.cxx
  322. src/Fl_PNG_Image.cxx
  323. src/Fl_PNM_Image.cxx
  324. '''
  325. img_lib = [ 'ntk', 'LIBJPEG', 'LIBPNG', 'LIBZ' ]
  326. img_inc = ['.', 'src', 'FL', 'src/xutf8/headers' ]
  327. bld( source = lib_images_source,
  328. features = 'cxx cxxshlib',
  329. vnum = API_VERSION,
  330. target = 'ntk_images',
  331. defines = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ],
  332. cflags = [ '-fPIC' ],
  333. cxxflags = [ '-fPIC' ],
  334. uselib_local = [ 'ntk' ],
  335. use = img_lib,
  336. includes = img_inc,
  337. # uselib = [ 'X11', 'cairo' ],
  338. install_path = '${LIBDIR}')
  339. bld( source = lib_images_source,
  340. features = 'cxx cxxstlib',
  341. vnum = API_VERSION,
  342. cflags = [ '-fPIC' ],
  343. cxxflags = [ '-fPIC' ],
  344. target = 'ntk_images',
  345. defines = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ],
  346. use = img_lib,
  347. includes = img_inc,
  348. # uselib_local = [ 'ntk' ],
  349. uselib = [ 'X11', 'cairo' ],
  350. install_path = '${LIBDIR}')
  351. lib_gl_source = '''
  352. src/Fl_Gl_Choice.cxx
  353. src/Fl_Gl_Device_Plugin.cxx
  354. src/Fl_Gl_Overlay.cxx
  355. src/Fl_Gl_Window.cxx
  356. '''
  357. if bld.env.USE_GL:
  358. print 'Using GL'
  359. bld( source = lib_gl_source,
  360. features = 'cxx cxxshlib',
  361. vnum = API_VERSION,
  362. target = 'ntk_gl',
  363. includes = ['.', 'src', 'FL', 'src/xutf8/headers' ],
  364. defines = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ],
  365. uselib_local = [ 'ntk' ],
  366. cflags = [ '-fPIC' ],
  367. cxxflags = [ '-fPIC' ],
  368. install_path = '${LIBDIR}')
  369. bld( source = lib_gl_source,
  370. features = 'cxx cxxstlib',
  371. vnum = API_VERSION,
  372. target = 'ntk_gl',
  373. cflags = [ '-fPIC' ],
  374. cxxflags = [ '-fPIC' ],
  375. includes = ['.', 'src', 'FL', 'src/xutf8/headers' ],
  376. uselib_local = [ 'ntk' ],
  377. defines = [ 'FL_LIBRARY=1', 'FL_INTERNALS=1' ],
  378. uselib = [ 'X11', 'cairo' ],
  379. install_path = '${LIBDIR}')
  380. # bld(
  381. # source = 'ntk-config.in'
  382. # target = 'ntk-config'
  383. # dict = { 'prefix': bld.env.PREFIX,
  384. # 'exec_prefix' : bld.env.EXEC_PREFIX,
  385. # 'bindir' : bld.env.BINDIR,
  386. # 'includedir' : bld.env.INCLUDEDIR,
  387. # 'libdir' : bld.env.LIBDIR,
  388. # 'srcdir' : bld.env.SRCDIR,
  389. # 'cc' : bld.env.CC,
  390. # 'cxx' : bld.env.CXX,
  391. # }
  392. # )
  393. bld( features = 'subst',
  394. source = 'ntk.pc.in',
  395. target = 'ntk.pc',
  396. encoding = 'utf8',
  397. install_path = '${LIBDIR}/pkgconfig',
  398. CFLAGS = string.join( CFLAGS, ' ' ),
  399. VERSION = VERSION,
  400. PREFIX = bld.env.PREFIX )
  401. bld( features = 'subst',
  402. source = 'ntk_images.pc.in',
  403. target = 'ntk_images.pc',
  404. encoding = 'utf8',
  405. install_path = '${LIBDIR}/pkgconfig',
  406. CFLAGS = string.join( CFLAGS, ' ' ),
  407. VERSION = VERSION,
  408. PREFIX = bld.env.PREFIX )
  409. bld( features = 'subst',
  410. source = 'ntk_gl.pc.in',
  411. target = 'ntk_gl.pc',
  412. encoding = 'utf8',
  413. install_path = '${LIBDIR}/pkgconfig',
  414. CFLAGS = string.join( CFLAGS, ' ' ),
  415. VERSION = VERSION,
  416. PREFIX = bld.env.PREFIX )
  417. bld( features = 'subst',
  418. source = 'ntk-uninstalled.pc.in',
  419. target = 'ntk-uninstalled.pc',
  420. encoding = 'utf8',
  421. CFLAGS = string.join( CFLAGS, ' ' ),
  422. VERSION = VERSION,
  423. BUILD = os.getcwd() + '/' + out )
  424. bld( features = 'subst',
  425. source = 'ntk_images.pc.in',
  426. target = 'ntk_images-uninstalled.pc',
  427. encoding = 'utf8',
  428. VERSION = VERSION,
  429. CFLAGS = string.join( CFLAGS, ' ' ),
  430. BUILD = os.getcwd() + '/' + out )
  431. bld( features = 'subst',
  432. source = 'ntk_gl.pc.in',
  433. target = 'ntk_gl-uninstalled.pc',
  434. encoding = 'utf8',
  435. VERSION = VERSION,
  436. CFLAGS = string.join( CFLAGS, ' ' ),
  437. BUILD = os.getcwd() + '/' + out )
  438. # bld( features = 'subst',
  439. # source = 'ntk-config.in',
  440. # target = '../ntk-config',
  441. # mode = 0777,
  442. # encoding = 'utf8',
  443. # # VERSION = VERSION,
  444. # FL_MAJOR_VERSION = FL_MAJOR_VERSION,
  445. # FL_MINOR_VERSION = FL_MINOR_VERSION,
  446. # FL_PATCH_VERSION = FL_PATCH_VERSION,
  447. # preifx = bld.env.PREFIX,
  448. # exec_prefix = bld.env.EXECPREFIX,
  449. # bindir = bld.env.BINDIR,
  450. # includedir = bld.env.INCLUDEDIR,
  451. # libdir = bld.env.LIBDIR,
  452. # srcdir = os.getcwd() + '/' + out,
  453. # CC = bld.env.CC[0],
  454. # CXX = bld.env.CXX[0],
  455. # CFLAGS = string.join( bld.env.CFLAGS, ' ' ),
  456. # CXXFLAGS = string.join( bld.env.CXXFLAGS, ' ' ),
  457. # LDFLAGS = bld.env.LDFLAGS,
  458. # CAIROLIBS = '-lcairo',
  459. # install_path = '${BINDIR}' )
  460. for i in bld.env.BUNDLED:
  461. bld.recurse(i)
  462. for i in children:
  463. bld.recurse(i)
  464. # 'PREFIX': bld.env.PREFIX,
  465. # 'EXEC_PREFIX' : bld.env.EXEC_PREFIX,
  466. # 'BINDIR' : bld.env.BINDIR,
  467. # 'INCLUDEDIR' : bld.env.INCLUDEDIR,
  468. # 'LIBDIR' : bld.env.LIBDIR,
  469. # 'SRCDIR' : bld.env.SRCDIR } )
  470. start_dir = bld.path.find_dir( 'FL' )
  471. bld.install_files( bld.env.INCLUDEDIR + '/ntk/FL', start_dir.ant_glob('*.H *.h'),
  472. cwd=start_dir, relative_trick=True)
  473. # bld.install_files( string.join( [ '${DATADIR}/doc', APPNAME ], '/' ), bld.path.ant_glob( 'doc/*.html doc/*.png' ) )