summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 271ea769332ce3235c79f6ae447853fd631795ec (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

NAME=fastback

ifndef DESTDIR
DESTDIR=/
endif


#
# RPM specific setup stuff
# 

default: fastback

fastback: fastback.o
	g++ -g -o $@ $$(curl-config --libs) $< 

fastback.o: fastback.cpp
	g++ -g -c -o $$(curl-config --cflags) $@ $<

install:
	install -d $(DESTDIR)/bin/ $(DESTDIR)/etc
	install fastback fastback-unload-receipt $(DESTDIR)/bin/
	install fastback.conf $(DESTDIR)/etc

uninstall:
	rm -rf $(DESTDIR)/bin/{fastback,fastback-unload-receipt}
	rm -rf $(DESTDIR)/etc/fastback.conf

clean:
	rm -rf fastback.o fastback




#
# Maintainer
#

#
# RPM Setup stuff
# 


SPECFILE=$(NAME).spec

## a base directory where we'll put as much temporary working stuff as we can
ifndef WORKDIR
WORKDIR := $(shell pwd)
endif
## of course all this can also be overridden in your RPM macros file,
## but this way you can separate your normal RPM setup from your CVS
## setup. Override RPM_WITH_DIRS in ~/.cvspkgsrc to avoid the usage of
## these variables.
SRCRPMDIR ?= $(WORKDIR)/SRPMS
BUILDDIR ?= $(WORKDIR)/BUILD
RPMDIR ?= $(WORKDIR)/RPMS
MOCKDIR ?= $(WORKDIR)

## SOURCEDIR is special; it has to match the CVS checkout directory, 
## because the CVS checkout directory contains the patch files. So it basically 
## can't be overridden without breaking things. But we leave it a variable
## for consistency, and in hopes of convincing it to work sometime.
ifndef SOURCEDIR
SOURCEDIR := $(shell pwd)
endif
ifndef SPECDIR
SPECDIR := $(shell pwd)
endif

#		--define "_builddir $(BUILDDIR)" \

ifndef RPM_DEFINES
RPM_DEFINES := --define "_sourcedir $(SOURCEDIR)" \
		--define "_specdir $(SPECDIR)" \
		--define "_srcrpmdir $(SRCRPMDIR)" \
		--define "_rpmdir $(RPMDIR)"
endif

# Initialize the variables that we need, but are not defined
# the version of the package

VER_REL := $(shell rpm $(RPM_DEFINES) -q --qf "%{VERSION} %{RELEASE}\n" --specfile $(SPECFILE)| head -1)

ifndef NAME
$(error "You can not run this Makefile without having NAME defined")
endif
ifndef VERSION
VERSION := $(word 1, $(VER_REL))
endif
# the release of the package
ifndef RELEASE
RELEASE := $(word 2, $(VER_REL))
endif

# RPM with all the overrides in place; you can override this in your
# .cvspkgsrc also, to use a default rpm setup
# the rpm build command line
ifndef RPM
RPM := rpmbuild
endif
ifndef RPM_WITH_DIRS
RPM_WITH_DIRS = $(RPM) $(RPM_DEFINES)
endif

#
# Actual Maintainer rules
#

TARFILES=fastback.cpp Makefile fastback.conf fastback-check test fastback-unload-receipt
TARFILENAME=$(NAME)-$(VERSION).tar.gz

# This should be changed to build on dist, when I build a dist
$(TARFILENAME): $(SPECFILE) $(TARFILES)
	rm -rf $(NAME)-$(VERSION)
	mkdir $(NAME)-$(VERSION)
	cp -r $(TARFILES) $(NAME)-$(VERSION)
	tar zcf $@ $(NAME)-$(VERSION)
	rm -rf $(NAME)-$(VERSION)

dist: $(TARFILENAME)

maintainer-clean: clean
	rm -rf $(TARFILENAME) 

#
# RPM install
# 

rpm-ver-rel:
	@echo $(VERSION) $(RELEASE)

srpm: $(SPECFILE) $(NAME)-$(VERSION).tar.gz
	$(RPM_WITH_DIRS) -bs $<

rpm: $(SPECFILE) $(NAME)-$(VERSION).tar.gz
	$(RPM_WITH_DIRS) -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log ; exit $${PIPESTATUS[0]}

rpm-clean: maintainer-clean
	rm -rf RPMS SRPMS rpmbuild