@@ -33,27 +33,26 @@ MANPAGE_OUT = _$(MANPAGE)
33
33
FUNC_STYLE := "() {"
34
34
35
35
ifneq ($(wildcard config.mak) ,)
36
- include config.mak
36
+ include config.mak
37
37
endif
38
38
39
39
manpage_section = $(subst .,,$(suffix $(MANPAGE ) ) )
40
40
function_createconf := $(FUNCS_DIR ) /_createconf.sh
41
41
function_awklib := $(FUNCS_DIR ) /_awklib.sh
42
42
43
43
ifneq ($(wildcard $(CONF_DIR ) /* ) ,)
44
- include_createconf = $(function_createconf )
45
- conf_dirs = $(shell find $(CONF_DIR ) -type d)
46
- conf_files = $(shell find $(CONF_DIR ) -type f)
44
+ include_createconf = $(function_createconf )
45
+ conf_dirs = $(shell find $(CONF_DIR ) -type d)
46
+ conf_files = $(shell find $(CONF_DIR ) -type f)
47
47
else
48
- $(shell rm -f $(function_createconf))
48
+ $(shell rm -f $(function_createconf))
49
49
endif
50
50
51
51
ifneq ($(wildcard $(AWK_DIR ) /* ) ,)
52
-
53
- include_awklib = $(function_awklib )
54
- awk_files = $(wildcard $(AWK_DIR ) /* )
52
+ include_awklib = $(function_awklib )
53
+ awk_files = $(wildcard $(AWK_DIR ) /* )
55
54
else
56
- $(shell rm -f $(function_awklib))
55
+ $(shell rm -f $(function_awklib))
57
56
endif
58
57
59
58
option_docs = $(wildcard $(DOCS_DIR ) /options/* )
@@ -70,21 +69,23 @@ function_files := \
70
69
# this is needed for _init.sh (BASE) to know it needs
71
70
# to be rebuilt on this event.
72
71
73
- ifeq ($(wildcard $(CACHE_DIR ) /got_func) ,)
74
- $(shell mkdir -p $(CACHE_DIR)/options)
75
- $(shell echo 0 > $(CACHE_DIR)/got_func)
76
- endif
77
-
78
- ifneq ($(wildcard $(FUNCS_DIR ) /* ) ,)
79
- ifneq ($(file < $(CACHE_DIR)/got_func), 1)
80
- $(shell echo 1 > $(CACHE_DIR)/got_func)
81
- endif
82
- else
83
- ifneq ($(file < $(CACHE_DIR)/got_func), 0)
84
- $(shell echo 0 > $(CACHE_DIR)/got_func)
72
+ ifneq ($(wildcard $(CACHE_DIR ) /got_func) ,)
73
+ ifneq ($(wildcard $(FUNCS_DIR)/*),)
74
+ ifneq ($(file < $(CACHE_DIR)/got_func), 1)
75
+ $(shell echo 1 > $(CACHE_DIR)/got_func)
76
+ endif
77
+ else
78
+ ifneq ($(file < $(CACHE_DIR)/got_func), 0)
79
+ $(shell echo 0 > $(CACHE_DIR)/got_func)
80
+ endif
85
81
endif
86
82
endif
87
83
84
+ $(CACHE_DIR ) /got_func : | $(CACHE_DIR ) /
85
+ @$(info making $@ )
86
+ [[ -d $$ {tmp:= $( FUNCS_DIR) } ]] && tmp=1 || tmp=0
87
+ echo $$ tmp > $@
88
+
88
89
clean :
89
90
rm -rf $(wildcard _* ) $(CACHE_DIR ) $(generated_functions )
90
91
@@ -135,7 +136,7 @@ $(MONOLITH): $(CACHE_DIR)/print_version.sh $(NAME) $(CACHE_DIR)/print_help.sh $(
135
136
grep -vhE -e ' ^#!/' -e ' #bashbud$$' $$ f
136
137
done
137
138
138
- printf '%s\n' '' 'main "@$$ "'
139
+ printf '%s\n' '' 'main "$$@ "'
139
140
} > $@
140
141
141
142
chmod +x $@
@@ -192,25 +193,43 @@ $(CACHE_DIR)/help_table.txt: $(CACHE_DIR)/long_help.md
192
193
paste <(echo "$$frag") <(echo "$$desc") | tr -d '\t'
193
194
done > $@
194
195
195
- $(function_awklib ) : $(awk_files ) | $(FUNCS_DIR ) /
196
+ $(CACHE_DIR ) / :
197
+ @$(info creating $(CACHE_DIR ) / dir)
198
+ mkdir -p $(CACHE_DIR ) $(CACHE_DIR ) /options
199
+
200
+ $(FUNCS_DIR ) / :
201
+ @$(info creating $(FUNCS_DIR ) / dir)
202
+ mkdir -p $(FUNCS_DIR )
203
+
204
+ $(CACHE_DIR ) /print_version.sh : config.mak | $(CACHE_DIR ) /
196
205
@$(info making $@ )
197
- {
198
- printf ' %s\n' \
199
- ' $(SHBANG)' \
200
- ' ' \
201
- ' ### _awklib() function is automatically generated' \
202
- ' ### from makefile based on the content of the $(AWK_DIR)/ directory' \
203
- ' '
206
+ echo $(SHBANG )
207
+ fstyle=$(FUNC_STYLE )
208
+ printf " __print_version$$ {fstyle}\n" > $@
209
+ printf ' %s\n' \
210
+ " $( INDENT) >&2 printf '%s\n' \\ " \
211
+ " $( INDENT) $( INDENT) '$( NAME) - version: $( VERSION) ' \\ " \
212
+ " $( INDENT) $( INDENT) 'updated: $( UPDATED) by $( AUTHOR) '" \
213
+ " }" \
214
+ " " >> $@
204
215
216
+ $(CACHE_DIR ) /print_help.sh : $(CACHE_DIR ) /help_table.txt $(CACHE_DIR ) /synopsis.txt
217
+ @$(info making $@ )
218
+ {
219
+ echo $(SHBANG )
205
220
fstyle=$(FUNC_STYLE )
206
- printf "_awklib$${fstyle}\n"
207
- printf '%s\n' \
208
- '[[ -d $$__dir ]] && { cat "$$__dir/$(AWK_DIR)/"* ; return ;} # bashbud' \
209
- "cat << 'EOAWK'"
210
- cat $(awk_files)
211
- printf '%s\n' "EOAWK" '}'
221
+ printf " __print_help$$ {fstyle}\n"
222
+ echo " $( INDENT) cat << 'EOB' >&2 "
223
+ if [[ options = " $( USAGE) " ]]; then
224
+ cat $(CACHE_DIR ) /synopsis.txt
225
+ echo
226
+ else
227
+ printf ' %s\n' ' usage: $(USAGE)' ' '
228
+ echo
229
+ fi
230
+ cat $(CACHE_DIR ) /help_table.txt
231
+ printf ' %s\n' ' EOB' ' }'
212
232
} > $@
213
-
214
233
215
234
$(function_createconf ) : $(conf_files ) | $(FUNCS_DIR ) /
216
235
@$(info making $@ )
@@ -245,46 +264,25 @@ $(function_createconf): $(conf_files) | $(FUNCS_DIR)/
245
264
echo '}'
246
265
} > $@
247
266
248
- $(CACHE_DIR ) / :
249
- @$(info creating $(CACHE_DIR ) / dir)
250
- mkdir -p $(CACHE_DIR ) $(CACHE_DIR ) /options
251
- [[ -d $( FUNCS_DIR) ]] \
252
- && echo 1 > $(CACHE_DIR ) /got_func \
253
- || echo 0 > $(CACHE_DIR ) /got_func
254
-
255
- $(FUNCS_DIR ) / :
256
- @$(info creating $(FUNCS_DIR ) / dir)
257
- mkdir -p $(FUNCS_DIR )
258
-
259
- $(CACHE_DIR ) /print_version.sh : config.mak | $(CACHE_DIR ) /
260
- @$(info making $@ )
261
- echo $(SHBANG )
262
- fstyle=$(FUNC_STYLE )
263
- printf " __print_version$$ {fstyle}\n" > $@
264
- printf ' %s\n' \
265
- " $( INDENT) >&2 printf '%s\n' \\ " \
266
- " $( INDENT) $( INDENT) '$( NAME) - version: $( VERSION) ' \\ " \
267
- " $( INDENT) $( INDENT) 'updated: $( UPDATED) by $( AUTHOR) '" \
268
- " }" \
269
- " " >> $@
270
-
271
- $(CACHE_DIR ) /print_help.sh : $(CACHE_DIR ) /help_table.txt $(CACHE_DIR ) /synopsis.txt
267
+ $(function_awklib ) : $(awk_files ) | $(FUNCS_DIR ) /
272
268
@$(info making $@ )
273
269
{
274
- echo $(SHBANG )
270
+ printf ' %s\n' \
271
+ ' $(SHBANG)' \
272
+ ' ' \
273
+ ' ### _awklib() function is automatically generated' \
274
+ ' ### from makefile based on the content of the $(AWK_DIR)/ directory' \
275
+ ' '
276
+
275
277
fstyle=$(FUNC_STYLE)
276
- printf " __print_help$$ {fstyle}\n"
277
- echo " $( INDENT) cat << 'EOB' >&2 "
278
- if [[ options = " $( USAGE) " ]]; then
279
- cat $(CACHE_DIR ) /synopsis.txt
280
- echo
281
- else
282
- printf ' %s\n' ' usage: $(USAGE)' ' '
283
- echo
284
- fi
285
- cat $(CACHE_DIR ) /help_table.txt
286
- printf ' %s\n' ' EOB' ' }'
278
+ printf "_awklib$${fstyle}\n"
279
+ printf '%s\n' \
280
+ '[[ -d $$__dir ]] && { cat "$$__dir/$(AWK_DIR)/"* ; return ;} # bashbud' \
281
+ "cat << 'EOAWK'"
282
+ cat $(awk_files)
283
+ printf '%s\n' "EOAWK" '}'
287
284
} > $@
285
+
288
286
$(CACHE_DIR ) /options_in_use $(CACHE_DIR ) /getopt & : $(OPTIONS_FILE ) | $(CACHE_DIR ) /
289
287
@$(info parsing $(OPTIONS_FILE ) )
290
288
mkdir -p $(DOCS_DIR ) /options
0 commit comments