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