summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: f1bfc117cd924112c6669b1abb07a95929be79fe (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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
######################################################################
#  Generate HTML pages from SGML docs.
#  ==================================
#
#  You may need to define (if the default location does not
#  correspond to your installation) the SGML_TOOL variable
#  (using SGML_TOOL=<path-to-sgml2html> on the make command
#  line).
#
######################################################################
#
#  FILTER_IMAGES is deprecated, use TARGET_TYPE instead. TARGET_TYPE
#  is used to defined the target for the doc to build: either with
#  images and directory names as file prefix for the web site 
#  (TARGET_TYPE=WEB) or without any screenshot and with file names to
#  fit the Sylpheed source code file name (to generate the doc to
#  include in the Sylpheed distribution).
#  TARGET_TYPE can be 'WEB' or any other value (including the null
#  string).
#  The default is 'WEB', so if you do not provide anything on the make
#  command line, the web site version is built.
#
######################################################################
#
#  To only build one type of doc (manual, faq,...) define the
#  ALL_TYPES list. For example: 
#  make ALL_TYPES=manual
#  should only build the HTML pages for the manual.
#  To only build for one language, define the LANGS variable:
#  make LANGS="fr de"
#  should build the french and german docs.
#  Combine the two variables to build one type of doc for
#  selected languages:
#  make ALL_TYPES=faq LANGS=es
#  should only build the spanish faq.
#
######################################################################
#
# $Log: Makefile,v $
# Revision 1.4  2003/03/12 20:10:26  fbarriere
# Added the use of the zh-sgmltools for the chinese doc.
#
# Revision 1.3  2002/08/27 19:35:36  fbarriere
# Changed FILTER_IMAGE, added the TARGET_TYPE switch, added packages generation part.
#
# Revision 1.2  2002/03/30 21:24:00  fbarriere
# Modified to build the HTML directory locally (when launched from
# a sub-directory), corrected the image filter (this one should
# work in all cases).
#
# Revision 1.1  2002/03/20 21:17:00  fbarriere
# New and unique Makefile for all the docs.
#
######################################################################

ifeq ($(LANG1), zh_TW.Big5)
	SGML_TOOL     := /usr/local/bin/bg5sgml2html
	SGML_TOOL_OPT := 
	#SGML_TOOL_OPT := --imagebuttons
else
	SGML_TOOL     := /usr/bin/sgml2html
	SGML_TOOL_OPT := --language=$(LANG1)
	#SGML_TOOL_OPT := --imagebuttons
endif

#
#  Final result type: WEB (with images and original names),
#  or any other value for a version using he file names
#  that fits the Sylpheed code and without the images.
#
TARGET_TYPE   := WEB

#
#  Derive some settings from the TARGET_TYPE:
#
ifeq ($(TARGET_TYPE), WEB)
	FILTER_IMAGES :=
	TARGET_NAME   := $(DOC_TYPE)
else
	FILTER_IMAGES := YES_MY_LORD
	ifeq ($(DOC_TYPE), manual)
		TARGET_NAME   := sylpheed
	else
		ifeq ($(DOC_TYPE), faq)
			TARGET_NAME   := sylpheed-faq
		else
			TARGET_NAME   := $(DOC_TYPE)
		endif
	endif
endif

#
#  Some usual shell commands with some arguments...
#
REMOVE        := /bin/rm -rf 
COPY          := /bin/cp -r 
MAKEDIR       := /bin/mkdir -p 
CAT           := /bin/cat 
TAR_CREATE    := /bin/tar cvfz 

TAR_SUFFIX    := tar.gz

# ####################################################
#  Edits under this point are not recommended.
# ####################################################
#
#  Well, sounds like the voice of the master, in fact,
#  the settings above this line are very specific to
#  your installation/configuration, while the rest
#  of the file contains some variables that are supposed
#  to be defined automatically and typical makefile
#  targets:sources and commands lines...
#  Don't be afraid and feel free to edit anything
#  you want under this line to make it work for you!
# ####################################################

#
#  Some basic settings: the date, some directories
#  and names often used in the target or source
#  parts. Defined here, 'cause it makes changes easier,
#  and allows their definition on the make command line
#  to override the values defined in this file.
#
TODAY         := $(shell date "+%d%m%Y")

HERE          := $(shell pwd)
ROOT_DIR      := $(HERE)
PACKAGE_DIR   := $(ROOT_DIR)/../packages
HTML_DIR      := $(ROOT_DIR)/HTML/$(DOC_TYPE)
SHOTS_DIR     := snapshots

#
#  Sed command file used to filter the images:
#
SED_CMD_FILE  := $(ROOT_DIR)/tools/filter_images.sed

#
#  Defines the list of languages to process.
#
LANG_tmp      := $(shell ls)
FILTER_OUT    := CVS Makefile HTML tools packages

ALL_TYPES     := $(filter-out $(FILTER_OUT), $(LANG_tmp))
LANGS         := $(filter-out $(FILTER_OUT), $(LANG_tmp))

#
#  List the source files, count the number of sections
#  and generate the sections number sequence. A complicated
#  GNU make + shell part just to count from 1 to the
#  number of sections of the SGML source. Looks like there
#  should be a better solution...
#
ifneq ($(LANG1), )
   SOURCE_FILES  := $(shell ls $(LANG1)/*.sgml)
   ifneq ($(FILTER_IMAGES), )
      SHOTS_tmp     :=
      SCREENSHOTS   :=
   else
      SHOTS_tmp     := $(shell ls $(LANG1)/$(SHOTS_DIR))
      SCREENSHOTS   := $(shell ls $(LANG1)/$(SHOTS_DIR)/*.png)
   endif
endif

ifneq ($(SOURCE_FILES), )
   SECTION_NUM   := $(shell /bin/cat $(SOURCE_FILES) | /bin/grep -c -i "<sect>")
   FILE_PREFIX   := $(basename $(notdir $(SOURCE_FILES)))
   NUM_SEQUENCE  := $(shell \
      index=1;\
      while [ $$index -le $(SECTION_NUM) ];\
      do\
         printf "%3d" $$index | /bin/sed 's/ /0/g' | /bin/sed 's/^/ /';\
         index=$$[$$index + 1];\
      done;\
   )
   html_doc_TARGETS := $(HTML_DIR)/$(LANG1)/$(TARGET_NAME).sgml $(addprefix $(HTML_DIR)/, $(SCREENSHOTS))
endif

#
#  Defines the SGML filter: when filtering images, remove them
#  while generating the complete SGML file.
#
ifneq ($(FILTER_IMAGES), )
   FILTER := /bin/sed -f $(SED_CMD_FILE) | /bin/sed -e '/<REMOVE_ME>/,/<\/REMOVE_ME>/d'
else
   FILTER := /usr/bin/tee 
endif


#
#  Top level targets: then propagate the make for each
#  document type (manual, faq,...), then for each language.
#

all: all_docs prep

prep:
	@ $(MAKEDIR) $(HTML_DIR) $(PACKAGE_DIR)

all_docs:
	@ for ONE_TYPE in $(ALL_TYPES);\
	do \
		echo "### Making all_langs in $$ONE_TYPE...";\
		$(MAKE) \
			-C $$ONE_TYPE \
			-f $(ROOT_DIR)/Makefile \
			DOC_TYPE=$$ONE_TYPE \
			ROOT_DIR=$(ROOT_DIR) \
			all_langs;\
	done;

all_langs:
	@ for ONE_LANG in $(LANGS);\
	do \
		echo "###### Making html_doc in $$ONE_LANG...";\
		$(MAKE) \
			-f $(ROOT_DIR)/Makefile \
			LANG1=$$ONE_LANG \
			DOC_TYPE=$(DOC_TYPE) \
			ROOT_DIR=$(ROOT_DIR) \
			html_doc ;\
	done;

html_doc: $(html_doc_TARGETS)

$(HTML_DIR)/$(LANG1)/$(TARGET_NAME).sgml: $(SOURCE_FILES)
	@ echo "######### Building $(HTML_DIR)/$(LANG1)/$(TARGET_NAME).sgml"
	@ $(MAKEDIR) $(HTML_DIR)/$(LANG1)
	@ $(CAT) $(SOURCE_FILES) | $(FILTER) > $(HTML_DIR)/$(LANG1)/$(TARGET_NAME).sgml
	@ echo "######### Building html file..."
	@ cd $(HTML_DIR)/$(LANG1); $(SGML_TOOL) $(SGML_TOOL_OPT) $@; cd $(HERE)

$(addprefix $(HTML_DIR)/, $(SCREENSHOTS)): $(HTML_DIR)/$(LANG1)/$(SHOTS_DIR)/%.png: $(LANG1)/$(SHOTS_DIR)/%.png
	@ if [ ! -d $(HTML_DIR)/$(LANG1)/$(SHOTS_DIR) ];\
	then\
		echo "######### Building $(HTML_DIR)/$(LANG1)/$(SHOTS_DIR)";\
		$(MAKEDIR) $(HTML_DIR)/$(LANG1)/$(SHOTS_DIR);\
	fi;
	@ echo "######### Importing: $<"
	@ $(COPY) $< $@

#
#  Build tar packages of the docs:
#

packages:
	@ for ONE_TYPE in $(ALL_TYPES);\
	do \
		echo "### Making packages for $$ONE_TYPE...";\
		$(MAKE) \
			-f $(ROOT_DIR)/Makefile \
			-C $(HTML_DIR)/$$ONE_TYPE \
			DOC_TYPE=$$ONE_TYPE \
			ROOT_DIR=$(ROOT_DIR) \
			all_package;\
	done;

all_package:
	@ for ONE_LANG in $(LANGS);\
	do \
		echo "###### Making package in $(DOC_TYPE)/$$ONE_LANG...";\
		$(MAKE) \
			-f $(ROOT_DIR)/Makefile \
			-C $(HTML_DIR)/$$ONE_TYPE/$$ONE_LANG \
			LANG1=$$ONE_LANG \
			DOC_TYPE=$(DOC_TYPE) \
			ROOT_DIR=$(ROOT_DIR) \
			package ;\
	done;

package:
	@ echo "######### Building package"
	@ $(TAR_CREATE) $(PACKAGE_DIR)/sylpheeddoc_$(DOC_TYPE)_$(LANG1)_$(TODAY).$(TAR_SUFFIX) -C $(HERE) .


# ####################################################
#
#  Usual clean target:
#
clean:
	@ for ONE_TYPE in $(ALL_TYPES);\
	do \
		echo "### Making html_clean in $$ONE_TYPE...";\
		$(MAKE) \
			-C $$ONE_TYPE \
			-f $(ROOT_DIR)/Makefile \
			DOC_TYPE=$$ONE_TYPE \
			ROOT_DIR=$(ROOT_DIR) \
			html_clean;\
	done;
	- $(REMOVE) $(PACKAGE_DIR)/*

html_clean:
	- $(REMOVE) $(HTML_DIR)