1 # Until the codebase has been overhauled (and the overhauling has itself been
2 # debugged :) you may read INSTALL for hints. But otherwise:
3 # You are on your own if you turn on fancy compiler features.
5 EXT_CFLAGS = -std=c89 \
7 -fno-unwind-tables -fno-asynchronous-unwind-tables \
9 -fstrict-overflow -Wstrict-overflow=5 \
10 -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2 \
11 -Wall -Wextra -pedantic \
12 -Wbad-function-cast -Wcast-align -Wcast-qual -Winit-self \
13 -Wshadow -Wunused -Wwrite-strings
18 @if [ -z "$(VERBOSE)" ]; then echo ' CC $(<)';\
19 else echo ' $$ $(CC) $(CFLAGS) $(INCLUDES) -c $(<)';\
21 $(CC) $(CFLAGS) $(INCLUDES) -c $(<)
24 all: _all_echoes $(UAGENT)
27 if [ -z "$(VERBOSE)" ]; then \
28 echo '. CC : $(CC) $(CFLAGS) $(WARN)';\
29 echo '. INCLUDES: $(INCLUDES)';\
30 echo '. LDFLAGS : $(LDFLAGS)';\
31 echo '. LIBS : $(LIBS)';\
34 @if [ -z "$(VERBOSE)" ]; then echo ' LD $(@)';\
35 else echo ' $$ $(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)';\
37 $(CC) $(LDFLAGS) -o $(@) $(OBJ) $(LIBS)
39 $(OBJ): config.h nail.h extern.h
43 md5.o imap.o smtp.o auxlily.o pop3.o: md5.h
46 mime_types.h: mime.types
48 < ./mime.types > $(@) sed -e '/^#/d; /^$$/d; s/^/ "/; s/$$/",/'
51 @echo 'Running test, please wait';\
52 $(SHELL) ./cc-test.sh --check-only ./$(UAGENT)
55 @[ -n "$(VERBOSE)" ] && echo ' GEN $(UAGENT) manual ($(@))';\
56 _VERSION=`< version.h \
57 sed -e 's/^\#define VERSION "\\(.\\{1,\\}\\)"$$/\\1/'` \
58 _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
59 < ./nail.1 > $(@) awk 'BEGIN {written = 0}\
60 /.\"--MKMAN-START--/, /.\"--MKMAN-END--/ {\
65 un = toupper(ENVIRON["_UAGENT"]);\
67 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
68 print ".ds UU \\\\%", un;\
69 print ".ds UA \\\\%", cn;\
70 printf ".ds UV \\\\%%%s [%s]\n", cn, ENVIRON["_VERSION"];\
71 print ".ds ua \\\\%", ln;\
72 print ".ds UR \\\\%", ENVIRON["_SYSCONFRC"];\
79 mkrc.rc: nail.rc mk.mk
80 @[ -n "$(VERBOSE)" ] &&\
81 echo ' GEN $(UAGENT) default resource file ($(@))';\
82 _SYSCONFRC="$(SYSCONFRC)" _UAGENT="$(UAGENT)" \
83 < ./nail.rc > $(@) awk 'BEGIN {written = 0}\
84 /#--MKRC-START--/, /#--MKRC-END--/ {\
89 ln = tolower(ENVIRON["_UAGENT"]);\
90 cn = toupper(substr(ln, 1, 1)) substr(ln, 2);\
91 print "# ", ENVIRON["_SYSCONFRC"];\
92 print "# Configuration file for ", cn, "(1)";\
101 install: _install_echoes mk.mk mkman.1 mkrc.rc
102 @if [ ! -d "$(DESTDIR)$(BINDIR)" ]; then \
103 [ -n "$(VERBOSE)" ] &&\
104 echo ' $$ mkdir -p "$(DESTDIR)$(BINDIR)"';\
105 mkdir -p "$(DESTDIR)$(BINDIR)";\
107 [ -n "$(VERBOSE)" ] &&\
108 echo ' $$ $(INSTALL) -c $(UAGENT) \
109 "$(DESTDIR)$(BINDIR)/$(UAGENT)"';\
110 $(INSTALL) -c $(UAGENT) "$(DESTDIR)$(BINDIR)/$(UAGENT)";\
111 [ -n "$(VERBOSE)" ] &&\
112 echo ' $$ $(STRIP) "$(DESTDIR)$(BINDIR)/$(UAGENT)"';\
113 $(STRIP) "$(DESTDIR)$(BINDIR)/$(UAGENT)";\
114 if [ ! -d "$(DESTDIR)$(MANDIR)/man1" ]; then \
115 [ -n "$(VERBOSE)" ] &&\
116 echo ' $$ mkdir -p "$(DESTDIR)$(MANDIR)/man1"';\
117 mkdir -p "$(DESTDIR)$(MANDIR)/man1";\
119 [ -n "$(VERBOSE)" ] &&\
120 echo ' $$ $(INSTALL) -c -m 644 ./mkman.1 \
121 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1"';\
122 $(INSTALL) -c -m 644 ./mkman.1 \
123 "$(DESTDIR)$(MANDIR)/man1/$(UAGENT).1";\
124 if [ ! -d "$(DESTDIR)$(SYSCONFDIR)" ]; then \
125 [ -n "$(VERBOSE)" ] &&\
126 echo ' $$ mkdir -p "$(DESTDIR)$(SYSCONFDIR)"';\
127 mkdir -p "$(DESTDIR)$(SYSCONFDIR)";\
129 if [ ! -f "$(DESTDIR)$(SYSCONFRC)" ]; then \
130 [ -n "$(VERBOSE)" ] &&\
131 echo ' $$ $(INSTALL) -c -m 644 ./mkrc.rc \
132 "$(DESTDIR)$(SYSCONFRC)"';\
133 $(INSTALL) -c -m 644 ./mkrc.rc "$(DESTDIR)$(SYSCONFRC)";\
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)"!'
147 @echo 'Cleaning up..';\
148 [ -n "$(VERBOSE)" ] &&\
149 echo ' $$ rm -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 \
151 rm -f $(OBJ) $(UAGENT) ./mime_types.h ./mkman.1 ./mkrc.rc
154 @echo 'Deconfiguring..';\
155 [ -n "$(VERBOSE)" ] && echo ' $$ rm -f ./config.* ./*.mk';\
156 rm -f ./config.* ./*.mk
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/' \
164 echo "$${VERSION}" | grep -q -F dirty ||\
165 VERSION="$${VERSION}-dirty";\
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;\
175 if [ "`git rev-parse --verify HEAD`" != \
176 "`git rev-parse --verify master`" ]; then \
177 echo >&2 'Not on the [master] branch';\
180 echo 'Name of release tag:';\
182 echo "Is $(UAGENT) <v$${REL}> correct? ENTER continues";\
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 archive --prefix="$(UAGENT)-$${REL}/" \
193 -o "$${TMPDIR}/$(UAGENT)-$${FREL}.tar.gz" HEAD &&\
195 tar -x -z -f "$(UAGENT)-$${FREL}.tar.gz" &&\
196 rm -f "$(UAGENT)-$${FREL}.tar.gz" &&\
197 tar -c -z -f "$(UAGENT)-$${FREL}.tar.gz" "$(UAGENT)-$${REL}" &&\
198 openssl md5 "$(UAGENT)-$${FREL}.tar.gz" > \
199 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
200 openssl sha1 "$(UAGENT)-$${FREL}.tar.gz" >> \
201 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
202 openssl sha256 "$(UAGENT)-$${FREL}.tar.gz" >> \
203 "$(UAGENT)-$${FREL}.cksum" 2>&1 &&\
204 echo "-put $(UAGENT)-$${FREL}.tar.gz" | \
205 sftp -b - sdaoden@frs.sourceforge.net:/home/frs/project/s-nail &&\
206 echo 'All seems fine';\
207 echo 'Really send announcement mail? ENTER continues';\
209 cd "$(UAGENT)-$${REL}" &&\
211 ./s-nail -A sdn_sf -s "[ANNOUNCE] Announcing S-nail v$${REL}" \
214 rm -rf "$(UAGENT)-$${REL}" &&\
217 # vim:set fenc=utf-8 filetype=make: