| 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 |
#define HAVE_STDDEF_H |
| 36 |
#ifdef HAVE_STDDEF_H |
| 37 |
#include <stddef.h> |
| 38 |
#endif |
| 39 |
|
| 40 |
#define HAVE_STDLIB_H |
| 41 |
#ifdef HAVE_STDLIB_H |
| 42 |
#include <stdlib.h> |
| 43 |
#endif |
| 44 |
|
| 45 |
#include <stdio.h> |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#undef NEED_BSD_STRINGS |
| 54 |
|
| 55 |
#ifdef NEED_BSD_STRINGS |
| 56 |
#include <strings.h> |
| 57 |
#else |
| 58 |
#include <string.h> |
| 59 |
#endif |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
#undef NEED_SYS_TYPES_H |
| 67 |
#ifdef NEED_SYS_TYPES_H |
| 68 |
#include <sys/types.h> |
| 69 |
#endif |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
#undef NEED_SPECIAL_INCLUDE |
| 85 |
|
| 86 |
#ifdef NEED_SPECIAL_INCLUDE |
| 87 |
#include <someincludefile.h> |
| 88 |
#endif |
| 89 |
|
| 90 |
typedef size_t my_size_t; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
#define HAVE_PROTOTYPES |
| 101 |
|
| 102 |
#ifdef HAVE_PROTOTYPES |
| 103 |
int testfunction (int arg1, int * arg2); |
| 104 |
|
| 105 |
struct methods_struct { |
| 106 |
int (*error_exit) (char *msgtext); |
| 107 |
int (*trace_message) (char *msgtext); |
| 108 |
int (*another_method) (void); |
| 109 |
}; |
| 110 |
|
| 111 |
int testfunction (int arg1, int * arg2) |
| 112 |
{ |
| 113 |
return arg2[arg1]; |
| 114 |
} |
| 115 |
|
| 116 |
int test2function (void) |
| 117 |
{ |
| 118 |
return 0; |
| 119 |
} |
| 120 |
#endif |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
#define HAVE_UNSIGNED_CHAR |
| 129 |
|
| 130 |
#ifdef HAVE_UNSIGNED_CHAR |
| 131 |
unsigned char un_char; |
| 132 |
#endif |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
#define HAVE_UNSIGNED_SHORT |
| 141 |
|
| 142 |
#ifdef HAVE_UNSIGNED_SHORT |
| 143 |
unsigned short un_short; |
| 144 |
#endif |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
#define HAVE_VOID |
| 152 |
|
| 153 |
#ifdef HAVE_VOID |
| 154 |
|
| 155 |
typedef void * void_ptr; |
| 156 |
#ifdef HAVE_PROTOTYPES |
| 157 |
typedef void (*void_func) (int a, int b); |
| 158 |
#else |
| 159 |
typedef void (*void_func) (); |
| 160 |
#endif |
| 161 |
|
| 162 |
#ifdef HAVE_PROTOTYPES |
| 163 |
void test3function (void_ptr arg1, void_func arg2) |
| 164 |
#else |
| 165 |
void test3function (arg1, arg2) |
| 166 |
void_ptr arg1; |
| 167 |
void_func arg2; |
| 168 |
#endif |
| 169 |
{ |
| 170 |
char * locptr = (char *) arg1; |
| 171 |
arg1 = (void *) locptr; |
| 172 |
(*arg2) (1, 2); |
| 173 |
} |
| 174 |
#endif |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
#define HAVE_CONST |
| 182 |
|
| 183 |
#ifdef HAVE_CONST |
| 184 |
static const int carray[3] = {1, 2, 3}; |
| 185 |
|
| 186 |
#ifdef HAVE_PROTOTYPES |
| 187 |
int test4function (const int arg1) |
| 188 |
#else |
| 189 |
int test4function (arg1) |
| 190 |
const int arg1; |
| 191 |
#endif |
| 192 |
{ |
| 193 |
return carray[arg1]; |
| 194 |
} |
| 195 |
#endif |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
#undef INCOMPLETE_TYPES_BROKEN |
| 203 |
|
| 204 |
#ifndef INCOMPLETE_TYPES_BROKEN |
| 205 |
typedef struct undefined_structure * undef_struct_ptr; |
| 206 |
#endif |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
#undef NEED_SHORT_EXTERNAL_NAMES |
| 214 |
|
| 215 |
#ifndef NEED_SHORT_EXTERNAL_NAMES |
| 216 |
|
| 217 |
int possibly_duplicate_function () |
| 218 |
{ |
| 219 |
return 0; |
| 220 |
} |
| 221 |
|
| 222 |
int possibly_dupli_function () |
| 223 |
{ |
| 224 |
return 1; |
| 225 |
} |
| 226 |
|
| 227 |
#endif |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
#ifdef HAVE_PROTOTYPES |
| 243 |
int is_char_signed (int arg) |
| 244 |
#else |
| 245 |
int is_char_signed (arg) |
| 246 |
int arg; |
| 247 |
#endif |
| 248 |
{ |
| 249 |
if (arg == 189) { |
| 250 |
return 0; |
| 251 |
} |
| 252 |
else if (arg != -67) { |
| 253 |
printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); |
| 254 |
printf("I fear the JPEG software will not work at all.\n\n"); |
| 255 |
} |
| 256 |
return 1; |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
#ifdef HAVE_PROTOTYPES |
| 261 |
int is_shifting_signed (long arg) |
| 262 |
#else |
| 263 |
int is_shifting_signed (arg) |
| 264 |
long arg; |
| 265 |
#endif |
| 266 |
|
| 267 |
{ |
| 268 |
long res = arg >> 4; |
| 269 |
|
| 270 |
if (res == -0x7F7E80CL) { |
| 271 |
return 1; |
| 272 |
} |
| 273 |
|
| 274 |
|
| 275 |
res |= (~0L) << (32-4); |
| 276 |
if (res == -0x7F7E80CL) { |
| 277 |
return 0; |
| 278 |
} |
| 279 |
printf("Right shift isn't acting as I expect it to.\n"); |
| 280 |
printf("I fear the JPEG software will not work at all.\n\n"); |
| 281 |
return 0; |
| 282 |
} |
| 283 |
|
| 284 |
|
| 285 |
#ifdef HAVE_PROTOTYPES |
| 286 |
int main (int argc, char ** argv) |
| 287 |
#else |
| 288 |
int main (argc, argv) |
| 289 |
int argc; |
| 290 |
char ** argv; |
| 291 |
#endif |
| 292 |
{ |
| 293 |
char signed_char_check = (char) (-67); |
| 294 |
FILE *outfile; |
| 295 |
|
| 296 |
|
| 297 |
if ((outfile = fopen("jconfig.h", "w")) == NULL) { |
| 298 |
printf("Failed to write jconfig.h\n"); |
| 299 |
return 1; |
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); |
| 304 |
fprintf(outfile, "/* see jconfig.doc for explanations */\n\n"); |
| 305 |
#ifdef HAVE_PROTOTYPES |
| 306 |
fprintf(outfile, "#define HAVE_PROTOTYPES\n"); |
| 307 |
#else |
| 308 |
fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); |
| 309 |
#endif |
| 310 |
#ifdef HAVE_UNSIGNED_CHAR |
| 311 |
fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); |
| 312 |
#else |
| 313 |
fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); |
| 314 |
#endif |
| 315 |
#ifdef HAVE_UNSIGNED_SHORT |
| 316 |
fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); |
| 317 |
#else |
| 318 |
fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); |
| 319 |
#endif |
| 320 |
#ifdef HAVE_VOID |
| 321 |
fprintf(outfile, "/* #define void char */\n"); |
| 322 |
#else |
| 323 |
fprintf(outfile, "#define void char\n"); |
| 324 |
#endif |
| 325 |
#ifdef HAVE_CONST |
| 326 |
fprintf(outfile, "/* #define const */\n"); |
| 327 |
#else |
| 328 |
fprintf(outfile, "#define const\n"); |
| 329 |
#endif |
| 330 |
if (is_char_signed((int) signed_char_check)) |
| 331 |
fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); |
| 332 |
else |
| 333 |
fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); |
| 334 |
#ifdef HAVE_STDDEF_H |
| 335 |
fprintf(outfile, "#define HAVE_STDDEF_H\n"); |
| 336 |
#else |
| 337 |
fprintf(outfile, "#undef HAVE_STDDEF_H\n"); |
| 338 |
#endif |
| 339 |
#ifdef HAVE_STDLIB_H |
| 340 |
fprintf(outfile, "#define HAVE_STDLIB_H\n"); |
| 341 |
#else |
| 342 |
fprintf(outfile, "#undef HAVE_STDLIB_H\n"); |
| 343 |
#endif |
| 344 |
#ifdef NEED_BSD_STRINGS |
| 345 |
fprintf(outfile, "#define NEED_BSD_STRINGS\n"); |
| 346 |
#else |
| 347 |
fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); |
| 348 |
#endif |
| 349 |
#ifdef NEED_SYS_TYPES_H |
| 350 |
fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); |
| 351 |
#else |
| 352 |
fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); |
| 353 |
#endif |
| 354 |
fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); |
| 355 |
#ifdef NEED_SHORT_EXTERNAL_NAMES |
| 356 |
fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); |
| 357 |
#else |
| 358 |
fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); |
| 359 |
#endif |
| 360 |
#ifdef INCOMPLETE_TYPES_BROKEN |
| 361 |
fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); |
| 362 |
#else |
| 363 |
fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); |
| 364 |
#endif |
| 365 |
fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); |
| 366 |
if (is_shifting_signed(-0x7F7E80B1L)) |
| 367 |
fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); |
| 368 |
else |
| 369 |
fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); |
| 370 |
fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); |
| 371 |
fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); |
| 372 |
fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); |
| 373 |
fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); |
| 374 |
fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); |
| 375 |
fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); |
| 376 |
fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); |
| 377 |
fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); |
| 378 |
fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); |
| 379 |
fprintf(outfile, "#undef DONT_USE_B_MODE\n"); |
| 380 |
fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); |
| 381 |
fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); |
| 382 |
|
| 383 |
|
| 384 |
fclose(outfile); |
| 385 |
|
| 386 |
|
| 387 |
printf("Configuration check for Independent JPEG Group's software done.\n"); |
| 388 |
printf("\nI have written the jconfig.h file for you.\n\n"); |
| 389 |
#ifdef HAVE_PROTOTYPES |
| 390 |
printf("You should use makefile.ansi as the starting point for your Makefile.\n"); |
| 391 |
#else |
| 392 |
printf("You should use makefile.unix as the starting point for your Makefile.\n"); |
| 393 |
#endif |
| 394 |
|
| 395 |
#ifdef NEED_SPECIAL_INCLUDE |
| 396 |
printf("\nYou'll need to change jconfig.h to include the system include file\n"); |
| 397 |
printf("that you found type size_t in, or add a direct definition of type\n"); |
| 398 |
printf("size_t if that's what you used. Just add it to the end.\n"); |
| 399 |
#endif |
| 400 |
|
| 401 |
return 0; |
| 402 |
} |