1 #@ make-config.in -- mk-config.mk template, completed by make-config.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="`< gen-version.h $(sed) \
7 -e '/ n_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): mk-config.h config.h nail.h nailfuns.h $(AMALGAM_DEP)
23 $(AMALGAM_TARGET) auxlily.c: gen-errors.h
24 $(AMALGAM_TARGET) accmacvar.o: gen-okeys.h gen-version.h
25 $(AMALGAM_TARGET) cmd-tab.o: cmd-tab.h
26 $(AMALGAM_TARGET) dotlock.o: dotlock.h
27 $(AMALGAM_TARGET) obs-imap.o: obs-imap-gssapi.h
28 $(AMALGAM_TARGET) mime-types.o: gen-mime-types.h
29 $(AMALGAM_TARGET) obs-imap.o pop3.o smtp.o urlcrecry.o: rfc1321.h
30 $(AMALGAM_TARGET) smtp.o: smtp-gssapi.h
31 $(AMALGAM_TARGET) termcap.o: gen-tcaps.h
33 $(VAL_PRIVSEP): privsep.o
34 $(ECHO_LINK)$(CC) $(LDFLAGS) -o $(@) privsep.o $(BASE_LIBS)
37 privsep.o: privsep.c mk-config.h config.h nail.h dotlock.h
38 $(ECHO_CC)$(CC) $(CFLAGS) $(BASE_INCS) -c privsep.c
43 awk=$(awk) cat=$(cat) cksum=$(cksum) rm=$(rm) sed=$(sed) grep=$(grep) \
44 $(SHELL) ./cc-test.sh --check-only ./$(VAL_UAGENT)
46 gen-mime-types.h: mime.types
48 LC_ALL=C < ./mime.types > $(@) $(awk) '\
49 function add(mt, ln) {\
50 gsub(/[[:space:]]+/, " ", ln);\
53 for (j = 1; j <= i; ++j) {\
55 e = (e ? e " " : "") k\
59 e_a[mt] = e_a[mt] " ";\
63 /^[[:space:]]*#/ {next}\
64 /^[[:space:]]*$$/ {ltype = ""; next}\
67 print "FAULTY CONTINUATION: " $$0 >> "/dev/stderr";\
71 /^(@([thH]@)? )?[[:alpha:]]/ {\
72 if ($$1 ~ /^@([thH]@)?$$/) {\
78 if ($$1 !~ /^([[:alnum:]]+)\/([[:alnum:]_+-]+)$$/)\
79 print "FAULTY MIME TYPE: <" $$1 ">" >> "/dev/stderr";\
80 ltype = $$1; $$1 = "";\
84 no_a[++no_ai] = nt_a[ltype] = ltype;\
88 for (z = 1; z <= no_ai; ++z) {\
91 mt = toupper(substr(t, 1, j - 1));\
92 j = substr(t, j + 1);\
98 if (tm == "@" || tm == "@t@")\
99 mt = "_MT_" mt " | _MT_PLAIN";\
100 else if (tm == "@h@")\
101 mt = "_MT_" mt " | _MT_SOUP_h";\
102 else if (tm == "@H@")\
103 mt = "_MT_" mt " | _MT_SOUP_H";\
105 print " {" mt ", " l ", \"" j e_a[t] "\"},"\
112 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
113 $(_version_from_header) \
114 < ./nail.1 > $(@) $(awk) '\
115 BEGIN { written = 0 }\
116 /\.\\"--MKMAN-START--/, /\.\\"--MKMAN-END--/ {\
120 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
122 un = toupper(ENVIRON["_UAGENT"]);\
124 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
125 print ".ds UU \\\\%", un;\
126 print ".ds UA \\\\%", cn;\
127 print ".ds uA \\\\%", ln;\
129 path = ENVIRON["_SYSCONFRC"];\
130 gsub("/", "/\\:", path);\
131 print ".ds UR \\\\%", path;\
140 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
141 $(_version_from_header) \
142 < ./nail.rc > $(@) $(awk) 'BEGIN {written = 0}\
143 /^#--MKRC-START--/, /^#--MKRC-END--/ {\
148 ln = tolower(ENVIRON["_UAGENT"]);\
149 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
150 print "#@ ", ENVIRON["_SYSCONFRC"];\
151 print "#@ Configuration file for ", cn, "(1) v",\
162 _dir="$(DESTDIR)$${1}";\
163 if [ -d "$${_dir}" ]; then :; else \
164 $(mkdir) -m 0755 -p "$${_dir}";\
168 _mode=$${1} _src=$${2} _xdst=$${3} _dst="$(DESTDIR)$${3}";\
169 $(cp) -f "$${_src}" "$${_dst}";\
170 $(chmod) $${_mode} "$${_dst}";\
172 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
173 "$(VAL_UAGENT)-uninstall.sh";\
176 _mode=$${1} _ident=$${2} _src=$${3} \
177 _xdst=$${4} _dst="$(DESTDIR)$${4}";\
178 $(cp) -f "$${_src}" "$${_dst}";\
179 $(chown) $${_ident} "$${_dst}";\
180 $(chmod) $${_mode} "$${_dst}";\
182 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
183 "$(VAL_UAGENT)-uninstall.sh";\
187 if [ "$(OPT_DEBUG)" != 0 ]; then :;\
188 elif [ -n "$(HAVE_STRIP)" ]; then \
189 $(strip) "$${_file}";\
193 echo '#!/bin/sh -' > "$(VAL_UAGENT)-uninstall.sh";\
194 echo '#@ Uninstall script for $(VAL_UAGENT)' >> \
195 "$(VAL_UAGENT)-uninstall.sh";\
196 echo >> "$(VAL_UAGENT)-uninstall.sh";\
197 echo 'DESTDIR="$(DESTDIR)"' >> "$(VAL_UAGENT)-uninstall.sh";\
198 echo 'DESTDIR=' >> "$(VAL_UAGENT)-uninstall.sh";\
199 echo >> "$(VAL_UAGENT)-uninstall.sh";\
201 if [ -n "$(DESTDIR)" ]; then __mkdir ''; fi;\
202 __mkdir "$(VAL_BINDIR)";\
203 __mkdir "$(VAL_MANDIR)/man1";\
204 __mkdir "$(VAL_SYSCONFDIR)";\
206 __stripfile "$(VAL_UAGENT)";\
207 __copyfile 0555 "$(VAL_UAGENT)" "$(VAL_BINDIR)/$(VAL_UAGENT)";\
208 __copyfile 0444 ./uman.1 "$(VAL_MANDIR)/man1/$(VAL_UAGENT).1";\
209 if [ -f "$(DESTDIR)$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)" ]; then :; else \
210 __copyfile 0444 ./urc.rc "$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)";\
213 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
214 __mkdir "$(VAL_LIBEXECDIR)";\
216 __stripfile "$(VAL_PRIVSEP)";\
218 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
219 m="g=rxs,$${m}" o=":$(VAL_PRIVSEP_GROUP)";\
223 if [ -n "$(VAL_PRIVSEP_USER)" ]; then \
224 m="u=rxs,$${m}" o="$(VAL_PRIVSEP_USER)$${o}";\
228 __copychownfile "$${m}" "$${o}" "$(VAL_PRIVSEP)" \
229 "$(VAL_LIBEXECDIR)/$(VAL_PRIVSEP)";\
232 if [ -z "$(DESTDIR)" ]; then \
233 __copyfile 0555 "$(VAL_UAGENT)-uninstall.sh" \
234 "$(VAL_BINDIR)/$(VAL_UAGENT)-uninstall.sh";\
239 @echo 'Invoke $(VAL_UAGENT)-uninstall.sh to uninstall $(VAL_UAGENT)'
243 $(rm) -f $(OBJ) $(VAL_UAGENT) ./gen-mime-types.h ./uman.1 ./urc.rc;\
244 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
245 $(rm) -f ./privsep.o ./$(VAL_PRIVSEP);\
248 if [ -f "$(VAL_UAGENT)-uninstall.sh" ]; then \
249 $(rm) -f ./$(VAL_UAGENT)-uninstall.sh;\
256 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise need to change
259 @LC_ALL=C; export LC_ALL;\
260 if [ -z "$(VERSION)" ]; then \
261 eval VERSION="`(git describe --tags) 2>/dev/null`";\
262 if [ -n "$${VERSION}" ]; then \
263 VERSION="`echo $${VERSION} |\
264 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
265 [ "`git status --porcelain |\
268 /gen-version\.h/ {next}\
273 VERSION="$${VERSION}-dirty";\
275 $(_version_from_header);\
276 echo "$${VERSION}" | $(grep) -q -F dirty ||\
277 VERSION="$${VERSION}-dirty";\
280 vmaj="`echo \"$${VERSION}\" |\
281 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
282 vmin="`echo \"$${VERSION}\" |\
283 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
284 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
285 vupd="`echo \"$${VERSION}\" |\
286 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
287 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
288 trap "$(rm) -f ./version.tmp" 0 1 2 15;\
289 printf > ./version.tmp "#define n_VERSION \"v$${VERSION}\"\n";\
290 printf >> ./version.tmp \
291 "#define n_VERSION_DATE \"`date -u +'%Y-%m-%d'`\"\n";\
292 printf >> ./version.tmp "#define n_VERSION_MAJOR \"$${vmaj}\"\n";\
293 printf >> ./version.tmp "#define n_VERSION_MINOR \"$${vmin}\"\n";\
294 printf >> ./version.tmp "#define n_VERSION_UPDATE \"$${vupd}\"\n";\
295 $(cmp) ./version.tmp ./gen-version.h >/dev/null 2>&1 && exit;\
296 $(mv) ./version.tmp ./gen-version.h;\