Krolyxon
Commit f55d9f4

Branches

Refs →

nsxivf55d9f4

Use and depend on GNU make...

- Use non-POSIX :=,?=,+= macro assignments, fixes issue #97
- No optimization level set in CFLAGS, expected to be set in environment
- Automatic header dependency tracking with one .d file per compilation unit
- Better fix for issue #181
Author
Bert Münnich
Date
2014-11-02 19:32 +0100
Committer
Bert Münnich · 2014-11-02 22:42 +0100
Parent
6cee581
Commit
f55d9f4283f7133ab5a137fc04ee19d1df62fafb

+17 −23

2 files changed

  1. M .gitignore +1 −1
  2. M Makefile +16 −22
M .gitignore View
@@ -1,4 +1,4 @@
1−.depend
21 config.h
2+*.d
33 *.o
44 sxiv
M Makefile View
@@ -1,32 +1,26 @@
1−VERSION = git-20141102
1+VERSION := git-20141102
22
3−PREFIX = /usr/local
4−MANPREFIX = $(PREFIX)/share/man
3+PREFIX := /usr/local
4+MANPREFIX := $(PREFIX)/share/man
55
6−CC = gcc
7−CFLAGS = -std=c99 -Wall -pedantic -O2
8−CPPFLAGS = -I$(PREFIX)/include -D_XOPEN_SOURCE=500 -DHAVE_LIBEXIF -DHAVE_GIFLIB
9−LDFLAGS = -L$(PREFIX)/lib
10−LIBS = -lX11 -lImlib2 -lexif -lgif
6+CC ?= gcc
7+CFLAGS += -std=c99 -Wall -pedantic
8+CPPFLAGS += -I$(PREFIX)/include -D_XOPEN_SOURCE=500 -DHAVE_LIBEXIF -DHAVE_GIFLIB
9+LDFLAGS += -L$(PREFIX)/lib
10+LIBS := -lX11 -lImlib2 -lexif -lgif
1111
12−SRC = commands.c image.c main.c options.c thumbs.c util.c window.c
13−OBJ = $(SRC:.c=.o)
12+SRC := commands.c image.c main.c options.c thumbs.c util.c window.c
13+DEP := $(SRC:.c=.d)
14+OBJ := $(SRC:.c=.o)
1415
15−all: sxiv
16+all: config.h sxiv
1617
1718 $(OBJ): Makefile
18−$(OBJ) .depend: config.h
1919
20−depend: .depend
20+-include $(DEP)
2121
22−.depend: $(SRC)
23− rm -f ./.depend
24− $(CC) $(CFLAGS) -MM $^ >./.depend
25−
26−-include .depend
27−
28−.c.o:
29− $(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
22+%.o: %.c
23+ $(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -MMD -c -o $@ $<
3024
3125 config.h:
3226 cp config.def.h $@
@@ -35,7 +29,7 @@ sxiv: $(OBJ)
3529 $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
3630
3731 clean:
38− rm -f $(OBJ) sxiv
32+ rm -f $(OBJ) $(DEP) sxiv
3933
4034 install: all
4135 mkdir -p $(DESTDIR)$(PREFIX)/bin