1 #@ mk-mk.in -- mk.mk template, completed by mk-conf.sh.
2 #@ Please see INSTALL and make.rc instead.
4 SIZE_CHECK = @if ( command -v size ) > /dev/null 2>&1; then size $(@); fi
6 _version_from_header = VERSION="`< version.h $(sed) \
7 -e '/ VERSION /b X' -e d -e ':X' \
8 -e 's/[^\"]*\"v\([^\"]\{1,\}\)\"/\1/'`"
10 OBJ = $(OBJ_SRC:.c=.o)
13 $(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(<)
16 all: $(VAL_UAGENT) $(OPTIONAL_PRIVSEP)
18 $(VAL_UAGENT): $(OBJ) uman.1 urc.rc
19 $(ECHO_LINK)$(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)
22 $(OBJ): config.h nail.h nailfuns.h $(AMALGAM_DEP)
23 $(AMALGAM_TARGET) accmacvar.o: okeys.h version.h
24 $(AMALGAM_TARGET) dotlock.o: dotlock.h
25 $(AMALGAM_TARGET) lex_input.o: cmd_tab.h
26 $(AMALGAM_TARGET) mime_types.o: mime_types.h
27 $(AMALGAM_TARGET) pop3.o smtp.o urlcrecry.o: rfc1321.h
28 $(AMALGAM_TARGET) smtp.o: smtp_gssapi.h
29 $(AMALGAM_TARGET) termcap.o: tcaps.h
31 $(VAL_PRIVSEP): privsep.o
32 $(ECHO_LINK)$(CC) $(LDFLAGS) -o $(@) privsep.o $(BASE_LIBS)
35 privsep.o: privsep.c config.h nail.h dotlock.h
36 $(ECHO_CC)$(CC) $(CFLAGS) $(BASE_INCS) -c privsep.c
41 awk=$(awk) cat=$(cat) cksum=$(cksum) rm=$(rm) sed=$(sed) grep=$(grep) \
42 $(SHELL) ./cc-test.sh --check-only ./$(VAL_UAGENT)
44 mime_types.h: mime.types
46 LC_ALL=C < ./mime.types > $(@) $(awk) '\
47 function add(mt, ln) {\
48 gsub(/[[:space:]]+/, " ", ln);\
51 for (j = 1; j <= i; ++j) {\
53 e = (e ? e " " : "") k\
57 e_a[mt] = e_a[mt] " ";\
61 /^[[:space:]]*#/ {next}\
62 /^[[:space:]]*$$/ {ltype = ""; next}\
65 print "FAULTY CONTINUATION: " $$0 >> "/dev/stderr";\
69 /^(@([thH]@)? )?[[:alpha:]]/ {\
70 if ($$1 ~ /^@([thH]@)?$$/) {\
76 if ($$1 !~ /^([[:alnum:]]+)\/([[:alnum:]_+-]+)$$/)\
77 print "FAULTY MIME TYPE: <" $$1 ">" >> "/dev/stderr";\
78 ltype = $$1; $$1 = "";\
82 no_a[++no_ai] = nt_a[ltype] = ltype;\
86 for (z = 1; z <= no_ai; ++z) {\
89 mt = toupper(substr(t, 1, j - 1));\
90 j = substr(t, j + 1);\
96 if (tm == "@" || tm == "@t@")\
97 mt = "_MT_" mt " | _MT_PLAIN";\
98 else if (tm == "@h@")\
99 mt = "_MT_" mt " | _MT_SOUP_h";\
100 else if (tm == "@H@")\
101 mt = "_MT_" mt " | _MT_SOUP_H";\
103 print " {" mt ", " l ", \"" j e_a[t] "\"},"\
110 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
111 $(_version_from_header) \
112 < ./nail.1 > $(@) $(awk) '\
113 BEGIN { written = 0 }\
114 /\.\\"--MKMAN-START--/, /\.\\"--MKMAN-END--/ {\
118 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
120 un = toupper(ENVIRON["_UAGENT"]);\
122 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
123 print ".ds UU \\\\%", un;\
124 print ".ds UA \\\\%", cn;\
125 print ".ds uA \\\\%", ln;\
127 path = ENVIRON["_SYSCONFRC"];\
128 gsub("/", "/\\:", path);\
129 print ".ds UR \\\\%", path;\
138 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
139 $(_version_from_header) \
140 < ./nail.rc > $(@) $(awk) 'BEGIN {written = 0}\
141 /^#--MKRC-START--/, /^#--MKRC-END--/ {\
146 ln = tolower(ENVIRON["_UAGENT"]);\
147 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
148 print "#@ ", ENVIRON["_SYSCONFRC"];\
149 print "#@ Configuration file for ", cn, "(1) v",\
160 _dir="$(DESTDIR)$${1}";\
161 if [ -d "$${_dir}" ]; then :; else \
162 $(mkdir) -m 0755 -p "$${_dir}";\
166 _mode=$${1} _src=$${2} _xdst=$${3} _dst="$(DESTDIR)$${3}";\
167 $(cp) -f "$${_src}" "$${_dst}";\
168 $(chmod) $${_mode} "$${_dst}";\
170 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
171 "$(VAL_UAGENT)-uninstall.sh";\
174 _mode=$${1} _ident=$${2} _src=$${3} \
175 _xdst=$${4} _dst="$(DESTDIR)$${4}";\
176 $(cp) -f "$${_src}" "$${_dst}";\
177 $(chown) $${_ident} "$${_dst}";\
178 $(chmod) $${_mode} "$${_dst}";\
180 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
181 "$(VAL_UAGENT)-uninstall.sh";\
185 if [ "$(OPT_DEBUG)" != 0 ]; then :;\
186 elif [ -n "$(HAVE_STRIP)" ]; then \
187 $(strip) "$${_file}";\
191 echo '#!/bin/sh -' > "$(VAL_UAGENT)-uninstall.sh";\
192 echo '#@ Uninstall script for $(VAL_UAGENT)' >> \
193 "$(VAL_UAGENT)-uninstall.sh";\
194 echo >> "$(VAL_UAGENT)-uninstall.sh";\
195 echo 'DESTDIR="$(DESTDIR)"' >> "$(VAL_UAGENT)-uninstall.sh";\
196 echo 'DESTDIR=' >> "$(VAL_UAGENT)-uninstall.sh";\
197 echo >> "$(VAL_UAGENT)-uninstall.sh";\
199 if [ -n "$(DESTDIR)" ]; then __mkdir ''; fi;\
200 __mkdir "$(VAL_BINDIR)";\
201 __mkdir "$(VAL_MANDIR)/man1";\
202 __mkdir "$(VAL_SYSCONFDIR)";\
204 __stripfile "$(VAL_UAGENT)";\
205 __copyfile 0555 "$(VAL_UAGENT)" "$(VAL_BINDIR)/$(VAL_UAGENT)";\
206 __copyfile 0444 ./uman.1 "$(VAL_MANDIR)/man1/$(VAL_UAGENT).1";\
207 if [ -f "$(DESTDIR)$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)" ]; then :; else \
208 __copyfile 0444 ./urc.rc "$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)";\
211 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
212 __mkdir "$(VAL_LIBEXECDIR)";\
214 __stripfile "$(VAL_PRIVSEP)";\
216 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
217 m="g=rxs,$${m}" o=":$(VAL_PRIVSEP_GROUP)";\
221 if [ -n "$(VAL_PRIVSEP_USER)" ]; then \
222 m="u=rxs,$${m}" o="$(VAL_PRIVSEP_USER)$${o}";\
226 __copychownfile "$${m}" "$${o}" "$(VAL_PRIVSEP)" \
227 "$(VAL_LIBEXECDIR)/$(VAL_PRIVSEP)";\
230 if [ -z "$(DESTDIR)" ]; then \
231 __copyfile 0555 "$(VAL_UAGENT)-uninstall.sh" \
232 "$(VAL_BINDIR)/$(VAL_UAGENT)-uninstall.sh";\
237 @echo 'Invoke $(VAL_UAGENT)-uninstall.sh to uninstall $(VAL_UAGENT)'
241 $(rm) -f $(OBJ) $(VAL_UAGENT) ./mime_types.h ./uman.1 ./urc.rc;\
242 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
243 $(rm) -f ./privsep.o ./$(VAL_PRIVSEP);\
246 if [ -f "$(VAL_UAGENT)-uninstall.sh" ]; then \
247 $(rm) -f ./$(VAL_UAGENT)-uninstall.sh;\
252 $(rm) -f ./config.* ./*.mk
254 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise need to change
257 @LC_ALL=C; export LC_ALL;\
258 if [ -z "$(VERSION)" ]; then \
259 eval VERSION="`(git describe --tags) 2>/dev/null`";\
260 if [ -n "$${VERSION}" ]; then \
261 VERSION="`echo $${VERSION} |\
262 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
263 [ "`git status --porcelain |\
271 VERSION="$${VERSION}-dirty";\
273 $(_version_from_header);\
274 echo "$${VERSION}" | $(grep) -q -F dirty ||\
275 VERSION="$${VERSION}-dirty";\
278 vmaj="`echo \"$${VERSION}\" |\
279 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
280 vmin="`echo \"$${VERSION}\" |\
281 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
282 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
283 vupd="`echo \"$${VERSION}\" |\
284 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
285 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
286 trap "$(rm) ./version.tmp" 0 1 2 15;\
287 printf > ./version.tmp "#define VERSION \"v$${VERSION}\"\n";\
288 printf >> ./version.tmp "#define VERSION_MAJOR \"$${vmaj}\"\n";\
289 printf >> ./version.tmp "#define VERSION_MINOR \"$${vmin}\"\n";\
290 printf >> ./version.tmp "#define VERSION_UPDATE \"$${vupd}\"\n";\
291 $(cmp) ./version.tmp ./version.h >/dev/null 2>&1 && exit;\
292 $(mv) ./version.tmp ./version.h;\