libamxrt  0.4.2
Ambiorix Run Time Library
makefile
Go to the documentation of this file.
1 include ../../makefile.inc
2 
3 ALIEN = $(shell which alien)
4 FAKEROOT = $(shell which fakeroot)
5 
6 NOW = $(shell date +"%a, %d %b %Y %H:%M:%S %z")
7 PKGDIR = ../../output/$(MACHINE)/
8 DEBDIR = $(PKGDIR)$(COMPONENT)-$(VERSION)/debian
9 PACKAGE_TAR_GZ = $(COMPONENT)-$(VERSION).tar.gz
10 LOG = $(shell $(GIT) log $$($(GIT) describe --tags | cut -d'-' -f1)..HEAD)
11 ARCHITECTURE = $(shell dpkg-architecture | grep DEB_TARGET_ARCH= | cut -d'=' -f2)
12 
13 PACKAGE_DEB = $(COMPONENT)_$(VERSION)_$(ARCHITECTURE).deb
14 
15 AFLAGS = -d -k --fixperms --test --description="JSON Reader/generation - JSON string variant" \
16  --version="$(VERSION)" --target="$(ARCHITECTURE)" -g -v
17 
18 # helper functions - used in multiple targets
19 # 1 - destination dir
20 # 2 - filename
21 define create_changelog
22  @$(ECHO) "Generating debian changelog from git log"
23  $(ECHO) "$(COMPONENT) ($(VERSION)) unstable; urgency=medium" > $(1)/$(2)
24  $(ECHO) "" >> $(1)/$(2)
25  $(GIT) log --pretty=format:" * %s" $$($(GIT) describe --tags | grep -v "merge" | cut -d'-' -f1)..HEAD >> $(1)/$(2)
26  $(ECHO) "" >> $(1)/$(2)
27  $(ECHO) "" >> $(1)/$(2)
28  $(GIT) log --pretty=format:" -- %an <%ae> $(NOW)" -1 >> $(1)/$(2)
29  $(ECHO) "" >> $(1)/$(2)
30  $(ECHO) "" >> $(1)/$(2)
31  $(CAT) changelog >> $(1)/$(2)
32 endef
33 
34 all: $(PKGDIR)$(PACKAGE_DEB)
35  $(INSTALL) -m 0644 $(PKGDIR)$(PACKAGE_DEB) ../../
36 
37 $(PKGDIR)$(PACKAGE_DEB): $(DEBDIR)/ changelog
38  @$(ECHO) "Install debian control files"
39  $(INSTALL) -m 0644 control $(DEBDIR)
40  $(INSTALL) -m 0644 copyright $(DEBDIR)
41  $(INSTALL) -m 0644 triggers $(DEBDIR)
42  $(INSTALL) -m 0644 compat $(DEBDIR)
43  $(INSTALL) -m 0644 rules $(DEBDIR)
44  $(ECHO) "Build debian package"
45  cd $(DEBDIR)/.. && $(FAKEROOT) make -f debian/rules binary
46 
47 changelog: $(DEBDIR)/
48 ifneq ($(LOG),)
49  $(call create_changelog,$(DEBDIR),changelog)
50 else
51  $(INSTALL) -m 0644 changelog $(DEBDIR)
52 endif
53 
54 $(DEBDIR)/: $(PKGDIR)$(PACKAGE_TAR_GZ)
55  rm -rf $(PKGDIR)/$(COMPONENT)-$(VERSION)
56  cd $(PKGDIR) && $(FAKEROOT) $(ALIEN) $(AFLAGS) $(PACKAGE_TAR_GZ)
57 
58 update_changelog:
59  $(call create_changelog,.,changelog.tmp)
60  mv changelog.tmp changelog
61 
62 .PHONY: all changelog update_changelog