Merge remote-tracking branch 'origin/master' into cooking
[xonotic/gmqcc.git] / distro / Makefile
1 DROPBOX := dropbox_uploader.sh
2 UNAME   := $(shell uname -m)
3 DOWNLOAD:= ../doc/html/download.c
4 BRANCH  := $(shell git rev-parse --abbrev-ref HEAD)
5 ifneq ($(shell uname -m), x86_64)
6     $(error Cannot build packages without an x86_64 capable CPU)
7 endif
8
9 .NOTPARALLEL: base
10 .NOTPARALLEL: upload
11
12 HEADER=\e[5;32;40m
13 RESET=\e[0;37;40m
14 INFO=\e[5;33;40m
15
16 base:
17         @echo -e "\n$(HEADER)Building Debian packages ...$(RESET)"
18         @echo -e "   $(INFO)=> building 64-bit package$(RESET)"
19         @$(MAKE) -C deb/ >/dev/null
20         @echo -e "   $(INFO)=> building 32-bit package$(RESET)"
21         @$(MAKE) -C deb/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
22         
23         @echo -e "\n$(HEADER)Building ArchLinux packages ...$(RESET)"
24         @echo -e "   $(INFO)=> building 64-bit package$(RESET)"
25         @$(MAKE) -C archlinux/this/ >/dev/null
26         @echo -e "   $(INFO)=> building 32-bit package$(RESET)"
27         @$(MAKE) -C archlinux/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
28
29         @echo -e "\n$(HEADER)Building ArchBSD packages ...$(RESET)"
30         @echo -e "   $(INFO)=> building 64-bit package$(RESET)"
31         @$(MAKE) -C archbsd/this/ >/dev/null
32         @echo -e "   $(INFO)=> building 32-bit package$(RESET)"
33         @$(MAKE) -C archbsd/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
34         
35         @echo -e "\n$(HEADER)Building Slackware packages ...$(RESET)"
36         @echo -e "   $(INFO)=> building 64-bit package$(RESET)"
37         @$(MAKE) -C slackware/this/ >/dev/null
38         @echo -e "   $(INFO)=> building 32-bit package$(RESET)"
39         @$(MAKE) -C slackware/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null
40
41         @echo -e "\n$(HEADER)Building Fedora packages ...$(RESET)"
42         @echo -e "   $(INFO)=> building 64-bit package$(RESET)"
43         @$(MAKE) -C fedora/this/ >/dev/null
44
45         @echo -e "\n\$(HEADER)Building Windows packages ...$(RESET)"
46         @echo -e "   $(INFO)=> building 64-bit package$(RESET)"
47         @$(MAKE) -C win64/ >/dev/null
48         @echo -e "   $(INFO)=> building 32-bit package$(RESET)"
49         @$(MAKE) -C win32/ >/dev/null
50         
51         @rm -rf pkgs/
52         @mkdir pkgs/
53         @mv deb/*.deb ./pkgs/
54         @mv archlinux/this/*pkg.tar.xz ./pkgs/
55         @mv archbsd/this/*pkg.tar.xz ./pkgs/
56         @mv win32/*.zip ./pkgs/
57         @mv win64/*.zip ./pkgs/
58         @mv slackware/this/*.txz ./pkgs/
59         @mv fedora/this/*.rpm ./pkgs/
60         
61         @echo -e "\n\n$(HEADER)Completed:$(RESET)"
62         @find ./pkgs/ -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\|rpm\)" -exec echo -e "  $(INFO)=>$(RESET) {}" \;
63         
64 upload:
65         @echo "APPKEY:76vh3q42hnvmzm3" > dropbox_config
66         @echo "APPSECRET:tmeecht2cmh72xa" >> dropbox_config
67         @echo "ACCESS_LEVEL:sandbox" >> dropbox_config
68         @echo "OAUTH_ACCESS_TOKEN:w0bxzf0dft8edfq" >> dropbox_config
69         @echo "OAUTH_ACCESS_TOKEN_SECRET:9vosx7x8gy4kgjk" >> dropbox_config
70         @wget -q "http://raw.github.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh"
71         @chmod +x dropbox_uploader.sh
72         @sed -i -e "s/~\/.dropbox_uploader/.\/dropbox_config/g" $$(basename $(DROPBOX))
73         @find ./pkgs -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\|rpm\)" -exec ./$$(basename $(DROPBOX)) upload {} \;
74         @rm dropbox_config dropbox_uploader.sh
75
76 website:
77         $(CC) $(DOWNLOAD) -o html.gen
78         @./html.gen ../
79         @rm html.gen
80         @git stash
81         @git checkout gh-pages
82         @rm -f ../download.html
83         @mv -f download.html ../download.html
84         @cd ..; git add download.html; git commit -m 'update download page'; git push origin gh-pages;
85         @git checkout $(BRANCH)
86         @git stash apply
87
88 clean:
89         @rm -rf pkgs/
90         @rm -f *.html
91
92 all: base upload