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.

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