From eaa925597d96f69141d42155928d649f4603bd07 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 27 Mar 2010 11:54:22 +0100 Subject: Support CFLAGS, PREFIX & LDFLAGS in Makefile; pretty make install output --- Makefile | 39 ++++++++++++++++++++++++--------------- test/main | 4 ++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index c8183e0..7ae094f 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,35 @@ -CFLAGS = -Wall -Wextra -pedantic -O2 -prefix = /usr/local +CFLAGS ?= -O2 +PREFIX ?= /usr/local + +CFLAGS += -Wall -Wextra -pedantic + +sysdir = ${DESTDIR}${PREFIX} all: bin/envstore bin/%: src/%.c - $(CC) $(CFLAGS) -o $@ $< + ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $< install: bin/envstore - mkdir -p $(prefix)/bin $(prefix)/share/man/man1 - cp bin/envstore $(prefix)/bin/envstore - cp bin/envify $(prefix)/bin/envify - cp man/1/envify $(prefix)/share/man/man1/envify.1 - cp man/1/envstore $(prefix)/share/man/man1/envstore.1 - chmod 755 $(prefix)/bin/envstore - chmod 755 $(prefix)/bin/envify - chmod 644 $(prefix)/share/man/man1/envify.1 - chmod 644 $(prefix)/share/man/man1/envstore.1 + @echo installing: + @echo 'envstore to ${sysdir}/bin' + @echo 'envify to ${sysdir}/bin' + @echo 'envstore.1 to ${sysdir}/share/man/man1' + @echo 'envify.1 to ${sysdir}/share/man/man1' + @mkdir -p ${sysdir}/bin ${sysdir}/share/man/man1 + @cp bin/envstore ${sysdir}/bin/envstore + @cp bin/envify ${sysdir}/bin/envify + @cp man/1/envify ${sysdir}/share/man/man1/envify.1 + @cp man/1/envstore ${sysdir}/share/man/man1/envstore.1 + @chmod 755 ${sysdir}/bin/envstore + @chmod 755 ${sysdir}/bin/envify + @chmod 644 ${sysdir}/share/man/man1/envify.1 + @chmod 644 ${sysdir}/share/man/man1/envstore.1 uninstall: - rm -f $(prefix)/bin/envstore $(prefix)/bin/envify - rm -f $(prefix)/share/man/man1/envify.1 - rm -f $(prefix)/share/man/man1/envstore.1 + rm -f ${sysdir}/bin/envstore ${sysdir}/bin/envify + rm -f ${sysdir}/share/man/man1/envify.1 + rm -f ${sysdir}/share/man/man1/envstore.1 test: test/main diff --git a/test/main b/test/main index eded353..6de0c92 100755 --- a/test/main +++ b/test/main @@ -20,10 +20,10 @@ echo "# make" make -s -B echo "# make install" -make -s install prefix=$testdir +make -s install DESTDIR=$testdir echo "# make uninstall" -make -s uninstall prefix=$testdir +make -s uninstall DESTDIR=$testdir rm -r $testdir -- cgit v1.2.3