1 #@ make-config.in -- mk-config.mk template, completed by make-config.sh.
2 #@ Please see INSTALL and make.rc instead.
4 .PHONY: all test install uninstall clean distclean
6 SIZE_CHECK = @if ( command -v size ) > /dev/null 2>&1; then size $(@); fi
8 _version_from_header = VERSION="`< gen-version.h $(sed) \
9 -e '/ n_VERSION /b X' -e d -e ':X' \
10 -e 's/[^\"]*\"v\([^\"]\{1,\}\)\"/\1/'`"
12 all: $(VAL_UAGENT) $(OPTIONAL_PRIVSEP)
14 $(VAL_UAGENT): $(OBJ) uman.1 urc.rc
15 $(ECHO_LINK)$(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)
18 $(OBJ): mk-config.h config.h $(SRCDIR)nail.h $(SRCDIR)nailfuns.h \
20 $(AMALGAM_TARGET) auxlily.o: $(SRCDIR)gen-errors.h
21 $(AMALGAM_TARGET) accmacvar.o: $(SRCDIR)gen-okeys.h gen-version.h
22 $(AMALGAM_TARGET) cmd-tab.o: $(SRCDIR)cmd-tab.h
23 $(AMALGAM_TARGET) dotlock.o: $(SRCDIR)dotlock.h
24 $(AMALGAM_TARGET) obs-imap.o: $(SRCDIR)obs-imap-gssapi.h
25 $(AMALGAM_TARGET) mime-types.o: gen-mime-types.h
26 $(AMALGAM_TARGET) obs-imap.o pop3.o smtp.o urlcrecry.o: $(SRCDIR)rfc1321.h
27 $(AMALGAM_TARGET) smtp.o: $(SRCDIR)smtp-gssapi.h
28 $(AMALGAM_TARGET) termcap.o: $(SRCDIR)gen-tcaps.h
30 $(VAL_PRIVSEP): privsep.o
31 $(ECHO_LINK)$(CC) $(LDFLAGS) -o $(@) privsep.o $(BASE_LIBS)
34 privsep.o: $(SRCDIR)privsep.c mk-config.h config.h \
35 $(SRCDIR)nail.h $(SRCDIR)dotlock.h
36 $(ECHO_CC)$(CC) $(CFLAGS) $(BASE_INCS) -c $(SRCDIR)privsep.c
38 gen-mime-types.h: $(SRCDIR)mime.types
40 LC_ALL=C < $(SRCDIR)mime.types > $(@) $(awk) '\
41 function add(mt, ln){\
42 gsub(/[[:space:]]+/, " ", ln);\
45 for(j = 1; j <= i; ++j){\
47 e = (e ? e " " : "") k\
51 e_a[mt] = e_a[mt] " ";\
55 /^[[:space:]]*#/{next}\
56 /^[[:space:]]*$$/{ltype = ""; next}\
59 print "FAULTY CONTINUATION: " $$0 >> "/dev/stderr";\
63 /^(@([thHq]@)? )?[[:alpha:]]/{\
64 if($$1 ~ /^@([thHq]@)?$$/){\
70 if($$1 !~ /^([[:alnum:]]+)\/([[:alnum:]_+-]+)$$/)\
71 print "FAULTY MIME TYPE: <" $$1 ">" >> "/dev/stderr";\
72 ltype = $$1; $$1 = "";\
76 no_a[++no_ai] = nt_a[ltype] = ltype;\
80 for(z = 1; z <= no_ai; ++z){\
83 mt = toupper(substr(t, 1, j - 1));\
84 j = substr(t, j + 1);\
90 if(tm == "@" || tm == "@t@")\
91 mt = "_MT_" mt " | a_MT_TM_PLAIN";\
93 mt = "_MT_" mt " | a_MT_TM_SOUP_h";\
95 mt = "_MT_" mt " | a_MT_TM_SOUP_H";\
97 mt = "_MT_" mt " | a_MT_TM_QUIET";\
99 print " {" mt ", " l ", \"" j e_a[t] "\"},"\
104 uman.1: $(SRCDIR)nail.1
107 _UAGENT="$(VAL_UAGENT)" \
108 _SYSCONFRC="$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)" \
109 _MAILRC="$(VAL_MAILRC)" \
110 _DEAD="$(VAL_DEAD)" \
111 _MBOX="$(VAL_MBOX)" \
112 _NETRC="$(VAL_NETRC)" \
113 _TMPDIR="$(VAL_TMPDIR)" \
114 _MT_S="$(VAL_MIME_TYPES_SYS)" \
115 _MT_U="$(VAL_MIME_TYPES_USR)" \
116 $(_version_from_header) \
117 < $(SRCDIR)nail.1 > $(@) $(awk) '\
118 BEGIN { written = 0 }\
119 /\.\\"--MKMAN-START--/, /\.\\"--MKMAN-END--/ {\
123 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
125 un = toupper(ENVIRON["_UAGENT"]);\
127 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
128 print ".ds UU \\\\%", un;\
129 print ".ds UA \\\\%", cn;\
130 print ".ds uA \\\\%", ln;\
131 path = ENVIRON["_SYSCONFRC"];\
132 gsub("/", "/\\:", path);\
133 print ".ds UR \\\\%", path;\
134 path = ENVIRON["_MAILRC"];\
135 gsub("/", "/\\:", path);\
136 print ".ds ur \\\\%", path;\
138 path = ENVIRON["_DEAD"];\
139 gsub("/", "/\\:", path);\
140 print ".ds VD \\\\%", path;\
141 path = ENVIRON["_MBOX"];\
142 gsub("/", "/\\:", path);\
143 print ".ds VM \\\\%", path;\
144 path = ENVIRON["_NETRC"];\
145 gsub("/", "/\\:", path);\
146 print ".ds VN \\\\%", path;\
147 path = ENVIRON["_TMPDIR"];\
148 gsub("/", "/\\:", path);\
149 print ".ds VT \\\\%", path;\
151 path = ENVIRON["_MT_S"];\
152 gsub("/", "/\\:", path);\
153 print ".ds vS \\\\%", path;\
154 path = ENVIRON["_MT_U"];\
155 gsub("/", "/\\:", path);\
156 print ".ds vU \\\\%", path;\
164 urc.rc: $(SRCDIR)nail.rc
166 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
167 $(_version_from_header) \
168 < $(SRCDIR)nail.rc > $(@) $(awk) 'BEGIN {written = 0}\
169 /^#--MKRC-START--/, /^#--MKRC-END--/ {\
174 ln = tolower(ENVIRON["_UAGENT"]);\
175 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
176 print "#@ ", ENVIRON["_SYSCONFRC"];\
177 print "#@ Configuration file for ", cn, " v",\
188 _dir="$(DESTDIR)$${1}";\
189 if [ -d "$${_dir}" ]; then :; else \
190 $(mkdir) -m 0755 -p "$${_dir}";\
194 _mode=$${1} _src=$${2} _xdst=$${3} _dst="$(DESTDIR)$${3}";\
195 $(cp) -f "$${_src}" "$${_dst}";\
196 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
197 "$(VAL_UAGENT)-uninstall.sh";\
198 $(chmod) $${_mode} "$${_dst}";\
202 _mode=$${1} _ident=$${2} _src=$${3} \
203 _xdst=$${4} _dst="$(DESTDIR)$${4}";\
204 $(cp) -f "$${_src}" "$${_dst}";\
205 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
206 "$(VAL_UAGENT)-uninstall.sh";\
207 $(chown) $${_ident} "$${_dst}" || true;\
208 $(chmod) $${_mode} "$${_dst}";\
213 if [ "$(OPT_DEBUG)" != 0 ]; then :;\
214 elif [ -n "$(HAVE_STRIP)" ]; then \
215 $(strip) "$${_file}";\
219 echo '#!/bin/sh -' > "$(VAL_UAGENT)-uninstall.sh";\
220 echo '#@ Uninstall script for $(VAL_UAGENT)' >> \
221 "$(VAL_UAGENT)-uninstall.sh";\
222 echo >> "$(VAL_UAGENT)-uninstall.sh";\
223 echo 'DESTDIR="$(DESTDIR)"' >> "$(VAL_UAGENT)-uninstall.sh";\
224 echo 'DESTDIR=' >> "$(VAL_UAGENT)-uninstall.sh";\
225 echo >> "$(VAL_UAGENT)-uninstall.sh";\
227 if [ -n "$(DESTDIR)" ]; then __mkdir ''; fi;\
228 __mkdir "$(VAL_BINDIR)";\
229 __mkdir "$(VAL_MANDIR)/man1";\
230 __mkdir "$(VAL_SYSCONFDIR)";\
232 __stripfile "$(VAL_UAGENT)";\
233 __copyfile 0555 "$(VAL_UAGENT)" "$(VAL_BINDIR)/$(VAL_UAGENT)";\
234 __copyfile 0444 ./uman.1 "$(VAL_MANDIR)/man1/$(VAL_UAGENT).1";\
235 if [ -f "$(DESTDIR)$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)" ]; then :; else \
236 __copyfile 0444 ./urc.rc "$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)";\
239 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
240 __mkdir "$(VAL_LIBEXECDIR)";\
242 __stripfile "$(VAL_PRIVSEP)";\
244 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
245 m="g=rxs,$${m}" o=":$(VAL_PRIVSEP_GROUP)";\
249 if [ -n "$(VAL_PRIVSEP_USER)" ]; then \
250 m="u=rxs,$${m}" o="$(VAL_PRIVSEP_USER)$${o}";\
254 __copychownfile "$${m}" "$${o}" "$(VAL_PRIVSEP)" \
255 "$(VAL_LIBEXECDIR)/$(VAL_PRIVSEP)";\
258 if [ -z "$(DESTDIR)" ]; then \
259 __copyfile 0555 "$(VAL_UAGENT)-uninstall.sh" \
260 "$(VAL_BINDIR)/$(VAL_UAGENT)-uninstall.sh";\
265 @echo 'Invoke $(VAL_UAGENT)-uninstall.sh to uninstall $(VAL_UAGENT)'
269 $(rm) -f $(OBJ) $(VAL_UAGENT) ./gen-mime-types.h ./uman.1 ./urc.rc;\
270 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
271 $(rm) -f ./privsep.o ./$(VAL_PRIVSEP);\
274 if [ -f "$(VAL_UAGENT)-uninstall.sh" ]; then \
275 $(rm) -f ./$(VAL_UAGENT)-uninstall.sh;\
282 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise need to change
285 @LC_ALL=C; export LC_ALL;\
286 if [ -z "$(VERSION)" ]; then \
287 eval VERSION="`(cd $(SRCDIR);\
288 [ -d .git ] && git describe --tags) 2>/dev/null`";\
289 if [ -n "$${VERSION}" ]; then \
290 VERSION="`echo $${VERSION} |\
291 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
292 [ "`(cd $(SRCDIR) && git status --porcelain) |\
295 /gen-version\.h/ {next}\
300 VERSION="$${VERSION}-dirty";\
302 $(_version_from_header);\
303 echo "$${VERSION}" | $(grep) -q -F dirty ||\
304 VERSION="$${VERSION}-dirty";\
307 vmaj="`echo \"$${VERSION}\" |\
308 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
309 vmin="`echo \"$${VERSION}\" |\
310 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
311 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
312 vupd="`echo \"$${VERSION}\" |\
313 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
314 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
315 trap "$(rm) -f ./version.tmp" 0 1 2 15;\
316 printf > ./version.tmp "#define n_VERSION \"v$${VERSION}\"\n";\
317 printf >> ./version.tmp \
318 "#define n_VERSION_DATE \"`date -u +'%Y-%m-%d'`\"\n";\
319 printf >> ./version.tmp "#define n_VERSION_MAJOR \"$${vmaj}\"\n";\
320 printf >> ./version.tmp "#define n_VERSION_MINOR \"$${vmin}\"\n";\
321 printf >> ./version.tmp "#define n_VERSION_UPDATE \"$${vupd}\"\n";\
322 printf >> ./version.tmp \
323 "#define n_VERSION_HEXNUM \"0x%02X%03X%03X\"\n" \
324 "$${vmaj}" "$${vmin}" "$${vupd}";\
325 $(cmp) ./version.tmp ./gen-version.h >/dev/null 2>&1 && exit;\
326 $(mv) ./version.tmp ./gen-version.h;\