Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Renamed XLIBS to config, added -D/-l options
Browse files Browse the repository at this point in the history
  • Loading branch information
Bert committed Sep 13, 2011
1 parent 255dd5b commit 81cfbf1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,4 +1,4 @@
XLIBS
config
config.h
*.o
sxiv
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Expand Up @@ -24,27 +24,27 @@ options:
@echo "CC $<"
@$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<

$(OBJ) XLIBS: Makefile config.h
$(OBJ) config: Makefile config.h

XLIBS: XLIBS.c
config: config.c
@$(CC) $(CFLAGS) -o $@ $@.c

config.h:
@echo "creating $@ from config.def.h"
@cp config.def.h $@

sxiv: $(OBJ) XLIBS
sxiv: $(OBJ) config
@echo "CC -o $@"
@$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $$(./XLIBS)
@$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $$(./config -l)

clean:
@echo "cleaning"
@rm -f $(OBJ) XLIBS sxiv sxiv-$(VERSION).tar.gz
@rm -f $(OBJ) config sxiv sxiv-$(VERSION).tar.gz

dist: clean
@echo "creating dist tarball"
@mkdir -p sxiv-$(VERSION)
@cp LICENSE Makefile README.md config.def.h sxiv.1 $(SRC) XLIBS.c \
@cp LICENSE Makefile README.md config.def.h sxiv.1 $(SRC) config.c \
sxiv-$(VERSION)
@tar -cf sxiv-$(VERSION).tar sxiv-$(VERSION)
@gzip sxiv-$(VERSION).tar
Expand Down
23 changes: 0 additions & 23 deletions XLIBS.c

This file was deleted.

45 changes: 45 additions & 0 deletions config.c
@@ -0,0 +1,45 @@
#define _POSIX_C_SOURCE 200112L
#define _FEATURE_CONFIG

#include <stdio.h>
#include <string.h>

#include "config.h"

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

int n = 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 i;

for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-D")) {
PUT_MACRO(EXIF_SUPPORT);
PUT_MACRO(GIF_SUPPORT);
endl();
} else if (!strcmp(argv[i], "-l")) {
puts_if("-lexif", EXIF_SUPPORT);
puts_if("-lgif", GIF_SUPPORT);
endl();
} else {
fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
return 1;
}
}
return 0;
}

0 comments on commit 81cfbf1

Please sign in to comment.