summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/LinHES-timezone/Makefile
blob: d543638cd3de8e326b7c0c7dc3b9ef80a44a55e7 (plain)
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
all: linhes_timezone

clean:
	rm -Rf tables maps \
	WorldTZ.mdb WorldTZ.mfd WorldTZ.mas WorldTZ.mws WorldTZ_readme.txt map_data.txt \
	extract_map_data create_map_include linhes_timezone timezone_map.h

#WorldTZ.mdb WorldTZ.mfd : WorldTZ_102.zip
#	unzip  WorldTZ_102.zip ; touch WorldTZ.mdb WorldTZ.mfd 

tables/AttrDesc : WorldTZ.mdb
	mkdir -p tables
	for table in $$(mdb-tables WorldTZ.mdb) ; do mdb-export WorldTZ.mdb $$table > tables/$$table ; done
	sed -i 's/ //g' tables/AttrDesc # Fix TZ corruption.
	echo 1254 >> tables/11001 # Add Central African Republic to the UTC+1 borders.
	grep -v ^7867$$ tables/11017 > tables/11017.tmp ; mv tables/11017.tmp tables/11017 # Remove WA from UTC+9
	grep -v ^7866$$ tables/11017 > tables/11017.tmp ; mv tables/11017.tmp tables/11017 # Remove WA/SA border from UTC+9
	echo 7867 >> tables/11016 # Put WA in UTC+8 

map_data.txt : extract_map_data WorldTZ.mfd
	./extract_map_data > map_data.txt
	
extract_map_data : extract_map_data.c
	cc --std=c99 -o extract_map_data -lm extract_map_data.c

maps : map_data.txt tables/AttrDesc
	mkdir maps
	for zone in $$(cat tables/AttrDesc | grep 110 | grep -v 11000 | grep -v 11020 | cut -d ',' -f 1) ; \
	do \
	  offset=$$(grep $$zone tables/AttrDesc | cut -d '"' -f 2 | sed 's/+//g' ) ; \
	  echo $$offset >> maps/zones ; \
	  boundary=boundary$$offset; \
	  echo $$boundary ; \
	  for section in $$(cat tables/$$zone) ; do grep "^$$section," map_data.txt >> maps/$$boundary ; done ; \
	done ; \
	for i in `cat tables/U8000 | grep -v ObjID | cut -d '"' -f 2 ` ; do \
	  echo i=$$i ; \
	  zone=$$(grep "^\\\"$$i\\\"," tables/U8000 | cut -d '"' -f 4) ; \
	  echo zone=$$zone ; \
	  tz_name=$$(grep "^\\\"$$i\\\"," tables/U7000 | cut -d '"' -f 4) ; \
	  echo tz_name=$$tz_name ; \
          tz_lat=$$(grep "^$$i," tables/U5000 | cut -d ',' -f 2) ; \
	  echo tz_lat=$$tz_lat ; \
  	  tz_lon=$$(grep "^$$i," tables/U6000 | cut -d ',' -f 2) ; \
	  echo tz_lon=$$tz_lon ; \
	  echo $$tz_lat $$tz_lon $$tz_name >> maps/places$$zone ; \
	done ;\
	for places in maps/places* ; do \
	  sort -g -r $$places > $$places.sorted ; mv $$places.sorted $$places ; \
	done ; \
	sort -g maps/zones > maps/zones.sorted
	cat Tux.csv >> maps/boundary14

./create_map_include : create_map_include.c maps
	cc -lm --std=gnu99 -o ./create_map_include create_map_include.c

timezone_map.h : ./create_map_include
	./create_map_include > timezone_map.h

linhes_timezone : linhes_timezone.c timezone_map.h
	cc --std=gnu99 -O3 -pthread -lXt -llirc_client -lm -o linhes_timezone linhes_timezone.c