Obsolete *autoinc* (keep only *newmail*)
[s-mailx.git] / mk-mk.in
blobf3098784ecdfd23aaeaa2924aac2888f7a77f193
1 #@ `mk-mk.in' -- mk.mk template, completed by mk-conf.sh
2 #@ Please see `INSTALL' and `conf.rc' instead.
4 OBJ = $(OBJ_SRC:.c=.o)
5 .SUFFIXES: .o .c .y
6 .c.o:
7         @if [ -z "$(VERBOSE)" ]; then echo '  CC $(<)';\
8         else echo '  $$ $(CC) $(CFLAGS) $(INCLUDES) -c $(<)';\
9         fi;\
10         $(CC) $(CFLAGS) $(INCLUDES) -c $(<)
11 .c .y: ;
13 all: _all_echoes $(UAGENT)
14 _all_echoes:
15         @echo 'Building..';\
16         if [ -z "$(VERBOSE)" ]; then \
17                 echo '. CC      : $(CC)';\
18                 echo '. CFLAGS  : $(CFLAGS)';\
19                 echo '. INCLUDES: $(INCLUDES)';\
20                 [ -n "$(LDFLAGS)" ] && echo '. LDFLAGS : $(LDFLAGS)';\
21                 echo '. LIBS    : $(LIBS)';\
22         fi
23 $(UAGENT): $(OBJ)
24         @if [ -z "$(VERBOSE)" ]; then echo '  LINK $(@)';\
25         else echo '  $$ $(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)';\
26         fi;\
27         $(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)
29 $(OBJ): config.h nail.h extern.h $(OBJ_DEP)
30 config.o acmava.o: okeys.h
31 config.o imap.o: imap_gssapi.h
32 config.o lex.o: cmd_tab.h
33 config.o main.o: version.h
34 config.o imap.o smtp.o auxlily.o pop3.o: rfc1321.h
35 config.o mime.o: mime_types.h
37 mime_types.h: mime.types
38         @echo '  GEN $(@)';\
39         < ./mime.types > $(@) $(SED) -e '/^#/d; /^$$/d; s/^/    "/; s/$$/",/'
41 test:
42         @echo 'Running test, please wait';\
43         $(SHELL) ./cc-test.sh --check-only ./$(UAGENT)
45 mkman.1: nail.1 mk.mk
46         @[ -n "$(VERBOSE)" ] && echo '  GEN $(UAGENT) manual ($(@))';\
47         _VERSION=`< version.h \
48                 $(SED) -e 's/^\#define VERSION "\\(.\\{1,\\}\\)"$$/\\1/'` \
49         _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
50         < ./nail.1 > $(@) $(AWK) 'BEGIN {written = 0}\
51         /.\"--MKMAN-START--/, /.\"--MKMAN-END--/ {\
52                 if (written == 1)\
53                         next;\
54                 written = 1;\
55                 OFS = "";\
56                 un = toupper(ENVIRON["_UAGENT"]);\
57                 ln = tolower(un);\
58                 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
59                 print ".ds UU \\\\%", un;\
60                 print ".ds UA \\\\%", cn;\
61                 printf ".ds UV \\\\%%%s [%s]\n", cn, ENVIRON["_VERSION"];\
62                 print ".ds ua \\\\%", ln;\
63                 print ".ds UR \\\\%", ENVIRON["_SYSCONFRC"];\
64                 OFS = " ";\
65                 next\
66         }\
67         {print}\
68         '
70 mkrc.rc: nail.rc mk.mk
71         @[ -n "$(VERBOSE)" ] &&\
72                 echo '  GEN $(UAGENT) default resource file ($(@))';\
73         _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
74         < ./nail.rc > $(@) $(AWK) 'BEGIN {written = 0}\
75         /#--MKRC-START--/, /#--MKRC-END--/ {\
76                 if (written == 1)\
77                         next;\
78                 written = 1;\
79                 OFS = "";\
80                 ln = tolower(ENVIRON["_UAGENT"]);\
81                 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
82                 print "# ", ENVIRON["_SYSCONFRC"];\
83                 print "# Configuration file for ", cn, "(1)";\
84                 OFS = " ";\
85                 next\
86         }\
87         {print}\
88         '
90 _install_echoes:
91         @echo 'Installing..'
92 install: _install_echoes mk.mk mkman.1 mkrc.rc
93         @__mkdir() {\
94                 _dir=$${1};\
95                 if [ ! -d "$${_dir}" ]; then \
96                         if [ -n "$(VERBOSE)" ]; then \
97                                 echo "  \$$ $(MKDIR) -m 0755 -p '$${_dir}'";\
98                         fi;\
99                         $(MKDIR) -m 0755 -p "$${_dir}";\
100                 fi; \
101         };\
102         __copyfile() {\
103                 _mode=$${1} _src=$${2} _dst=$${3};\
104                 if [ -n "$(VERBOSE)" ]; then \
105                         echo "  \$$ $(CP) -f '$${_src}' '$${_dst}'";\
106                         echo "  \$$ $(CHMOD) $${_mode} '$${_dst}'";\
107                 fi;\
108                 $(CP) -f "$${_src}" "$${_dst}";\
109                 $(CHMOD) $${_mode} "$${_dst}";\
110         };\
111         __stripfile() {\
112                 _file=$${1};\
113                 if [ "$(WANT_DEBUG)" != 0 ]; then \
114                         if [ -n "$(VERBOSE)" ]; then \
115                                 echo "  \$$ :WANT_DEBUG=1, not strip(1)ing";\
116                         fi;\
117                 elif [ -n "$(HAVE_STRIP)" ]; then \
118                         if [ -n "$(VERBOSE)" ]; then \
119                                 echo "  \$$ $(STRIP) '$${_file}'";\
120                         fi;\
121                         $(STRIP) "$${_file}";\
122                 fi;\
123         };\
124         if [ -n "$(DESTDIR)" ]; then __mkdir "$(DESTDIR)"; fi;\
125         __mkdir "$(DESTDIR)$(BINDIR)";\
126         __copyfile 0755 "$(UAGENT)" "$(DESTDIR)$(BINDIR)/$(UAGENT)";\
127         __stripfile "$(DESTDIR)$(BINDIR)/$(UAGENT)";\
128         __mkdir "$(DESTDIR)$(MANDIR)/man1";\
129         __copyfile 0644 ./mkman.1 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1";\
130         __mkdir "$(DESTDIR)$(SYSCONFDIR)";\
131         if [ ! -f "$(DESTDIR)$(SYSCONFRC)" ]; then \
132                 __copyfile 0644 ./mkrc.rc "$(DESTDIR)$(SYSCONFRC)";\
133         fi
135 uninstall:
136         @echo 'Uninstalling..';\
137         [ -n "$(VERBOSE)" ] &&\
138                 echo '  $$ $(RM) -f "$(DESTDIR)$(BINDIR)/$(UAGENT)" \
139                         "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1"';\
140         $(RM) -f "$(DESTDIR)$(BINDIR)/$(UAGENT)" \
141                 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1";\
142         [ -n "$(VERBOSE)" ] && [ -f "$(DESTDIR)$(SYSCONFRC)" ] &&\
143                 echo '  NOTE: not removing "$(DESTDIR)$(SYSCONFRC)"!'
145 clean:
146         @echo 'Cleaning up..';\
147         [ -n "$(VERBOSE)" ] &&\
148                 echo '  $$ $(RM) -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 \
149                         ./mkrc.rc';\
150         $(RM) -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 ./mkrc.rc
152 distclean: clean
153         @echo 'Deconfiguring..';\
154         [ -n "$(VERBOSE)" ] && echo '  $$ $(RM) -f ./config.* ./*.mk';\
155         $(RM) -f ./config.* ./*.mk
157 _update-version:
158         @if [ -z "$(VERSION)" ]; then \
159                 eval VERSION="`(git describe --tags) 2>/dev/null`";\
160                 if [ -z "$${VERSION}" ]; then \
161                         VERSION="`$(SED) -e 's/[^\"]*\"\([^\"]\{1,\}\)\"/\1/' \
162                                 version.h`";\
163                         echo "$${VERSION}" | $(GREP) -q -F dirty ||\
164                                 VERSION="$${VERSION}-dirty";\
165                 fi;\
166         fi;\
167         trap "$(RM) ./version.tmp" 0 1 2 15;\
168         printf > ./version.tmp "#define VERSION \"$${VERSION}\"\n";\
169         $(CMP) ./version.tmp ./version.h >/dev/null 2>&1 && exit;\
170         mv ./version.tmp ./version.h;\
171         trap - 0 1 2 15
173 _update-release:
174         if [ "`git rev-parse --verify HEAD`" != \
175                         "`git rev-parse --verify master`" ]; then \
176                 echo >&2 'Not on the [master] branch';\
177                 exit 1;\
178         fi;\
179         echo 'Name of release tag:';\
180         read REL;\
181         echo "Is $(UAGENT) <v$${REL}> correct?  ENTER continues";\
182         read i;\
183         FREL=`echo $${REL} | $(SED) -e 's/\./_/g'` &&\
184         $(MAKE) -f ./mk.mk _update-version &&\
185         git add version.h &&\
186         git commit -m "Bump $(UAGENT) v$${REL}" &&\
187         git tag -f "v$${REL}" &&\
188         $(MAKE) -f ./mk.mk _update-version &&\
189         git add version.h && git commit --amend &&\
190         git tag -f "v$${REL}" &&\
191         git update-ref refs/heads/next master &&\
192         git log --no-walk --decorate --oneline --branches --remotes &&\
193         git branch &&\
194         echo "Push git(1) repo?  ENTER continues";\
195         read i;\
196         git push &&\
197         git archive --prefix="$(UAGENT)-$${REL}/" \
198                 -o "$${TMPDIR}/$(UAGENT)-$${FREL}.tar.gz" HEAD &&\
199         cd "$${TMPDIR}" &&\
200         tar -x -z -f "$(UAGENT)-$${FREL}.tar.gz" &&\
201         $(RM) -f "$(UAGENT)-$${FREL}.tar.gz" &&\
202         tar -c -f "$(UAGENT)-$${FREL}.tar" "$(UAGENT)-$${REL}" &&\
203         < "$(UAGENT)-$${FREL}.tar" gzip > "$(UAGENT)-$${FREL}.tar.gz" &&\
204         < "$(UAGENT)-$${FREL}.tar" xz > "$(UAGENT)-$${FREL}.tar.xz" &&\
205         $(RM) -f "$(UAGENT)-$${FREL}.tar" &&\
206         openssl md5 "$(UAGENT)-$${FREL}.tar.gz" > \
207                 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
208         openssl sha1 "$(UAGENT)-$${FREL}.tar.gz" >> \
209                 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
210         openssl sha256 "$(UAGENT)-$${FREL}.tar.gz" >> \
211                 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
212         openssl md5 "$(UAGENT)-$${FREL}.tar.xz" >> \
213                 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
214         openssl sha1 "$(UAGENT)-$${FREL}.tar.xz" >> \
215                 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
216         openssl sha256 "$(UAGENT)-$${FREL}.tar.xz" >> \
217                 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
218         ( echo "-put $(UAGENT)-$${FREL}.tar.gz";\
219           echo "-put $(UAGENT)-$${FREL}.tar.xz" ) | \
220         sftp -b - sdaoden@frs.sourceforge.net:/home/frs/project/s-nail &&\
221         echo 'All seems fine';\
222         echo 'Really send announcement mail?  ENTER continues';\
223         read i;\
224         cd "$(UAGENT)-$${REL}" &&\
225         make devel &&\
226         ./s-nail -A sdn_sf -s "[ANNOUNCE] of S-nail v$${REL}" nail-announce &&\
227         cd .. &&\
228         echo "Really remove $(UAGENT)-$${REL} build dir?  ENTER continues";\
229         read i;\
230         $(RM) -rf "$(UAGENT)-$${REL}" &&\
231         echo 'Uff.'
233 # vim:set fenc=utf-8 ft=make: