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
+17 −23
2 files changed
- M .gitignore +1 −1
- M Makefile +16 −22
| @@ -1,4 +1,4 @@ | |||
| 1 | − | .depend | |
| 2 | 1 | config.h | |
| 2 | + | *.d | |
| 3 | 3 | *.o | |
| 4 | 4 | sxiv | |
| @@ -1,32 +1,26 @@ | |||
| 1 | − | VERSION = git-20141102 | |
| 1 | + | VERSION := git-20141102 | |
| 2 | 2 | ||
| 3 | − | PREFIX = /usr/local | |
| 4 | − | MANPREFIX = $(PREFIX)/share/man | |
| 3 | + | PREFIX := /usr/local | |
| 4 | + | MANPREFIX := $(PREFIX)/share/man | |
| 5 | 5 | ||
| 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 | |
| 11 | 11 | ||
| 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) | |
| 14 | 15 | ||
| 15 | − | all: sxiv | |
| 16 | + | all: config.h sxiv | |
| 16 | 17 | ||
| 17 | 18 | $(OBJ): Makefile | |
| 18 | − | $(OBJ) .depend: config.h | |
| 19 | 19 | ||
| 20 | − | depend: .depend | |
| 20 | + | -include $(DEP) | |
| 21 | 21 | ||
| 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 $@ $< | |
| 30 | 24 | ||
| 31 | 25 | config.h: | |
| 32 | 26 | cp config.def.h $@ | |
| @@ -35,7 +29,7 @@ sxiv: $(OBJ) | |||
| 35 | 29 | $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) | |
| 36 | 30 | ||
| 37 | 31 | clean: | |
| 38 | − | rm -f $(OBJ) sxiv | |
| 32 | + | rm -f $(OBJ) $(DEP) sxiv | |
| 39 | 33 | ||
| 40 | 34 | install: all | |
| 41 | 35 | mkdir -p $(DESTDIR)$(PREFIX)/bin | |