You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

149 lines
4.2 KiB

  1. export USE_HTTP=1
  2. #export USE_HTTPS=1
  3. #export USE_FTP=1
  4. #USE_FTP_MANUAL=1
  5. DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
  6. CFLAGS=-Wall -g -D_GNU_SOURCE -DARCH_TEXT='"$(DEB_HOST_ARCH)"'
  7. templates=debian/choose-mirror-bin.templates-in
  8. ifeq (1,${USE_HTTP})
  9. CFLAGS:=$(CFLAGS) -DWITH_HTTP
  10. templates:=$(templates) debian/choose-mirror-bin.templates.http-in
  11. endif
  12. ifeq (1,${USE_HTTPS})
  13. CFLAGS:=$(CFLAGS) -DWITH_HTTPS
  14. templates:=$(templates) debian/choose-mirror-bin.templates.https-in
  15. endif
  16. ifeq (1,${USE_FTP})
  17. CFLAGS:=$(CFLAGS) -DWITH_FTP
  18. templates:=$(templates) debian/choose-mirror-bin.templates.ftp.base-in
  19. templates:=$(templates) debian/choose-mirror-bin.templates.ftp.sel-in
  20. endif
  21. ifeq (1,${USE_FTP_MANUAL})
  22. CFLAGS:=$(CFLAGS) -DWITH_FTP_MANUAL
  23. templates:=$(templates) debian/choose-mirror-bin.templates.ftp.base-in
  24. endif
  25. templates:=$(templates) debian/choose-mirror-bin.templates.both-in
  26. OBJS=$(subst .c,.o,$(wildcard *.c))
  27. BIN=choose-mirror
  28. LIBS=-ldebconfclient -ldebian-installer
  29. STRIP=strip
  30. # Derivative distributions may want to change these.
  31. MIRRORLISTURL=https://git.devuan.org/d-i/choose-mirror/raw/master/Mirrors.masterlist
  32. MASTERLIST=Mirrors.masterlist
  33. ifdef DEBUG
  34. CFLAGS:=$(CFLAGS) -DDODEBUG
  35. else
  36. CFLAGS:=$(CFLAGS) -Os -fomit-frame-pointer
  37. endif
  38. all: $(BIN) debian/choose-mirror-bin.templates
  39. ifdef MIRRORLISTURL
  40. # Freshen Mirrors.masterlist file, but allow failure.
  41. $(MASTERLIST): force-try-update
  42. if [ "$$ONLINE" != n ]; then \
  43. if wget -nv '$(MIRRORLISTURL)' -O - > $@.new && \
  44. test -s $@.new; then \
  45. mv $@.new $@; \
  46. else \
  47. rm -f $@.new; \
  48. fi; \
  49. fi
  50. force-try-update: ;
  51. check-masterlist:
  52. @if [ -d .git ] && which git >/dev/null 2>&1; then \
  53. last=`git log --format=format:%at -- $(MASTERLIST)|head -1`; \
  54. now=`date +%s`; \
  55. if [ $$((now-last)) -gt $$((60*60*24*14)) ]; then \
  56. printf "\n\n*** WARNING: $(MASTERLIST) was last committed more\n"; \
  57. printf "*** than 2 weeks ago, maybe it needs an update?"; \
  58. echo; echo; echo "You can try the following command to run a sync, and use git diff/git commit:"; \
  59. echo " make $(MASTERLIST)";\
  60. sleep 5; \
  61. fi; \
  62. fi
  63. else
  64. check-masterlist:
  65. :
  66. endif
  67. debian/iso_3166.tab:
  68. isoquery -c | cut -f 1,4 | sort >debian/iso_3166.tab
  69. debian/httplist-countries: $(MASTERLIST) debian/iso_3166.tab
  70. ./mirrorlist httplist $^
  71. debian/httpslist-countries: $(MASTERLIST) debian/iso_3166.tab
  72. ./mirrorlist httpslist $^
  73. debian/ftplist-countries: $(MASTERLIST) debian/iso_3166.tab
  74. ./mirrorlist ftplist $^
  75. debian/choose-mirror-bin.templates: $(MASTERLIST) $(templates) debian/httplist-countries debian/httpslist-countries debian/ftplist-countries debian/iso_3166.tab
  76. # Grab ISO codes from iso-codes package
  77. ./get-iso-codes
  78. # Build the templates
  79. ./mktemplates $(templates)
  80. mirrors_http.h: $(MASTERLIST) debian/iso_3166.tab
  81. if [ "$$USE_HTTP" ]; then ./mirrorlist http $^; fi
  82. mirrors_https.h: $(MASTERLIST) debian/iso_3166.tab
  83. if [ "$$USE_HTTPS" ]; then ./mirrorlist https $^; fi
  84. mirrors_ftp.h: $(MASTERLIST) debian/iso_3166.tab
  85. if [ "$$USE_FTP" ]; then ./mirrorlist ftp $^; fi
  86. choose-mirror.o: mirrors_http.h mirrors_https.h mirrors_ftp.h
  87. $(BIN): $(OBJS)
  88. $(CC) -o $(BIN) $(OBJS) $(LIBS) $(LDFLAGS)
  89. strip: $(BIN)
  90. $(STRIP) --remove-section=.comment --remove-section=.note $(BIN)
  91. # Size optimized and stripped binary target.
  92. small: CFLAGS:=-Os $(CFLAGS) -DSMALL
  93. small: clean strip debian/choose-mirror-bin.templates
  94. ls -l $(BIN)
  95. ftp: CFLAGS:=-Os -Wall -g -D_GNU_SOURCE -DWITH_FTP -DSMALL
  96. ftp: clean strip
  97. ls -l $(BIN)
  98. http: CFLAGS:=-Os -Wall -g -D_GNU_SOURCE -DWITH_HTTP -DSMALL
  99. http: clean strip
  100. ls -l $(BIN)
  101. https: CFLAGS:=-Os -Wall -g -D_GNU_SOURCE -DWITH_HTTPS -DSMALL
  102. https: clean strip
  103. ls -l $(BIN)
  104. clean:
  105. rm -f $(BIN) $(OBJS) *~ mirrors_*.h
  106. rm -f debian/templates-countries debian/httplist-countries debian/httpslist-countries debian/ftplist-countries
  107. rm -f demo demo.templates
  108. rm -rf debian/iso-codes/ debian/pobuild*/
  109. rm -f debian/iso_3166.tab
  110. reallyclean: clean
  111. rm -f debian/choose-mirror-bin.templates
  112. ifdef MIRRORLISTURL
  113. rm -f Mirrors.masterlist
  114. endif
  115. .PHONY: demo
  116. demo: choose-mirror demo.templates
  117. ln -sf choose-mirror demo
  118. DEBCONF_DEBUG=developer /usr/share/debconf/frontend ./demo
  119. demo.templates: debian/choose-mirror-bin.templates
  120. po2debconf $< > $@