File: Makefile.freebsd

package info (click to toggle)
sdlperl 1.20.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,804 kB
  • ctags: 2,169
  • sloc: perl: 7,397; ansic: 232; makefile: 72; sh: 1
file content (119 lines) | stat: -rw-r--r-- 2,541 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env perl 

use strict;
use ExtUtils::MakeMaker;

#
# Configure SDL proper
#

use vars qw/ $sdl_cflags $sdl_libs @dirs $inc_flags %ext @defs /;

#
# Configuration detection of Linux / Unix
#

chomp ($sdl_cflags = "-I/usr/X11R6/include " . `sdl11-config --cflags`);
chomp ($sdl_libs = "-L/usr/X11R6/lib " . `sdl11-config --libs`);
$sdl_libs =~ s/-Wl,-rpath,\/usr\/local\/lib//; # suppress the insanity
$sdl_libs =~ s/-pthread//;

#
# Search paths
#

@dirs=(
	'/usr/local/include',
	'/usr/local/include/SDL11', 
	'/usr/local/include/smpeg',
	'/usr/X11R6/include',
	'/usr/X11R6/include/GL', 
);

$inc_flags = $ENV{'DEBUG'} . ' ' . $ENV{'CFLAGS'};

#
# Registed extensions
#

%ext = ( 
	SDL_image => { inc => 'HAVE_SDL_IMAGE', test => 'SDL_image.h' },
	SDL_mixer => { inc => 'HAVE_SDL_MIXER', test => 'SDL_mixer.h' },
	SDL_net => { inc => 'HAVE_SDL_NET', test => 'SDL_net.h' },
	SDL_ttf => { inc => 'HAVE_SDL_TTF', test => 'SDL_ttf.h' },
	SDL_gfx => { inc => 'HAVE_SDL_GFX', test => 'SDL_gfxPrimitives.h' },
	SDL_console => { inc => 'HAVE_SDL_CONSOLE', test => 'CON_console.h' },
	png => { inc => 'HAVE_PNG', test => 'png.h' },
	jpeg => { inc => 'HAVE_JPEG', test => 'jpeglib.h' },
	GL => { inc => 'HAVE_GL', test => 'gl.h' },
	GLU => { inc => 'HAVE_GLU', test => 'glu.h' },
	smpeg => { inc => 'HAVE_SMPEG', test => 'smpeg.h' },
);

#
# Locate optional packages
#

my ($e,$d);
for $e ( keys %ext ) {
	for $d (@dirs) {
		$ext{$e}{exists} ||= -e "$d/$ext{$e}{test}" 
	}
}
	
sub found_mod {
	printf "%-24s%s\n", "Found $_[0]",  ( $_[1] ? "yes" : "no" );
}

for $e ( sort keys %ext ) {
	found_mod ($e,$ext{$e}{exists});
}

#
# Get GLU version
#

if  ( $ext{GLU}{exists} ) {
	print "Detecting GLU Version\n";
	system ("gcc -o detect detect.c $sdl_cflags -lGLU -lGL $sdl_libs -pthread");
	my $version = `./detect` * 10;
	push @defs, "-DHAVE_GLU_VERSION=$version";
	system ("rm detect");
}

#
# Test For thread support
#

if ( $Config{usethreads} ) {
	push @defs, "-DUSE_THREADS";
}


#
# Specify Makefile options
#

my %options = (
    'NAME'	=> 'SDL_perl',
    'VERSION_FROM' => 'SDL.pm', 
    'LIBS'	=> [ join( " ",	"$sdl_libs", 
			map { $ext{$_}{exists} ? "-l$_" : '' } (sort keys %ext),
			)
		],  
    'DEFINE'	=> join ( " ", @defs, map { $ext{$_}{exists} ? "-D$ext{$_}{inc}" : '' } sort keys %ext),
    'INC'	=> "$inc_flags $sdl_cflags",
    'OBJECT'	=> (	
			 ($ext{SDL_image}{exists} ? 'SFont.o ' : "") .
			 'SDL_perl.o ' .
			 ($ext{GL}{exists} ? 'OpenGL.o ' : "") 
		),
);
    
#
# Write Makefile 
#

WriteMakefile(%options );