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
106 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
107 $(_version_from_header) \
108 < $(SRCDIR)nail.1 > $(@) $(awk) '\
109 BEGIN { written = 0 }\
110 /\.\\"--MKMAN-START--/, /\.\\"--MKMAN-END--/ {\
114 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
116 un = toupper(ENVIRON["_UAGENT"]);\
118 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
119 print ".ds UU \\\\%", un;\
120 print ".ds UA \\\\%", cn;\
121 print ".ds uA \\\\%", ln;\
123 path = ENVIRON["_SYSCONFRC"];\
124 gsub("/", "/\\:", path);\
125 print ".ds UR \\\\%", path;\
132 urc.rc: $(SRCDIR)nail.rc
134 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
135 $(_version_from_header) \
136 < $(SRCDIR)nail.rc > $(@) $(awk) 'BEGIN {written = 0}\
137 /^#--MKRC-START--/, /^#--MKRC-END--/ {\
142 ln = tolower(ENVIRON["_UAGENT"]);\
143 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
144 print "#@ ", ENVIRON["_SYSCONFRC"];\
145 print "#@ Configuration file for ", cn, " v",\
156 _dir="$(DESTDIR)$${1}";\
157 if [ -d "$${_dir}" ]; then :; else \
158 $(mkdir) -m 0755 -p "$${_dir}";\
162 _mode=$${1} _src=$${2} _xdst=$${3} _dst="$(DESTDIR)$${3}";\
163 $(cp) -f "$${_src}" "$${_dst}";\
164 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
165 "$(VAL_UAGENT)-uninstall.sh";\
166 $(chmod) $${_mode} "$${_dst}";\
170 _mode=$${1} _ident=$${2} _src=$${3} \
171 _xdst=$${4} _dst="$(DESTDIR)$${4}";\
172 $(cp) -f "$${_src}" "$${_dst}";\
173 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
174 "$(VAL_UAGENT)-uninstall.sh";\
175 $(chown) $${_ident} "$${_dst}" || true;\
176 $(chmod) $${_mode} "$${_dst}";\
181 if [ "$(OPT_DEBUG)" != 0 ]; then :;\
182 elif [ -n "$(HAVE_STRIP)" ]; then \
183 $(strip) "$${_file}";\
187 echo '#!/bin/sh -' > "$(VAL_UAGENT)-uninstall.sh";\
188 echo '#@ Uninstall script for $(VAL_UAGENT)' >> \
189 "$(VAL_UAGENT)-uninstall.sh";\
190 echo >> "$(VAL_UAGENT)-uninstall.sh";\
191 echo 'DESTDIR="$(DESTDIR)"' >> "$(VAL_UAGENT)-uninstall.sh";\
192 echo 'DESTDIR=' >> "$(VAL_UAGENT)-uninstall.sh";\
193 echo >> "$(VAL_UAGENT)-uninstall.sh";\
195 if [ -n "$(DESTDIR)" ]; then __mkdir ''; fi;\
196 __mkdir "$(VAL_BINDIR)";\
197 __mkdir "$(VAL_MANDIR)/man1";\
198 __mkdir "$(VAL_SYSCONFDIR)";\
200 __stripfile "$(VAL_UAGENT)";\
201 __copyfile 0555 "$(VAL_UAGENT)" "$(VAL_BINDIR)/$(VAL_UAGENT)";\
202 __copyfile 0444 ./uman.1 "$(VAL_MANDIR)/man1/$(VAL_UAGENT).1";\
203 if [ -f "$(DESTDIR)$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)" ]; then :; else \
204 __copyfile 0444 ./urc.rc "$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)";\
207 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
208 __mkdir "$(VAL_LIBEXECDIR)";\
210 __stripfile "$(VAL_PRIVSEP)";\
212 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
213 m="g=rxs,$${m}" o=":$(VAL_PRIVSEP_GROUP)";\
217 if [ -n "$(VAL_PRIVSEP_USER)" ]; then \
218 m="u=rxs,$${m}" o="$(VAL_PRIVSEP_USER)$${o}";\
222 __copychownfile "$${m}" "$${o}" "$(VAL_PRIVSEP)" \
223 "$(VAL_LIBEXECDIR)/$(VAL_PRIVSEP)";\
226 if [ -z "$(DESTDIR)" ]; then \
227 __copyfile 0555 "$(VAL_UAGENT)-uninstall.sh" \
228 "$(VAL_BINDIR)/$(VAL_UAGENT)-uninstall.sh";\
233 @echo 'Invoke $(VAL_UAGENT)-uninstall.sh to uninstall $(VAL_UAGENT)'
237 $(rm) -f $(OBJ) $(VAL_UAGENT) ./gen-mime-types.h ./uman.1 ./urc.rc;\
238 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
239 $(rm) -f ./privsep.o ./$(VAL_PRIVSEP);\
242 if [ -f "$(VAL_UAGENT)-uninstall.sh" ]; then \
243 $(rm) -f ./$(VAL_UAGENT)-uninstall.sh;\
250 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise need to change
253 @LC_ALL=C; export LC_ALL;\
254 if [ -z "$(VERSION)" ]; then \
255 eval VERSION="`(cd $(SRCDIR);\
256 [ -d .git ] && git describe --tags) 2>/dev/null`";\
257 if [ -n "$${VERSION}" ]; then \
258 VERSION="`echo $${VERSION} |\
259 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
260 [ "`(cd $(SRCDIR) && git status --porcelain) |\
263 /gen-version\.h/ {next}\
268 VERSION="$${VERSION}-dirty";\
270 $(_version_from_header);\
271 echo "$${VERSION}" | $(grep) -q -F dirty ||\
272 VERSION="$${VERSION}-dirty";\
275 vmaj="`echo \"$${VERSION}\" |\
276 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
277 vmin="`echo \"$${VERSION}\" |\
278 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
279 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
280 vupd="`echo \"$${VERSION}\" |\
281 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
282 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
283 trap "$(rm) -f ./version.tmp" 0 1 2 15;\
284 printf > ./version.tmp "#define n_VERSION \"v$${VERSION}\"\n";\
285 printf >> ./version.tmp \
286 "#define n_VERSION_DATE \"`date -u +'%Y-%m-%d'`\"\n";\
287 printf >> ./version.tmp "#define n_VERSION_MAJOR \"$${vmaj}\"\n";\
288 printf >> ./version.tmp "#define n_VERSION_MINOR \"$${vmin}\"\n";\
289 printf >> ./version.tmp "#define n_VERSION_UPDATE \"$${vupd}\"\n";\
290 $(cmp) ./version.tmp ./gen-version.h >/dev/null 2>&1 && exit;\
291 $(mv) ./version.tmp ./gen-version.h;\