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.

515 lines
15KB

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