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.

559 lines
17KB

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