Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Renamed XLIBS to config, added -D/-l options

  • Loading branch information...
commit 81cfbf171dfd11c6f8a4d277159ee077b5ca0255 1 parent 255dd5b
Bert Münnich authored September 13, 2011
2  .gitignore
... ...
@@ -1,4 +1,4 @@
1  
-XLIBS
  1
+config
2 2
 config.h
3 3
 *.o
4 4
 sxiv
12  Makefile
@@ -24,27 +24,27 @@ options:
24 24
 	@echo "CC $<"
25 25
 	@$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
26 26
 
27  
-$(OBJ) XLIBS: Makefile config.h
  27
+$(OBJ) config: Makefile config.h
28 28
 
29  
-XLIBS: XLIBS.c
  29
+config: config.c
30 30
 	@$(CC) $(CFLAGS) -o $@ $@.c
31 31
 
32 32
 config.h:
33 33
 	@echo "creating $@ from config.def.h"
34 34
 	@cp config.def.h $@
35 35
 
36  
-sxiv:	$(OBJ) XLIBS
  36
+sxiv:	$(OBJ) config
37 37
 	@echo "CC -o $@"
38  
-	@$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $$(./XLIBS)
  38
+	@$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $$(./config -l)
39 39
 
40 40
 clean:
41 41
 	@echo "cleaning"
42  
-	@rm -f $(OBJ) XLIBS sxiv sxiv-$(VERSION).tar.gz
  42
+	@rm -f $(OBJ) config sxiv sxiv-$(VERSION).tar.gz
43 43
 
44 44
 dist: clean
45 45
 	@echo "creating dist tarball"
46 46
 	@mkdir -p sxiv-$(VERSION)
47  
-	@cp LICENSE Makefile README.md config.def.h sxiv.1 $(SRC) XLIBS.c \
  47
+	@cp LICENSE Makefile README.md config.def.h sxiv.1 $(SRC) config.c \
48 48
 	    sxiv-$(VERSION)
49 49
 	@tar -cf sxiv-$(VERSION).tar sxiv-$(VERSION)
50 50
 	@gzip sxiv-$(VERSION).tar
23  XLIBS.c
... ...
@@ -1,23 +0,0 @@
1  
-#define _POSIX_C_SOURCE 200112L
2  
-#define _FEATURE_CONFIG
3  
-
4  
-#include <stdio.h>
5  
-
6  
-#include "config.h"
7  
-
8  
-int n = 0;
9  
-
10  
-inline void put_lib_flag(const char *flag, int needed) {
11  
-	if (needed)
12  
-		printf("%s%s", n++ ? " " : "", flag);
13  
-}
14  
-
15  
-int main(int argc, char **argv) {
16  
-	put_lib_flag("-lexif", EXIF_SUPPORT);
17  
-	put_lib_flag("-lgif",  GIF_SUPPORT);
18  
-
19  
-	if (n)
20  
-		printf("\n");
21  
-
22  
-	return 0;
23  
-}
45  config.c
... ...
@@ -0,0 +1,45 @@
  1
+#define _POSIX_C_SOURCE 200112L
  2
+#define _FEATURE_CONFIG
  3
+
  4
+#include <stdio.h>
  5
+#include <string.h>
  6
+
  7
+#include "config.h"
  8
+
  9
+#define QUOTE(m) #m
  10
+#define PUT_MACRO(m) \
  11
+	printf("%s-D%s=%s", n++ ? " " : "", #m, QUOTE(m))
  12
+
  13
+int n = 0;
  14
+
  15
+inline void puts_if(const char *s, int c) {
  16
+	if (c)
  17
+		printf("%s%s", n++ ? " " : "", s);
  18
+}
  19
+
  20
+inline void endl() {
  21
+	if (n) {
  22
+		printf("\n");
  23
+		n = 0;
  24
+	}
  25
+}
  26
+
  27
+int main(int argc, char **argv) {
  28
+	int i;
  29
+
  30
+	for (i = 1; i < argc; i++) {
  31
+		if (!strcmp(argv[i], "-D")) {
  32
+			PUT_MACRO(EXIF_SUPPORT);
  33
+			PUT_MACRO(GIF_SUPPORT);
  34
+			endl();
  35
+		} else if (!strcmp(argv[i], "-l")) {
  36
+			puts_if("-lexif", EXIF_SUPPORT);
  37
+			puts_if("-lgif",  GIF_SUPPORT);
  38
+			endl();
  39
+		} else {
  40
+			fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
  41
+			return 1;
  42
+		}
  43
+	}
  44
+	return 0;
  45
+}

0 notes on commit 81cfbf1

Please sign in to comment.
Something went wrong with that request. Please try again.