1#
2#
3#  C++ Portable Types Library (PTypes)
4#  Version 2.1.1  Released 27-Jun-2007
5#
6#  Copyright (C) 2001-2007 Hovik Melikyan
7#
8#  http://www.melikyan.com/ptypes/
9#
10#
11#
12# Makefile for all platforms, called automatically from
13# Makefile.<platform>
14#
15
16.SUFFIXES:	.cxx .o
17
18AR              = ar cru
19RANLIB          = ranlib
20
21DDEBUG          = $(DEBUG_FLAGS)
22INCDIR          = ../include
23CXXOPTS         = $(OS_CXXOPTS) $(DDEBUG) -I$(INCDIR) $(CFLAGS)
24LDLIBS          = $(OS_LDLIBS)
25
26CXXOPTS_ST      = -DPTYPES_ST $(OS_CXXOPTS_ST) $(DDEBUG) -I$(INCDIR) $(CFLAGS)
27LDLIBS_ST       = $(OS_LDLIBS_ST)
28
29LIBNAME         = libptypes.a
30LIBNAME_ST      = libptypesn.a
31LIBDEST         = ../lib
32
33SOBASENAME      = libptypes
34SONAME          = $(SOBASENAME).$(SOEXT)
35SOVER           = 21
36SOREALNAME      = $(SOBASENAME).$(SOEXT).$(SOVER)
37SODEST          = ../so
38
39
40LIBOBJS       = mt/pversion.o mt/pmem.o mt/pfatal.o mt/pstring.o mt/pcset.o mt/pcsetdbg.o \
41		mt/pstrmanip.o mt/pstrutils.o mt/pstrconv.o mt/pstrtoi.o mt/pstrcase.o mt/ptime.o \
42		mt/punknown.o mt/pcomponent.o mt/pexcept.o mt/ppodlist.o mt/pobjlist.o mt/pstrlist.o mt/ptextmap.o \
43		mt/patomic.o mt/pasync.o mt/psemaphore.o mt/pthread.o mt/pmsgq.o mt/ptimedsem.o \
44		mt/prwlock.o mt/ptrigger.o mt/pmtxtable.o mt/pvariant.o \
45		mt/piobase.o mt/pinstm.o mt/pinfile.o mt/ppipe.o mt/pinmem.o mt/poutmem.o \
46		mt/pintee.o mt/poutstm.o mt/poutfile.o mt/pinfilter.o mt/poutfilter.o mt/pmd5.o \
47		mt/pputf.o mt/pstdio.o mt/pfdxstm.o mt/pnpipe.o mt/pnpserver.o \
48		mt/pipbase.o mt/pipsvbase.o mt/pipstm.o mt/pipstmsv.o mt/pipmsg.o mt/pipmsgsv.o \
49		mt/punit.o \
50		$(EXTRA_OBJS)
51
52LIBOBJS_ST    = st/pversion.o st/pmem.o st/pfatal.o st/pstring.o st/pcset.o st/pcsetdbg.o \
53		st/pstrmanip.o st/pstrutils.o st/pstrconv.o st/pstrtoi.o st/pstrcase.o st/ptime.o \
54		st/punknown.o st/pcomponent.o st/pexcept.o st/ppodlist.o st/pobjlist.o st/pstrlist.o st/ptextmap.o \
55		st/patomic.o st/pvariant.o \
56		st/piobase.o st/pinstm.o st/pinfile.o st/ppipe.o st/pinmem.o st/poutmem.o \
57		st/pintee.o st/poutstm.o st/poutfile.o st/pinfilter.o st/poutfilter.o st/pmd5.o \
58		st/pputf.o st/pstdio.o st/pfdxstm.o st/pnpipe.o st/pnpserver.o \
59		st/pipbase.o st/pipsvbase.o st/pipstm.o st/pipstmsv.o st/pipmsg.o st/pipmsgsv.o \
60		$(EXTRA_OBJS_ST)
61
62HLEVEL1		= $(INCDIR)/pport.h
63
64HLEVEL2		= $(HLEVEL1) $(INCDIR)/ptypes.h $(INCDIR)/pasync.h $(INCDIR)/ptime.h
65
66HLEVEL3		= $(HLEVEL2) $(INCDIR)/pstreams.h
67
68HLEVEL4		= $(HLEVEL3) $(INCDIR)/pinet.h
69
70HALL		= $(HLEVEL4)
71
72
73all: mtlib shlib stlib ptypes_test ptypesn_test
74
75mtlib: mt $(LIBNAME)
76
77shlib: mt $(SOREALNAME)
78
79stlib: st $(LIBNAME_ST)
80
81
82#
83# libptypes
84#
85
86$(LIBNAME): $(LIBOBJS)
87	$(AR) $@ $(LIBOBJS)
88	$(RANLIB) $@
89	mkdir -p $(LIBDEST) ; cp $@ $(LIBDEST)/
90
91$(SOREALNAME): $(LIBOBJS)
92	$(LIBTOOL) $(LIBOBJS) $(LDLIBS) $(SOINSTOPT) -o $@
93	rm -f $(SONAME) ; ln -s $@ $(SONAME)
94	mkdir -p $(SODEST) ; cp $@ $(SODEST)/
95	cd $(SODEST) ; rm -f $(SONAME) ; ln -s $@ $(SONAME) ; $(SOSTRIP) $@
96
97$(LIBNAME_ST): $(LIBOBJS_ST)
98	$(AR) $@ $(LIBOBJS_ST)
99	$(RANLIB) $@
100	mkdir -p $(LIBDEST) ; cp $@ $(LIBDEST)/
101
102mt:
103	if [ ! -d mt ] ; then mkdir mt ; fi
104
105st:
106	if [ ! -d st ] ; then mkdir st ; fi
107
108#
109# multithreaded compilation
110#
111
112mt/pversion.o: pversion.cxx $(HLEVEL1)
113	$(CXX) -c $(CXXOPTS) -o $@ pversion.cxx
114
115mt/pmem.o: pmem.cxx $(HLEVEL1)
116	$(CXX) -c $(CXXOPTS) -o $@ pmem.cxx
117
118mt/pfatal.o: pfatal.cxx $(HLEVEL1)
119	$(CXX) -c $(CXXOPTS) -o $@ pfatal.cxx
120
121mt/pstring.o: pstring.cxx $(HLEVEL3)
122	$(CXX) -c $(CXXOPTS) -o $@ pstring.cxx
123
124mt/pcset.o: pcset.cxx $(HLEVEL2)
125	$(CXX) -c $(CXXOPTS) -o $@ pcset.cxx
126
127mt/pcsetdbg.o: pcsetdbg.cxx $(HLEVEL2)
128	$(CXX) -c $(CXXOPTS) -o $@ pcsetdbg.cxx
129
130mt/pstrmanip.o: pstrmanip.cxx $(HLEVEL2)
131	$(CXX) -c $(CXXOPTS) -o $@ pstrmanip.cxx
132
133mt/pstrutils.o: pstrutils.cxx $(HLEVEL2)
134	$(CXX) -c $(CXXOPTS) -o $@ pstrutils.cxx
135
136mt/pstrconv.o: pstrconv.cxx $(HLEVEL2)
137	$(CXX) -c $(CXXOPTS) -o $@ pstrconv.cxx
138
139mt/pstrtoi.o: pstrtoi.cxx $(HLEVEL2)
140	$(CXX) -c $(CXXOPTS) -o $@ pstrtoi.cxx
141
142mt/pstrcase.o: pstrcase.cxx $(HLEVEL2)
143	$(CXX) -c $(CXXOPTS) -o $@ pstrcase.cxx
144
145mt/ptime.o: ptime.cxx $(HLEVEL2)
146	$(CXX) -c $(CXXOPTS) -o $@ ptime.cxx
147
148mt/punknown.o: punknown.cxx $(HLEVEL2)
149	$(CXX) -c $(CXXOPTS) -o $@ punknown.cxx
150
151mt/pcomponent.o: pcomponent.cxx $(HLEVEL2)
152	$(CXX) -c $(CXXOPTS) -o $@ pcomponent.cxx
153
154mt/pexcept.o: pexcept.cxx $(HLEVEL2)
155	$(CXX) -c $(CXXOPTS) -o $@ pexcept.cxx
156
157mt/ppodlist.o: ppodlist.cxx $(HLEVEL2)
158	$(CXX) -c $(CXXOPTS) -o $@ ppodlist.cxx
159
160mt/pobjlist.o: pobjlist.cxx $(HLEVEL2)
161	$(CXX) -c $(CXXOPTS) -o $@ pobjlist.cxx
162
163mt/pstrlist.o: pstrlist.cxx $(HLEVEL2)
164	$(CXX) -c $(CXXOPTS) -o $@ pstrlist.cxx
165
166mt/ptextmap.o: ptextmap.cxx $(HLEVEL2)
167	$(CXX) -c $(CXXOPTS) -o $@ ptextmap.cxx
168
169mt/patomic.o: patomic.cxx $(HLEVEL2)
170	$(CXX) -c $(CXXOPTS) -o $@ patomic.cxx
171
172mt/pasync.o: pasync.cxx $(HLEVEL2)
173	$(CXX) -c $(CXXOPTS) -o $@ pasync.cxx
174
175mt/psemaphore.o: psemaphore.cxx $(HLEVEL2)
176	$(CXX) -c $(CXXOPTS) -o $@ psemaphore.cxx
177
178mt/pthread.o: pthread.cxx $(HLEVEL2)
179	$(CXX) -c $(CXXOPTS) -o $@ pthread.cxx
180
181mt/pmsgq.o: pmsgq.cxx $(HLEVEL2)
182	$(CXX) -c $(CXXOPTS) -o $@ pmsgq.cxx
183
184mt/ptimedsem.o: ptimedsem.cxx $(HLEVEL2)
185	$(CXX) -c $(CXXOPTS) -o $@ ptimedsem.cxx
186
187mt/prwlock.o: prwlock.cxx $(HLEVEL2)
188	$(CXX) -c $(CXXOPTS) -o $@ prwlock.cxx
189
190mt/ptrigger.o: ptrigger.cxx $(HLEVEL2)
191	$(CXX) -c $(CXXOPTS) -o $@ ptrigger.cxx
192
193mt/pmtxtable.o: pmtxtable.cxx $(HLEVEL2)
194	$(CXX) -c $(CXXOPTS) -o $@ pmtxtable.cxx
195
196mt/pvariant.o: pvariant.cxx $(HLEVEL2)
197	$(CXX) -c $(CXXOPTS) -o $@ pvariant.cxx
198
199mt/piobase.o: piobase.cxx $(HLEVEL3)
200	$(CXX) -c $(CXXOPTS) -o $@ piobase.cxx
201
202mt/pinstm.o: pinstm.cxx $(HLEVEL3)
203	$(CXX) -c $(CXXOPTS) -o $@ pinstm.cxx
204
205mt/pinfile.o: pinfile.cxx $(HLEVEL3)
206	$(CXX) -c $(CXXOPTS) -o $@ pinfile.cxx
207
208mt/ppipe.o: ppipe.cxx $(HLEVEL3)
209	$(CXX) -c $(CXXOPTS) -o $@ ppipe.cxx
210
211mt/pintee.o: pintee.cxx $(HLEVEL3)
212	$(CXX) -c $(CXXOPTS) -o $@ pintee.cxx
213
214mt/pinmem.o: pinmem.cxx $(HLEVEL3)
215	$(CXX) -c $(CXXOPTS) -o $@ pinmem.cxx
216
217mt/poutmem.o: poutmem.cxx $(HLEVEL3)
218	$(CXX) -c $(CXXOPTS) -o $@ poutmem.cxx
219
220mt/poutstm.o: poutstm.cxx $(HLEVEL3)
221	$(CXX) -c $(CXXOPTS) -o $@ poutstm.cxx
222
223mt/poutfile.o: poutfile.cxx $(HLEVEL3)
224	$(CXX) -c $(CXXOPTS) -o $@ poutfile.cxx
225
226mt/pinfilter.o: pinfilter.cxx $(HLEVEL3)
227	$(CXX) -c $(CXXOPTS) -o $@ pinfilter.cxx
228
229mt/poutfilter.o: poutfilter.cxx $(HLEVEL3)
230	$(CXX) -c $(CXXOPTS) -o $@ poutfilter.cxx
231
232mt/pmd5.o: pmd5.cxx $(HLEVEL3)
233	$(CXX) -c $(CXXOPTS) -o $@ pmd5.cxx
234
235mt/pputf.o: pputf.cxx $(HLEVEL3)
236	$(CXX) -c $(CXXOPTS) -o $@ pputf.cxx
237
238mt/pstdio.o: pstdio.cxx $(HLEVEL3)
239	$(CXX) -c $(CXXOPTS) -o $@ pstdio.cxx
240
241mt/pfdxstm.o: pfdxstm.cxx $(HLEVEL3)
242	$(CXX) -c $(CXXOPTS) -o $@ pfdxstm.cxx
243
244mt/pnpipe.o: pnpipe.cxx $(HLEVEL3)
245	$(CXX) -c $(CXXOPTS) -o $@ pnpipe.cxx
246
247mt/pnpserver.o: pnpserver.cxx $(HLEVEL3)
248	$(CXX) -c $(CXXOPTS) -o $@ pnpserver.cxx
249
250mt/pipbase.o: pipbase.cxx $(HLEVEL4)
251	$(CXX) -c $(CXXOPTS) -o $@ pipbase.cxx
252
253mt/pipsvbase.o: pipsvbase.cxx $(HLEVEL4)
254	$(CXX) -c $(CXXOPTS) -o $@ pipsvbase.cxx
255
256mt/pipstm.o: pipstm.cxx $(HLEVEL4)
257	$(CXX) -c $(CXXOPTS) -o $@ pipstm.cxx
258
259mt/pipstmsv.o: pipstmsv.cxx $(HLEVEL4)
260	$(CXX) -c $(CXXOPTS) -o $@ pipstmsv.cxx
261
262mt/pipmsg.o: pipmsg.cxx $(HLEVEL4)
263	$(CXX) -c $(CXXOPTS) -o $@ pipmsg.cxx
264
265mt/pipmsgsv.o: pipmsgsv.cxx $(HLEVEL4)
266	$(CXX) -c $(CXXOPTS) -o $@ pipmsgsv.cxx
267
268mt/punit.o: punit.cxx $(HLEVEL3)
269	$(CXX) -c $(CXXOPTS) -o $@ punit.cxx
270
271
272#
273# single-threaded compilation
274#
275
276st/pversion.o: pversion.cxx $(HLEVEL1)
277	$(CXX) -c $(CXXOPTS_ST) -o $@ pversion.cxx
278
279st/pmem.o: pmem.cxx $(HLEVEL1)
280	$(CXX) -c $(CXXOPTS_ST) -o $@ pmem.cxx
281
282st/pfatal.o: pfatal.cxx $(HLEVEL1)
283	$(CXX) -c $(CXXOPTS_ST) -o $@ pfatal.cxx
284
285st/pstring.o: pstring.cxx $(HLEVEL3)
286	$(CXX) -c $(CXXOPTS_ST) -o $@ pstring.cxx
287
288st/pcset.o: pcset.cxx $(HLEVEL2)
289	$(CXX) -c $(CXXOPTS_ST) -o $@ pcset.cxx
290
291st/pcsetdbg.o: pcsetdbg.cxx $(HLEVEL2)
292	$(CXX) -c $(CXXOPTS_ST) -o $@ pcsetdbg.cxx
293
294st/pstrmanip.o: pstrmanip.cxx $(HLEVEL2)
295	$(CXX) -c $(CXXOPTS_ST) -o $@ pstrmanip.cxx
296
297st/pstrutils.o: pstrutils.cxx $(HLEVEL2)
298	$(CXX) -c $(CXXOPTS_ST) -o $@ pstrutils.cxx
299
300st/pstrconv.o: pstrconv.cxx $(HLEVEL2)
301	$(CXX) -c $(CXXOPTS_ST) -o $@ pstrconv.cxx
302
303st/pstrtoi.o: pstrtoi.cxx $(HLEVEL2)
304	$(CXX) -c $(CXXOPTS_ST) -o $@ pstrtoi.cxx
305
306st/pstrcase.o: pstrcase.cxx $(HLEVEL2)
307	$(CXX) -c $(CXXOPTS_ST) -o $@ pstrcase.cxx
308
309st/ptime.o: ptime.cxx $(HLEVEL2)
310	$(CXX) -c $(CXXOPTS_ST) -o $@ ptime.cxx
311
312st/punknown.o: punknown.cxx $(HLEVEL2)
313	$(CXX) -c $(CXXOPTS_ST) -o $@ punknown.cxx
314
315st/pcomponent.o: pcomponent.cxx $(HLEVEL2)
316	$(CXX) -c $(CXXOPTS_ST) -o $@ pcomponent.cxx
317
318st/pexcept.o: pexcept.cxx $(HLEVEL2)
319	$(CXX) -c $(CXXOPTS_ST) -o $@ pexcept.cxx
320
321st/ppodlist.o: ppodlist.cxx $(HLEVEL2)
322	$(CXX) -c $(CXXOPTS_ST) -o $@ ppodlist.cxx
323
324st/pobjlist.o: pobjlist.cxx $(HLEVEL2)
325	$(CXX) -c $(CXXOPTS_ST) -o $@ pobjlist.cxx
326
327st/pstrlist.o: pstrlist.cxx $(HLEVEL2)
328	$(CXX) -c $(CXXOPTS_ST) -o $@ pstrlist.cxx
329
330st/ptextmap.o: ptextmap.cxx $(HLEVEL2)
331	$(CXX) -c $(CXXOPTS_ST) -o $@ ptextmap.cxx
332
333st/patomic.o: patomic.cxx $(HLEVEL2)
334	$(CXX) -c $(CXXOPTS_ST) -o $@ patomic.cxx
335
336st/pvariant.o: pvariant.cxx $(HLEVEL2)
337	$(CXX) -c $(CXXOPTS_ST) -o $@ pvariant.cxx
338
339st/piobase.o: piobase.cxx $(HLEVEL3)
340	$(CXX) -c $(CXXOPTS_ST) -o $@ piobase.cxx
341
342st/pinstm.o: pinstm.cxx $(HLEVEL3)
343	$(CXX) -c $(CXXOPTS_ST) -o $@ pinstm.cxx
344
345st/pinfile.o: pinfile.cxx $(HLEVEL3)
346	$(CXX) -c $(CXXOPTS_ST) -o $@ pinfile.cxx
347
348st/ppipe.o: ppipe.cxx $(HLEVEL3)
349	$(CXX) -c $(CXXOPTS_ST) -o $@ ppipe.cxx
350
351st/pintee.o: pintee.cxx $(HLEVEL3)
352	$(CXX) -c $(CXXOPTS_ST) -o $@ pintee.cxx
353
354st/pinmem.o: pinmem.cxx $(HLEVEL3)
355	$(CXX) -c $(CXXOPTS_ST) -o $@ pinmem.cxx
356
357st/poutmem.o: poutmem.cxx $(HLEVEL3)
358	$(CXX) -c $(CXXOPTS_ST) -o $@ poutmem.cxx
359
360st/poutstm.o: poutstm.cxx $(HLEVEL3)
361	$(CXX) -c $(CXXOPTS_ST) -o $@ poutstm.cxx
362
363st/poutfile.o: poutfile.cxx $(HLEVEL3)
364	$(CXX) -c $(CXXOPTS_ST) -o $@ poutfile.cxx
365
366st/pinfilter.o: pinfilter.cxx $(HLEVEL3)
367	$(CXX) -c $(CXXOPTS_ST) -o $@ pinfilter.cxx
368
369st/poutfilter.o: poutfilter.cxx $(HLEVEL3)
370	$(CXX) -c $(CXXOPTS_ST) -o $@ poutfilter.cxx
371
372st/pmd5.o: pmd5.cxx $(HLEVEL3)
373	$(CXX) -c $(CXXOPTS_ST) -o $@ pmd5.cxx
374
375st/pputf.o: pputf.cxx $(HLEVEL3)
376	$(CXX) -c $(CXXOPTS_ST) -o $@ pputf.cxx
377
378st/pstdio.o: pstdio.cxx $(HLEVEL3)
379	$(CXX) -c $(CXXOPTS_ST) -o $@ pstdio.cxx
380
381st/pfdxstm.o: pfdxstm.cxx $(HLEVEL3)
382	$(CXX) -c $(CXXOPTS_ST) -o $@ pfdxstm.cxx
383
384st/pnpipe.o: pnpipe.cxx $(HLEVEL3)
385	$(CXX) -c $(CXXOPTS_ST) -o $@ pnpipe.cxx
386
387st/pnpserver.o: pnpserver.cxx $(HLEVEL3)
388	$(CXX) -c $(CXXOPTS_ST) -o $@ pnpserver.cxx
389
390st/pipbase.o: pipbase.cxx $(HLEVEL4)
391	$(CXX) -c $(CXXOPTS_ST) -o $@ pipbase.cxx
392
393st/pipsvbase.o: pipsvbase.cxx $(HLEVEL4)
394	$(CXX) -c $(CXXOPTS_ST) -o $@ pipsvbase.cxx
395
396st/pipstm.o: pipstm.cxx $(HLEVEL4)
397	$(CXX) -c $(CXXOPTS_ST) -o $@ pipstm.cxx
398
399st/pipstmsv.o: pipstmsv.cxx $(HLEVEL4)
400	$(CXX) -c $(CXXOPTS_ST) -o $@ pipstmsv.cxx
401
402st/pipmsg.o: pipmsg.cxx $(HLEVEL4)
403	$(CXX) -c $(CXXOPTS_ST) -o $@ pipmsg.cxx
404
405st/pipmsgsv.o: pipmsgsv.cxx $(HLEVEL4)
406	$(CXX) -c $(CXXOPTS_ST) -o $@ pipmsgsv.cxx
407
408
409
410#
411# libptypes test program
412#
413
414mt/ptypes_test.o: ptypes_test.cxx $(HALL)
415	$(CXX) -c $(CXXOPTS) -o $@ ptypes_test.cxx
416
417ptypes_test: mt/ptypes_test.o $(LIBNAME)
418	$(CXX) $(CXXOPTS) mt/ptypes_test.o -L./ libptypes.a $(LDLIBS) -o $@
419
420st/ptypes_test.o: ptypes_test.cxx $(HALL)
421	$(CXX) -c $(CXXOPTS_ST) -o $@ ptypes_test.cxx
422
423ptypesn_test: st/ptypes_test.o $(LIBNAME)
424	$(CXX) $(CXXOPTS_ST) st/ptypes_test.o -L./ libptypesn.a $(LDLIBS_ST) -o $@
425
426
427#
428# clean
429#
430
431clean: clean-src
432	rm -f $(LIBDEST)/$(LIBNAME) $(LIBDEST)/$(LIBNAME_ST)
433	rm -f $(SODEST)/$(SONAME) $(SODEST)/$(SOREALNAME)
434
435clean-src:
436	rm -rf mt st
437	rm -f $(LIBNAME) $(LIBNAME_ST) $(SONAME) $(SOREALNAME)
438	rm -f core *.core core.*
439	rm -f ptypes_test ptypesn_test ptypes_test.exe ptypesn_test.exe
440	rm -f stmtest.txt
441
442#
443# install
444#
445
446install: $(LIBNAME) $(SOREALNAME) ${LIBNAME_ST}
447	@echo ; echo "#####  Installing header files in ${PREFIX}/include/ptypes"
448	mkdir -p ${PREFIX}/include/ptypes
449	install -m 444 ${INCDIR}/*.h ${PREFIX}/include/ptypes
450	@echo ; echo "#####  Installing libraries (libptypes*) in ${PREFIX}/lib"
451	mkdir -p ${PREFIX}/lib
452	install -m 444 $(LIBDEST)/$(LIBNAME) $(LIBDEST)/$(LIBNAME_ST) ${PREFIX}/lib
453	install -m 444 $(SODEST)/$(SOREALNAME) ${PREFIX}/lib
454	cd ${PREFIX}/lib ; rm -f ${SONAME} ; ln -s ${SOREALNAME} ${SONAME}
455	@echo ; echo "#####  Installing documentation in ${PREFIX}/share/doc/ptypes/doc"
456	mkdir -p ${PREFIX}/share/doc/ptypes/doc
457	cd .. ; install -m 444 LICENSE index.html ${PREFIX}/share/doc/ptypes
458	cd ../doc ; tar cf - * | tar xf - -C ${PREFIX}/share/doc/ptypes/doc
459
460uninstall:
461	rm -rf ${PREFIX}/include/ptypes
462	cd ${PREFIX}/lib ; rm -f $(LIBNAME) $(LIBNAME_ST) $(SONAME) $(SOREALNAME)
463	rm -rf ${PREFIX}/share/doc/ptypes
464