]> git.cworth.org Git - fips/blob - Makefile.local
Initial commit of fips repository
[fips] / Makefile.local
1 # -*- makefile -*-
2
3 # Here's the (hopefully simple) versioning scheme.
4 #
5 # Releases of fips have a two-digit version (0.1, 0.2, etc.). We
6 # increment the second digit for each release and increment the first
7 # digit when we reach particularly major milestones of usability.
8 #
9 # Between releases, (such as when compiling fips from the git
10 # repository), we let git append identification of the actual commit.
11 PACKAGE=fips
12
13 IS_GIT=$(shell if [ -d .git ] ; then echo yes ; else echo no; fi)
14
15 ifeq ($(IS_GIT),yes)
16 DATE:=$(shell git log --date=short -1 --pretty=format:%cd)
17 else
18 DATE:=$(shell date +%F)
19 endif
20
21 VERSION:=$(shell cat ${srcdir}/version)
22 ifeq ($(filter release release-message pre-release, $(MAKECMDGOALS)),)
23 ifeq ($(IS_GIT),yes)
24 VERSION:=$(shell git describe --match '[0-9.]*' 2>/dev/null | sed -e s/_/~/ -e s/-/+/ -e s/-/~/)
25 endif
26 endif
27
28 UPSTREAM_TAG=$(subst ~,_,$(VERSION))
29 DEB_TAG=debian/$(UPSTREAM_TAG)-1
30
31 RELEASE_HOST=cworth.org
32 RELEASE_DIR=/home/cworth/public_html/fips/releases
33 RELEASE_URL=http://cworth.org/fips/releases
34 TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz
35 DEB_TAR_FILE=$(PACKAGE)_$(VERSION).orig.tar.gz
36 SHA1_FILE=$(TAR_FILE).sha1
37 GPG_FILE=$(SHA1_FILE).asc
38
39 # Smash together user's values with our extra values
40 FINAL_CFLAGS = -DFIPS_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
41 FINAL_FIPS_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(TALLOC_LDFLAGS)
42 FINAL_FIPS_LINKER = CC
43 ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)
44 FINAL_FIPS_LDFLAGS += $(CONFIGURE_LDFLAGS)
45 endif
46 ifeq ($(LIBDIR_IN_LDCONFIG),0)
47 FINAL_FIPS_LDFLAGS += $(RPATH_LDFLAGS)
48 endif
49
50 .PHONY: all
51 all: fips
52 ifeq ($(MAKECMDGOALS),)
53 ifeq ($(shell cat .first-build-message 2>/dev/null),)
54         @FIPS_FIRST_BUILD=1 $(MAKE) --no-print-directory all
55         @echo ""
56         @echo "Compilation of fips is now complete. You can install fips with:"
57         @echo ""
58         @echo " make install"
59         @echo ""
60         @echo "Note that depending on the prefix to which you are installing"
61         @echo "you may need root permission (such as \"sudo make install\")."
62         @echo "See \"./configure --help\" for help on setting an alternate prefix."
63         @echo Printed > .first-build-message
64 endif
65 endif
66
67 $(TAR_FILE):
68         if git tag -v $(VERSION) >/dev/null 2>&1; then \
69            ref=$(VERSION); \
70         else \
71            ref="HEAD" ; \
72            echo "Warning: No signed tag for $(VERSION)"; \
73         fi ; \
74         git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ $$ref > $(TAR_FILE).tmp
75         echo $(VERSION) > version.tmp
76         tar --append -f $(TAR_FILE).tmp --transform s_^_$(PACKAGE)-$(VERSION)/_  --transform 's_.tmp$$__' version.tmp
77         rm version.tmp
78         gzip < $(TAR_FILE).tmp > $(TAR_FILE)
79         @echo "Source is ready for release in $(TAR_FILE)"
80
81 $(SHA1_FILE): $(TAR_FILE)
82         sha1sum $^ > $@
83
84 $(GPG_FILE): $(SHA1_FILE)
85         @echo "Please enter your GPG password to sign the checksum."
86         gpg --armor --sign $^ 
87
88 .PHONY: dist
89 dist: $(TAR_FILE)
90
91 .PHONY: test
92 test:
93         @echo "FIXME: Should consider adding a test suite here."
94
95 # We invoke make recursively only to force ordering of our phony
96 # targets in the case of parallel invocation of make (-j).
97 #
98 # We carefully ensure that our VERSION variable is passed down to any
99 # sub-ordinate make invocations (which won't otherwise know that they
100 # are part of the release and need to take the version from the
101 # version file).
102 .PHONY: release
103 release: verify-source-tree-and-version
104         $(MAKE) VERSION=$(VERSION) verify-newer
105         $(MAKE) VERSION=$(VERSION) clean
106         $(MAKE) VERSION=$(VERSION) test
107         git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
108         $(MAKE) VERSION=$(VERSION) $(GPG_FILE)
109         ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
110         pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
111         git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
112         mkdir -p releases
113         mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
114         $(MAKE) VERSION=$(VERSION) release-message > $(PACKAGE)-$(VERSION).announce
115 ifeq ($(REALLY_UPLOAD),yes)
116         git push origin $(VERSION)
117         cd releases && scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
118         ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-* ; ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(TAR_FILE)"
119 endif
120         @echo "Please send a release announcement using $(PACKAGE)-$(VERSION).announce as a template."
121
122 .PHONY: pre-release
123 pre-release:
124         $(MAKE) VERSION=$(VERSION) clean
125         $(MAKE) VERSION=$(VERSION) test
126         git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
127         git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
128         $(MAKE) VERSION=$(VERSION) $(TAR_FILE)
129         ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
130         pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
131         mkdir -p releases
132         mv $(TAR_FILE) $(DEB_TAR_FILE) releases
133
134 .PHONY: debian-snapshot
135 debian-snapshot:
136         make VERSION=$(VERSION) clean
137         TMPFILE=$$(mktemp /tmp/fips.XXXXXX);            \
138           cp debian/changelog $${TMPFILE};              \
139           EDITOR=/bin/true dch -b -v $(VERSION)+1       \
140             -D UNRELEASED 'test build, not for upload'; \
141           echo '3.0 (native)' > debian/source/format;   \
142           debuild -us -uc;                              \
143           mv -f $${TMPFILE} debian/changelog;           \
144           echo '3.0 (quilt)' > debian/source/format
145
146 .PHONY: release-message
147 release-message:
148         @echo "To: XXX"
149         @echo "Subject: $(PACKAGE) release $(VERSION) now available"
150         @echo ""
151         @echo "Where to obtain fips $(VERSION)"
152         @echo "==========================="
153         @echo "  $(RELEASE_URL)/$(TAR_FILE)"
154         @echo ""
155         @echo "Which can be verified with:"
156         @echo ""
157         @echo "  $(RELEASE_URL)/$(SHA1_FILE)"
158         @echo -n "  "
159         @cat releases/$(SHA1_FILE)
160         @echo ""
161         @echo "  $(RELEASE_URL)/$(GPG_FILE)"
162         @echo "  (signed by `getent passwd "$$USER" | cut -d: -f 5 | cut -d, -f 1`)"
163         @echo ""
164         @echo "What's new in fips $(VERSION)"
165         @echo "========================="
166         @sed -ne '/^[Ff]ips $(VERSION)/{n;n;b NEWS}; d; :NEWS /^===/q; {p;n;b NEWS}' < NEWS | head -n -2
167         @echo ""
168         @echo "What is fips"
169         @echo "============"
170         @echo "Fips is a program for monitoring performance of OpenGL applications"
171
172 # This is a chain of dependencies rather than a simple list simply to
173 # avoid the messages getting interleaved in the case of a parallel
174 # make invocation.
175 .PHONY: verify-source-tree-and-version
176 verify-source-tree-and-version: verify-no-dirty-code
177
178 .PHONY: verify-no-dirty-code
179 verify-no-dirty-code:
180 ifeq ($(IS_GIT),yes)
181         @printf "Checking that source tree is clean..."
182 ifneq ($(shell git ls-files -m),)
183         @echo "No"
184         @echo "The following files have been modified since the most recent git commit:"
185         @echo ""
186         @git ls-files -m
187         @echo ""
188         @echo "The release will be made from the committed state, but perhaps you meant"
189         @echo "to commit this code first? Please clean this up to make it more clear."
190         @false
191 else
192         @echo "Good"
193 endif
194 endif
195
196 .PHONY: verify-newer
197 verify-newer:
198         @echo -n "Checking that no $(VERSION) release already exists..."
199         @wget -q -O /dev/null $(RELEASE_URL)/$(TAR_FILE) ; \
200         case $$? in \
201           8) echo "Good." ;; \
202           0) echo "Ouch."; \
203              echo "Found: $(RELEASE_URL)/$(TAR_FILE)"; \
204              echo "Refusing to replace an existing release."; \
205              echo "Don't forget to update \"version\" as described in RELEASING before release." ; \
206              false ;; \
207           *) echo "An unexpected error occured"; \
208              false;; esac
209
210 # The user has not set any verbosity, default to quiet mode and inform the
211 # user how to enable verbose compiles.
212 ifeq ($(V),)
213 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
214 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
215 endif
216 # The user has explicitly enabled quiet compilation.
217 ifeq ($(V),0)
218 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
219 endif
220 # Otherwise, print the full command line.
221 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
222
223 %.o: %.c $(global_deps)
224         @mkdir -p .deps/$(@D)
225         $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
226
227 .PHONY : clean
228 clean:
229         rm -rf $(CLEAN); rm -rf .deps
230
231 .PHONY: distclean
232 distclean: clean
233         rm -rf $(DISTCLEAN)
234
235 fips_srcs = \
236         fips.c
237
238 fips_modules = $(fips_srcs:.c=.o)
239
240 fips: $(fips_modules)
241         $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS)) $^ $(FINAL_FIPS_LDFLAGS) -o $@
242
243 .PHONY: install
244 install: all
245         mkdir -p $(DESTDIR)$(prefix)/bin/
246         install fips $(DESTDIR)$(prefix)/bin/fips
247 ifeq ($(MAKECMDGOALS), install)
248         @echo ""
249         @echo "Fips is now installed to $(DESTDIR)$(prefix)"
250         @echo ""
251 endif
252
253 SRCS  := $(SRCS) $(fips_srcs)
254 CLEAN := $(CLEAN) fips $(fips_modules)
255
256 DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config
257
258 DEPS := $(SRCS:%.c=.deps/%.d)
259 DEPS := $(DEPS:%.cc=.deps/%.d)
260 -include $(DEPS)