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.

533 lines
15KB

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