# System utilities
CC = cc
CFLAGS = -Iinclude/ -Ilib/ -g -Wall -Wextra -Wpedantic
HOME = /home/trinity
PREFIX = /usr/local
RM = rm -f

all:

dist/argued:
	$(MAKE) -C argued
	cp argued/argued dist

dist/argued.1:
	cp argued/argued.1 dist

dist/battery:
	cp niceties/battery dist

dist/battery.linux:
	cp niceties/battery.linux dist

dist/battery.netbsd:
	cp niceties/battery.netbsd dist

dist/data:
	cp niceties/data dist

dist/echo:
	$(MAKE) -C echo echo
	cp echo/echo dist

dist/echo.1:
	cp echo/echo.1 dist

# i made this script to fetch icons for my grandmother and put them in icons/
# so i wouldn't have to fetch the icons for her desktop when i made her a new
# system.
# i could have downloaded all the icons and put them into a repo for her but
# this uses less space
dist/grammy:	dist/grammy.tmp/989wclz.com.png \
		dist/grammy.tmp/amazon.com.ico \
		dist/grammy.tmp/bangordailynews.com.png \
		dist/grammy.tmp/theguardian.com.png \
		dist/grammy.tmp/centralmaine.com.png \
		dist/grammy.tmp/dictionary.com.png \
		dist/grammy.tmp/google.com.jpg \
		dist/grammy.tmp/longfellowsgreenhouses.com.jpg \
		dist/grammy.tmp/mainepublic.org.png \
		dist/grammy.tmp/news.google.com.png \
		dist/grammy.tmp/newscentermaine.com.png \
		dist/grammy.tmp/pressherald.com.png \
		dist/grammy.tmp/weather.com.png
	mv dist/grammy.tmp dist/grammy
dist/grammy.tmp:
	mkdir -p dist/grammy.tmp
dist/grammy.tmp/989wclz.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/989wclz.com.png" "https://web.archive.org/web/20200629174002if_/https://989wclz.com/wp-content/themes/wclz/img/touch-icon-144.png"
dist/grammy.tmp/amazon.com.ico: dist/grammy.tmp
	curl -o "dist/grammy.tmp/amazon.com.ico" "https://web.archive.org/web/20200718050400if_/https://www.amazon.com/favicon.ico"
dist/grammy.tmp/bangordailynews.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/bangordailynews.com.png" "http://web.archive.org/web/20200721195123if_/https://i0.wp.com/bdn-data.s3.amazonaws.com/uploads/2020/06/BDN-logo_green-3-1.png"
dist/grammy.tmp/theguardian.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/theguardian.com.png" "https://web.archive.org/web/20200720041457if_/https://assets.guim.co.uk/images/favicons/fee5e2d638d1c35f6d501fa397e53329/152x152.png"
dist/grammy.tmp/centralmaine.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/centralmaine.com.png" "https://web.archive.org/web/20200720023956if_/https://multifiles.pressherald.com/uploads/sites/2/2014/06/apple-touch-icon-iphone-retina-display.png"
dist/grammy.tmp/dictionary.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/dictionary.com.png" "https://web.archive.org/web/20200719135458if_/https://www.dictionary.com/hp-assets/dcom_favicon-1bff2f1b49c077ed504e55c3649f2a4b.png"
dist/grammy.tmp/google.com.jpg: dist/grammy.tmp
	curl -o "dist/grammy.tmp/google.com.jpg" "https://web.archive.org/web/20170621105937if_/https://yt3.ggpht.com/-v0soe-ievYE/AAAAAAAAAAI/AAAAAAAAAAA/OixOH_h84Po/s900-c-k-no/photo.jpg"
dist/grammy.tmp/longfellowsgreenhouses.com.jpg: dist/grammy.tmp
	curl -o "dist/grammy.tmp/longfellowsgreenhouses.com.jpg" "https://web.archive.org/web/20200718173559im_/https://longfellowsgreenhouses.com/wp-content/uploads/2020/03/Longfellows-Logo-Light-Green.jpg"
dist/grammy.tmp/mainepublic.org.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/mainepublic.org.png" "https://d3kle7qwymxpcy.cloudfront.net/images/broadcasts/e5/8e/30457/1/c300.png"
dist/grammy.tmp/news.google.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/news.google.com.png" "https://upload.wikimedia.org/wikipedia/commons/0/0b/Google_News_icon.png"
dist/grammy.tmp/newscentermaine.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/newscentermaine.com.png" "https://web.archive.org/web/20200721190548if_/https://www.newscentermaine.com/assets/favicons/WCSH.png?ver=2.4.7.4"
dist/grammy.tmp/pressherald.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/pressherald.com.png" "https://multifiles.pressherald.com/uploads/sites/4/2014/06/apple-touch-icon-iphone-retina-display.png"
dist/grammy.tmp/weather.com.png: dist/grammy.tmp
	curl -o "dist/grammy.tmp/weather.com.png" "https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/The_Weather_Channel_logo_2005-present.svg/1200px-The_Weather_Channel_logo_2005-present.svg.png"

HOMEPAGE_FILES = homepage homepage.content propaganda/*
dist/homepage:
	mkdir -p dist/homepage.tmp
	cp $(HOMEPAGE_FILES) dist/homepage.tmp
	cd dist/homepage.tmp; sh homepage; cd ../..
	$(RM) dist/homepage.tmp/homepage dist/homepage.tmp/homepage.local
	mv dist/homepage.tmp dist/homepage
dist/homepage.tar.gz: dist/homepage
	tar cz -C dist/homepage . >dist/homepage.tar.gz

dist/ifpublic:
	cp niceties/ifpublic dist

dist/lowercase:
	$(MAKE) -C lowercase lowercase
	cp lowercase/lowercase dist

dist/peek:
	$(MAKE) -C peek
	cp peek/peek dist

dist/peek.1:
	cp peek/peek.1 dist

dist/prompt:
	$(MAKE) -C echo prompt
	cp echo/prompt dist

dist/prompt.1:
	cp echo/prompt.1 dist

dist/pschdir:
	$(MAKE) -C pschdir
	cp pschdir/pschdir dist

dist/rot:
	$(MAKE) -C rot
	cp rot/rot dist

dist/rot13:
	cp rot/rot13 dist

dist/simexec:
	$(MAKE) -C simexec
	cp simexec/simexec dist

dist/simexec.1:
	cp simexec/simexec.1 dist

dist/scrut:
	$(MAKE) -C scrut
	cp scrut/scrut dist

dist/scrut.1:
	cp scrut/scrut.1 dist

dist/sleep:
	$(MAKE) -C sleep
	cp sleep/sleep dist

dist/sleep.1:
	cp sleep/sleep.1 dist

dist/spacer.bin:
	# creates an 8GB empty file
	# that way when the alarm bells go off you can delete it to save a
	# couple minutes before the system really runs out of disk
	#
	#     512     * 16777216 = 8GB
	dd bs=512 count=16777216 </dev/zero >dist/spacer.bin

dist/str:
	$(MAKE) -C str
	cp str/str dist

dist/str.1:
	cp str/str.1 dist

dist/strcmp:
	$(MAKE) -C strcmp
	cp strcmp/strcmp dist

dist/strcmp.1:
	cp strcmp/strcmp.1 dist

dist/uppercase:
	$(MAKE) -C lowercase uppercase
	cp lowercase/uppercase dist

dist/volume:
	cp niceties/volume dist

dist/volume.netbsd:
	cp niceties/volume.netbsd dist

dist/volume.pulseaudio:
	cp niceties/volume.pulseaudio dist

dist/volume.1:
	cp niceties/volume.1 dist
