Updated Changelog
[centerim/davrieb.git] / libmsn / Makefile.func
blob4b2422df5b34893564dfcb6f104dd4bd006e7677
2 # Motor IDE functional Makefile template
3 #       for static library in C/C++
5 # Written by Konstantin Klyagin <k@thekonst.net>
6 # Distributed under the GNU Public License
8 # Project settings and files
10 SOURCES = msn/authdata.cpp msn/buddy.cpp msn/connection.cpp msn/filetransfer.cpp msn/invitation.cpp msn/message.cpp msn/notificationserver.cpp msn/passport.cpp msn/switchboardserver.cpp msn/util.cpp 
11 HEADERS = msn/authdata.h msn/buddy.h msn/connection.h msn/errorcodes.h msn/externals.h msn/filetransfer.h msn/invitation.h msn/message.h msn/msn.h msn/notificationserver.h msn/passport.h msn/sstream_fix.h msn/switchboardserver.h msn/util.h 
12 DOCS = ChangeLog AUTHORS COPYING INSTALL NEWS README 
13 MISCF = libmsn.motor 
14 BUILDF = Makefile.am msn/Makefile.am configure.in 
15 ALL_FILES := $(strip $(SOURCES) $(HEADERS) $(MISCF) $(DOCS))
16 ALL_DIRS := $(sort $(dir $(ALL_FILES)))
17 PROJNAME = libmsn
18 PROJVER = 0.1
19 INCLDIRS = ../connwrap ../connwrap-0.1 
20 DIST_TARGZ := $(PROJNAME)-$(PROJVER).tar.gz
21 LIB = liblibmsn.a
22 WANT = CFLAGS="-O0 -g" CXXFLAGS="-O0 -g"
23 # WANT_AUTOCONF=2.1 WANT_AUTOMAKE=1.4 CFLAGS="-O0 -g" CXXFLAGS="-O0 -g"
25 # Motor specific targets
27 # Executed every time there is a need to compile the stuff
29 build: ready
30         $(WANT) $(MAKE)
32 ready: makesure
33         @if test ! -f Makefile.am; then $(MAKE) -f Makefile.func automake; fi
34         @if test ! -f Makefile.in; then $(WANT) automake; fi
35         @if test ! -f configure; then $(WANT) autoconf; fi
36         @if test ! -f Makefile; then \
37             $(WANT) ./configure; \
38         fi
40 # Invoked for cleaning up
42 clean: ready
43         $(MAKE) distclean
45 # This one starts the debugger
47 debug:
49 # Executed on project creation
51 start: automake makesure
53 # Executed on project modification
55 update: automake
56         rm -f config.cache && $(WANT) ./configure
58 dist: makesure automake
59         @if test ! -f Makefile; then ./configure; fi
60         $(MAKE) dist
62 rpmspec:
63         @if test ! -f libmsn.spec; then \
64             echo "libmsn.spec file not found!"; \
65             exit 1; \
66         fi
67         sed "s/^]*Version\: .*$$/Version: $(PROJVER)/g" <libmsn.spec >libmsn.spec.uver
68         if test -z "`egrep '^]*BuildRoot: ' libmsn.spec`"; then \
69             echo "BuildRoot: /var/tmp/%{name}-buildroot" >libmsn.spec; \
70             cat libmsn.spec.uver >>libmsn.spec; \
71         fi
72         rm -f libmsn.spec.uver
74 rpm: rpmspec dist
75         @if test ! -f ~/.motor/rpmrc; then \
76             echo "macrofiles:   /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/etc/rpm/macros.specspo:/etc/rpm/macros:/etc/rpm/%{_target}/macros:~/.rpmmacros:~/.motor/rpmmacros" >~/.motor/rpmrc; \
77         fi
78         @if test ! -f ~/.motor/rpmmacros; then \
79             echo "%_topdir      $${HOME}/.motor/rpm"    >>~/.motor/rpmmacros; \
80             echo "%_builddir    %{_topdir}/BUILD"       >>~/.motor/rpmmacros; \
81             echo "%_rpmdir      %{_topdir}/RPMS"        >>~/.motor/rpmmacros; \
82             echo "%_sourcedir   %{_topdir}/SOURCES"     >>~/.motor/rpmmacros; \
83             echo "%_specdir     %{_topdir}/SPECS"       >>~/.motor/rpmmacros; \
84             echo "%_srcrpmdir   %{_topdir}/SRPMS"       >>~/.motor/rpmmacros; \
85             echo "%_tmppath     %{_var}/tmp"            >>~/.motor/rpmmacros; \
86         fi
87         -for i in SPECS BUILD RPMS SRPMS; do \
88             mkdir -p "$${HOME}/.motor/rpm/$$i"; \
89         done
90         rpm --rcfile ~/.motor/rpmrc -ta /$(DIST_TARGZ)
91         find "${HOME}/.motor/rpm" -name $(PROJNAME)-$(PROJVER)*rpm -exec mv {} "" \;
92         rm -rf "${HOME}/.motor/rpm"
95 # mfdetect(currentfiles) returns
96 #       1 - root dir    2 - prog dir
97 #       3 - lib dir     4 - doc dir
98 #       5 - misc dir
100 # finlist(currentfiles, setof) $result to the list of files matched
102 # variables
103 #       rfnames - files in the current directory (with relative path names)
104 #       fnames  - files in the current directory (filenames only)
105 #       dnames  - current dir subdirectories
107 automake:
108         @rootfound=0; \
109         cflgs=""; \
110         if test ! -z "$(INCLDIRS)"; then \
111             idirs=`for i in $(addprefix -I, $(INCLDIRS)); do (echo -n "$$i " | \
112                 grep -v "^-I/" | sed 's/^-I/-I\\\\044(top_srcdir)\//g'); done; \
113                 for i in $(addprefix -I, $(INCLDIRS)); do (echo -n "$$i " | \
114                 grep "^-I/"); done`; \
115             idirs=`echo $$idirs | sed "s/\n//g"`; \
116         fi; \
117         idirs=`echo -e "$$idirs"`; \
118         \
119         finlist () { \
120             result=""; \
121             for i in $$1; do \
122                 gmask=`echo $$i | sed 's/\//\\\\\//g' | sed 's/\./\\\\\./g'`; \
123                 gmask="\<$$gmask\>"; \
124                 if test ! -z "`echo $$2 | egrep $$gmask`"; then \
125                 result="$$result $$i"; fi; \
126             done; \
127         }; \
128         mfdetect () { \
129             if test -z "$$2"; then return 2; fi; \
130             finlist "$$1" "$(SOURCES)"; \
131             if test ! -z "$$result"; then return 3; fi; \
132             finlist "$$1" "$(DOCS)"; \
133             if test ! -z "$$result"; then return 4; fi; \
134             return 5; \
135         }; \
136         getlastword () { \
137             result=`echo $$1 | sed "s/^\(.*\)\/\([^/]\+\)\/$$/\2/g" | sed "s/\///g"`; \
138         }; \
139         replaceparam() { \
140             param="$$1"; val="$$2"; fname="$$3"; \
141             pat="^$$param "; \
142             \
143             if test -z "`grep $$pat $$fname`"; then \
144                 echo "$$param = $$val" >>$$fname; \
145             else \
146                 grep -B 9999 -m 1 "$$pat" $$fname | head -n -1 >$$fname.motor.tmp; \
147                 echo "$$param = $$val" >>$$fname.motor.tmp; \
148                 grep -A 9999 "$$pat" $$fname | sed '1d' >>$$fname.motor.tmp; \
149                 mv $$fname.motor.tmp $$fname; \
150             fi; \
151         }; \
152         extractsubdirs () { dextracted=""; \
153             for ndir; do \
154                 pathcomp=""; \
155                 set `echo ":$$ndir" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`; \
156                 if test "$$ndir" != "po/" -a "$ndir" != "./po/"; then \
157                 for d; do pathcomp="$$pathcomp$$d"; \
158                     pathcomp="$$pathcomp/"; \
159                     dextracted="$$dextracted $$pathcomp"; \
160                     if test $$pathcomp = "./"; then pathcomp=""; fi; \
161                 done; fi; \
162             done; \
163             dextracted=`for i in $$dextracted; do echo $$i; done | sort -u`; \
164         }; \
165         \
166         extractsubdirs ./ $(ALL_DIRS); \
167         echo $$dextracted >.dextracted; \
168         for dir in $$dextracted; do \
169             if test "$$dir" = "./"; then dir=""; fi; \
170             gmask="^$$dir[^/]+$$"; \
171         \
172             rfnames=""; \
173             if test ! -z "$(ALL_FILES)"; then \
174                 rfnames=`for i in $(ALL_FILES); do echo $$i | egrep $$gmask; done`; \
175                 rfnames=`echo $$rfnames | sed "s/\n//g"`; \
176             fi; \
177             if test ! -z "$$dir"; then \
178                 gmask="s/`echo $$dir | sed 's/\//\\\\\//g'`//g"; \
179                 fnames=`echo $$rfnames | sed $$gmask`; \
180                 gmask="^$$dir[^/]+/$$" ;\
181             else \
182                 fnames="$$rfnames"; \
183                 gmask="^[^.][^/]*/$$" ;\
184             fi; \
185             if test -f "$${dir}libmsn.spec"; then fnames="$$fnames libmsn.spec"; fi; \
186         \
187             dnames=`for i in $$dextracted; do echo $$i | egrep $$gmask; done`; \
188             dnames=`echo $$dnames | sed "s/\n//g"`; \
189             if test ! -z "$$dir"; then \
190                 gmask="s/`echo $$dir | sed 's/\//\\\\\//g'`//g"; \
191                 dnames=`echo $$dnames | sed $$gmask`; \
192             fi; \
193             dnames=`echo $$dnames | sed "s/\///g"`; \
194         \
195             mfdetect "$$rfnames" "$$dir"; tmf=$$?; \
196             amfname="$${dir}Makefile.am"; \
197             case "$$tmf" in \
198                 2) pdir="$$dir"; \
199                    pfnames="$$fnames"; \
200                    pdnames="$$dnames"; \
201                    ;; \
202                 3) getlastword $$dir; lib=$$result; \
203                    finlist "$$fnames" "$(SOURCES)"; \
204                    if test ! -z "$$result"; then \
205                        replaceparam INCLUDES "$$idirs" $$amfname; \
206                        replaceparam CPPFLAGS "$$cflgs" $$amfname; \
207                        lib=`echo $$lib | sed 's/[-.,]/_/g'`; \
208                        replaceparam noinst_LIBRARIES lib$${lib}.a $$amfname; \
209                        replaceparam lib$${lib}_a_SOURCES "$${result}" $$amfname; \
210                        objs=`for i in $$result; do echo "$${dir}$${i}" | sed 's/^\(.*\)\.\(.*\)$$/\1.o/g'; done`; \
211                        objs=`echo $$objs | sed "s/\n//g"`; \
212                        plibs="$$plibs $$objs"; \
213                    fi; ;; \
214             esac; \
215             replaceparam EXTRA_DIST "$$fnames" $$amfname; \
216             replaceparam SUBDIRS "$$dnames" $$amfname; \
217         done; \
218         amfname="$${pdir}Makefile.am"; \
219         lmain=$(notdir $(LIB)); \
220         lmain=`echo $$lmain | sed "s/^lib\(.*\)\.a$$/\1/g" | sed 's/[-.,]/_/g'`; \
221         replaceparam INCLUDES "$$idirs" $$amfname; \
222         replaceparam CPPFLAGS "$$cflgs" $$amfname; \
223         finlist "$$pfnames" "$(SOURCES)"; \
224         replaceparam noinst_LIBRARIES lib$${lmain}.a $$amfname; \
225         replaceparam lib$${lmain}_a_SOURCES "$${result}" $$amfname; \
226         pldflags=''; \
227         if test ! -z "$$plibs"; then \
228             replaceparam lib$${lmain}_a_LIBADD "$${plibs}" $$amfname; \
229         fi; if test ! -z "$$pdnames"; then \
230             replaceparam SUBDIRS "$$pdnames" $$amfname; \
231         fi; \
232         replaceparam EXTRA_DIST "$${pfnames}" $$amfname; \
233         replaceparam AUTOMAKE_OPTIONS foreign $$amfname
234         @cat configure.in | egrep -v "^]*AC_OUTPUT" >configure.in.acout
235         @for i in `cat .dextracted && rm -f .dextracted`; do \
236             if test ! -z "$$acmfnames"; then acmfnames="$$acmfnames "; fi; \
237             if test $$i = "./"; then i=""; fi; \
238             acmfnames="$${acmfnames}$${i}Makefile"; \
239         done; \
240         echo "AC_OUTPUT($${acmfnames})" >>configure.in.acout
241         @sed "s/^]*AM_INIT_AUTOMAKE\(.*\)/AM_INIT_AUTOMAKE($(PROJNAME), $(PROJVER))/g" <configure.in.acout >configure.in
242         @$(RM) configure.in.acout
243         @if test ! -z "`egrep '^]*AM_CONFIG_HEADER' configure.in`"; then \
244             if test ! -f config.h.in; then $(WANT) autoheader; fi; \
245         fi
246         $(WANT) aclocal; autoconf
247         -$(WANT) automake -a -c
249 makesure:
250         @for i in $(ALL_FILES) $(BUILDF); do \
251             if test ! -f $$i; then touch $$i; fi; \
252         done
254 tags:
255         @if test "$$MOTOR_TAGS" = "file"; then \
256             TFILES="$$MOTOR_CURRENTFILE"; \
257         elif test "$$MOTOR_TAGS" = "project"; then \
258             TFILES=" msn/authdata.cpp msn/buddy.cpp msn/connection.cpp msn/filetransfer.cpp msn/invitation.cpp msn/message.cpp msn/notificationserver.cpp msn/passport.cpp msn/switchboardserver.cpp msn/util.cpp msn/authdata.h msn/buddy.h msn/connection.h msn/errorcodes.h msn/externals.h msn/filetransfer.h msn/invitation.h msn/message.h msn/msn.h msn/notificationserver.h msn/passport.h msn/sstream_fix.h msn/switchboardserver.h msn/util.h"; \
259         elif test "$$MOTOR_TAGS" = "all"; then \
260             TFILES=" msn/authdata.cpp msn/buddy.cpp msn/connection.cpp msn/filetransfer.cpp msn/invitation.cpp msn/message.cpp msn/notificationserver.cpp msn/passport.cpp msn/switchboardserver.cpp msn/util.cpp msn/authdata.h msn/buddy.h msn/connection.h msn/errorcodes.h msn/externals.h msn/filetransfer.h msn/invitation.h msn/message.h msn/msn.h msn/notificationserver.h msn/passport.h msn/sstream_fix.h msn/switchboardserver.h msn/util.h"; \
261         fi; \
262         if test ! -z "$$TFILES"; then ctags --excmd=number -f - $$TFILES; fi
264 target: ready
265         @$(WANT) $(MAKE) `cat .maketarget && rm -f .maketarget`
267 gnudoc:
268         touch INSTALL NEWS README COPYING AUTHORS ChangeLog
270 .PHONY: build update debug automake dist rpm start makesure target \
271     gnudoc