summaryrefslogtreecommitdiff
path: root/php-kolab/Kolab_Server/Makefile
blob: 25b92efabecc1844ef7811d4d8ed7805925d8be4 (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
# If home is unset this Makefile assumes the Kolab server installation
# resides in /kolab. If this is not the case this Makefile must be
# called using
#
# HOME="/mykolabroot" make TARGET
#
ifeq "x$(HOME)" "x"
  HOME = /kolab
endif

# If HOME is set to /root it is likely that somebody is calling this
# Makefile as root user. In this case this Makefile assumes that the
# Kolab server installation resides in /kolab.
#
# In the (hopefully) unlikely event that somebody really installed the
# Kolab server in /root this Makefile will fail.
ifeq "x$(HOME)" "x/root"
  HOME = /kolab
endif

# Set the location of the rpm binary
ifeq "x$(RPM)" "x"
  RPM = $(HOME)/bin/openpkg rpm
endif

# Set the location for rpm source package installations
ifeq "x$(KOLABRPMSRC)" "x"
  KOLABRPMSRC = $(HOME)/RPM/SRC
endif

# Set the location for rpm packages
ifeq "x$(KOLABRPMPKG)" "x"
  KOLABRPMPKG = $(HOME)/RPM/PKG
endif

# Set the location for the rpm temporary directory
ifeq "x$(KOLABRPMTMP)" "x"
  KOLABRPMTMP = $(HOME)/RPM/TMP
endif

# Determine the suffix for binary packages on this system
ifeq "x$(PLATTAG)" "x"
	PLATTAG = $(shell $(RPM) -q --qf="%{ARCH}-%{OS}" openpkg)-$(HOME:/%=%)
endif

# Determine the staging area for collecting new source rpms
ifeq "x$(STAGING)" "x"
  STAGING = ../../stage
endif

# Determine the package name from the *.spec file
PACKAGE = $(shell grep "%define[ ]*V_package" *.spec | sed -e "s/.*V_package \([A-Za-z\-\_]*\).*/\1/")

# Determine the package version from the *.spec file
VERSION = $(shell grep "%define[ ]*V_version" *.spec | sed -e "s/.*V_version\s*\([0-9.]*\).*/\1/")

# Determine the release number from the *.spec file
RELEASE = $(shell grep "%define[ ]*V_release" *.spec | sed -e "s/.*V_release\s*\([0-9]*\).*/\1/")

# Determine the download url for the PEAR package from the *.spec file
SOURCE_URL=$(shell grep "%define[ ]*V_sourceurl" *.spec | sed -e "s/.*V_sourceurl\s*\(.*\)/\1/")

# Get the list of patches if there are any in this directory
PATCHES = $(shell ls *.patch 2> /dev/null)

# Generate the full package name
SOURCE_0=$(PACKAGE)-$(VERSION).tgz

# Generate a list of extra files for the package
EXTRA=ChangeLog $(PATCHES)


# Default target to generate the source rpm package
.PHONY: all
all: $(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm

# Target for placing the source rpm in the staging area
.PHONY: dist
dist: all
	test -d $(STAGING) || mkdir $(STAGING)
	cp $(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm $(STAGING)

# Target for installing the binary rpm package in our current Kolab
# server installation
.PHONY: install
install: $(KOLABRPMPKG)/$(PACKAGE)-$(VERSION)-$(RELEASE).$(PLATTAG).rpm
	$(RPM) -Uhv --force $(KOLABRPMPKG)/$(PACKAGE)-$(VERSION)-$(RELEASE).$(PLATTAG).rpm

# Target for retrieving the source package
$(KOLABRPMSRC)/$(PACKAGE)/$(SOURCE_0): 
	test -d $(KOLABRPMSRC)/$(PACKAGE) || mkdir $(KOLABRPMSRC)/$(PACKAGE)
	cd $(KOLABRPMSRC)/$(PACKAGE) && wget -c "$(SOURCE_URL)/$(SOURCE_0)"

# Target for preparing the source area and building the package
$(KOLABRPMPKG)/$(PACKAGE)-$(VERSION)-$(RELEASE).$(PLATTAG).rpm: Makefile $(PACKAGE).spec $(EXTRA) $(KOLABRPMSRC)/$(PACKAGE)/$(SOURCE_0)
	cp $(PACKAGE).spec $(EXTRA) $(KOLABRPMSRC)/$(PACKAGE)
	cd $(KOLABRPMSRC)/$(PACKAGE) && $(RPM) -ba $(PACKAGE).spec

# Target for fetching the source rpm into the current directory
$(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm: $(KOLABRPMPKG)/$(PACKAGE)-$(VERSION)-$(RELEASE).$(PLATTAG).rpm
	cp -p $(KOLABRPMPKG)/$(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm .

# Target for cleaning up the files that can be generated with this Makefile
.PHONY: clean
clean:
	rm -rf $(KOLABRPMPKG)/$(PACKAGE)-$(VERSION)-$(RELEASE).$(PLATTAG).rpm
	rm -rf $(KOLABRPMSRC)/$(PACKAGE)
	rm -rf $(KOLABRPMTMP)/$(PACKAGE)*
	rm -rf $(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm
	rm -rf *~