move (redundant) ifdef checks from source to build files

We've been tracking program deps in the build files, so it ends up
being redundant for a lot of our test/example programs.  Clean them
up, and update some of the cmake/automake files as needed.
master
Mike Frysinger 2018-06-21 23:55:11 -04:00
parent fd06f7f83c
commit 08b0dbaec6
19 changed files with 17 additions and 116 deletions

View File

@ -1,15 +1,22 @@
include_directories (BEFORE "${GD_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}")
SET(TESTS_FILES
arc
crop
gif
nnquant
tgaread
gif
)
if (PNG_FOUND)
LIST(APPEND TEST_FILES arc crop tgaread)
if (JPEG_FOUND)
LIST(APPEND TESTS_FILES copyrotated flip nnquantnnquant)
if (UNIX)
target_link_libraries(copyrotated m)
endif (UNIX)
endif (JPEG_FOUND)
endif (PNG_FOUND)
if (JPEG_FOUND)
LIST(APPEND TESTS_FILES copyrotated flip)
LIST(APPEND TESTS_FILES resize)
endif (JPEG_FOUND)
if (TIFF_FOUND)
@ -27,12 +34,6 @@ FOREACH(test_name ${TESTS_FILES})
target_link_libraries (${test_name} ${GD_LINK_LIB})
ENDFOREACH(test_name)
if(JPEG_FOUND)
if(UNIX)
target_link_libraries(copyrotated m)
endif(UNIX)
endif(JPEG_FOUND)
if (WIN32 AND NOT MINGW AND NOT MSYS)
add_executable(windows WIN32 "windows.c")
target_link_libraries (windows ${GD_LINK_LIB})

View File

@ -19,11 +19,7 @@ int main()
gdImageDestroy(im);
return 1;
}
#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
#else
printf("No PNG support. Cannot save image.\n");
#endif
fclose(fp);
gdImageDestroy(im);

View File

@ -12,11 +12,7 @@ void save_png(gdImagePtr im, const char *filename)
fprintf(stderr, "Can't save png image %s\n", filename);
return;
}
#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
#else
printf("No PNG support. Cannot save image.\n");
#endif
fclose(fp);
}
@ -30,12 +26,7 @@ gdImagePtr read_png(const char *filename)
fprintf(stderr, "Can't read png image %s\n", filename);
return NULL;
}
#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng(fp);
#else
im = NULL;
printf("No PNG support. Cannot read image.\n");
#endif
fclose(fp);
return im;
}

View File

@ -12,17 +12,12 @@ void save_png(gdImagePtr im, const char *filename)
fprintf(stderr, "Can't save png image %s\n", filename);
return;
}
#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
#else
printf("No PNG support. Cannot save image.\n");
#endif
fclose(fp);
}
int main()
{
#ifdef HAVE_JPEG
gdImagePtr im, im2;
FILE *fp;
char path[2048];
@ -56,9 +51,5 @@ int main()
save_png(im, "a_jquant_dither.png");
gdImageDestroy(im);
#else
printf("JPEG support is required for this example. Please recompile GD with JPEG or change this example to use another format as input.");
return 1;
#endif
return 0;
}

View File

@ -44,11 +44,7 @@ int main()
gdImageDestroy(im);
return 1;
}
#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
#else
printf("No PNG support. Cannot save image.\n");
#endif
gdImagePng(im, fp);
fclose(fp);
gdImageDestroy(im);
}

View File

@ -146,7 +146,7 @@ if (PNG_FOUND)
endif()
endif()
if (FREETYPE_FOUND)
if (FREETYPE_FOUND AND JPEG_FOUND)
set(GD_PROGRAMS ${GD_PROGRAMS} annotate)
endif()

View File

@ -23,7 +23,9 @@ check_PROGRAMS += fontconfigtest
endif
if HAVE_LIBFREETYPE
if HAVE_LIBJPEG
bin_PROGRAMS += annotate
endif
check_PROGRAMS += gdtestft testtr
endif

View File

@ -16,17 +16,6 @@ enum { left, center, right };
int main(int argc, char *argv[])
{
#ifndef HAVE_LIBFREETYPE
(void)argc;
(void)argv;
/* 2.0.12 */
fprintf(stderr, "annotate is not useful without freetype.\n"
"Install freetype, then './configure; make clean; make install'\n"
"the gd library again.\n"
);
return 1;
#else
gdImagePtr im;
char *iin, *iout;
FILE *in, *out;
@ -70,12 +59,7 @@ int main(int argc, char *argv[])
exit(2);
}
#ifdef HAVE_LIBJPEG
im = gdImageCreateFromJpeg(in);
#else
fprintf(stderr, "No JPEG library support available.\n");
exit(1);
#endif
fclose(in);
@ -200,13 +184,8 @@ badLine:
fprintf(stderr, "Cannot create %s\n", iout);
exit(5);
}
#ifdef HAVE_LIBJPEG
gdImageJpeg(im, out, 95);
#else
fprintf(stderr, "No JPEG library support available.\n");
#endif
gdImageDestroy(im);
fclose(out);
return 0;
#endif /* HAVE_LIBFREETYPE */
}

View File

@ -8,10 +8,6 @@
int main(void)
{
/* 2.0.22: can't depend on PNG either */
#ifndef HAVE_LIBPNG
fprintf(stderr, "Requires PNG support, gd was compiled without it\n");
return 0;
#else
char *error;
#ifdef HAVE_LIBJPEG
FILE *in = 0;
@ -64,6 +60,5 @@ int main(void)
gdImagePng(im, out);
fclose(out);
gdImageDestroy(im);
#endif /* HAVE_LIBPNG */
return 0;
}

View File

@ -52,11 +52,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
#ifdef HAVE_LIBPNG
gdImagePng (im, out);
#else
fprintf(stderr, "No PNG library support available.\n");
#endif
fclose (out);
gdImageDestroy (im);

View File

@ -16,7 +16,6 @@
int
main (void)
{
#ifdef HAVE_LIBPNG
/* Input and output files */
FILE *in;
FILE *out;
@ -181,8 +180,5 @@ main (void)
if (im_in) {
gdImageDestroy (im_in);
}
#else
fprintf(stderr, "No PNG library support.\n");
#endif /* HAVE_LIBPNG */
return 0;
}

View File

@ -49,11 +49,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
#ifdef HAVE_LIBPNG
gdImagePng (im, out);
#else
fprintf(stderr, "No PNG library support.\n");
#endif
fclose (out);
gdImageDestroy (im);

View File

@ -24,7 +24,6 @@ static int fwriteWrapper (void *context, const char *buffer, int len);
int
main (int argc, char **argv)
{
#ifdef HAVE_LIBPNG
gdImagePtr im, ref, im2, im3;
FILE *in, *out;
void *iptr;
@ -409,9 +408,6 @@ main (int argc, char **argv)
}
gdImageDestroy (im);
gdImageDestroy (ref);
#else
fprintf(stderr, "No PNG library support.\n");
#endif /* HAVE_LIBPNG */
return 0;
}

View File

@ -26,13 +26,6 @@
int
main (int argc, char *argv[])
{
#ifndef HAVE_LIBFREETYPE
fprintf(stderr, "gd was not compiled with HAVE_LIBFREETYPE defined.\n");
fprintf(stderr, "Install the FreeType library, including the\n");
fprintf(stderr, "header files. Then edit the gd Makefile, type\n");
fprintf(stderr, "make clean, and type make again.\n");
return 1;
#else
gdImagePtr im;
int blue;
int blueAlpha;
@ -186,5 +179,4 @@ main (int argc, char *argv[])
gdImageDestroy (im);
return 0;
#endif /* HAVE_LIBFREETYPE */
}

View File

@ -38,11 +38,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
#ifdef HAVE_LIBPNG
gdImagePng (im, out);
#else
fprintf(stderr, "No PNG library support.\n");
#endif
fclose (out);
gdImageDestroy (im);

View File

@ -25,11 +25,7 @@ main (int argc, char **argv)
fprintf (stderr, "Input file does not exist!\n");
exit (1);
}
#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng (in);
#else
fprintf (stderr, "No PNG library support available.\n");
#endif
fclose (in);
if (!im) {
fprintf (stderr, "Input is not in PNG format!\n");

View File

@ -30,12 +30,7 @@ main (int argc, char **argv)
fprintf(stderr, "Input file does not exist!\n");
exit (1);
}
#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng (in);
#else
im = NULL;
fprintf(stderr, "No PNG library support available.\n");
#endif
fclose (in);
if (!im) {
fprintf(stderr, "Input is not in PNG format!\n");

View File

@ -17,7 +17,6 @@ void testDrawing (gdImagePtr im_in,
int
main (int argc, char *argv[])
{
#ifdef HAVE_LIBPNG
/* Input and output files */
FILE *in;
@ -55,9 +54,6 @@ main (int argc, char *argv[])
testDrawing (im_in, 2.0, 0, 1, "noblending-doublesize-palette.png");
testDrawing (im_in, 2.0, 1, 1, "blending-doublesize-palette.png");
gdImageDestroy (im_in);
#else
fprintf (stderr, "No PNG library support.\n");
#endif
return 0;
}
@ -116,11 +112,7 @@ testDrawing (gdImagePtr im_in,
gdImageTrueColorToPalette (im_out, 1, 256);
}
#ifdef HAVE_LIBPNG
gdImagePng (im_out, out);
#else
fprintf (stderr, "No PNG library support.\n");
#endif
fclose (out);
gdImageDestroy (im_out);

View File

@ -11,7 +11,6 @@
int
main(void)
{
#ifdef HAVE_LIBFREETYPE
int transparent, green, black;
gdImagePtr im;
@ -47,8 +46,4 @@ main(void)
gdImageDestroy (im);
return 0;
#else
fprintf(stderr, "Compiled without freetype support\n");
return 0;
#endif /* HAVE_LIBFREETYPE */
}