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) lex.o: cmd_tab.h
35 $(AMALGAM_TARGET) mime_types.o: mime_types.h
36 $(AMALGAM_TARGET) pop3.o smtp.o urlcrecry.o: rfc1321.h
37 $(AMALGAM_TARGET) smtp.o: smtp_gssapi.h
40 @if [ -z "$(VERBOSE)" ]; then echo ' LINK $(@)';\
41 else echo ' $$ $(CC) $(LDFLAGS) -o $(@) privsep.o';\
43 $(CC) $(LDFLAGS) -o $(@) privsep.o
44 @if ( command -v size ) > /dev/null 2>&1; then size $(@); fi
46 privsep.o: config.h nail.h dotlock.h
48 mime_types.h: mime.types
50 LC_ALL=C < ./mime.types > $(@) $(awk) '\
51 function add(mt, ln) {\
52 gsub(/[[:space:]]+/, " ", ln);\
55 for (j = 1; j <= i; ++j) {\
57 e = (e ? e " " : "") k\
61 e_a[mt] = e_a[mt] " ";\
65 /^[[:space:]]*#/ {next}\
66 /^[[:space:]]*$$/ {ltype = ""; next}\
69 print "FAULTY CONTINUATION: " $$0 >> "/dev/stderr";\
73 /^(@([thH]@)? )?[[:alpha:]]/ {\
74 if ($$1 ~ /^@([thH]@)?$$/) {\
80 if ($$1 !~ /^([[:alnum:]]+)\/([[:alnum:]_+-]+)$$/)\
81 print "FAULTY MIME TYPE: <" $$1 ">" >> "/dev/stderr";\
82 ltype = $$1; $$1 = "";\
86 no_a[++no_ai] = nt_a[ltype] = ltype;\
90 for (z = 1; z <= no_ai; ++z) {\
93 mt = toupper(substr(t, 1, j - 1));\
94 j = substr(t, j + 1);\
100 if (tm == "@" || tm == "@t@")\
101 mt = "_MT_" mt " | _MT_PLAIN";\
102 else if (tm == "@h@")\
103 mt = "_MT_" mt " | _MT_SOUP_h";\
104 else if (tm == "@H@")\
105 mt = "_MT_" mt " | _MT_SOUP_H";\
107 print " {" mt ", " l ", \"" j e_a[t] "\"},"\
113 @echo 'Running test, please wait';\
115 awk=$(awk) cat=$(cat) cksum=$(cksum) rm=$(rm) sed=$(sed) grep=$(grep) \
116 $(SHELL) ./cc-test.sh --check-only ./$(UAGENT)
118 # Corresponds to same thing in makefile!
119 _version_from_header = VERSION="`< version.h $(sed) \
120 -e '/ VERSION /b X' -e d -e ':X' \
121 -e 's/[^\"]*\"v\([^\"]\{1,\}\)\"/\1/'`"
124 @[ -n "$(VERBOSE)" ] && echo ' GEN $(UAGENT) manual ($(@))';\
125 LC_ALL=C _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
126 $(_version_from_header) \
127 < ./nail.1 > $(@) $(awk) '\
128 BEGIN { written = 0 }\
129 /\.\\"--MKMAN-START--/, /\.\\"--MKMAN-END--/ {\
133 un = toupper(ENVIRON["_UAGENT"]);\
135 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
136 print ".ds UU \\\\%", un;\
137 print ".ds UA \\\\%", cn;\
138 print ".ds ua \\\\%", ln;\
139 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
140 path = ENVIRON["_SYSCONFRC"];\
141 gsub("/", "/\\:", path);\
142 print ".ds UR \\\\%", path;\
150 @[ -n "$(VERBOSE)" ] &&\
151 echo ' GEN $(UAGENT) default resource file ($(@))';\
152 LC_ALL=C _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
153 $(_version_from_header) \
154 < ./nail.rc > $(@) $(awk) 'BEGIN {written = 0}\
155 /^#--MKRC-START--/, /^#--MKRC-END--/ {\
160 ln = tolower(ENVIRON["_UAGENT"]);\
161 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
162 print "#@ ", ENVIRON["_SYSCONFRC"];\
163 print "#@ Configuration file for ", cn, "(1) v",\
173 install: _install_echoes mkman.1 mkrc.rc
176 if [ -d "$${_dir}" ]; then :; else\
177 [ -n "$(VERBOSE)" ] &&\
178 echo " \$$ $(mkdir) -m 0755 -p '$${_dir}'";\
179 $(mkdir) -m 0755 -p "$${_dir}";\
183 _mode=$${1} _src=$${2} _dst=$${3};\
184 [ -n "$(VERBOSE)" ] &&\
185 echo " \$$ $(cp) -f '$${_src}' '$${_dst}'";\
186 $(cp) -f "$${_src}" "$${_dst}";\
187 [ -n "$(VERBOSE)" ] &&\
188 echo " \$$ $(chmod) $${_mode} '$${_dst}'";\
189 $(chmod) $${_mode} "$${_dst}";\
192 _mode=$${1} _ident=$${2} _src=$${3} _dst=$${4};\
193 [ -n "$(VERBOSE)" ] &&\
194 echo " \$$ $(cp) -f '$${_src}' '$${_dst}'";\
195 $(cp) -f "$${_src}" "$${_dst}";\
196 [ -n "$(VERBOSE)" ] &&\
197 echo " \$$ $(chown) $${_ident} '$${_dst}'";\
198 $(chown) $${_ident} "$${_dst}";\
199 [ -n "$(VERBOSE)" ] &&\
200 echo " \$$ $(chmod) $${_mode} '$${_dst}'";\
201 $(chmod) $${_mode} "$${_dst}";\
205 if [ "$(WANT_DEBUG)" != 0 ]; then \
206 [ -n "$(VERBOSE)" ] &&\
207 echo " \$$ :WANT_DEBUG=1, not strip(1)ing";\
208 elif [ -n "$(HAVE_STRIP)" ]; then \
209 [ -n "$(VERBOSE)" ] &&\
210 echo " \$$ $(STRIP) '$${_file}'";\
211 $(strip) "$${_file}";\
214 if [ -n "$(DESTDIR)" ]; then __mkdir "$(DESTDIR)"; fi;\
215 __mkdir "$(DESTDIR)$(BINDIR)";\
216 __stripfile "$(UAGENT)";\
217 __copyfile 0555 "$(UAGENT)" "$(DESTDIR)$(BINDIR)/$(UAGENT)";\
218 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
219 __mkdir "$(DESTDIR)$(LIBEXECDIR)";\
220 __stripfile "$(PRIVSEP)";\
222 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
223 m="g=rxs,$${m}" o=":$(PRIVSEP_GROUP)";\
227 if [ -n "$(PRIVSEP_USER)" ]; then \
228 m="u=rxs,$${m}" o="$(PRIVSEP_USER)$${o}";\
232 __copychownfile "$${m}" "$${o}" "$(PRIVSEP)" \
233 "$(DESTDIR)$(LIBEXECDIR)/$(PRIVSEP)";\
235 __mkdir "$(DESTDIR)$(MANDIR)/man1";\
236 __copyfile 0444 ./mkman.1 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1";\
237 __mkdir "$(DESTDIR)$(SYSCONFDIR)";\
238 if [ -f "$(DESTDIR)$(SYSCONFDIR)/$(SYSCONFRC)" ]; then :; else\
239 __copyfile 0444 ./mkrc.rc \
240 "$(DESTDIR)$(SYSCONFDIR)/$(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;\