Blame gtkmm-osx/jpeg-6b/ckconfig.c

darco 56a656
/*
darco 56a656
 * ckconfig.c
darco 56a656
 *
darco 56a656
 * Copyright (C) 1991-1994, Thomas G. Lane.
darco 56a656
 * This file is part of the Independent JPEG Group's software.
darco 56a656
 * For conditions of distribution and use, see the accompanying README file.
darco 56a656
 */
darco 56a656
darco 56a656
/*
darco 56a656
 * This program is intended to help you determine how to configure the JPEG
darco 56a656
 * software for installation on a particular system.  The idea is to try to
darco 56a656
 * compile and execute this program.  If your compiler fails to compile the
darco 56a656
 * program, make changes as indicated in the comments below.  Once you can
darco 56a656
 * compile the program, run it, and it will produce a "jconfig.h" file for
darco 56a656
 * your system.
darco 56a656
 *
darco 56a656
 * As a general rule, each time you try to compile this program,
darco 56a656
 * pay attention only to the *first* error message you get from the compiler.
darco 56a656
 * Many C compilers will issue lots of spurious error messages once they
darco 56a656
 * have gotten confused.  Go to the line indicated in the first error message,
darco 56a656
 * and read the comments preceding that line to see what to change.
darco 56a656
 *
darco 56a656
 * Almost all of the edits you may need to make to this program consist of
darco 56a656
 * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL",
darco 56a656
 * or vice versa.  This is called defining or undefining that symbol.
darco 56a656
 */
darco 56a656
darco 56a656
darco 56a656
/* First we must see if your system has the include files we need.
darco 56a656
 * We start out with the assumption that your system has all the ANSI-standard
darco 56a656
 * include files.  If you get any error trying to include one of these files,
darco 56a656
 * undefine the corresponding HAVE_xxx symbol.
darco 56a656
 */
darco 56a656
darco 56a656
#define HAVE_STDDEF_H		/* replace 'define' by 'undef' if error here */
darco 56a656
#ifdef HAVE_STDDEF_H		/* next line will be skipped if you undef... */
darco 56a656
#include <stddef.h></stddef.h>
darco 56a656
#endif
darco 56a656
darco 56a656
#define HAVE_STDLIB_H		/* same thing for stdlib.h */
darco 56a656
#ifdef HAVE_STDLIB_H
darco 56a656
#include <stdlib.h></stdlib.h>
darco 56a656
#endif
darco 56a656
darco 56a656
#include <stdio.h>		/* If you ain't got this, you ain't got C. */</stdio.h>
darco 56a656
darco 56a656
/* We have to see if your string functions are defined by
darco 56a656
 * strings.h (old BSD convention) or string.h (everybody else).
darco 56a656
 * We try the non-BSD convention first; define NEED_BSD_STRINGS
darco 56a656
 * if the compiler says it can't find string.h.
darco 56a656
 */
darco 56a656
darco 56a656
#undef NEED_BSD_STRINGS
darco 56a656
darco 56a656
#ifdef NEED_BSD_STRINGS
darco 56a656
#include <strings.h></strings.h>
darco 56a656
#else
darco 56a656
#include <string.h></string.h>
darco 56a656
#endif
darco 56a656
darco 56a656
/* On some systems (especially older Unix machines), type size_t is
darco 56a656
 * defined only in the include file <sys types.h="">.  If you get a failure</sys>
darco 56a656
 * on the size_t test below, try defining NEED_SYS_TYPES_H.
darco 56a656
 */
darco 56a656
darco 56a656
#undef NEED_SYS_TYPES_H		/* start by assuming we don't need it */
darco 56a656
#ifdef NEED_SYS_TYPES_H
darco 56a656
#include <sys types.h=""></sys>
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
/* Usually type size_t is defined in one of the include files we've included
darco 56a656
 * above.  If not, you'll get an error on the "typedef size_t my_size_t;" line.
darco 56a656
 * In that case, first try defining NEED_SYS_TYPES_H just above.
darco 56a656
 * If that doesn't work, you'll have to search through your system library
darco 56a656
 * to figure out which include file defines "size_t".  Look for a line that
darco 56a656
 * says "typedef something-or-other size_t;".  Then, change the line below
darco 56a656
 * that says "#include <someincludefile.h>" to instead include the file</someincludefile.h>
darco 56a656
 * you found size_t in, and define NEED_SPECIAL_INCLUDE.  If you can't find
darco 56a656
 * type size_t anywhere, try replacing "#include <someincludefile.h>" with</someincludefile.h>
darco 56a656
 * "typedef unsigned int size_t;".
darco 56a656
 */
darco 56a656
darco 56a656
#undef NEED_SPECIAL_INCLUDE	/* assume we DON'T need it, for starters */
darco 56a656
darco 56a656
#ifdef NEED_SPECIAL_INCLUDE
darco 56a656
#include <someincludefile.h></someincludefile.h>
darco 56a656
#endif
darco 56a656
darco 56a656
typedef size_t my_size_t;	/* The payoff: do we have size_t now? */
darco 56a656
darco 56a656
darco 56a656
/* The next question is whether your compiler supports ANSI-style function
darco 56a656
 * prototypes.  You need to know this in order to choose between using
darco 56a656
 * makefile.ansi and using makefile.unix.
darco 56a656
 * The #define line below is set to assume you have ANSI function prototypes.
darco 56a656
 * If you get an error in this group of lines, undefine HAVE_PROTOTYPES.
darco 56a656
 */
darco 56a656
darco 56a656
#define HAVE_PROTOTYPES
darco 56a656
darco 56a656
#ifdef HAVE_PROTOTYPES
darco 56a656
int testfunction (int arg1, int * arg2); /* check prototypes */
darco 56a656
darco 56a656
struct methods_struct {		/* check method-pointer declarations */
darco 56a656
  int (*error_exit) (char *msgtext);
darco 56a656
  int (*trace_message) (char *msgtext);
darco 56a656
  int (*another_method) (void);
darco 56a656
};
darco 56a656
darco 56a656
int testfunction (int arg1, int * arg2) /* check definitions */
darco 56a656
{
darco 56a656
  return arg2[arg1];
darco 56a656
}
darco 56a656
darco 56a656
int test2function (void)	/* check void arg list */
darco 56a656
{
darco 56a656
  return 0;
darco 56a656
}
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
/* Now we want to find out if your compiler knows what "unsigned char" means.
darco 56a656
 * If you get an error on the "unsigned char un_char;" line,
darco 56a656
 * then undefine HAVE_UNSIGNED_CHAR.
darco 56a656
 */
darco 56a656
darco 56a656
#define HAVE_UNSIGNED_CHAR
darco 56a656
darco 56a656
#ifdef HAVE_UNSIGNED_CHAR
darco 56a656
unsigned char un_char;
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
/* Now we want to find out if your compiler knows what "unsigned short" means.
darco 56a656
 * If you get an error on the "unsigned short un_short;" line,
darco 56a656
 * then undefine HAVE_UNSIGNED_SHORT.
darco 56a656
 */
darco 56a656
darco 56a656
#define HAVE_UNSIGNED_SHORT
darco 56a656
darco 56a656
#ifdef HAVE_UNSIGNED_SHORT
darco 56a656
unsigned short un_short;
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
/* Now we want to find out if your compiler understands type "void".
darco 56a656
 * If you get an error anywhere in here, undefine HAVE_VOID.
darco 56a656
 */
darco 56a656
darco 56a656
#define HAVE_VOID
darco 56a656
darco 56a656
#ifdef HAVE_VOID
darco 56a656
/* Caution: a C++ compiler will insist on complete prototypes */
darco 56a656
typedef void * void_ptr;	/* check void * */
darco 56a656
#ifdef HAVE_PROTOTYPES		/* check ptr to function returning void */
darco 56a656
typedef void (*void_func) (int a, int b);
darco 56a656
#else
darco 56a656
typedef void (*void_func) ();
darco 56a656
#endif
darco 56a656
darco 56a656
#ifdef HAVE_PROTOTYPES		/* check void function result */
darco 56a656
void test3function (void_ptr arg1, void_func arg2)
darco 56a656
#else
darco 56a656
void test3function (arg1, arg2)
darco 56a656
     void_ptr arg1;
darco 56a656
     void_func arg2;
darco 56a656
#endif
darco 56a656
{
darco 56a656
  char * locptr = (char *) arg1; /* check casting to and from void * */
darco 56a656
  arg1 = (void *) locptr;
darco 56a656
  (*arg2) (1, 2);		/* check call of fcn returning void */
darco 56a656
}
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
/* Now we want to find out if your compiler knows what "const" means.
darco 56a656
 * If you get an error here, undefine HAVE_CONST.
darco 56a656
 */
darco 56a656
darco 56a656
#define HAVE_CONST
darco 56a656
darco 56a656
#ifdef HAVE_CONST
darco 56a656
static const int carray[3] = {1, 2, 3};
darco 56a656
darco 56a656
#ifdef HAVE_PROTOTYPES
darco 56a656
int test4function (const int arg1)
darco 56a656
#else
darco 56a656
int test4function (arg1)
darco 56a656
     const int arg1;
darco 56a656
#endif
darco 56a656
{
darco 56a656
  return carray[arg1];
darco 56a656
}
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
/* If you get an error or warning about this structure definition,
darco 56a656
 * define INCOMPLETE_TYPES_BROKEN.
darco 56a656
 */
darco 56a656
darco 56a656
#undef INCOMPLETE_TYPES_BROKEN
darco 56a656
darco 56a656
#ifndef INCOMPLETE_TYPES_BROKEN
darco 56a656
typedef struct undefined_structure * undef_struct_ptr;
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
/* If you get an error about duplicate names,
darco 56a656
 * define NEED_SHORT_EXTERNAL_NAMES.
darco 56a656
 */
darco 56a656
darco 56a656
#undef NEED_SHORT_EXTERNAL_NAMES
darco 56a656
darco 56a656
#ifndef NEED_SHORT_EXTERNAL_NAMES
darco 56a656
darco 56a656
int possibly_duplicate_function ()
darco 56a656
{
darco 56a656
  return 0;
darco 56a656
}
darco 56a656
darco 56a656
int possibly_dupli_function ()
darco 56a656
{
darco 56a656
  return 1;
darco 56a656
}
darco 56a656
darco 56a656
#endif
darco 56a656
darco 56a656
darco 56a656
darco 56a656
/************************************************************************
darco 56a656
 *  OK, that's it.  You should not have to change anything beyond this
darco 56a656
 *  point in order to compile and execute this program.  (You might get
darco 56a656
 *  some warnings, but you can ignore them.)
darco 56a656
 *  When you run the program, it will make a couple more tests that it
darco 56a656
 *  can do automatically, and then it will create jconfig.h and print out
darco 56a656
 *  any additional suggestions it has.
darco 56a656
 ************************************************************************
darco 56a656
 */
darco 56a656
darco 56a656
darco 56a656
#ifdef HAVE_PROTOTYPES
darco 56a656
int is_char_signed (int arg)
darco 56a656
#else
darco 56a656
int is_char_signed (arg)
darco 56a656
     int arg;
darco 56a656
#endif
darco 56a656
{
darco 56a656
  if (arg == 189) {		/* expected result for unsigned char */
darco 56a656
    return 0;			/* type char is unsigned */
darco 56a656
  }
darco 56a656
  else if (arg != -67) {	/* expected result for signed char */
darco 56a656
    printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
darco 56a656
    printf("I fear the JPEG software will not work at all.\n\n");
darco 56a656
  }
darco 56a656
  return 1;			/* assume char is signed otherwise */
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
#ifdef HAVE_PROTOTYPES
darco 56a656
int is_shifting_signed (long arg)
darco 56a656
#else
darco 56a656
int is_shifting_signed (arg)
darco 56a656
     long arg;
darco 56a656
#endif
darco 56a656
/* See whether right-shift on a long is signed or not. */
darco 56a656
{
darco 56a656
  long res = arg >> 4;
darco 56a656
darco 56a656
  if (res == -0x7F7E80CL) {	/* expected result for signed shift */
darco 56a656
    return 1;			/* right shift is signed */
darco 56a656
  }
darco 56a656
  /* see if unsigned-shift hack will fix it. */
darco 56a656
  /* we can't just test exact value since it depends on width of long... */
darco 56a656
  res |= (~0L) << (32-4);
darco 56a656
  if (res == -0x7F7E80CL) {	/* expected result now? */
darco 56a656
    return 0;			/* right shift is unsigned */
darco 56a656
  }
darco 56a656
  printf("Right shift isn't acting as I expect it to.\n");
darco 56a656
  printf("I fear the JPEG software will not work at all.\n\n");
darco 56a656
  return 0;			/* try it with unsigned anyway */
darco 56a656
}
darco 56a656
darco 56a656
darco 56a656
#ifdef HAVE_PROTOTYPES
darco 56a656
int main (int argc, char ** argv)
darco 56a656
#else
darco 56a656
int main (argc, argv)
darco 56a656
     int argc;
darco 56a656
     char ** argv;
darco 56a656
#endif
darco 56a656
{
darco 56a656
  char signed_char_check = (char) (-67);
darco 56a656
  FILE *outfile;
darco 56a656
darco 56a656
  /* Attempt to write jconfig.h */
darco 56a656
  if ((outfile = fopen("jconfig.h", "w")) == NULL) {
darco 56a656
    printf("Failed to write jconfig.h\n");
darco 56a656
    return 1;
darco 56a656
  }
darco 56a656
darco 56a656
  /* Write out all the info */
darco 56a656
  fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n");
darco 56a656
  fprintf(outfile, "/* see jconfig.doc for explanations */\n\n");
darco 56a656
#ifdef HAVE_PROTOTYPES
darco 56a656
  fprintf(outfile, "#define HAVE_PROTOTYPES\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef HAVE_PROTOTYPES\n");
darco 56a656
#endif
darco 56a656
#ifdef HAVE_UNSIGNED_CHAR
darco 56a656
  fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n");
darco 56a656
#endif
darco 56a656
#ifdef HAVE_UNSIGNED_SHORT
darco 56a656
  fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n");
darco 56a656
#endif
darco 56a656
#ifdef HAVE_VOID
darco 56a656
  fprintf(outfile, "/* #define void char */\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#define void char\n");
darco 56a656
#endif
darco 56a656
#ifdef HAVE_CONST
darco 56a656
  fprintf(outfile, "/* #define const */\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#define const\n");
darco 56a656
#endif
darco 56a656
  if (is_char_signed((int) signed_char_check))
darco 56a656
    fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n");
darco 56a656
  else
darco 56a656
    fprintf(outfile, "#define CHAR_IS_UNSIGNED\n");
darco 56a656
#ifdef HAVE_STDDEF_H
darco 56a656
  fprintf(outfile, "#define HAVE_STDDEF_H\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef HAVE_STDDEF_H\n");
darco 56a656
#endif
darco 56a656
#ifdef HAVE_STDLIB_H
darco 56a656
  fprintf(outfile, "#define HAVE_STDLIB_H\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef HAVE_STDLIB_H\n");
darco 56a656
#endif
darco 56a656
#ifdef NEED_BSD_STRINGS
darco 56a656
  fprintf(outfile, "#define NEED_BSD_STRINGS\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef NEED_BSD_STRINGS\n");
darco 56a656
#endif
darco 56a656
#ifdef NEED_SYS_TYPES_H
darco 56a656
  fprintf(outfile, "#define NEED_SYS_TYPES_H\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef NEED_SYS_TYPES_H\n");
darco 56a656
#endif
darco 56a656
  fprintf(outfile, "#undef NEED_FAR_POINTERS\n");
darco 56a656
#ifdef NEED_SHORT_EXTERNAL_NAMES
darco 56a656
  fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n");
darco 56a656
#endif
darco 56a656
#ifdef INCOMPLETE_TYPES_BROKEN
darco 56a656
  fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n");
darco 56a656
#else
darco 56a656
  fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n");
darco 56a656
#endif
darco 56a656
  fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n");
darco 56a656
  if (is_shifting_signed(-0x7F7E80B1L))
darco 56a656
    fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n");
darco 56a656
  else
darco 56a656
    fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n");
darco 56a656
  fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n");
darco 56a656
  fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n");
darco 56a656
  fprintf(outfile, "#define BMP_SUPPORTED		/* BMP image file format */\n");
darco 56a656
  fprintf(outfile, "#define GIF_SUPPORTED		/* GIF image file format */\n");
darco 56a656
  fprintf(outfile, "#define PPM_SUPPORTED		/* PBMPLUS PPM/PGM image file format */\n");
darco 56a656
  fprintf(outfile, "#undef RLE_SUPPORTED		/* Utah RLE image file format */\n");
darco 56a656
  fprintf(outfile, "#define TARGA_SUPPORTED		/* Targa image file format */\n\n");
darco 56a656
  fprintf(outfile, "#undef TWO_FILE_COMMANDLINE	/* You may need this on non-Unix systems */\n");
darco 56a656
  fprintf(outfile, "#undef NEED_SIGNAL_CATCHER	/* Define this if you use jmemname.c */\n");
darco 56a656
  fprintf(outfile, "#undef DONT_USE_B_MODE\n");
darco 56a656
  fprintf(outfile, "/* #define PROGRESS_REPORT */	/* optional */\n");
darco 56a656
  fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n");
darco 56a656
darco 56a656
  /* Close the jconfig.h file */
darco 56a656
  fclose(outfile);
darco 56a656
darco 56a656
  /* User report */
darco 56a656
  printf("Configuration check for Independent JPEG Group's software done.\n");
darco 56a656
  printf("\nI have written the jconfig.h file for you.\n\n");
darco 56a656
#ifdef HAVE_PROTOTYPES
darco 56a656
  printf("You should use makefile.ansi as the starting point for your Makefile.\n");
darco 56a656
#else
darco 56a656
  printf("You should use makefile.unix as the starting point for your Makefile.\n");
darco 56a656
#endif
darco 56a656
darco 56a656
#ifdef NEED_SPECIAL_INCLUDE
darco 56a656
  printf("\nYou'll need to change jconfig.h to include the system include file\n");
darco 56a656
  printf("that you found type size_t in, or add a direct definition of type\n");
darco 56a656
  printf("size_t if that's what you used.  Just add it to the end.\n");
darco 56a656
#endif
darco 56a656
darco 56a656
  return 0;
darco 56a656
}