Add to git.
[c2lib.git] / Makefile+
1 # -*- Makefile -*-
2 #
3 # This is a make+ file. Make+ is a set of scripts which enhance GNU
4 # make and let you build RPMs, and other package types with just one
5 # control file.  To build this package you will need to download make+
6 # from this site: http://www.annexia.org/freeware/makeplus/
7
8 PACKAGE         := c2lib
9 VERSION_MAJOR   := 1
10 VERSION_MINOR   := 4.2
11 VERSION         := $(VERSION_MAJOR).$(VERSION_MINOR)
12
13 SUMMARY         := A library of useful functions for C.
14 COPYRIGHT       := GNU LGPL (see http://www.gnu.org/)
15 AUTHOR          := Richard Jones <rich@annexia.org>
16
17 define DESCRIPTION
18 c2lib is a library of useful functions which augment those found in
19 the standard libc. It contains a pool allocator, many string
20 functions, STL-like vector and hash types and miscellaneous utilities.
21 endef
22
23 RPM_REQUIRES    := pcre >= 3.9
24 RPM_GROUP       := Development/Libraries
25
26 CFLAGS          += -Wall -Werror -g -O2 -D_GNU_SOURCE
27 ifneq ($(shell uname), SunOS)
28 # Avoid a warning about reordering system include paths.
29 CFLAGS          += $(shell pcre-config --cflags)
30 endif
31 LIBS            += $(shell pcre-config --libs) -lm
32
33 OBJS    := hash.o matvec.o pool.o pre.o pstring.o tree.o vector.o
34 LOBJS   := $(OBJS:.o=.lo)
35 HEADERS := $(srcdir)/hash.h $(srcdir)/matvec.h \
36         $(srcdir)/pool.h $(srcdir)/pre.h $(srcdir)/pstring.h \
37         $(srcdir)/tree.h $(srcdir)/vector.h
38
39 all:    static dynamic manpages syms
40
41 # Configure the system.
42
43 configure:
44         $(MP_CONFIGURE_START)
45         $(MP_REQUIRE_PROG) pcre-config
46         $(MP_CHECK_HEADERS) alloca.h assert.h ctype.h fcntl.h string.h unistd.h
47         $(MP_CHECK_FUNCS) vasprintf
48         $(MP_CONFIGURE_END)
49
50 # Build the static library.
51
52 static: libc2lib.a
53
54 libc2lib.a: $(OBJS)
55         $(MP_LINK_STATIC) $@ $^
56
57 # Build the dynamic library.
58
59 dynamic: libc2lib.so
60
61 libc2lib.so: $(LOBJS)
62         $(MP_LINK_DYNAMIC) $@ $^ $(LIBS)
63
64 # Build the manual pages.
65
66 manpages: $(srcdir)/*.h
67         if cdoc; then \
68                 rm -f *.3; \
69                 cdoc \
70                         --author '$(AUTHOR)' \
71                         --license '$(COPYRIGHT)' \
72                         --version '$(PACKAGE)-$(VERSION)' \
73                         $^; \
74         fi
75
76 # Build the symbols table.
77
78 syms: libc2lib.syms
79
80 libc2lib.syms: libc2lib.so
81         nm $< | sort | grep -i '^[0-9a-f]' | awk '{print $$1 " " $$3}' > $@
82
83 # Test.
84
85 test: test_hash test_matvec test_pool test_pre test_pstring test_sash \
86         test_shash test_tree test_vector
87         LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(MP_RUN_TESTS) $^
88
89 test_hash: test_hash.o
90         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
91 test_matvec: test_matvec.o
92         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
93 test_pool: test_pool.o
94         $(CC) $(CFLAGS) $^ -o $@ $(LIBS)
95 test_pre: test_pre.o
96         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
97 test_pstring: test_pstring.o
98         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
99 test_sash: test_sash.o
100         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
101 test_shash: test_shash.o
102         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
103 test_tree: test_tree.o
104         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
105 test_vector: test_vector.o
106         $(CC) $(CFLAGS) $^ -o $@ -L. -lc2lib $(LIBS)
107
108 # Install.
109
110 install:
111         install -d $(DESTDIR)$(libdir)
112         install -d $(DESTDIR)$(pkgincludedir)
113         install -d $(DESTDIR)$(man3dir)
114         install -d $(DESTDIR)$(datadir)/rws/symtabs/
115
116         $(MP_INSTALL_STATIC_LIB) libc2lib.a
117         $(MP_INSTALL_DYNAMIC_LIB) libc2lib.so
118         install -m 0644 $(HEADERS) $(DESTDIR)$(pkgincludedir)
119         install -m 0644 *.3        $(DESTDIR)$(man3dir)
120         install -m 0644 *.syms     $(DESTDIR)$(datadir)/rws/symtabs/
121
122 force:
123
124 define WEBSITE
125 <% include page_header.msp %>
126
127     <h1>c2lib - a Perl/STL-like library of basics for C</h1>
128
129     <p>
130       c2lib is a library of basic tools for use by C
131       programmers. It contains features heavily influenced
132       by both Perl's string handling and C++'s Standard
133       Template Library (STL). The library has been designed
134       to be very easy to use and is fully documented in
135       manual pages.
136     </p>
137
138     <p>
139       <a href="doc/">There is extensive documentation and
140         a tutorial here.</a>
141     </p>
142
143     <h1>Download</h1>
144
145     <table border="1">
146       <tr>
147         <th> File </th>
148         <th> Format </th>
149         <th> Contents </th>
150       </tr>
151       <tr>
152         <td> <a href="$(PACKAGE)-$(VERSION).tar.gz">$(PACKAGE)-$(VERSION).tar.gz</a> </td>
153         <td> tar.gz </td>
154         <td> Latest source distribution </td>
155       </tr>
156       <tr>
157         <td> <a href="$(PACKAGE)-$(VERSION)-1.i686.rpm">$(PACKAGE)-$(VERSION)-1.i686.rpm</a> </td>
158         <td> i686 binary RPM </td>
159         <td> Binary development libraries, header files, man pages
160           for Red Hat Linux </td>
161       </tr>
162       <tr>
163         <td> <a href="$(PACKAGE)-$(VERSION)-1.src.rpm">$(PACKAGE)-$(VERSION)-1.src.rpm</a> </td>
164         <td> source RPM </td>
165         <td> Source files for Red Hat Linux </td>
166       </tr>
167     </table>
168
169     <p>
170      Dependencies:
171     </p>
172
173     <ul>
174       <li> You will need to install the <a href="http://www.pcre.org/">Perl
175           Compatible Regular Expressions (PCRE)</a> library.
176       <li> Since 1.3.0, c2lib requires the <a href="../makeplus/">make+</a>
177           build system.
178       <li> To rebuild the manual pages which come with the
179         package, you will also need to download
180         <a href="../cdoc/">cdoc</a>.
181     </ul>
182
183     <p>
184       <a href="/cgi-bin/autopatch.pl?dir=c2lib">Patches between versions
185         ...</a>
186     </p>
187
188     <h1>News</h1>
189
190 <p>
191 <b>Sat Mar 1 2003:</b>
192 Created README and INSTALL files (thanks to David Chappell). Updated
193 <code>Makefile+</code> to work with the new version of make+.
194 <strong>NB: The RPMs were built on Debian and may not work on Red Hat
195 Linux.</strong> </p>
196
197 <p>
198 <b>Sat Feb  8 17:00:47 GMT 2003:</b>
199 Ported to Solaris, OpenBSD and FreeBSD (thanks to
200 <a href="http://www.azazel.net/">Jeremy Sowden</a>
201 and <a href="http://www.mondaymorning.org/">Richard Baker</a>
202 for help and equipment). Don't link c2lib itself into the
203 <code>test_pool</code> program. Link test programs correctly
204 with <code>pcre</code>.
205 </p>
206
207 <p>
208 <strong>Attn:</strong> Solaris
209 has a library called <code>libc2</code>. I have had to rename this
210 library to <code>libc2lib</code>, so you will need to link your
211 programs against <code>-lc2lib</code>. I have also moved the
212 header files into the <code>c2lib/<code> subdirectory of
213 includedir, so you may need to specify <code>-I/usr/include/c2lib</code>
214 when building.
215 </p>
216
217 <p>
218 <b>Sat Dec  7 17:18:02 GMT 2002:</b> Updated to use the
219 <a href="../makeplus/">make+</a> build system.
220 </p>
221
222 <p>
223 <b>Mon Nov 25 09:31:37 GMT 2002:</b> Added symbols file for full
224 symbol resolution in monolith.
225 </p>
226
227   <p>
228     <b>Sun Nov 17 23:31:32 GMT 2002:</b> Debian packages. Added MSP files.
229     <code>pmalloc</code> now initialises memory to <code>0xefefefef</code>
230     so we can catch uninitialised memory problems. Further fixes
231     to compile on RH 7.3. Added <code>vector_push_back_vector</code> etc.
232   </p>
233
234     <p>
235       <b>Tue Oct 15 23:40:42 BST 2002:</b> Multiple bug fixes.
236     </p>
237
238     <p>
239       <b>Sun Oct 13 12:55:08 BST 2002:</b> Added <code>pmap</code>
240       and <code>pgrep</code> functions.
241     </p>
242
243     <p>
244       <b>Tue Oct 8 16:18:02 BST 2002:</b> Fix issues with building on
245       Red Hat Linux 7.3 (thanks to Adam Monsen). The supplied
246       RPM should now install on Red Hat Linux systems.
247     </p>
248
249     <p>
250       <b>Sun Oct  6 18:07:39 BST 2002:</b> Completely rewrote
251       the <code>pstr*split</code> functions so they produce the
252       same results as the Perl equivalents in all the corner
253       cases. Added <code>pstr*split2</code> functions (see
254       the manual pages).
255     </p>
256
257     <p>
258       <b>Sun Oct  6 13:00:39 BST 2002:</b> Added a <code>tree</code>
259       type (required by monolith). Removed the old <code>pmatch*</code> and
260       <code>psubst*</code> functions. These were badly thought
261       out and implemented. Replaced with <code>precomp</code>,
262       <code>prematch</code>, <code>presubst</code> functions
263       which are wrappers around the <a href="http://www.pcre.org/">Perl
264         Compatible Regular Expressions (PCRE)</a> library.
265       <code>pstrresplit</code> has also changed to use PCRE.
266     </p>
267
268     <p>
269       <b>Sat Sep  7 15:24:32 BST 2002:</b> Packages are
270       now available as i686 binary RPMs and source RPMs.
271     </p>
272
273     <h1>Old news and old versions</h1>
274
275     <p>
276       <b>Fri May  2 19:49:25 BST 2002</b>
277     </p>
278
279     <p>
280       <a href="c2lib-1.2.14.tar.gz">c2lib-1.2.14.tar.gz</a> released.
281       Added an extensive tutorial and online manual pages.
282     </p>
283
284     <p>
285       <b>Thu Jun 21 23:12:26 BST 2001</b>
286     </p>
287
288     <p>
289       <a href="c2lib-1.2.12.tar.gz">c2lib-1.2.12.tar.gz</a> released.
290       Fixed <code>psort</code> function and updated documentation.
291     </p>
292
293     <p>
294       <b>Fri Jun 15 15:40:35 BST 2001</b>
295     </p>
296
297     <p>
298       <a href="c2lib-1.2.11.tar.gz">c2lib-1.2.11.tar.gz</a> released.
299       Profiling support. Added <code>pstrncat</code>,
300       <code>psubst</code> and <code>psubstx</code> functions.
301       Fixed a memory leak and did rigorous memory leak
302       checking -- I\'m pretty sure there are none left now.
303       Removed arbitrary limit on number of substring
304       matches in <code>pmatch</code> function.
305       Documentation updates.
306     </p>
307
308     <p>
309       <b>Mon Apr  9 17:18:38 BST 2001</b>
310     </p>
311
312     <p>
313       <a href="c2lib-1.2.8.tar.gz">c2lib-1.2.8.tar.gz</a> released.
314       Documentation fixes.
315     </p>
316
317     <p>
318       <b>Wed Mar 28 14:25:42 BST 2001</b>
319     </p>
320
321     <p>
322       <a href="c2lib-1.2.7.tar.gz">c2lib-1.2.7.tar.gz</a> released.
323       Fixed a problem with calling <code>isspace</code> on
324       Solaris (thanks to Tomonori Manome again).
325     </p>
326
327     <p>
328       <b>Mon Mar 26 12:59:15 BST 2001</b>
329     </p>
330
331     <p>
332       <a href="c2lib-1.2.6.tar.gz">c2lib-1.2.6.tar.gz</a> released.
333       <code>pstrresplit</code> fixed.
334       <code>pvector</code> and <code>pvectora</code> functions
335       added: use these to quickly build vectors from lists of strings.
336       <code>ptrimfront</code>, <code>ptrimback</code> and <code>ptrim</code>
337       functions added for trimming whitespace from strings.
338       <code>pgetline*</code> and <code>pmatch*</code> functions
339       added which make it trivial to read in configuration files.
340       <code>new_subvector</code> added for creating sub-vectors
341       of existing vectors.
342       Some minor const-correctness changes.
343       Documentation updates.
344       Test suite updates.
345     </p>
346
347     <p>
348       <b>Mon Mar 19 11:40:34 GMT 2001</b>
349     </p>
350
351     <p>
352       <a href="c2lib-1.2.3.tar.gz">c2lib-1.2.3.tar.gz</a> released.
353       This adds the <i>shash</i> type: a mapping of strings
354       to anything (another specialized hash).
355       Port to Solaris/Intel and Solaris/Sparc (thanks to
356       Tomonori Manome for this).
357     </p>
358
359     <p>
360       <b>Mon Mar 12 12:12:49 GMT 2001</b>
361     </p>
362
363     <p>
364       <a href="c2lib-1.2.1.tar.gz">c2lib-1.2.1.tar.gz</a> released.
365       This fixes a bug in the way the library was calling
366       <code>pstrcat</code>. Upgrading is highly recommended.
367     </p>
368
369     <p>
370       <b>Fri Mar  9 17:26:45 GMT 2001</b>
371     </p>
372
373     <p>
374       <a href="c2lib-1.2.0.tar.gz">c2lib-1.2.0.tar.gz</a> released.
375       The pool allocator has been completely rewritten for this
376       release, and is much more efficient.
377     </p>
378
379     <p>
380       <b>Wed Mar  7 14:56:43 GMT 2001</b>
381     </p>
382
383     <p>
384       <a href="c2lib-1.1.12.tar.gz">c2lib-1.1.12.tar.gz</a> released.
385       Added <code>pchrs</code> and <code>pstrs</code> string
386       functions. Added <code>pvsprintf</code>. Changed
387       <code>psprintf</code> to make it much more memory efficient
388       (it uses <code>vasprintf(3)</code> if available).
389       Const-correctness fixes.
390     </p>
391
392     <p>
393       <b>Fri Feb 16 17:46:41 GMT 2001</b>
394     </p>
395
396     <p>
397       <a href="c2lib-1.1.10.tar.gz">c2lib-1.1.10.tar.gz</a> released.
398       All functions are documented in manual pages.
399     </p>
400
401 <% include page_footer.msp %>
402 endef
403
404 upload_website:
405         scp $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)-1.*.rpm \
406         $(PACKAGE)-$(VERSION).bin.tar.gz \
407         10.0.0.248:annexia.org/freeware/$(PACKAGE)/
408         scp index.html \
409         10.0.0.248:annexia.org/freeware/$(PACKAGE)/index.msp
410
411 .PHONY: static dynamic manpages syms