config.h, socket.c: move NI_MAXHOST to socket.c
[s-mailx.git] / make-config.in
blobf13d144fd712868d08e5a9a6acfa8324a0a2956b
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)
16         $(SIZE_CHECK)
18 $(OBJ): mk-config.h config.h $(SRCDIR)nail.h $(SRCDIR)nailfuns.h \
19                 $(AMALGAM_DEP)
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)
32         $(SIZE_CHECK)
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 test: all
39         $(ECHO_TEST)\
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
45         $(ECHO_GEN)\
46         LC_ALL=C < $(SRCDIR)mime.types > $(@) $(awk) '\
47         function add(mt, ln){\
48                 gsub(/[[:space:]]+/, " ", ln);\
49                 i = split(ln, i_a);\
50                 e = "";\
51                 for(j = 1; j <= i; ++j){\
52                         k = i_a[j];\
53                         e = (e ? e " " : "") k\
54                 }\
55                 if(e){\
56                         if(e_a[mt])\
57                                 e_a[mt] = e_a[mt] " ";\
58                         e_a[mt] = e_a[mt] e\
59                 }\
60         }\
61         /^[[:space:]]*#/{next}\
62         /^[[:space:]]*$$/{ltype = ""; next}\
63         /^[[:space:]]/{\
64                 if(!ltype)\
65                         print "FAULTY CONTINUATION: " $$0 >> "/dev/stderr";\
66                 add(ltype, $$0);\
67                 next\
68         }\
69         /^(@([thHq]@)? )?[[:alpha:]]/{\
70                 if($$1 ~ /^@([thHq]@)?$$/){\
71                         pa = $$1;\
72                         $$1 = $$2;\
73                         $$2 = ""\
74                 }else\
75                         pa = "";\
76                 if($$1 !~ /^([[:alnum:]]+)\/([[:alnum:]_+-]+)$$/)\
77                         print "FAULTY MIME TYPE: <" $$1 ">" >> "/dev/stderr";\
78                 ltype = $$1; $$1 = "";\
79                 if(pa)\
80                         p_a[ltype] = pa;\
81                 if(!nt_a[ltype])\
82                         no_a[++no_ai] = nt_a[ltype] = ltype;\
83                 add(ltype, $$0)\
84         }\
85         END{\
86                 for(z = 1; z <= no_ai; ++z){\
87                         t = no_a[z];\
88                         j = index(t, "/");\
89                         mt = toupper(substr(t, 1, j - 1));\
90                         j = substr(t, j + 1);\
91                         l = length(j);\
92                         if(!p_a[t])\
93                                 mt = "_MT_" mt;\
94                         else{\
95                                 tm = p_a[t];\
96                                 if(tm == "@" || tm == "@t@")\
97                                         mt = "_MT_" mt " | a_MT_TM_PLAIN";\
98                                 else if(tm == "@h@")\
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";\
104                         }\
105                         print "   {" mt ", " l ", \"" j e_a[t] "\"},"\
106                 }\
107         }\
108         '
110 uman.1: $(SRCDIR)nail.1
111         $(ECHO_GEN)\
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--/ {\
117                 if (written++ != 0)\
118                         next;\
119                 OFS = "";\
120                 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
121                 \
122                 un = toupper(ENVIRON["_UAGENT"]);\
123                 ln = tolower(un);\
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;\
128                 \
129                 path = ENVIRON["_SYSCONFRC"];\
130                 gsub("/", "/\\:", path);\
131                 print ".ds UR \\\\%", path;\
132                 OFS = " ";\
133                 next\
134         }\
135         {print}\
136         '
138 urc.rc: $(SRCDIR)nail.rc
139         $(ECHO_GEN)\
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--/ {\
144                 if (written == 1)\
145                         next;\
146                 written = 1;\
147                 OFS = "";\
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",\
152                         ENVIRON["VERSION"];\
153                 OFS = " ";\
154                 next\
155         }\
156         {print}\
157         '
159 install:
160         $(ECHO_BLOCK_BEGIN)\
161         __mkdir() {\
162                 _dir="$(DESTDIR)$${1}";\
163                 if [ -d "$${_dir}" ]; then :; else \
164                         $(mkdir) -m 0755 -p "$${_dir}";\
165                 fi;\
166         };\
167         __copyfile() {\
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}";\
173                 \
174         };\
175         __copychownfile() {\
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}";\
183                 \
184         };\
185         __stripfile() {\
186                 _file=$${1};\
187                 if [ "$(OPT_DEBUG)" != 0 ]; then :;\
188                 elif [ -n "$(HAVE_STRIP)" ]; then \
189                         $(strip) "$${_file}";\
190                 fi;\
191         };\
192         \
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";\
200         \
201         if [ -n "$(DESTDIR)" ]; then __mkdir ''; fi;\
202         __mkdir "$(VAL_BINDIR)";\
203         __mkdir "$(VAL_MANDIR)/man1";\
204         __mkdir "$(VAL_SYSCONFDIR)";\
205         \
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)";\
211         fi;\
212         \
213         if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
214                 __mkdir "$(VAL_LIBEXECDIR)";\
215                 \
216                 __stripfile "$(VAL_PRIVSEP)";\
217                 m='o=rx' o=;\
218                 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
219                         m="g=rxs,$${m}" o=":$(VAL_PRIVSEP_GROUP)";\
220                 else \
221                         m="g=rx,$${m}";\
222                 fi;\
223                 if [ -n "$(VAL_PRIVSEP_USER)" ]; then \
224                         m="u=rxs,$${m}" o="$(VAL_PRIVSEP_USER)$${o}";\
225                 else \
226                         m="u=rx,$${m}";\
227                 fi;\
228                 __copychownfile "$${m}" "$${o}" "$(VAL_PRIVSEP)" \
229                         "$(VAL_LIBEXECDIR)/$(VAL_PRIVSEP)";\
230         fi;\
231         \
232         if [ -z "$(DESTDIR)" ]; then \
233                 __copyfile 0555 "$(VAL_UAGENT)-uninstall.sh" \
234                         "$(VAL_BINDIR)/$(VAL_UAGENT)-uninstall.sh";\
235         fi;\
236         $(ECHO_BLOCK_END)
238 uninstall:
239         @echo 'Invoke $(VAL_UAGENT)-uninstall.sh to uninstall $(VAL_UAGENT)'
241 clean:
242         $(ECHO_CMD)\
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);\
246         fi;\
247         \
248         if [ -f "$(VAL_UAGENT)-uninstall.sh" ]; then \
249                 $(rm) -f ./$(VAL_UAGENT)-uninstall.sh;\
250         fi
252 distclean: clean
253         $(ECHO_CMD)\
254         $(rm) -f ./mk-*
256 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise need to change
257 # make-release.inc
258 _update-version:
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) |\
267                                 $(awk) '\
268                                         BEGIN {n=0}\
269                                         /gen-version\.h/ {next}\
270                                         /^\?\?/ {next}\
271                                         {++n}\
272                                         END {print n}\
273                                 '`" -ne 0 ] &&\
274                                 VERSION="$${VERSION}-dirty";\
275                 else \
276                         $(_version_from_header);\
277                         echo "$${VERSION}" | $(grep) -q -F dirty ||\
278                                 VERSION="$${VERSION}-dirty";\
279                 fi;\
280         fi;\
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;\
298         trap : 0 1 2 15
300 # s-mk-mode