forked from ali-rantakari/icalBuddy
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
241 lines (186 loc) · 9.9 KB
/
Makefile
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# icalBuddy makefile
#
# Created by Ali Rantakari on 18 June, 2008
#
SHELL=/bin/bash
CURRDATE=$(shell date +"%Y-%m-%d")
APP_VERSION=$(shell ./icalBuddy -V)
VERSION_ON_SERVER=$(shell curl -Ss http://hasseg.org/icalBuddy/?versioncheck=y)
TEMP_DEPLOYMENT_DIR=deployment/$(APP_VERSION)
TEMP_DEPLOYMENT_ZIPFILE=$(TEMP_DEPLOYMENT_DIR)/icalBuddy-v$(APP_VERSION).zip
TEMP_DEPLOYMENT_MANFILE="deployment/man.html"
TEMP_DEPLOYMENT_L10NMANFILE="deployment/localization-man.html"
TEMP_DEPLOYMENT_CONFIGMANFILE="deployment/config-man.html"
TEMP_DEPLOYMENT_FAQFILE="deployment/faq.html"
FILES_TO_PACKAGE="$(TEMP_DEPLOYMENT_FAQFILE) icalBuddy icalBuddy.1 icalBuddyLocalization.1 icalBuddyConfig.1"
VERSIONCHANGELOGFILELOC="$(TEMP_DEPLOYMENT_DIR)/changelog.html"
GENERALCHANGELOGFILELOC="changelog.html"
SCP_TARGET=$(shell cat ./deploymentScpTarget)
DEPLOYMENT_INCLUDES_DIR="./deployment-files"
COMPILER_GCC=gcc
COMPILER_CLANG=clang
COMPILER=$(COMPILER_CLANG)
CC_WARN_OPTS=-Wall -Wextra -Wno-unused-parameter -Werror
SOURCE_FILES=icalBuddy[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*.m ANSIEscapeHelper.m HG*.m IcalBuddy*.m *+HGAdditions.m
all: icalBuddy
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# compile the binary itself
#-------------------------------------------------------------------------
icalBuddy: $(SOURCE_FILES) icalBuddy.m
@echo
@echo ---- Compiling main app:
@echo ======================================
$(COMPILER) $(ARG_DEBUG) -O3 $(CC_WARN_OPTS) -std=c99 -force_cpusubtype_ALL -mmacosx-version-min=10.5 -arch x86_64 -framework Cocoa -framework CalendarStore -framework AppKit -framework AddressBook -o $@ icalBuddy.m $(SOURCE_FILES)
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# compile test binary
#-------------------------------------------------------------------------
testIcalBuddy: $(SOURCE_FILES) icalBuddy.m calendarStoreMock/*.m
@echo
@echo ---- Compiling TEST version of main app:
@echo ======================================
$(COMPILER) $(ARG_DEBUG) -O3 -Wall -std=c99 -force_cpusubtype_ALL -mmacosx-version-min=10.5 -arch x86_64 -DUSE_MOCKED_CALENDARSTORE -framework Cocoa -framework CalendarStore -framework AppKit -framework AddressBook -o $@ icalBuddy.m calendarStoreMock/*.m $(SOURCE_FILES)
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# run clang static analyzer
#-------------------------------------------------------------------------
analyze:
@echo
@echo ---- Analyzing:
@echo ======================================
$(COMPILER_CLANG) --analyze icalBuddy.m $(SOURCE_FILES)
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# compile the test runner
#-------------------------------------------------------------------------
testRunner: $(SOURCE_FILES)
@echo
@echo ---- Compiling test runner:
@echo ======================================
$(COMPILER) $(ARG_DEBUG) -O3 -Wall -std=c99 -force_cpusubtype_ALL -mmacosx-version-min=10.5 -arch x86_64 -DUSE_MOCKED_CALENDARSTORE -framework Cocoa -framework CalendarStore -framework AppKit -framework AddressBook -o $@ testRunner.m $(SOURCE_FILES) calendarStoreMock/*.m tests/unit/*.m
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# write usage output to text file
#-------------------------------------------------------------------------
usage.txt: icalBuddy
@echo
@echo ---- generating usage.txt:
@echo ======================================
./icalBuddy > usage.txt
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# generate main man page from POD syntax file
#-------------------------------------------------------------------------
icalBuddy.1: icalBuddy.pod
@echo
@echo ---- Generating manpage from POD file:
@echo ======================================
pod2man --section=1 --release="$(APP_VERSION)" --center="icalBuddy" --date="$(CURRDATE)" icalBuddy.pod > icalBuddy.1
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# generate configuration man page from POD syntax file
#-------------------------------------------------------------------------
icalBuddyConfig.1: icalBuddyConfig.pod
@echo
@echo ---- Generating config manpage from POD file:
@echo ======================================
pod2man --section=1 --release="$(APP_VERSION)" --center="icalBuddy configuration" --date="$(CURRDATE)" icalBuddyConfig.pod > icalBuddyConfig.1
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# generate localization man page from POD syntax file
#-------------------------------------------------------------------------
icalBuddyLocalization.1: icalBuddyLocalization.pod
@echo
@echo ---- Generating localization manpage from POD file:
@echo ======================================
pod2man --section=1 --release="$(APP_VERSION)" --center="icalBuddy localization" --date="$(CURRDATE)" icalBuddyLocalization.pod > icalBuddyLocalization.1
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# generate FAQ HTML
#-------------------------------------------------------------------------
deployment/faq.html: faq.markdown faq-style.css
@echo
@echo ---- Generating HTML from FAQ:
@echo ======================================
echo "<html><head><title>icalBuddy FAQ</title>" > $(TEMP_DEPLOYMENT_FAQFILE)
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" >> $(TEMP_DEPLOYMENT_FAQFILE)
echo "<style type='text/css'>" >> $(TEMP_DEPLOYMENT_FAQFILE)
cat faq-style.css >> $(TEMP_DEPLOYMENT_FAQFILE)
echo "</style>" >> $(TEMP_DEPLOYMENT_FAQFILE)
echo "</head><body><div id='main'>" >> $(TEMP_DEPLOYMENT_FAQFILE)
echo "<h1>icalBuddy FAQ</h1> <hr /> <h2>Table Of Contents</h2>" >> $(TEMP_DEPLOYMENT_FAQFILE)
utils/discount -T -f +toc faq.markdown >> $(TEMP_DEPLOYMENT_FAQFILE)
echo "</div></body></html>" >> $(TEMP_DEPLOYMENT_FAQFILE)
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# generate documentation
#-------------------------------------------------------------------------
docs: icalBuddy.1 deployment/faq.html icalBuddyLocalization.1 icalBuddyConfig.1 usage.txt
@echo
@echo ---- Generating HTML from manpages:
@echo ======================================
utils/manserver.pl icalBuddy.1 | sed -e 's/<BODY .*>/<BODY>/' > $(TEMP_DEPLOYMENT_MANFILE)
utils/manserver.pl icalBuddyLocalization.1 | sed -e 's/<BODY .*>/<BODY>/' > $(TEMP_DEPLOYMENT_L10NMANFILE)
utils/manserver.pl icalBuddyConfig.1 | sed -e 's/<BODY .*>/<BODY>/' > $(TEMP_DEPLOYMENT_CONFIGMANFILE)
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# make release package (prepare for deployment)
#-------------------------------------------------------------------------
package: icalBuddy docs
@echo
@echo ---- Preparing for deployment:
@echo ======================================
# create zip archive
mkdir -p $(TEMP_DEPLOYMENT_DIR)
echo "-D -j $(TEMP_DEPLOYMENT_ZIPFILE) $(FILES_TO_PACKAGE)" | xargs zip
cd "$(DEPLOYMENT_INCLUDES_DIR)"; echo "-g -x *.DS_Store -R ../$(TEMP_DEPLOYMENT_ZIPFILE) *" | xargs zip
# if changelog doesn't already exist in the deployment dir
# for this version, get 'general' changelog file from root if
# one exists, and if not, create an empty changelog file
@( if [ ! -e $(VERSIONCHANGELOGFILELOC) ];then\
if [ -e $(GENERALCHANGELOGFILELOC) ];then\
cp $(GENERALCHANGELOGFILELOC) $(VERSIONCHANGELOGFILELOC);\
echo "Copied existing changelog.html from project root into deployment dir - opening it for editing";\
else\
echo -e "<ul>\n <li></li>\n</ul>\n" > $(VERSIONCHANGELOGFILELOC);\
echo "Created new empty changelog.html into deployment dir - opening it for editing";\
fi; \
else\
echo "changelog.html exists for $(APP_VERSION) - opening it for editing";\
fi )
@open -a Fraise $(VERSIONCHANGELOGFILELOC)
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
# deploy to server
#-------------------------------------------------------------------------
deploy: package
@echo
@echo ---- Deploying to server:
@echo ======================================
@echo "Checking latest version number vs. current version number..."
@( if [ "$(VERSION_ON_SERVER)" != "$(APP_VERSION)" ];then\
echo "Latest version on server is $(VERSION_ON_SERVER). Uploading $(APP_VERSION).";\
else\
echo "NOTE: Current version exists on server: ($(APP_VERSION)).";\
fi;\
echo "Press enter to continue uploading to server or Ctrl-C to cancel.";\
read INPUTSTR;\
scp -r $(TEMP_DEPLOYMENT_DIR) $(TEMP_DEPLOYMENT_MANFILE) $(TEMP_DEPLOYMENT_L10NMANFILE) $(TEMP_DEPLOYMENT_CONFIGMANFILE) $(TEMP_DEPLOYMENT_FAQFILE) usage.txt $(SCP_TARGET); )
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
clean:
@echo
@echo ---- Cleaning up:
@echo ======================================
-rm -Rf icalBuddy
-rm -Rf icalBuddy.1
-rm -Rf testIcalBuddy
-rm -Rf testRunner
-rm -Rf icalBuddy*.plist
-rm -Rf IcalBuddy*.plist
-rm -Rf HG*.plist
-rm -Rf ANSIEscape*.plist
-rm -Rf icalBuddyConfig.1
-rm -Rf icalBuddyLocalization.1
-rm -Rf deployment/*