summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-06-12 01:46:33 +0200
committerDave Reisner <d@falconindy.com>2011-06-16 22:16:42 +0200
commit30121576b576395244b0e4564722abb3d2a44c4c (patch)
tree1188c6b52966962149197ea5aba97e37515ee96d /Makefile
parent5aa93f8ed37b0ded7a6dc393795441cec1e42d2b (diff)
downloadmkinitcpio-30121576b576395244b0e4564722abb3d2a44c4c.tar.gz
mkinitcpio-30121576b576395244b0e4564722abb3d2a44c4c.tar.xz
Makefile: refactor and simplify
This should all lead to easier maintenance. * use git-archive to create the tarball, appending DIST_EXTRA to the tarball afterwards. * use commonly defined variables such as ${RM} * always use install, rather than cp to ensure proper permissions * functionize creation of directories * add .PHONY targets * combined commands wherever possible Signed-off-by: Dave Reisner <d@falconindy.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile94
1 files changed, 42 insertions, 52 deletions
diff --git a/Makefile b/Makefile
index 4d41ad8..66e2d8d 100644
--- a/Makefile
+++ b/Makefile
@@ -2,13 +2,22 @@
VERSION = 0.6.15
+DIRS = \
+ /bin \
+ /sbin \
+ /etc/mkinitcpio.d \
+ /lib/initcpio/hooks \
+ /lib/initcpio/install \
+ /lib/initcpio/udev \
+ /usr/share/man/man5
+
+DIST_EXTRA = \
+ mkinitcpio.5
+
all: doc
install: all
- install -d ${DESTDIR}/bin
- install -d ${DESTDIR}/sbin
- install -d ${DESTDIR}/lib/initcpio
- install -d ${DESTDIR}/etc
+ $(foreach dir,${DIRS},install -dm755 ${DESTDIR}${dir};)
sed -e 's|CONFIG="mkinitcpio.conf"|CONFIG="/etc/mkinitcpio.conf"|g' \
-e 's|FUNCTIONS="functions"|FUNCTIONS="/lib/initcpio/functions"|g' \
@@ -17,59 +26,40 @@ install: all
-e 's|PRESETDIR="mkinitcpio.d"|PRESETDIR="/etc/mkinitcpio.d"|g' \
< mkinitcpio > ${DESTDIR}/sbin/mkinitcpio
- chmod 755 ${DESTDIR}/sbin/mkinitcpio
-
sed "s|%VERSION%|${VERSION}|g" < lsinitcpio > ${DESTDIR}/bin/lsinitcpio
- chmod 755 ${DESTDIR}/bin/lsinitcpio
-
- install -D -m644 mkinitcpio.conf ${DESTDIR}/etc/mkinitcpio.conf
- install -D -m755 init ${DESTDIR}/lib/initcpio/init
- install -D -m755 init_functions ${DESTDIR}/lib/initcpio/init_functions
- install -D -m644 functions ${DESTDIR}/lib/initcpio/functions
- install -D -m644 01-memdisk.rules ${DESTDIR}/lib/initcpio/udev/01-memdisk.rules
- install -d ${DESTDIR}/lib/initcpio/hooks
- install -d ${DESTDIR}/lib/initcpio/install
- install -d ${DESTDIR}/etc/mkinitcpio.d
+ chmod 755 ${DESTDIR}/bin/lsinitcpio ${DESTDIR}/sbin/mkinitcpio
- cp -R hooks/* ${DESTDIR}/lib/initcpio/hooks
- cp -R install/* ${DESTDIR}/lib/initcpio/install
- cp -R mkinitcpio.d/* ${DESTDIR}/etc/mkinitcpio.d
+ install -m644 mkinitcpio.conf ${DESTDIR}/etc/mkinitcpio.conf
+ install -m755 -t ${DESTDIR}/lib/initcpio init
+ install -m644 -t ${DESTDIR}/lib/initcpio init_functions functions
+ install -m644 01-memdisk.rules ${DESTDIR}/lib/initcpio/udev/01-memdisk.rules
- install -D -m644 mkinitcpio.5.gz ${DESTDIR}/usr/share/man/man5/mkinitcpio.5.gz
+ install -m644 -t ${DESTDIR}/lib/initcpio/hooks hooks/*
+ install -m644 -t ${DESTDIR}/lib/initcpio/install install/*
+ install -m644 -t ${DESTDIR}/etc/mkinitcpio.d mkinitcpio.d/*
-doc: mkinitcpio.5.gz
+ install -m644 mkinitcpio.5 ${DESTDIR}/usr/share/man/man5/mkinitcpio.5
-mkinitcpio.5.gz: mkinitcpio.5.txt
- a2x -d manpage -f manpage -a mansource=mkinitcpio -a manversion=${VERSION} -a manmanual=mkinitcpio mkinitcpio.5.txt
- gzip -c --best mkinitcpio.5 > mkinitcpio.5.gz
+doc: mkinitcpio.5
+mkinitcpio.5: mkinitcpio.5.txt
+ a2x -d manpage \
+ -f manpage \
+ -a mansource=mkinitcpio \
+ -a manversion=${VERSION} \
+ -a manmanual=mkinitcpio mkinitcpio.5.txt
clean:
- rm -rf build
- rm -f mkinitcpio-${VERSION}.tar.gz
- rm -f mkinitcpio.5
- rm -f mkinitcpio.5.xml
- rm -f mkinitcpio.5.gz
-
-TARBALL_FILES = \
- Makefile \
- LICENSE \
- README \
- hooks \
- functions \
- init \
- init_functions \
- install \
- 01-memdisk.rules \
- lsinitcpio \
- mkinitcpio \
- mkinitcpio.conf \
- mkinitcpio.d \
- mkinitcpio.5.txt \
- mkinitcpio.5.gz
-
-tarball: mkinitcpio.5.gz
- mkdir -p build/mkinitcpio-${VERSION}
- cp -a --backup=none ${TARBALL_FILES} build/mkinitcpio-${VERSION}
- tar cvvzf mkinitcpio-${VERSION}.tar.gz -C build mkinitcpio-${VERSION}
-
+ ${RM} -r build mkinitcpio-${VERSION}
+ ${RM} mkinitcpio-${VERSION}.tar.gz mkinitcpio.5 mkinitcpio.5.gz
+
+tarball: dist
+dist: doc
+ git archive --prefix=mkinitcpio-${VERSION}/ -o mkinitcpio-${VERSION}.tar HEAD
+ mkdir mkinitcpio-${VERSION}; \
+ cp -t mkinitcpio-${VERSION} ${DIST_EXTRA}; \
+ tar uf mkinitcpio-${VERSION}.tar mkinitcpio-${VERSION}; \
+ ${RM} -r mkinitcpio-${VERSION}
+ gzip -9 mkinitcpio-${VERSION}.tar
+
+.PHONY: clean dist install tarball