Krolyxon
Commit b96c106

Branches

Refs →

nsxivb96c106

Overhauled building

- config.h -> config.def.h
- Create config.h during make, if it does not exist
- Nice make output
- Use XFLAGS and XLIBS to include additional compile-time features,
  which depend on third-party libraries
Author
Bert
Date
2011-09-08 15:41 +0200
Parent
8f34b7e
Commit
b96c10633782d697a4f5573099b0762630b45347

+59 −24

5 files changed

  1. M .gitignore +2 −1
  2. M Makefile +52 −18
  3. M Makefile.netbsd +1 −1
  4. R config.h → config.def.h +0 −0
  5. M image.c +4 −4
M .gitignore View
@@ -1,5 +1,6 @@
1+config.h
12 *.o
23 sxiv
34 cscope.out
4−release
55 tags
6+release
M Makefile View
@@ -1,30 +1,64 @@
1−all: sxiv
1+VERSION = git-20110908
22
3−VERSION = git-20110906
4−
5−CC = gcc
6−DESTDIR =
7−PREFIX = /usr/local
8−CFLAGS = -Wall -pedantic -O2 -DVERSION=\"$(VERSION)\" -DHAVE_GIFLIB
3+CC = gcc
4+CFLAGS = -Wall -pedantic -O2
95 LDFLAGS =
10−LIBS = -lX11 -lImlib2 -lgif
6+LIBS = -lX11 -lImlib2
7+
8+PREFIX = /usr/local
9+MANPREFIX = $(PREFIX)/share/man
1110
1211 SRC = commands.c image.c main.c options.c thumbs.c util.c window.c
1312 OBJ = $(SRC:.c=.o)
1413
15−sxiv: $(OBJ)
16− $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
14+all: options sxiv
1715
18−$(OBJ): Makefile config.h
16+options:
17+ @echo "sxiv build options:"
18+ @echo "CC = $(CC)"
19+ @echo "CFLAGS = $(CFLAGS)"
20+ @echo "XFLAGS = $(XFLAGS)"
21+ @echo "LDFLAGS = $(LDFLAGS)"
22+ @echo "XLIBS = $(XLIBS)"
23+ @echo "PREFIX = $(PREFIX)"
1924
2025 .c.o:
21− $(CC) $(CFLAGS) -c -o $@ $<
26+ @echo "CC $<"
27+ @$(CC) $(CFLAGS) $(XFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
2228
23−install: all
24− install -D -m 755 -o root -g root sxiv $(DESTDIR)$(PREFIX)/bin/sxiv
25− mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1
26− sed "s/VERSION/$(VERSION)/g" sxiv.1 > $(DESTDIR)$(PREFIX)/share/man/man1/sxiv.1
27− chmod 644 $(DESTDIR)$(PREFIX)/share/man/man1/sxiv.1
29+$(OBJ): Makefile config.h
30+
31+config.h:
32+ @echo "creating $@ from config.def.h"
33+ @cp config.def.h $@
34+
35+sxiv: $(OBJ)
36+ @echo "CC -o $@"
37+ @$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $(XLIBS)
2838
2939 clean:
30− rm -f $(OBJ) sxiv
40+ @echo "cleaning"
41+ @rm -f $(OBJ) sxiv sxiv-$(VERSION).tar.gz
42+
43+dist: clean
44+ @echo "creating dist tarball"
45+ @mkdir -p sxiv-$(VERSION)
46+ @cp LICENSE Makefile Makefile.netbsd README.md config.def.h \
47+ sxiv.1 $(SRC) sxiv-$(VERSION)
48+ @tar -cf sxiv-$(VERSION).tar sxiv-$(VERSION)
49+ @gzip sxiv-$(VERSION).tar
50+ @rm -rf sxiv-$(VERSION)
51+
52+install: all
53+ @echo "installing executable file to $(DESTDIR)$(PREFIX)/bin"
54+ @install -D -m 755 sxiv $(DESTDIR)$(PREFIX)/bin/sxiv
55+ @echo "installing manual page to $(DESTDIR)$(MANPREFIX)/man1"
56+ @mkdir -p $(DESTDIR)$(MANPREFIX)/man1
57+ @sed "s/VERSION/$(VERSION)/g" sxiv.1 > $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
58+ @chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
59+
60+uninstall:
61+ @echo "removing executable file from $(DESTDIR)$(PREFIX)/bin"
62+ @rm -f $(DESTDIR)$(PREFIX)/bin/sxiv
63+ @echo "removing manual page from $(DESTDIR)$(MANPREFIX)/man1"
64+ @rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
M Makefile.netbsd View
@@ -1,4 +1,4 @@
11 .include "Makefile"
22
3−CFLAGS = -Wall -pedantic -O2 -DVERSION=\"$(VERSION)\" -DHAVE_GIFLIB -I/usr/X11R7/include -I/usr/pkg/include
3+CFLAGS = -Wall -pedantic -O2 -I/usr/X11R7/include -I/usr/pkg/include
44 LDFLAGS = -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib
R config.h → config.def.h View

[No content changes]

M image.c View
@@ -18,7 +18,7 @@
1818
1919 #include <unistd.h>
2020
21−#ifdef HAVE_GIFLIB
21+#ifdef GIF_SUPPORT
2222 #include <stdlib.h>
2323 #include <string.h>
2424 #include <sys/types.h>
@@ -59,7 +59,7 @@ void img_init(img_t *img, win_t *win) {
5959 }
6060 }
6161
62−#ifdef HAVE_GIFLIB
62+#ifdef GIF_SUPPORT
6363 /* Originally based on, but in its current form merely inspired by Imlib2's
6464 * src/modules/loaders/loader_gif.c:load(), written by Carsten Haitzler.
6565 */
@@ -223,7 +223,7 @@ int img_load_gif(img_t *img, const fileinfo_t *file) {
223223
224224 return !err;
225225 }
226−#endif /* HAVE_GIFLIB */
226+#endif /* GIF_SUPPORT */
227227
228228 int img_load(img_t *img, const fileinfo_t *file) {
229229 const char *fmt;
@@ -241,7 +241,7 @@ int img_load(img_t *img, const fileinfo_t *file) {
241241 imlib_context_set_anti_alias(img->aa);
242242
243243 fmt = imlib_image_format();
244−#ifdef HAVE_GIFLIB
244+#ifdef GIF_SUPPORT
245245 if (!strcmp(fmt, "gif"))
246246 img_load_gif(img, file);
247247 #else