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) dotlock.o: dotlock.h
34 $(AMALGAM_TARGET) lex_input.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
38 $(AMALGAM_TARGET) termcap.o: tcaps.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)$(SYSCONFDIR)/$(SYSCONFRC)" ]; then :; else\
240 __copyfile 0444 ./mkrc.rc \
241 "$(DESTDIR)$(SYSCONFDIR)/$(SYSCONFRC)";\
245 @echo 'Uninstalling..';\
246 [ -n "$(VERBOSE)" ] &&\
247 echo ' $$ $(rm) -f "$(DESTDIR)$(BINDIR)/$(UAGENT)" \
248 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1"';\
249 $(rm) -f "$(DESTDIR)$(BINDIR)/$(UAGENT)" \
250 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1";\
251 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
252 [ -n "$(VERBOSE)" ] &&\
254 ' $$ $(rm) -f "$(DESTDIR)$(LIBEXECDIR)/$(PRIVSEP)"';\
255 $(rm) -f "$(DESTDIR)$(LIBEXECDIR)/$(PRIVSEP)";\
257 if [ -n "$(VERBOSE)" ] && [ -f "$(DESTDIR)$(SYSCONFRC)" ]; then \
258 echo ' NOTE: not removing "$(DESTDIR)$(SYSCONFRC)"';\
262 @echo 'Cleaning up..';\
263 [ -n "$(VERBOSE)" ] &&\
264 echo ' $$ $(rm) -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 \
266 $(rm) -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 ./mkrc.rc;\
267 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
268 [ -n "$(VERBOSE)" ] &&\
269 echo ' $$ $(rm) -f ./privsep.o $(PRIVSEP)';\
270 $(rm) -f ./privsep.o $(PRIVSEP);\
274 @echo 'Deconfiguring..';\
275 [ -n "$(VERBOSE)" ] && echo ' $$ $(rm) -f ./config.* ./*.mk';\
276 $(rm) -f ./config.* ./*.mk
278 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise modify makefile
280 @LC_ALL=C; export LC_ALL;\
281 if [ -z "$(VERSION)" ]; then \
282 eval VERSION="`(git describe --tags) 2>/dev/null`";\
283 if [ -n "$${VERSION}" ]; then \
284 VERSION="`echo $${VERSION} |\
285 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
286 [ "`git status --porcelain |\
294 VERSION="$${VERSION}-dirty";\
296 $(_version_from_header);\
297 echo "$${VERSION}" | $(grep) -q -F dirty ||\
298 VERSION="$${VERSION}-dirty";\
301 vmaj="`echo \"$${VERSION}\" |\
302 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
303 vmin="`echo \"$${VERSION}\" |\
304 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
305 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
306 vupd="`echo \"$${VERSION}\" |\
307 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
308 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
309 trap "$(rm) ./version.tmp" 0 1 2 15;\
310 printf > ./version.tmp "#define VERSION \"v$${VERSION}\"\n";\
311 printf >> ./version.tmp "#define VERSION_MAJOR \"$${vmaj}\"\n";\
312 printf >> ./version.tmp "#define VERSION_MINOR \"$${vmin}\"\n";\
313 printf >> ./version.tmp "#define VERSION_UPDATE \"$${vupd}\"\n";\
314 $(cmp) ./version.tmp ./version.h >/dev/null 2>&1 && exit;\
315 $(mv) ./version.tmp ./version.h;\