1 #@ "mk-mk.in" -- mk.mk template, completed by mk-conf.sh.
2 #@ Please see "INSTALL" and "make.rc" instead.
7 @if [ -z "$(VERBOSE)" ]; then echo ' CC $(<)';\
8 else echo ' $$ $(CC) $(CFLAGS) $(INCS) -c $(<)';\
10 $(CC) $(CFLAGS) $(INCS) -c $(<)
13 all: _all_echoes $(UAGENT) $(OPTIONAL_PRIVSEP)
16 if [ -z "$(VERBOSE)" ]; then \
18 echo '. CFLAGS : $(CFLAGS)';\
19 echo '. INCS : $(INCS)';\
20 [ -n "$(LDFLAGS)" ] && echo '. LDFLAGS : $(LDFLAGS)';\
21 echo '. LIBS : $(LIBS)';\
25 @if [ -z "$(VERBOSE)" ]; then echo ' LINK $(@)';\
26 else echo ' $$ $(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)';\
28 $(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)
29 @if ( command -v size ) > /dev/null 2>&1; then size $(@); fi
31 $(OBJ): config.h nail.h nailfuns.h $(AMALGAM_DEP)
32 $(AMALGAM_TARGET) accmacvar.o: okeys.h version.h
33 $(AMALGAM_TARGET) fio.o: dotlock.h
34 $(AMALGAM_TARGET) imap.o: imap_gssapi.h
35 $(AMALGAM_TARGET) lex.o: cmd_tab.h
36 $(AMALGAM_TARGET) mime_types.o: mime_types.h
37 $(AMALGAM_TARGET) imap.c pop3.o smtp.o urlcrecry.o: rfc1321.h
38 $(AMALGAM_TARGET) smtp.o: smtp_gssapi.h
41 @if [ -z "$(VERBOSE)" ]; then echo ' LINK $(@)';\
42 else echo ' $$ $(CC) $(LDFLAGS) -o $(@) privsep.o';\
44 $(CC) $(LDFLAGS) -o $(@) privsep.o
45 @if ( command -v size ) > /dev/null 2>&1; then size $(@); fi
47 privsep.o: config.h nail.h dotlock.h
49 mime_types.h: mime.types
51 LC_ALL=C < ./mime.types > $(@) $(awk) '\
52 function add(mt, ln) {\
53 gsub(/[[:space:]]+/, " ", ln);\
56 for (j = 1; j <= i; ++j) {\
58 e = (e ? e " " : "") k\
62 e_a[mt] = e_a[mt] " ";\
66 /^[[:space:]]*#/ {next}\
67 /^[[:space:]]*$$/ {ltype = ""; next}\
70 print "FAULTY CONTINUATION: " $$0 >> "/dev/stderr";\
74 /^(@([thH]@)? )?[[:alpha:]]/ {\
75 if ($$1 ~ /^@([thH]@)?$$/) {\
81 if ($$1 !~ /^([[:alnum:]]+)\/([[:alnum:]_+-]+)$$/)\
82 print "FAULTY MIME TYPE: <" $$1 ">" >> "/dev/stderr";\
83 ltype = $$1; $$1 = "";\
87 no_a[++no_ai] = nt_a[ltype] = ltype;\
91 for (z = 1; z <= no_ai; ++z) {\
94 mt = toupper(substr(t, 1, j - 1));\
95 j = substr(t, j + 1);\
101 if (tm == "@" || tm == "@t@")\
102 mt = "_MT_" mt " | _MT_PLAIN";\
103 else if (tm == "@h@")\
104 mt = "_MT_" mt " | _MT_SOUP_h";\
105 else if (tm == "@H@")\
106 mt = "_MT_" mt " | _MT_SOUP_H";\
108 print " {" mt ", " l ", \"" j e_a[t] "\"},"\
114 @echo 'Running test, please wait';\
116 awk=$(awk) cat=$(cat) cksum=$(cksum) rm=$(rm) sed=$(sed) grep=$(grep) \
117 $(SHELL) ./cc-test.sh --check-only ./$(UAGENT)
119 # Corresponds to same thing in makefile!
120 _version_from_header = VERSION="`< version.h $(sed) \
121 -e '/ VERSION /b X' -e d -e ':X' \
122 -e 's/[^\"]*\"v\([^\"]\{1,\}\)\"/\1/'`"
125 @[ -n "$(VERBOSE)" ] && echo ' GEN $(UAGENT) manual ($(@))';\
126 LC_ALL=C _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
127 $(_version_from_header) \
128 < ./nail.1 > $(@) $(awk) '\
129 BEGIN { written = 0 }\
130 /\.\\"--MKMAN-START--/, /\.\\"--MKMAN-END--/ {\
134 un = toupper(ENVIRON["_UAGENT"]);\
136 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
137 print ".ds UU \\\\%", un;\
138 print ".ds UA \\\\%", cn;\
139 print ".ds ua \\\\%", ln;\
140 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
141 path = ENVIRON["_SYSCONFRC"];\
142 gsub("/", "/\\:", path);\
143 print ".ds UR \\\\%", path;\
151 @[ -n "$(VERBOSE)" ] &&\
152 echo ' GEN $(UAGENT) default resource file ($(@))';\
153 LC_ALL=C _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
154 $(_version_from_header) \
155 < ./nail.rc > $(@) $(awk) 'BEGIN {written = 0}\
156 /^#--MKRC-START--/, /^#--MKRC-END--/ {\
161 ln = tolower(ENVIRON["_UAGENT"]);\
162 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
163 print "#@ ", ENVIRON["_SYSCONFRC"];\
164 print "#@ Configuration file for ", cn, "(1) v",\
174 install: _install_echoes mkman.1 mkrc.rc
177 if [ -d "$${_dir}" ]; then :; else\
178 [ -n "$(VERBOSE)" ] &&\
179 echo " \$$ $(mkdir) -m 0755 -p '$${_dir}'";\
180 $(mkdir) -m 0755 -p "$${_dir}";\
184 _mode=$${1} _src=$${2} _dst=$${3};\
185 [ -n "$(VERBOSE)" ] &&\
186 echo " \$$ $(cp) -f '$${_src}' '$${_dst}'";\
187 $(cp) -f "$${_src}" "$${_dst}";\
188 [ -n "$(VERBOSE)" ] &&\
189 echo " \$$ $(chmod) $${_mode} '$${_dst}'";\
190 $(chmod) $${_mode} "$${_dst}";\
193 _mode=$${1} _ident=$${2} _src=$${3} _dst=$${4};\
194 [ -n "$(VERBOSE)" ] &&\
195 echo " \$$ $(cp) -f '$${_src}' '$${_dst}'";\
196 $(cp) -f "$${_src}" "$${_dst}";\
197 [ -n "$(VERBOSE)" ] &&\
198 echo " \$$ $(chown) $${_ident} '$${_dst}'";\
199 $(chown) $${_ident} "$${_dst}";\
200 [ -n "$(VERBOSE)" ] &&\
201 echo " \$$ $(chmod) $${_mode} '$${_dst}'";\
202 $(chmod) $${_mode} "$${_dst}";\
206 if [ "$(WANT_DEBUG)" != 0 ]; then \
207 [ -n "$(VERBOSE)" ] &&\
208 echo " \$$ :WANT_DEBUG=1, not strip(1)ing";\
209 elif [ -n "$(HAVE_STRIP)" ]; then \
210 [ -n "$(VERBOSE)" ] &&\
211 echo " \$$ $(STRIP) '$${_file}'";\
212 $(strip) "$${_file}";\
215 if [ -n "$(DESTDIR)" ]; then __mkdir "$(DESTDIR)"; fi;\
216 __mkdir "$(DESTDIR)$(BINDIR)";\
217 __stripfile "$(UAGENT)";\
218 __copyfile 0555 "$(UAGENT)" "$(DESTDIR)$(BINDIR)/$(UAGENT)";\
219 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
220 __mkdir "$(DESTDIR)$(LIBEXECDIR)";\
221 __stripfile "$(PRIVSEP)";\
223 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
224 m="g=rxs,$${m}" o=":$(PRIVSEP_GROUP)";\
228 if [ -n "$(PRIVSEP_USER)" ]; then \
229 m="u=rxs,$${m}" o="$(PRIVSEP_USER)$${o}";\
233 __copychownfile "$${m}" "$${o}" "$(PRIVSEP)" \
234 "$(DESTDIR)$(LIBEXECDIR)/$(PRIVSEP)";\
236 __mkdir "$(DESTDIR)$(MANDIR)/man1";\
237 __copyfile 0444 ./mkman.1 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1";\
238 __mkdir "$(DESTDIR)$(SYSCONFDIR)";\
239 if [ -f "$(DESTDIR)$(SYSCONFRC)" ]; then :; else\
240 __copyfile 0444 ./mkrc.rc "$(DESTDIR)$(SYSCONFRC)";\
244 @echo 'Uninstalling..';\
245 [ -n "$(VERBOSE)" ] &&\
246 echo ' $$ $(rm) -f "$(DESTDIR)$(BINDIR)/$(UAGENT)" \
247 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1"';\
248 $(rm) -f "$(DESTDIR)$(BINDIR)/$(UAGENT)" \
249 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1";\
250 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
251 [ -n "$(VERBOSE)" ] &&\
253 ' $$ $(rm) -f "$(DESTDIR)$(LIBEXECDIR)/$(PRIVSEP)"';\
254 $(rm) -f "$(DESTDIR)$(LIBEXECDIR)/$(PRIVSEP)";\
256 if [ -n "$(VERBOSE)" ] && [ -f "$(DESTDIR)$(SYSCONFRC)" ]; then \
257 echo ' NOTE: not removing "$(DESTDIR)$(SYSCONFRC)"';\
261 @echo 'Cleaning up..';\
262 [ -n "$(VERBOSE)" ] &&\
263 echo ' $$ $(rm) -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 \
265 $(rm) -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 ./mkrc.rc;\
266 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
267 [ -n "$(VERBOSE)" ] &&\
268 echo ' $$ $(rm) -f ./privsep.o $(PRIVSEP)';\
269 $(rm) -f ./privsep.o $(PRIVSEP);\
273 @echo 'Deconfiguring..';\
274 [ -n "$(VERBOSE)" ] && echo ' $$ $(rm) -f ./config.* ./*.mk';\
275 $(rm) -f ./config.* ./*.mk
277 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise modify makefile
279 @LC_ALL=C; export LC_ALL;\
280 if [ -z "$(VERSION)" ]; then \
281 eval VERSION="`(git describe --tags) 2>/dev/null`";\
282 if [ -n "$${VERSION}" ]; then \
283 VERSION="`echo $${VERSION} |\
284 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
285 [ "`git status --porcelain |\
293 VERSION="$${VERSION}-dirty";\
295 $(_version_from_header);\
296 echo "$${VERSION}" | $(grep) -q -F dirty ||\
297 VERSION="$${VERSION}-dirty";\
300 vmaj="`echo \"$${VERSION}\" |\
301 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
302 vmin="`echo \"$${VERSION}\" |\
303 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
304 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
305 vupd="`echo \"$${VERSION}\" |\
306 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
307 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
308 trap "$(rm) ./version.tmp" 0 1 2 15;\
309 printf > ./version.tmp "#define VERSION \"v$${VERSION}\"\n";\
310 printf >> ./version.tmp "#define VERSION_MAJOR \"$${vmaj}\"\n";\
311 printf >> ./version.tmp "#define VERSION_MINOR \"$${vmin}\"\n";\
312 printf >> ./version.tmp "#define VERSION_UPDATE \"$${vupd}\"\n";\
313 $(cmp) ./version.tmp ./version.h >/dev/null 2>&1 && exit;\
314 $(mv) ./version.tmp ./version.h;\