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