summaryrefslogtreecommitdiffstats
path: root/config.c
blob: c7e1df0c42cd4ffb2ef5c6475ccf486669edbcc4 (plain) (blame)
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
#define _POSIX_C_SOURCE 200112L
#define _FEATURE_CONFIG

#include <stdio.h>

#include "config.h"

#define QUOTE(m) #m
#define PUT_MACRO(m) \
	printf(" -D%s=%s", #m, QUOTE(m))

int puts_if(const char *s, int c) {
	return c ? printf(" %s", s) : 0;
}

int main(int argc, char **argv) {
	int i;
	unsigned int n = 0;

	for (i = 1; i < argc; i++) {
		switch ((argv[i][0] != '-' || argv[i][2] != '\0') ? -1 : argv[i][1]) {
			case 'D':
				n += PUT_MACRO(EXIF_SUPPORT);
				n += PUT_MACRO(GIF_SUPPORT);
				break;
			case 'l':
				n += puts_if("-lexif", EXIF_SUPPORT);
				n += puts_if("-lgif",  GIF_SUPPORT);
				break;
			default:
				fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
				return 1;
		}
	}
	if (n > 0)
		printf("\n");
	return 0;
}