File: Makefile

package info (click to toggle)
choose-mirror 2.135
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,636 kB
  • sloc: ansic: 792; perl: 201; sh: 162; makefile: 136
file content (153 lines) | stat: -rw-r--r-- 4,450 bytes parent folder | download | duplicates (3)
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
142
143
144
145
146
147
148
149
150
151
152
153
export USE_HTTP=1
export USE_HTTPS=1
#export USE_FTP=1
USE_FTP_MANUAL=1

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

CFLAGS?=-g
CFLAGS+=-Wall -D_GNU_SOURCE -DARCH_TEXT='"$(DEB_HOST_ARCH)"'
templates=debian/choose-mirror-bin.templates-in

ifeq (1,${USE_HTTP})
CFLAGS:=$(CFLAGS) -DWITH_HTTP
templates:=$(templates) debian/choose-mirror-bin.templates.http-in
endif
ifeq (1,${USE_HTTPS})
CFLAGS:=$(CFLAGS) -DWITH_HTTPS
templates:=$(templates) debian/choose-mirror-bin.templates.https-in
endif
ifeq (1,${USE_FTP})
CFLAGS:=$(CFLAGS) -DWITH_FTP
templates:=$(templates) debian/choose-mirror-bin.templates.ftp.base-in
templates:=$(templates) debian/choose-mirror-bin.templates.ftp.sel-in
endif
ifeq (1,${USE_FTP_MANUAL})
CFLAGS:=$(CFLAGS) -DWITH_FTP_MANUAL
templates:=$(templates) debian/choose-mirror-bin.templates.ftp.base-in
endif
templates:=$(templates) debian/choose-mirror-bin.templates.both-in

OBJS=$(subst .c,.o,$(wildcard *.c))
BIN=choose-mirror
LIBS=-ldebconfclient -ldebian-installer
STRIP=strip

# Derivative distributions may want to change these.
MIRRORLISTURL=https://mirror-master.debian.org/status/Mirrors.masterlist
MASTERLIST=Mirrors.masterlist

ifdef DEBUG
CFLAGS:=$(CFLAGS) -DDODEBUG
else
CFLAGS:=$(CFLAGS) -Os -fomit-frame-pointer
endif

all: $(BIN) debian/choose-mirror-bin.templates

ifdef MIRRORLISTURL
# Freshen Mirrors.masterlist file, but allow failure.
$(MASTERLIST): force-try-update
	if [ "$$ONLINE" != n ]; then \
		if wget -nv '$(MIRRORLISTURL)' -O - > $@.new && \
		   test -s $@.new; then \
        		mv $@.new $@; \
		else \
			rm -f $@.new; \
		fi; \
	fi
force-try-update: ;

check-masterlist:
	@if [ -d .git ] && which git >/dev/null 2>&1; then \
		last=`git log --format=format:%at -- $(MASTERLIST)|head -1`; \
		now=`date +%s`; \
		if [ $$((now-last)) -gt $$((60*60*24*14)) ]; then \
			printf "\n\n*** WARNING: $(MASTERLIST) was last committed more\n"; \
			printf "*** than 2 weeks ago, maybe it needs an update?"; \
			echo; echo; echo "You can try the following command to run a sync, and use git diff/git commit:"; \
			echo "   make $(MASTERLIST)";\
			sleep 5; \
		fi; \
	fi
else
check-masterlist:
	:
endif

debian/iso_3166.tab:
	isoquery -c | cut -f 1,4 | sort >debian/iso_3166.tab

debian/httplist-countries: $(MASTERLIST) debian/iso_3166.tab
	./mirrorlist httplist $^

debian/httpslist-countries: $(MASTERLIST) debian/iso_3166.tab
	./mirrorlist httpslist $^

debian/ftplist-countries: $(MASTERLIST) debian/iso_3166.tab
	./mirrorlist ftplist $^

debian/port_architecture: $(MASTERLIST) debian/iso_3166.tab
	./mirrorlist port_architecture $^

debian/choose-mirror-bin.templates: $(MASTERLIST) $(templates) debian/httplist-countries debian/httpslist-countries debian/ftplist-countries debian/iso_3166.tab debian/port_architecture
	# Grab ISO codes from iso-codes package
	./get-iso-codes
	# Build the templates
	./mktemplates $(templates)

mirrors_http.h: $(MASTERLIST) debian/iso_3166.tab
	if [ "$$USE_HTTP" ]; then ./mirrorlist http $^; fi

mirrors_https.h: $(MASTERLIST) debian/iso_3166.tab
	if [ "$$USE_HTTPS" ]; then ./mirrorlist https $^; fi

mirrors_ftp.h: $(MASTERLIST) debian/iso_3166.tab
	if [ "$$USE_FTP" ]; then ./mirrorlist ftp $^; fi

choose-mirror.o: mirrors_http.h mirrors_https.h mirrors_ftp.h

$(BIN): $(OBJS)
	$(CC) -o $(BIN) $(OBJS) $(LIBS) $(LDFLAGS)

strip: $(BIN)
	$(STRIP) --remove-section=.comment --remove-section=.note $(BIN)

# Size optimized and stripped binary target.
small: CFLAGS:=-Os $(CFLAGS) -DSMALL
small: clean strip debian/choose-mirror-bin.templates
	ls -l $(BIN)

ftp: CFLAGS:=-Os -Wall -g -D_GNU_SOURCE -DWITH_FTP -DSMALL
ftp: clean strip
	ls -l $(BIN)

http: CFLAGS:=-Os -Wall -g -D_GNU_SOURCE -DWITH_HTTP -DSMALL
http: clean strip
	ls -l $(BIN)

https: CFLAGS:=-Os -Wall -g -D_GNU_SOURCE -DWITH_HTTPS -DSMALL
https: clean strip
	ls -l $(BIN)

clean:
	rm -f $(BIN) $(OBJS) *~ mirrors_*.h
	rm -f debian/templates-countries debian/httplist-countries debian/httpslist-countries debian/ftplist-countries
	rm -f demo demo.templates
	rm -rf debian/iso-codes/ debian/pobuild*/
	rm -f debian/iso_3166.tab
	rm -f debian/port_architecture

reallyclean: clean
	rm -f debian/choose-mirror-bin.templates
ifdef MIRRORLISTURL
	rm -f Mirrors.masterlist
endif

.PHONY: demo
demo: choose-mirror demo.templates
	ln -sf choose-mirror demo
	DEBCONF_DEBUG=developer /usr/share/debconf/frontend ./demo

demo.templates: debian/choose-mirror-bin.templates
	po2debconf $< > $@