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
This commit is contained in:
parent
6cee58117a
commit
f55d9f4283
|
@ -1,4 +1,4 @@
|
||||||
.depend
|
|
||||||
config.h
|
config.h
|
||||||
|
*.d
|
||||||
*.o
|
*.o
|
||||||
sxiv
|
sxiv
|
||||||
|
|
38
Makefile
38
Makefile
|
@ -1,32 +1,26 @@
|
||||||
VERSION = git-20141102
|
VERSION := git-20141102
|
||||||
|
|
||||||
PREFIX = /usr/local
|
PREFIX := /usr/local
|
||||||
MANPREFIX = $(PREFIX)/share/man
|
MANPREFIX := $(PREFIX)/share/man
|
||||||
|
|
||||||
CC = gcc
|
CC ?= gcc
|
||||||
CFLAGS = -std=c99 -Wall -pedantic -O2
|
CFLAGS += -std=c99 -Wall -pedantic
|
||||||
CPPFLAGS = -I$(PREFIX)/include -D_XOPEN_SOURCE=500 -DHAVE_LIBEXIF -DHAVE_GIFLIB
|
CPPFLAGS += -I$(PREFIX)/include -D_XOPEN_SOURCE=500 -DHAVE_LIBEXIF -DHAVE_GIFLIB
|
||||||
LDFLAGS = -L$(PREFIX)/lib
|
LDFLAGS += -L$(PREFIX)/lib
|
||||||
LIBS = -lX11 -lImlib2 -lexif -lgif
|
LIBS := -lX11 -lImlib2 -lexif -lgif
|
||||||
|
|
||||||
SRC = commands.c image.c main.c options.c thumbs.c util.c window.c
|
SRC := commands.c image.c main.c options.c thumbs.c util.c window.c
|
||||||
OBJ = $(SRC:.c=.o)
|
DEP := $(SRC:.c=.d)
|
||||||
|
OBJ := $(SRC:.c=.o)
|
||||||
|
|
||||||
all: sxiv
|
all: config.h sxiv
|
||||||
|
|
||||||
$(OBJ): Makefile
|
$(OBJ): Makefile
|
||||||
$(OBJ) .depend: config.h
|
|
||||||
|
|
||||||
depend: .depend
|
-include $(DEP)
|
||||||
|
|
||||||
.depend: $(SRC)
|
%.o: %.c
|
||||||
rm -f ./.depend
|
$(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -MMD -c -o $@ $<
|
||||||
$(CC) $(CFLAGS) -MM $^ >./.depend
|
|
||||||
|
|
||||||
-include .depend
|
|
||||||
|
|
||||||
.c.o:
|
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
|
|
||||||
|
|
||||||
config.h:
|
config.h:
|
||||||
cp config.def.h $@
|
cp config.def.h $@
|
||||||
|
@ -35,7 +29,7 @@ sxiv: $(OBJ)
|
||||||
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJ) sxiv
|
rm -f $(OBJ) $(DEP) sxiv
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||||
|
|
Loading…
Reference in New Issue