PageRenderTime 84ms CodeModel.GetById 23ms app.highlight 55ms RepoModel.GetById 1ms app.codeStats 1ms

/Build.PL

http://github.com/PerlGameDev/SDL
Perl | 647 lines | 553 code | 20 blank | 74 comment | 1 complexity | 46b0b963c626c4caa1c1c428012ed3b9 MD5 | raw file
  1#! perl -w
  2#
  3# Copyright (C) 2003 chromatic
  4# Copyright (C) 2004 David J. Goehrig
  5# Copyright (C) 2010 Kartik Thakore
  6
  7use strict;
  8use warnings;
  9use Carp;
 10
 11use lib 'inc';
 12use Alien::SDL;
 13
 14print STDERR <<BROKENMSG;
 15*************************** !!!WARNING!!! ********************************
 16This Release breaks back compatibility support with versions 2.4x and below
 17**************************************************************************
 18BROKENMSG
 19
 20### We need the platform-specific module
 21my %platforms = (
 22	MSWin32     => 'Windows',
 23	MacOS       => 'Darwin',
 24	darwin      => 'Darwin',
 25	cygwin      => 'Unix',
 26	freebsd     => 'Unix',
 27	gnukfreebsd => 'Unix',
 28	linux       => 'Unix',
 29	netbsd      => 'Unix',
 30	openbsd     => 'Unix',
 31	solaris     => 'Unix',
 32);
 33my $package = 'My::Builder::' . ( $platforms{$^O} || 'Unix' );
 34print "Using '$package' class ...\n";
 35eval "require $package" or Carp::confess "Require '$package' failed: $@\n";
 36
 37### Subsystems to build
 38#    <subsystem>
 39#        <file> = hash of the following 2 values:
 40#            <from> = location of source file
 41#            <to>   = location of build file to get name right
 42#        <libraries> = list reqiured libraries, names the same as keys to hash %libraries
 43my %subsystems = (
 44	SDL => {
 45		file => {
 46			from => 'src/SDL.xs',
 47			to   => 'lib/SDL_perl.xs',
 48		},
 49		libraries => [qw( SDL )],
 50	},
 51	Time => {
 52		file => {
 53			from => 'src/Core/Time.xs',
 54			to   => 'lib/SDL/Time.xs',
 55		},
 56		libraries => [qw( SDL )],
 57	},
 58	Events => {
 59		file => {
 60			from => 'src/Core/Events.xs',
 61			to   => 'lib/SDL/Events.xs',
 62		},
 63		libraries => [qw( SDL )],
 64	},
 65	Event => {
 66		file => {
 67			from => 'src/Core/objects/Event.xs',
 68			to   => 'lib/SDL/Event.xs',
 69		},
 70		libraries => [qw( SDL )],
 71	},
 72	GFX => {
 73		file => {
 74			from => 'src/GFX/GFX.xs',
 75			to   => 'lib/SDL/GFX.xs',
 76		},
 77		libraries => [qw( SDL SDL_gfx_primitives )],
 78	},
 79	BlitFunc => {
 80		file => {
 81			from => 'src/GFX/BlitFunc.xs',
 82			to   => 'lib/SDL/GFX/BlitFunc.xs',
 83		},
 84		libraries => [qw( SDL SDL_gfx_blitfunc )],
 85	},
 86	Framerate => {
 87		file => {
 88			from => 'src/GFX/Framerate.xs',
 89			to   => 'lib/SDL/GFX/Framerate.xs',
 90		},
 91		libraries => [qw( SDL SDL_gfx_framerate )],
 92	},
 93	FPSManager => {
 94		file => {
 95			from => 'src/GFX/FPSManager.xs',
 96			to   => 'lib/SDL/GFX/FPSManager.xs',
 97		},
 98		libraries => [qw( SDL SDL_gfx_framerate )],
 99	},
100	ImageFilter => {
101		file => {
102			from => 'src/GFX/ImageFilter.xs',
103			to   => 'lib/SDL/GFX/ImageFilter.xs',
104		},
105		libraries => [qw( SDL SDL_gfx_imagefilter )],
106	},
107	Primitives => {
108		file => {
109			from => 'src/GFX/Primitives.xs',
110			to   => 'lib/SDL/GFX/Primitives.xs',
111		},
112		libraries => [qw( SDL SDL_gfx_primitives )],
113	},
114	Rotozoom => {
115		file => {
116			from => 'src/GFX/Rotozoom.xs',
117			to   => 'lib/SDL/GFX/Rotozoom.xs',
118		},
119		libraries => [qw( SDL SDL_gfx_rotozoom )],
120	},
121	MultiThread => {
122		file => {
123			from => 'src/Core/MultiThread.xs',
124			to   => 'lib/SDL/MultiThread.xs',
125		},
126		libraries => [qw( SDL )],
127	},
128	Video => {
129		file => {
130			from => 'src/Core/Video.xs',
131			to   => 'lib/SDL/Video.xs',
132		},
133		libraries => [qw( SDL )],
134	},
135	Audio => {
136		file => {
137			from => 'src/Core/Audio.xs',
138			to   => 'lib/SDL/Audio.xs',
139		},
140		libraries => [qw( SDL )],
141	},
142	Rect => {
143		file => {
144			from => 'src/Core/objects/Rect.xs',
145			to   => 'lib/SDL/Rect.xs',
146		},
147		libraries => [qw( SDL )],
148	},
149	Color => {
150		file => {
151			from => 'src/Core/objects/Color.xs',
152			to   => 'lib/SDL/Color.xs',
153		},
154		libraries => [qw( SDL )],
155	},
156	Surface => {
157		file => {
158			from => 'src/Core/objects/Surface.xs',
159			to   => 'lib/SDL/Surface.xs',
160		},
161		libraries => [qw( SDL )],
162	},
163	SurfaceX => {
164		file => {
165			from => 'src/SDLx/Surface.xs',
166			to   => 'lib/SDLx/Surface.xs',
167		},
168		libraries => [qw( SDL SDL_gfx_primitives )],
169	},
170	TimerX => {
171		file => {
172			from => 'src/SDLx/Timer.xs',
173			to   => 'lib/SDLx/Controller/Timer.xs',
174		},
175		libraries => [qw( SDL )],
176	},
177	ValidateX => {
178		file => {
179			from => 'src/SDLx/Validate.xs',
180			to   => 'lib/SDLx/Validate.xs',
181		},
182		libraries => [qw( SDL )],
183	},
184	InterfaceX => {
185		file => {
186			from => 'src/SDLx/Controller/Interface.xs',
187			to   => 'lib/SDLx/Controller/Interface.xs',
188		},
189		libraries => [qw( SDL  )],
190	},
191	StateX => {
192		file => {
193			from => 'src/SDLx/Controller/State.xs',
194			to   => 'lib/SDLx/Controller/State.xs',
195		},
196		libraries => [qw( SDL  )],
197	},
198	Overlay => {
199		file => {
200			from => 'src/Core/objects/Overlay.xs',
201			to   => 'lib/SDL/Overlay.xs',
202		},
203		libraries => [qw( SDL )],
204	},
205	RWOps => {
206		file => {
207			from => 'src/Core/objects/RWOps.xs',
208			to   => 'lib/SDL/RWOps.xs',
209		},
210		libraries => [qw( SDL )],
211	},
212	PixelFormat => {
213		file => {
214			from => 'src/Core/objects/PixelFormat.xs',
215			to   => 'lib/SDL/PixelFormat.xs',
216		},
217		libraries => [qw( SDL )],
218	},
219	LayerManagerX => {
220		file => {
221			from => 'src/SDLx/LayerManager.xs',
222			to   => 'lib/SDLx/LayerManager.xs',
223		},
224		libraries => [qw( SDL )],
225	},
226	LayerX => {
227		file => {
228			from => 'src/SDLx/Layer.xs',
229			to   => 'lib/SDLx/Layer.xs',
230		},
231		libraries => [qw( SDL SDL_image )],
232	},
233	AudioSpec => {
234		file => {
235			from => 'src/Core/objects/AudioSpec.xs',
236			to   => 'lib/SDL/AudioSpec.xs',
237		},
238		libraries => [qw( SDL )],
239	},
240	AudioCVT => {
241		file => {
242			from => 'src/Core/objects/AudioCVT.xs',
243			to   => 'lib/SDL/AudioCVT.xs',
244		},
245		libraries => [qw( SDL )],
246	},
247	Mixer => {
248		file => {
249			from => 'src/Mixer/Mixer.xs',
250			to   => 'lib/SDL/Mixer.xs',
251		},
252		libraries => [qw( SDL SDL_mixer )],
253	},
254	MixerSamples => {
255		file => {
256			from => 'src/Mixer/Samples.xs',
257			to   => 'lib/SDL/Mixer/Samples.xs',
258		},
259		libraries => [qw( SDL SDL_mixer )],
260	},
261	MixerChannels => {
262		file => {
263			from => 'src/Mixer/Channels.xs',
264			to   => 'lib/SDL/Mixer/Channels.xs',
265		},
266		libraries => [qw( SDL SDL_mixer )],
267	},
268	MixerGroups => {
269		file => {
270			from => 'src/Mixer/Groups.xs',
271			to   => 'lib/SDL/Mixer/Groups.xs',
272		},
273		libraries => [qw( SDL SDL_mixer )],
274	},
275	MixerMusic => {
276		file => {
277			from => 'src/Mixer/Music.xs',
278			to   => 'lib/SDL/Mixer/Music.xs',
279		},
280		libraries => [qw( SDL SDL_mixer )],
281	},
282	MixerEffects => {
283		file => {
284			from => 'src/Mixer/Effects.xs',
285			to   => 'lib/SDL/Mixer/Effects.xs',
286		},
287		libraries => [qw( SDL SDL_mixer )],
288	},
289	MixChunk => {
290		file => {
291			from => 'src/Mixer/objects/MixChunk.xs',
292			to   => 'lib/SDL/Mixer/MixChunk.xs',
293		},
294		libraries => [qw( SDL SDL_mixer )],
295	},
296	MixMusic => {
297		file => {
298			from => 'src/Mixer/objects/MixMusic.xs',
299			to   => 'lib/SDL/Mixer/MixMusic.xs',
300		},
301		libraries => [qw( SDL SDL_mixer )],
302	},
303	Palette => {
304		file => {
305			from => 'src/Core/objects/Palette.xs',
306			to   => 'lib/SDL/Palette.xs',
307		},
308		libraries => [qw( SDL )],
309	},
310	VideoInfo => {
311		file => {
312			from => 'src/Core/objects/VideoInfo.xs',
313			to   => 'lib/SDL/VideoInfo.xs',
314		},
315		libraries => [qw( SDL )],
316	},
317	Mouse => {
318		file => {
319			from => 'src/Core/Mouse.xs',
320			to   => 'lib/SDL/Mouse.xs',
321		},
322		libraries => [qw( SDL )],
323	},
324	Cursor => {
325		file => {
326			from => 'src/Core/objects/Cursor.xs',
327			to   => 'lib/SDL/Cursor.xs',
328		},
329		libraries => [qw( SDL )],
330	},
331	Joystick => {
332		file => {
333			from => 'src/Core/Joystick.xs',
334			to   => 'lib/SDL/Joystick.xs',
335		},
336		libraries => [qw( SDL )],
337	},
338	CDROM => {
339		file => {
340			from => 'src/Core/CDROM.xs',
341			to   => 'lib/SDL/CDROM.xs',
342		},
343		libraries => [qw( SDL )],
344	},
345	CDTrack => {
346		file => {
347			from => 'src/Core/objects/CDTrack.xs',
348			to   => 'lib/SDL/CDTrack.xs',
349		},
350		libraries => [qw( SDL )],
351	},
352	CD => {
353		file => {
354			from => 'src/Core/objects/CD.xs',
355			to   => 'lib/SDL/CD.xs',
356		},
357		libraries => [qw( SDL )],
358	},
359	TTF => {
360		file => {
361			from => 'src/TTF/TTF.xs',
362			to   => 'lib/SDL/TTF.xs',
363		},
364		libraries => [qw( SDL SDL_ttf )],
365	},
366	TTF_Font => {
367		file => {
368			from => 'src/TTF/objects/Font.xs',
369			to   => 'lib/SDL/TTF/Font.xs',
370		},
371		libraries => [qw( SDL SDL_ttf )],
372	},
373	Version => {
374		file => {
375			from => 'src/Core/objects/Version.xs',
376			to   => 'lib/SDL/Version.xs',
377		},
378		libraries => [qw( SDL )],
379	},
380	Image => {
381		file => {
382			from => 'src/Image.xs',
383			to   => 'lib/SDL/Image.xs',
384		},
385		libraries => [qw( SDL SDL_image )],
386	},
387	SFont => {
388		file => {
389			from => 'src/SDLx/SFont.xs',
390			to   => 'lib/SDLx/SFont.xs',
391		},
392		libraries => [qw( SDL SDL_image )],
393	},
394
395#	SMPEG => {
396#			file	=> {
397#				from => 'src/SMPEG.xs',
398#				to   =>	'lib/SDL/SMPEG.xs',
399#			},
400#			libraries => [qw( SDL smpeg)],
401#		},
402#	MPEG => {
403#			file	=> {
404#				from => 'src/SMPEG/Info.xs',
405#				to   =>	'lib/SDL/SMPEG/Info.xs',
406#			},
407#			libraries => [qw( SDL smpeg)],
408#		},
409	Pango => {
410		file => {
411			from => 'src/Pango/Pango.xs',
412			to   => 'lib/SDL/Pango.xs',
413		},
414		libraries => [qw( SDL SDL_Pango )],
415	},
416	Context => {
417		file => {
418			from => 'src/Pango/objects/Context.xs',
419			to   => 'lib/SDL/Pango/Context.xs',
420		},
421		libraries => [qw( SDL SDL_Pango )],
422	},
423
424	#	Net => {
425	#		file      => {
426	#			from  => 'src/Net/Net.xs',
427	#			to    => 'lib/SDL/Net.xs',
428	#		},
429	#		libraries => [qw( SDL SDL_net )],
430	#	},
431	#	TCP => {
432	#		file      => {
433	#			from  => 'src/Net/TCP.xs',
434	#			to    => 'lib/SDL/Net/TCP.xs',
435	#		},
436	#		libraries => [qw( SDL SDL_net )],
437	#	},
438	#	UDP => {
439	#		file      => {
440	#			from  => 'src/Net/UDP.xs',
441	#			to    => 'lib/SDL/Net/UDP.xs',
442	#		},
443	#		libraries => [qw( SDL SDL_net )],
444	#	},
445	#	IPaddress => {
446	#		file      => {
447	#			from  => 'src/Net/objects/IPaddress.xs',
448	#			to    => 'lib/SDL/Net/IPaddress.xs',
449	#		},
450	#		libraries => [qw( SDL SDL_net )],
451	#	},
452
453);
454
455### External libraries
456#    <library name> = symbolic library name
457#        <define> = value that will be used as -D<value> option when compiling XS code
458#        <header> = header related to the library that will be used for avalability detection,
459#                   could be a sigle value or an array of values
460#        <lib>    = value that will be used as -l<value> option when linking XS code
461my %libraries = (
462	SDL => {
463		define => 'HAVE_SDL',
464		header => 'SDL.h',
465		lib    => 'SDL',
466	},
467	SDL_image => {
468		define => 'HAVE_SDL_IMAGE',
469		header => 'SDL_image.h',
470		lib    => 'SDL_image',
471	},
472	SDL_mixer => {
473		define => 'HAVE_SDL_MIXER',
474		header => 'SDL_mixer.h',
475		lib    => 'SDL_mixer',
476	},
477
478	#	SDL_net     => {
479	#		define => 'HAVE_SDL_NET',
480	#		header => 'SDL_net.h',
481	#		lib    => 'SDL_net',
482	#	},
483	SDL_ttf => {
484		define => 'HAVE_SDL_TTF',
485		header => 'SDL_ttf.h',
486		lib    => 'SDL_ttf',
487	},
488	SDL_gfx => {
489		define => 'HAVE_SDL_GFX',
490		header => 'SDL_gfxPrimitives.h',
491		lib    => 'SDL_gfx',
492	},
493	SDL_gfx_blitfunc => {
494		define => 'HAVE_SDL_GFX_BLITFUNC',
495		header => 'SDL_gfxBlitFunc.h',
496		lib    => 'SDL_gfx',
497	},
498	SDL_gfx_framerate => {
499		define => 'HAVE_SDL_GFX_FRAMERATE',
500		header => 'SDL_framerate.h',
501		lib    => 'SDL_gfx',
502	},
503	SDL_gfx_imagefilter => {
504		define => 'HAVE_SDL_GFX_IMAGEFILTER',
505		header => 'SDL_imageFilter.h',
506		lib    => 'SDL_gfx',
507	},
508	SDL_gfx_primitives => {
509		define => 'HAVE_SDL_GFX_PRIMITIVES',
510		header => 'SDL_gfxPrimitives.h',
511		lib    => 'SDL_gfx',
512	},
513	SDL_gfx_rotozoom => {
514		define => 'HAVE_SDL_GFX_ROTOZOOM',
515		header => 'SDL_rotozoom.h',
516		lib    => 'SDL_gfx',
517	},
518	SDL_Pango => {
519		define => 'HAVE_SDL_PANGO',
520		header => 'SDL_Pango.h',
521		lib    => 'SDL_Pango',
522	},
523	png => {
524		define => 'HAVE_PNG',
525		header => 'png.h',
526		lib    => 'png',
527	},
528	jpeg => {
529		define => 'HAVE_JPEG',
530		header => 'jpeglib.h',
531		lib    => 'jpeg',
532	},
533	tiff => {
534		define => 'HAVE_TIFF',
535		header => 'tiff.h',
536		lib    => 'tiff',
537	},
538
539	smpeg => {
540		define => 'HAVE_SMPEG',
541		header => 'smpeg/smpeg.h',
542		lib    => 'smpeg',
543	},
544	GL => {
545		define => 'HAVE_GL',
546		header => [ 'GL/gl.h', 'GL/glext.h' ],
547		lib    => ( $^O =~ /^(MSWin32|cygwin)$/ )
548		? 'opengl32'
549		: 'GL', # xxx not nice
550	},
551	GLU => {
552		define => 'HAVE_GLU',
553		header => 'GL/glu.h',
554		lib    => ( $^O =~ /^(MSWin32|cygwin)$/ ) ? 'glu32' : 'GLU', # xxx not nice
555	},
556);
557
558### Mangle the compilable files into a format Module::Build can understand
559my %xs =
560	map { $subsystems{$_}{file}{from} => $subsystems{$_}{file}{to} }
561	keys %subsystems;
562
563### Standard Module::Build stuff
564$My::Builder::config = $My::Builder::config;       # Prevent a warning
565my $build = $package->new(
566	module_name        => 'SDL',
567	dist_name          => 'SDL',
568	license            => 'lgpl',
569	dist_version_from  => 'lib/SDL.pm',
570	configure_requires => {
571		'ExtUtils::CBuilder' => '0.260301',
572		'Alien::SDL'         => '1.446',
573		'File::Find'         => '0',
574		'File::ShareDir'     => '1.0',
575		'Tie::Simple'        => '0',
576		"Module::Build"      => '0.40',
577		'Capture::Tiny'      => '0',
578	},
579	build_requires => {
580		'Test::Simple'      => '0.88',
581   		'Capture::Tiny'     => '0',
582		'Test::Most'        => '0.21',
583		'Alien::SDL'        => '1.446',
584		'File::Find'        => '0',
585		'File::ShareDir'    => '1.0',
586		'Tie::Simple'       => '0',
587		'Scalar::Util'      => '0',
588	},
589	requires => {
590		'Scalar::Util'   => '0',
591		'Tie::Simple'    => '0',
592		'File::ShareDir' => '1.0',
593		'CPAN'           => '1.92',
594		'perl'           => '5.008000',
595	},
596	share_dir => 'share',
597
598	build_recommends => {
599		'Pod::ToDemo' => '0.20',
600	},
601	config   => $My::Builder::config,
602	c_source => 'src',
603	xs_files => \%xs,
604	meta_add => {},
605	typemap_files => { 'typemap' => 'lib/SDL/typemap' },
606
607	#create_readme => 1, ### make sense only if there is some POD doc in the file specified by dist_version_from
608	meta_merge => {
609		resources => {
610			bugtracker => 'http://github.com/PerlGameDev/SDL/issues',
611			repository => 'http://github.com/PerlGameDev/SDL'
612		}
613	},
614	dist_abstract => 'SDL bindings to Perl',
615	dist_author   => 'Kartik Thakore <KTHAKORE@cpan.org>',
616);
617
618### Alien::SDL quick check
619warn "###WARNING### Alien::SDL seems to be broken"
620	unless Alien::SDL->config('prefix');
621
622### See which subsystems can be built -- do we have headers for them?
623print "Detecting available libraries ...\n";
624my $build_systems = $build->find_subsystems( \%subsystems, \%libraries );
625my $lib_translate = $build->translate_table( \%subsystems, \%libraries );
626
627### Save info about available subsystems for future SDL::ConfigData
628print "Writing config_data ...\n";
629$build->config_data( 'SDL_cfg',           $build_systems );
630$build->config_data( 'SDL_lib_translate', $lib_translate );
631$build->config_data( 'subsystems',        \%subsystems );
632$build->config_data( 'libraries',         \%libraries );
633
634### Something that was originally special to MacOS/Darwin
635# somebody MacOS/Darwin friendly should review whether it is still necessary
636$build->special_build_settings();
637
638### Get some info into M::B notes
639print "Saving some info to 'notes' ...\n";
640$build->notes( 'subsystems',    \%subsystems );
641$build->notes( 'libraries',     \%libraries );
642$build->notes( 'build_systems', $build_systems );
643$build->notes( 'sdl_cflags',    Alien::SDL->config('cflags') );
644$build->notes( 'sdl_libs',      Alien::SDL->config('libs') );
645$build->set_file_flags(); # creates notes('file_flags')
646$build->add_build_element('typemap');
647$build->create_build_script();