aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 9e3f4fb80a177875d2e1c8faa250a4cfcdcd4140 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Basic Makefile for compiling & installing the files.
#
# Supports standard GNU Makefile variables for specifying the paths:
# * prefix
# * exec_prefix
# * bindir
# * sbindir
# * libdir
# * datarootdir
# * datadir
# * mandir
# * sysconfdir
# * localstatedir
# * DESTDIR
#

SHELL          = /bin/bash

# Normally /usr/local is used. However, it does not make sense for us to use it
# here, as it just complicates things even further.
prefix         = /usr
exec_prefix    = $(prefix)
bindir         = $(prefix)/bin
sbindir        = $(prefix)/sbin
libdir         = $(prefix)/lib
libexecdir     = $(exec_prefix)/libexec
datarootdir    = $(prefix)/share
datadir        = $(datarootdir)
mandir         = $(datadir)/man
sysconfdir     = /etc
localstatedir  = /var
sharedstatedir = $(localstatedir)/lib

VERSION       := $(shell gawk '/Version:/ { print $$2 }' initscripts.spec)
NEXT_VERSION  := $(shell gawk '/Version:/ { print $$2 + 0.01}' initscripts.spec)

Mageia_DIR     := mageia
Mageia_FILES   := $(shell cd $(Mageia_DIR); find etc network-scripts usr -type f \! -name .keep)
Mageia_SUBDIRS := $(shell cd $(Mageia_DIR); find -type d -links 2)
PO             := po-mageia
Mageia_MANDIR  := man-mageia


all: make-binaries make-translations


make-binaries:
	$(MAKE) -C src

make-translations:
	$(MAKE) -C $(PO) PYTHON=$(PYTHON)


# NOTE: We are no longer installing into /usr/sbin directory, because this is
#       just a symlink to /usr/bin, thanks to UsrMove change. Instead, we just
#       use virtual provides for /usr/sbin/<utility> in specfile (for backward
#       compatibility).
install: install-mageia install-binaries install-translations install-etc install-usr install-network-scripts install-man install-post

install-mageia:
	@echo "Modifying structure for Mageia"
	# Ensure the directories used by Mageia exist in the main directory
	@for i in $(Mageia_SUBDIRS); do mkdir -p $$i; echo "$$i";done
	# Now copy over the various files to the main directory. This allows
	# the standard logic of this Makefile to work
	@for i in $(Mageia_FILES);do cp -a $(Mageia_DIR)/$$i $$i;done


install-binaries:
	$(MAKE) install -C src DESTDIR=$(DESTDIR) prefix=$(prefix) bindir=$(bindir) libdir=$(libdir)

install-translations:
	$(MAKE) install -C $(PO)  DESTDIR=$(DESTDIR) prefix=$(prefix) bindir=$(bindir) libdir=$(libdir) \
	                                          datarootdir=$(datarootdir) datadir=$(datadir) sysconfdir=$(sysconfdir)


# NOTE: We are removing auxiliary symlink at the beginning.
install-etc:
	rm -f etc/sysconfig/network-scripts
	install -m 0755 -d $(DESTDIR)$(sysconfdir)
	cp -a        etc/* $(DESTDIR)$(sysconfdir)/

install-usr:
	install -m 0755 -d $(DESTDIR)$(prefix)
	cp -a        usr/* $(DESTDIR)$(prefix)/

install-network-scripts: install-usr install-etc
	install -m 0755 -d      $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts
	cp -a network-scripts/* $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts/

install-man: install-usr
	install -m 0755 -d      $(DESTDIR)$(mandir)/man1
	install -m 0755 -d      $(DESTDIR)$(mandir)/man8
	install -m 0644 man/*.1 $(DESTDIR)$(mandir)/man1
	install -m 0644 man/*.8 $(DESTDIR)$(mandir)/man8
	# install translated man pages
	for j in 1 8 ; do \
	   for i in $(Mageia_MANDIR)/??* ; do \
	       install -d $(DESTDIR)$(mandir)/`basename $$i`/man$$j ; \
	       install -m 644 $$i/*.$$j $(DESTDIR)$(mandir)/`basename $$i`/man$$j ; \
	   done ; \
	done


# Initscripts still ship some empty directories necessary for system to function
# correctly...
install-post: install-etc
	install -m 0755 -d $(DESTDIR)$(sysconfdir)/sysconfig/console
	install -m 0755 -d $(DESTDIR)$(sysconfdir)/sysconfig/modules
	install -m 0755 -d $(DESTDIR)$(sharedstatedir)/stateless/state
	install -m 0755 -d $(DESTDIR)$(sharedstatedir)/stateless/writable
	install -m 0755 -d $(DESTDIR)$(libexecdir)/initscripts/legacy-actions
	for idx in {0..6}; do \
	    dir=$(DESTDIR)$(sysconfdir)/rc.d/rc$$idx.d; \
	    install -m 0755 -d $$dir; \
	    ln -srf $(DESTDIR)$(sysconfdir)/rc.d/rc$$idx.d $(DESTDIR)$(sysconfdir)/; \
	done
	ln -srf $(DESTDIR)$(sysconfdir)/rc.d/init.d $(DESTDIR)$(sysconfdir)/init.d

clean: clean-mageia
	$(MAKE) clean -C src
	$(MAKE) clean -C $(PO)
	@find . -name "*~" -exec rm -v -f {} \;

clean-mageia:
	# Remove the files we've added
	@for i in $(Mageia_FILES);do rm -f $$i;done
	# Try to remove any empty directories caused by the files we've removed
	@for i in $(Mageia_SUBDIRS);do [ -d "$$1" ] && [ ! -h "$$1" ] && rmdir "$$1" 2> /dev/null || :;done

tag:
	@git tag -a -f -m "$(VERSION) release" $(VERSION)
	@echo "Tagged as $(VERSION)"

release-commit:
	@git log --decorate=no --format="- %s" $(VERSION)..HEAD > .changelog.tmp
	@rpmdev-bumpspec -n $(NEXT_VERSION) -f .changelog.tmp initscripts.spec
	@rm -f .changelog.tmp
	@git add initscripts.spec
	@git commit --message="$(NEXT_VERSION)"
	@echo -e "\n       New release commit ($(NEXT_VERSION)) created:\n"
	@git show

archive: clean
	@git archive --format=tar --prefix=initscripts-$(VERSION)/ HEAD > initscripts-$(VERSION).tar
	@mkdir -p initscripts-$(VERSION)/
	@tar --append -f initscripts-$(VERSION).tar initscripts-$(VERSION)
	@gzip -f initscripts-$(VERSION).tar
	@rm -rf initscripts-$(VERSION)
	@echo "The archive is at initscripts-$(VERSION).tar.gz"


mageiadist: clean
	@git archive --format=tar --prefix=initscripts-$(VERSION)/ HEAD ':po-mageia' ':man-mageia' > initscripts-$(VERSION)-mageia.tar
	@mkdir -p initscripts-$(VERSION)/
	@tar --append -f initscripts-$(VERSION)-mageia.tar initscripts-$(VERSION)
	@gzip -f initscripts-$(VERSION)-mageia.tar
	@rm -rf initscripts-$(VERSION)
	@echo "The Mageia archive is at initscripts-$(VERSION)-mageia.tar.gz"
	@git diff 10.04...distro/mga ':!po-mageia' ':!man-mageia' > initscripts-$(VERSION)-mageia.patch
	@echo "The Mageia patch is at initscripts-$(VERSION)-mageia.patch"