1 #@ mk-mk.in -- mk.mk template, completed by mk-conf.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="`< version.h $(sed) \
7 -e '/ 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)
19 $(ECHO_LINK)$(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)
22 $(OBJ): config.h nail.h nailfuns.h $(AMALGAM_DEP)
23 $(AMALGAM_TARGET) accmacvar.o: okeys.h version.h
24 $(AMALGAM_TARGET) dotlock.o: dotlock.h
25 $(AMALGAM_TARGET) lex_input.o: cmd_tab.h
26 $(AMALGAM_TARGET) mime_types.o: mime_types.h
27 $(AMALGAM_TARGET) pop3.o smtp.o urlcrecry.o: rfc1321.h
28 $(AMALGAM_TARGET) smtp.o: smtp_gssapi.h
29 $(AMALGAM_TARGET) termcap.o: tcaps.h
31 $(VAL_PRIVSEP): privsep.o
32 $(ECHO_LINK)$(CC) $(LDFLAGS) -o $(@) privsep.o $(BASE_LIBS)
35 privsep.o: privsep.c config.h nail.h dotlock.h
36 $(ECHO_CC)$(CC) $(CFLAGS) $(BASE_INCS) -c privsep.c
41 awk=$(awk) cat=$(cat) cksum=$(cksum) rm=$(rm) sed=$(sed) grep=$(grep) \
42 $(SHELL) ./cc-test.sh --check-only ./$(VAL_UAGENT)
44 mime_types.h: mime.types
46 LC_ALL=C < ./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 /^(@([thH]@)? )?[[:alpha:]]/ {\
70 if ($$1 ~ /^@([thH]@)?$$/) {\
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 " | _MT_PLAIN";\
98 else if (tm == "@h@")\
99 mt = "_MT_" mt " | _MT_SOUP_h";\
100 else if (tm == "@H@")\
101 mt = "_MT_" mt " | _MT_SOUP_H";\
103 print " {" mt ", " l ", \"" j e_a[t] "\"},"\
110 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
111 $(_version_from_header) \
112 < ./nail.1 > $(@) $(awk) '\
113 BEGIN { written = 0 }\
114 /\.\\"--MKMAN-START--/, /\.\\"--MKMAN-END--/ {\
118 un = toupper(ENVIRON["_UAGENT"]);\
120 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
121 print ".ds UU \\\\%", un;\
122 print ".ds UA \\\\%", cn;\
123 print ".ds ua \\\\%", ln;\
124 print ".ds VV \\\\%v", ENVIRON["VERSION"];\
125 path = ENVIRON["_SYSCONFRC"];\
126 gsub("/", "/\\:", path);\
127 print ".ds UR \\\\%", path;\
136 LC_ALL=C _SYSCONFRC="$(VAL_SYSCONFRC)" _UAGENT="$(VAL_UAGENT)" \
137 $(_version_from_header) \
138 < ./nail.rc > $(@) $(awk) 'BEGIN {written = 0}\
139 /^#--MKRC-START--/, /^#--MKRC-END--/ {\
144 ln = tolower(ENVIRON["_UAGENT"]);\
145 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
146 print "#@ ", ENVIRON["_SYSCONFRC"];\
147 print "#@ Configuration file for ", cn, "(1) v",\
155 install: mkman.1 mkrc.rc
159 if [ -d "$${_dir}" ]; then :; else\
160 $(mkdir) -m 0755 -p "$${_dir}";\
164 _mode=$${1} _src=$${2} _dst=$${3};\
165 $(cp) -f "$${_src}" "$${_dst}";\
166 $(chmod) $${_mode} "$${_dst}";\
169 _mode=$${1} _ident=$${2} _src=$${3} _dst=$${4};\
170 $(cp) -f "$${_src}" "$${_dst}";\
171 $(chown) $${_ident} "$${_dst}";\
172 $(chmod) $${_mode} "$${_dst}";\
176 if [ "$(OPT_DEBUG)" != 0 ]; then :;\
177 elif [ -n "$(HAVE_STRIP)" ]; then \
178 $(strip) "$${_file}";\
181 if [ -n "$(DESTDIR)" ]; then __mkdir "$(DESTDIR)"; fi;\
182 __mkdir "$(DESTDIR)$(VAL_BINDIR)";\
183 __stripfile "$(VAL_UAGENT)";\
184 __copyfile 0555 "$(VAL_UAGENT)" \
185 "$(DESTDIR)$(VAL_BINDIR)/$(VAL_UAGENT)";\
186 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
187 __mkdir "$(DESTDIR)$(VAL_LIBEXECDIR)";\
188 __stripfile "$(VAL_PRIVSEP)";\
190 if [ -n "$(_____PRIVSEP_GROUP)" ]; then \
191 m="g=rxs,$${m}" o=":$(VAL_PRIVSEP_GROUP)";\
195 if [ -n "$(VAL_PRIVSEP_USER)" ]; then \
196 m="u=rxs,$${m}" o="$(VAL_PRIVSEP_USER)$${o}";\
200 __copychownfile "$${m}" "$${o}" "$(VAL_PRIVSEP)" \
201 "$(DESTDIR)$(VAL_LIBEXECDIR)/$(VAL_PRIVSEP)";\
203 __mkdir "$(DESTDIR)$(VAL_MANDIR)/man1";\
204 __copyfile 0444 ./mkman.1 \
205 "$(DESTDIR)$(VAL_MANDIR)/man1/$(VAL_UAGENT).1";\
206 __mkdir "$(DESTDIR)$(VAL_SYSCONFDIR)";\
207 if [ -f "$(DESTDIR)$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)" ]; then :; else\
208 __copyfile 0444 ./mkrc.rc \
209 "$(DESTDIR)$(VAL_SYSCONFDIR)/$(VAL_SYSCONFRC)";\
215 echo 'Uninstalling..';\
216 $(rm) -f "$(DESTDIR)$(VAL_BINDIR)/$(VAL_UAGENT)" \
217 "$(DESTDIR)$(VAL_MANDIR)/man1/$(VAL_UAGENT).1";\
218 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
219 $(rm) -f "$(DESTDIR)$(VAL_LIBEXECDIR)/$(VAL_PRIVSEP)";\
221 if [ -n "$(VERBOSE)" ] && [ -f "$(DESTDIR)$(VAL_SYSCONFRC)" ]; then \
222 echo ' NOTE: not removing "$(DESTDIR)$(VAL_SYSCONFRC)"';\
228 $(rm) -f $(OBJ) $(VAL_UAGENT) ./mime_types.h ./mkman.1 ./mkrc.rc;\
229 if [ -n "$(OPTIONAL_PRIVSEP)" ]; then \
230 $(rm) -f ./privsep.o $(VAL_PRIVSEP);\
235 $(rm) -f ./config.* ./*.mk
237 # MUST work with "grep=grep sed=sed cmp=cmp mv=mv", otherwise need to change
240 @LC_ALL=C; export LC_ALL;\
241 if [ -z "$(VERSION)" ]; then \
242 eval VERSION="`(git describe --tags) 2>/dev/null`";\
243 if [ -n "$${VERSION}" ]; then \
244 VERSION="`echo $${VERSION} |\
245 $(sed) -e 's/^v\{0,1\}\(.*\)/\1/'`";\
246 [ "`git status --porcelain |\
254 VERSION="$${VERSION}-dirty";\
256 $(_version_from_header);\
257 echo "$${VERSION}" | $(grep) -q -F dirty ||\
258 VERSION="$${VERSION}-dirty";\
261 vmaj="`echo \"$${VERSION}\" |\
262 $(sed) -e 's/^\([^.]\{1,\}\).*/\1/'`";\
263 vmin="`echo \"$${VERSION}\" |\
264 $(sed) -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`";\
265 [ "$${vmin}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vmin=0;\
266 vupd="`echo \"$${VERSION}\" |\
267 $(sed) -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`";\
268 [ "$${vupd}" = "$${VERSION}" ] && VERSION="$${VERSION}.0" vupd=0;\
269 trap "$(rm) ./version.tmp" 0 1 2 15;\
270 printf > ./version.tmp "#define VERSION \"v$${VERSION}\"\n";\
271 printf >> ./version.tmp "#define VERSION_MAJOR \"$${vmaj}\"\n";\
272 printf >> ./version.tmp "#define VERSION_MINOR \"$${vmin}\"\n";\
273 printf >> ./version.tmp "#define VERSION_UPDATE \"$${vupd}\"\n";\
274 $(cmp) ./version.tmp ./version.h >/dev/null 2>&1 && exit;\
275 $(mv) ./version.tmp ./version.h;\