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
40 MAKE=$(MAKE) SHELL=$(SHELL) \
41 awk=$(awk) cat=$(cat) cksum=$(cksum) rm=$(rm) sed=$(sed) grep=$(grep) \
42 $(SHELL) $(SRCDIR)cc-test.sh --check-only ./$(VAL_UAGENT)
44 gen-mime-types.h: $(SRCDIR)mime.types
46 LC_ALL=C < $(SRCDIR)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 /^(@([thHq]@)? )?[[:alpha:]]/{\
70 if($$1 ~ /^@([thHq]@)?$$/){\
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 " | a_MT_TM_PLAIN";\
99 mt = "_MT_" mt " | a_MT_TM_SOUP_h";\
100 else if(tm == "@H@")\
101 mt = "_MT_" mt " | a_MT_TM_SOUP_H";\
102 else if(tm == "@q@")\
103 mt = "_MT_" mt " | a_MT_TM_QUIET";\
105 print " {" mt ", " l ", \"" j e_a[t] "\"},"\
110 uman.1: $(SRCDIR)nail.1
112 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
113 $(_version_from_header) \
114 < $(SRCDIR)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;\
138 urc.rc: $(SRCDIR)nail.rc
140 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
141 $(_version_from_header) \
142 < $(SRCDIR)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, " 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 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
171 "$(VAL_UAGENT)-uninstall.sh";\
172 $(chmod) $${_mode} "$${_dst}";\
176 _mode=$${1} _ident=$${2} _src=$${3} \
177 _xdst=$${4} _dst="$(DESTDIR)$${4}";\
178 $(cp) -f "$${_src}" "$${_dst}";\
179 echo "rm -f \"\$${DESTDIR}$${_xdst}\"" >> \
180 "$(VAL_UAGENT)-uninstall.sh";\
181 $(chown) $${_ident} "$${_dst}" || true;\
182 $(chmod) $${_mode} "$${_dst}";\
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="`(cd $(SRCDIR);\
262 [ -d .git ] && git describe --tags) 2>/dev/null`";\
263 if [ -n "$${VERSION}" ]; then \
264 VERSION="`echo $${VERSION} |\
265 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
266 [ "`(cd $(SRCDIR) && git status --porcelain) |\
269 /gen-version\.h/ {next}\
274 VERSION="$${VERSION}-dirty";\
276 $(_version_from_header);\
277 echo "$${VERSION}" | $(grep) -q -F dirty ||\
278 VERSION="$${VERSION}-dirty";\
281 vmaj="`echo \"$${VERSION}\" |\
282 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
283 vmin="`echo \"$${VERSION}\" |\
284 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
285 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
286 vupd="`echo \"$${VERSION}\" |\
287 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
288 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
289 trap "$(rm) -f ./version.tmp" 0 1 2 15;\
290 printf > ./version.tmp "#define n_VERSION \"v$${VERSION}\"\n";\
291 printf >> ./version.tmp \
292 "#define n_VERSION_DATE \"`date -u +'%Y-%m-%d'`\"\n";\
293 printf >> ./version.tmp "#define n_VERSION_MAJOR \"$${vmaj}\"\n";\
294 printf >> ./version.tmp "#define n_VERSION_MINOR \"$${vmin}\"\n";\
295 printf >> ./version.tmp "#define n_VERSION_UPDATE \"$${vupd}\"\n";\
296 $(cmp) ./version.tmp ./gen-version.h >/dev/null 2>&1 && exit;\
297 $(mv) ./version.tmp ./gen-version.h;\