Simplified config.c
This commit is contained in:
parent
515e410451
commit
8e1d8a97d3
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
VERSION = git-20110917
|
VERSION = git-20110923
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -pedantic -O2
|
CFLAGS = -Wall -pedantic -O2
|
||||||
|
|
44
config.c
44
config.c
|
@ -2,44 +2,36 @@
|
||||||
#define _FEATURE_CONFIG
|
#define _FEATURE_CONFIG
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define QUOTE(m) #m
|
#define QUOTE(m) #m
|
||||||
#define PUT_MACRO(m) \
|
#define PUT_MACRO(m) \
|
||||||
printf("%s-D%s=%s", n++ ? " " : "", #m, QUOTE(m))
|
printf(" -D%s=%s", #m, QUOTE(m))
|
||||||
|
|
||||||
int n = 0;
|
inline int puts_if(const char *s, int c) {
|
||||||
|
return c ? printf(" %s", s) : 0;
|
||||||
inline void puts_if(const char *s, int c) {
|
|
||||||
if (c)
|
|
||||||
printf("%s%s", n++ ? " " : "", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void endl() {
|
|
||||||
if (n) {
|
|
||||||
printf("\n");
|
|
||||||
n = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
int i;
|
int i, n = 0;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "-D")) {
|
switch (argv[i][0] != '-' || argv[i][2] ? -1 : argv[i][1]) {
|
||||||
PUT_MACRO(EXIF_SUPPORT);
|
case 'D':
|
||||||
PUT_MACRO(GIF_SUPPORT);
|
n += PUT_MACRO(EXIF_SUPPORT);
|
||||||
endl();
|
n += PUT_MACRO(GIF_SUPPORT);
|
||||||
} else if (!strcmp(argv[i], "-l")) {
|
break;
|
||||||
puts_if("-lexif", EXIF_SUPPORT);
|
case 'l':
|
||||||
puts_if("-lgif", GIF_SUPPORT);
|
n += puts_if("-lexif", EXIF_SUPPORT);
|
||||||
endl();
|
n += puts_if("-lgif", GIF_SUPPORT);
|
||||||
} else {
|
break;
|
||||||
fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
|
default:
|
||||||
return 1;
|
fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (n)
|
||||||
|
printf("\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue