Changeset 167
- Timestamp:
- 06/15/05 13:35:38
- Files:
-
- openpgpsdk/trunk/configure (modified) (4 diffs)
- openpgpsdk/trunk/examples/packet-dump.c (modified) (3 diffs)
- openpgpsdk/trunk/include/configure.h.template (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/configure
r140 r167 4 4 5 5 use Carp; 6 use File::Temp; 6 7 7 8 our %Subst=( … … 27 28 28 29 my @Headers=qw(alloca.h); 30 my @Types=qw(time_t); 29 31 30 32 our %Knowledge=( 31 cc => sub { return chooseBinary('gcc','cc')33 cc => sub { return chooseBinary('gcc','cc') 32 34 || croak 'Can\'t find C compiler'; }, 33 path => sub { return [split /:/,$ENV{PATH}]; }, 35 path => sub { return [split /:/,$ENV{PATH}]; }, 36 time_t => sub { return typeInfo('time_t','time.h'); } 34 37 ); 35 38 … … 45 48 } 46 49 47 my $os=`uname -s`;50 #my $os=`uname -s`; 48 51 49 52 $Subst{'CC'}=getKnowledge('cc'); 50 53 51 54 findHeaders(\@Headers); 55 investigateTypes(\@Types); 52 56 53 57 fixSubst(); … … 155 159 } 156 160 161 sub build { 162 my $code=shift; 163 164 my $cc=getKnowledge('cc'); 165 my $fh=new File::Temp(SUFFIX => '.c'); 166 # print $fh->filename(),"\n"; 167 print $fh $code; 168 # print $code; 169 $fh->close(); 170 171 my $cmd="$cc -Wall -Werror -c ".$fh; 172 # print "$cmd\n"; 173 my $ret=system("$cmd > /dev/null 2>&1"); 174 175 return $ret == 0; 176 } 177 178 sub typeInfo { 179 my $type=shift; 180 my $header=shift; 181 182 my %info; 183 184 print "Getting info about $type.\n"; 185 186 foreach my $fmt (qw(%d %ld)) { 187 my $code="#include <$header>\n"; 188 $code .= "#include <stdio.h>\n"; 189 $code .= "void f(void) { static $type t; printf(\"$fmt\",t); }\n"; 190 if(build($code)) { 191 $info{fmt}=$fmt; 192 print " $type printf format is $fmt\n"; 193 } 194 } 195 croak "Can't determine print format for $type" if !defined $info{fmt}; 196 197 return \%info; 198 } 199 200 sub investigateTypes { 201 my $types=shift; 202 203 foreach my $type (@$types) { 204 my $info=getKnowledge($type); 205 $Subst{uc($type)."_FMT"}="\"$info->{fmt}\""; 206 } 207 } 208 openpgpsdk/trunk/examples/packet-dump.c
r166 r167 2 2 #include "packet-parse.h" 3 3 #include "packet-show.h" 4 #include "configure.h" 4 5 #include "util.h" 5 6 #include <unistd.h> … … 20 21 static void showtime(const unsigned char *name,time_t t) 21 22 { 22 printf("%s= %ld(%.24s)",name,t,ctime(&t));23 printf("%s=" TIME_T_FMT " (%.24s)",name,t,ctime(&t)); 23 24 } 24 25 … … 45 46 print_indent(); 46 47 printf("%s: ",name); 47 printf("duration %ldseconds",time);48 printf("duration " TIME_T_FMT " seconds",time); 48 49 49 50 mins=time/60; openpgpsdk/trunk/include/configure.h.template
r127 r167 1 1 %HAVE_ALLOCA_H% 2 #define TIME_T_FMT %TIME_T_FMT%
