1 From 947a7e332908dcba1c7e523fbdc927d39ee6adb1 Mon Sep 17 00:00:00 2001
2 From: Hans Ulrich Niedermann <hun@n-dimensional.de>
3 Date: Tue, 19 Nov 2013 23:40:50 +0100
4 Subject: [PATCH] Make build/install more user and packaging friendly
6 Make the build and install more user and packaging friendly
7 by introducing the following features in the Makefile:
9 * Honor the $(CFLAGS) set when calling make.
11 * Prefix all install locations with $(DESTDIR) for
12 easy package building.
14 * Use GNU Makefile conventions for defining installation
15 directories. This means $(bindir) and $(man1dir)
16 instead of the former $(INSTALL_DIR) and $(MAN_DIR).
18 * Use install(1) for installing files and directories
19 so that permissions can be set properly.
21 * Stop "make clean" failing when it has nothing to do.
23 * Add 'uninstall' make target.
25 * Make 'install' target build executable if necessary.
27 Makefile | 40 +++++++++++++++++++++++++++++-----------
28 1 file changed, 29 insertions(+), 11 deletions(-)
30 diff --git a/Makefile b/Makefile
31 index 0f4f810..942a7a5 100644
43 -MAN_DIR=/usr/share/man/man1
46 +# Use GNU makefile conventions for directory names with one notable
47 +# exception: prefix is not /usr/local in order to keep the default
48 +# installation location for beep.
50 +exec_prefix=$(prefix)
51 +bindir=$(exec_prefix)/bin
52 +datarootdir=$(prefix)/share
53 +mandir=$(datarootdir)/man
54 +man1dir=$(mandir)/man1
66 + $(CC) $(FLAGS) $(CFLAGS) -o $(EXEC_NAME) beep.c
69 - ${CC} ${FLAGS} -o ${EXEC_NAME} beep.c
71 + $(INSTALL) -m 0755 -d $(DESTDIR)$(bindir)
72 + $(INSTALL) -m 0755 $(EXEC_NAME) $(DESTDIR)$(bindir)/
73 + $(INSTALL) -m 0755 -d $(DESTDIR)$(man1dir)
74 + $(INSTALL) -m 0644 $(MAN_FILE) $(DESTDIR)$(man1dir)/
77 - cp ${EXEC_NAME} ${INSTALL_DIR}
78 - # rm -f /usr/man/man1/beep.1.bz2
79 - cp ${MAN_FILE} ${MAN_DIR}
81 + rm -f $(DESTDIR)$(bindir)/$(EXEC_NAME)
82 + rm -f $(DESTDIR)$(man1dir)/$(MAN_FILE)