aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-11-02 19:32:08 +0100
committerBert Münnich <ber.t@posteo.de>2014-11-02 22:42:59 +0100
commitf55d9f4283f7133ab5a137fc04ee19d1df62fafb (patch)
tree8e4d75e9bc88ddc75e981fa0c6f239ede9665ec6 /Makefile
parent6cee58117aedb00f250fce27a343d39708197257 (diff)
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
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile38
1 files changed, 16 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 12357b6..0568242 100644
--- a/Makefile
+++ b/Makefile
@@ -1,32 +1,26 @@
-VERSION = git-20141102
+VERSION := git-20141102
-PREFIX = /usr/local
-MANPREFIX = $(PREFIX)/share/man
+PREFIX := /usr/local
+MANPREFIX := $(PREFIX)/share/man
-CC = gcc
-CFLAGS = -std=c99 -Wall -pedantic -O2
-CPPFLAGS = -I$(PREFIX)/include -D_XOPEN_SOURCE=500 -DHAVE_LIBEXIF -DHAVE_GIFLIB
-LDFLAGS = -L$(PREFIX)/lib
-LIBS = -lX11 -lImlib2 -lexif -lgif
+CC ?= gcc
+CFLAGS += -std=c99 -Wall -pedantic
+CPPFLAGS += -I$(PREFIX)/include -D_XOPEN_SOURCE=500 -DHAVE_LIBEXIF -DHAVE_GIFLIB
+LDFLAGS += -L$(PREFIX)/lib
+LIBS := -lX11 -lImlib2 -lexif -lgif
-SRC = commands.c image.c main.c options.c thumbs.c util.c window.c
-OBJ = $(SRC:.c=.o)
+SRC := commands.c image.c main.c options.c thumbs.c util.c window.c
+DEP := $(SRC:.c=.d)
+OBJ := $(SRC:.c=.o)
-all: sxiv
+all: config.h sxiv
$(OBJ): Makefile
-$(OBJ) .depend: config.h
-depend: .depend
+-include $(DEP)
-.depend: $(SRC)
- rm -f ./.depend
- $(CC) $(CFLAGS) -MM $^ >./.depend
-
--include .depend
-
-.c.o:
- $(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
+%.o: %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -MMD -c -o $@ $<
config.h:
cp config.def.h $@
@@ -35,7 +29,7 @@ sxiv: $(OBJ)
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
clean:
- rm -f $(OBJ) sxiv
+ rm -f $(OBJ) $(DEP) sxiv
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin