Revise Makefile

Use uppercase for externally defined macros and lowercase for macros defined in
the makefile.

Also simplify generation of version.h.
This commit is contained in:
Bert Münnich 2018-10-11 13:41:45 +02:00
parent f7714eaf90
commit 971f5d6694
1 changed files with 18 additions and 24 deletions

View File

@ -1,4 +1,4 @@
VERSION = 24+ version = 24+
srcdir = . srcdir = .
VPATH = $(srcdir) VPATH = $(srcdir)
@ -6,10 +6,6 @@ VPATH = $(srcdir)
PREFIX = /usr/local PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man MANPREFIX = $(PREFIX)/share/man
CC = cc
DEF_CFLAGS = -std=c99 -Wall -pedantic
DEF_CPPFLAGS = -I/usr/include/freetype2
# autoreload backend: inotify/nop # autoreload backend: inotify/nop
AUTORELOAD = inotify AUTORELOAD = inotify
@ -19,19 +15,18 @@ HAVE_GIFLIB = 1
# enable features requiring libexif (-lexif) # enable features requiring libexif (-lexif)
HAVE_LIBEXIF = 1 HAVE_LIBEXIF = 1
ALL_CFLAGS = $(DEF_CFLAGS) $(CFLAGS) cflags = -std=c99 -Wall -pedantic $(CFLAGS)
REQ_CPPFLAGS = -I. -D_XOPEN_SOURCE=700 \ cppflags = -I. $(CPPFLAGS) -D_XOPEN_SOURCE=700 -DHAVE_GIFLIB=$(HAVE_GIFLIB) \
-DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) -I/usr/include/freetype2
ALL_CPPFLAGS = $(REQ_CPPFLAGS) $(DEF_CPPFLAGS) $(CPPFLAGS)
LIB_EXIF_0 = lib_exif_0 =
LIB_EXIF_1 = -lexif lib_exif_1 = -lexif
LIB_GIF_0 = lib_gif_0 =
LIB_GIF_1 = -lgif lib_gif_1 = -lgif
LDLIBS = -lImlib2 -lX11 -lXft -lfontconfig \ ldlibs = $(LDLIBS) -lImlib2 -lX11 -lXft -lfontconfig \
$(LIB_EXIF_$(HAVE_LIBEXIF)) $(LIB_GIF_$(HAVE_GIFLIB)) $(lib_exif_$(HAVE_LIBEXIF)) $(lib_gif_$(HAVE_GIFLIB))
OBJS = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \ objs = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \
thumbs.o util.o window.o thumbs.o util.o window.o
all: sxiv all: sxiv
@ -41,17 +36,17 @@ all: sxiv
.SUFFIXES: .c .o .SUFFIXES: .c .o
$(V).SILENT: $(V).SILENT:
sxiv: $(OBJS) sxiv: $(objs)
@echo "LINK $@" @echo "LINK $@"
$(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJS) $(LDLIBS) $(CC) $(LDFLAGS) -o $@ $(objs) $(ldlibs)
$(OBJS): Makefile sxiv.h commands.lst config.h $(objs): Makefile sxiv.h commands.lst config.h
options.o: version.h options.o: version.h
window.o: icon/data.h window.o: icon/data.h
.c.o: .c.o:
@echo "CC $@" @echo "CC $@"
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $< $(CC) $(cflags) $(cppflags) -c -o $@ $<
config.h: config.h:
@echo "GEN $@" @echo "GEN $@"
@ -59,9 +54,8 @@ config.h:
version.h: Makefile .git/index version.h: Makefile .git/index
@echo "GEN $@" @echo "GEN $@"
VERSION="$$(cd $(srcdir); git describe 2>/dev/null)"; \ v="$$(cd $(srcdir); git describe 2>/dev/null)"; \
[ -z "$$VERSION" ] && VERSION="$(VERSION)"; \ echo "#define VERSION \"$${v:-$(version)}\"" >$@
echo "#define VERSION \"$$VERSION\"" >$@
.git/index: .git/index:
@ -75,7 +69,7 @@ install: all
chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv
@echo "INSTALL sxiv.1" @echo "INSTALL sxiv.1"
mkdir -p $(DESTDIR)$(MANPREFIX)/man1 mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" sxiv.1 \ sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(version)!g" sxiv.1 \
>$(DESTDIR)$(MANPREFIX)/man1/sxiv.1 >$(DESTDIR)$(MANPREFIX)/man1/sxiv.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
@echo "INSTALL share/sxiv/" @echo "INSTALL share/sxiv/"