Allowed Close to set closed flag before attepting lock of channels
[pwlib.git] / make / unix.mak
blobfd14a6aea20fcda26144cc1e035bb57b7924c3f1
2 # unix.mak
4 # First part of make rules, included in ptlib.mak and pwlib.mak.
5 # Note: Do not put any targets in the file. This should defaine variables
6 # only, as targets are all in common.mak
8 # Portable Windows Library
10 # Copyright (c) 1993-1998 Equivalence Pty. Ltd.
12 # The contents of this file are subject to the Mozilla Public License
13 # Version 1.0 (the "License"); you may not use this file except in
14 # compliance with the License. You may obtain a copy of the License at
15 # http://www.mozilla.org/MPL/
17 # Software distributed under the License is distributed on an "AS IS"
18 # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19 # the License for the specific language governing rights and limitations
20 # under the License.
22 # The Original Code is Portable Windows Library.
24 # The Initial Developer of the Original Code is Equivalence Pty. Ltd.
26 # Portions are Copyright (C) 1993 Free Software Foundation, Inc.
27 # All Rights Reserved.
29 # Contributor(s): ______________________________________.
31 # $Log$
32 # Revision 1.190 2004/06/18 00:38:08 csoutheren
33 # Added check for FD_SETSIZE as suggested by Joegen E. Baclor
35 # Revision 1.189 2004/06/10 01:36:44 csoutheren
36 # Fixed problems with static links
38 # Revision 1.188 2004/05/30 04:49:42 ykiryanov
39 # Streamlined BeOS section
41 # Revision 1.187 2004/04/25 22:11:34 ykiryanov
42 # Added posix library to make files
44 # Revision 1.186 2004/04/21 03:47:36 ykiryanov
45 # Added libdl.so to library list for BeOS
47 # Revision 1.185 2004/04/12 03:35:27 csoutheren
48 # Fixed problems with non-recursuve mutexes and critical sections on
49 # older compilers and libc
51 # Revision 1.184 2004/02/26 11:19:07 csoutheren
52 # Added changes for BeOS, thanks to Yuri Kiryanov
53 # Added changes to fix link problems on some platforms, thanks to Klaus Kaempf
55 # Revision 1.183 2004/02/21 19:44:54 ykiryanov
56 # Fixed make parameters for BeOS: Changed default on BeOS to using Be BONE
58 # Revision 1.182 2004/02/11 05:09:14 csoutheren
59 # Fixed problems with regex libraries on Solaris, and with host OS numbering
60 # being a quoted string rather than a number. Thanks to Chad Attermann
61 # Fixed problems SSL detection problems thanks to Michal Zygmuntowicz
63 # Revision 1.181 2004/02/09 06:24:37 csoutheren
64 # Allowed CXX environment variable to define C++ compiler to use
65 # as required by configure
67 # Revision 1.180 2004/01/29 13:43:59 csoutheren
68 # Moved some preprocessor symbols from the command line to include files
69 # Modified to set P_HAS_SEMAPHORES to 0 for Linux kernels >= 2.6
70 # Applied patches for Solaris thanks to Michal Zygmuntowicz
72 # Revision 1.179 2003/11/02 16:00:26 shawn
73 # Panther requires -lresolv
75 # Revision 1.178 2003/09/18 23:02:35 csoutheren
76 # Removed definition of PMEMORY_CHECK
78 # Revision 1.177 2003/09/17 01:18:03 csoutheren
79 # Removed recursive include file system and removed all references
80 # to deprecated coooperative threading support
82 # Revision 1.176 2003/09/08 21:11:09 dereksmithies
83 # Remove hardcoded path from make file. Thanks Damien Sandras.
85 # Revision 1.175 2003/07/24 22:01:42 dereksmithies
86 # Add fixes from Peter Nixon for fixing install problems. Thanks.
88 # Revision 1.174 2003/06/18 13:19:01 csoutheren
89 # Default debug builds now shared
91 # Revision 1.173 2003/06/17 12:05:01 csoutheren
92 # Changed compiler flags for optimised build
94 # Revision 1.172 2003/05/22 12:17:06 dsandras
96 # Removed unneeded code since Firewire support has been moved to configure.
98 # Revision 1.171 2003/05/06 09:47:20 robertj
99 # Fixed up MacOSX changes so is compatible with previous "API" not requiring
100 # downstream libraries to change
102 # Revision 1.170 2003/05/06 06:59:12 robertj
103 # Dynamic library support for MacOSX, thanks Hugo Santos
105 # Revision 1.169 2003/05/05 13:10:59 robertj
106 # Solaris compatibility
108 # Revision 1.168 2003/04/17 07:29:27 robertj
109 # Fixed solaris link problem
111 # Revision 1.167 2003/04/17 00:05:04 craigs
112 # Added patches from Hugo Santos mainly for Darwin compatibility
114 # Revision 1.166 2003/04/16 07:16:55 craigs
115 # Modified for new autoconf based configuration
118 # Log truncated by CRS 14 April 2003
121 ifndef PWLIBDIR
122 PWLIBDIR = $(HOME)/pwlib
123 endif
125 ####################################################
127 # include generated build options file, then include it
128 include $(PWLIBDIR)/make/ptbuildopts.mak
130 ###############################################################################
132 # this section used to normalise the machine name and OS type
133 # this is now done by autoconf - but this left here as a reference
137 ifdef USE_OLD_MACHINE_CHECKING
139 ifndef OSTYPE
140 OSTYPE := $(shell uname -s)
141 endif
143 ifndef MACHTYPE
144 MACHTYPE := $(shell uname -m)
145 endif
147 ifneq (,$(findstring linux,$(HOSTTYPE)))
148 ifneq (,$(findstring $(HOSTTYPE),i386-linux i486-linux))
149 OSTYPE := linux
150 MACHTYPE := x86
151 endif
152 endif
154 ifeq ($(OSTYPE),mklinux)
155 OSTYPE := linux
156 MACHTYPE := ppc
157 endif
159 ifneq (,$(findstring $(OSTYPE),Linux linux-gnu))
160 OSTYPE := linux
161 endif
163 ifneq (,$(findstring $(OSTYPE),Solaris SunOS))
164 OSTYPE := solaris
165 endif
167 ifneq (,$(findstring $(OSTYPE),IRIX))
168 OSTYPE := irix
169 endif
171 #Convert bash shell OSTYPE of 'freebsd3.4' to 'FreeBSD'
172 ifneq (,$(findstring freebsd,$(OSTYPE)))
173 OSTYPE := FreeBSD
174 endif
176 #Convert bash shell OSTYPE of 'openbsd2.6' to 'OpenBSD'
177 ifneq (,$(findstring openbsd,$(OSTYPE)))
178 OSTYPE := OpenBSD
179 endif
181 ifneq (,$(findstring macos,$(OSTYPE)))
182 OSTYPE := Darwin
183 endif
185 ifneq (,$(findstring darwin,$(OSTYPE)))
186 OSTYPE := Darwin
187 endif
189 ifneq (,$(findstring AIX,$(OSTYPE)))
190 MACHTYPE := ppc
191 endif
193 ifneq (,$(findstring $(OS),VXWORKS))
194 OSTYPE := VxWorks
195 endif
197 ifneq (,$(findstring netbsd,$(OSTYPE)))
198 OSTYPE := NetBSD
199 endif
201 ifneq (,$(findstring sparc, $(MACHTYPE)))
202 MACHTYPE := sparc
203 endif
205 ifneq (,$(findstring sun4, $(MACHTYPE)))
206 MACHTYPE := sparc
207 endif
209 ifneq (,$(findstring i86, $(MACHTYPE)))
210 MACHTYPE := x86
211 endif
213 ifneq (,$(findstring i386, $(MACHTYPE)))
214 MACHTYPE := x86
215 endif
217 ifneq (,$(findstring i486, $(MACHTYPE)))
218 MACHTYPE := x86
219 POSSIBLE_CPUTYPE := i486
220 endif
222 ifneq (,$(findstring i586, $(MACHTYPE)))
223 MACHTYPE := x86
224 POSSIBLE_CPUTYPE := i586
225 endif
227 ifneq (,$(findstring i686, $(MACHTYPE)))
228 MACHTYPE := x86
229 POSSIBLE_CPUTYPE := i686
230 endif
232 #make sure x86 does not match x86_64 by mistake
233 ifneq (,$(findstring x86, $(MACHTYPE)))
234 ifneq (,$(findstring x86_64, $(MACHTYPE)))
235 MACHTYPE := x86_64
236 else
237 MACHTYPE := x86
238 endif
239 endif
241 ifneq (,$(findstring powerpc, $(MACHTYPE)))
242 MACHTYPE := ppc
243 endif
245 ifneq (,$(findstring ppc, $(MACHTYPE)))
246 ifneq (,$(findstring ppc64, $(MACHTYPE)))
247 MACHTYPE := ppc64
248 else
249 MACHTYPE := ppc
250 endif
251 endif
253 ifneq (,$(findstring Power, $(MACHTYPE)))
254 MACHTYPE := ppc
255 endif
257 ifneq (,$(findstring mips, $(MACHTYPE)))
258 MACHTYPE := mips
259 endif
261 ifneq (,$(findstring alpha, $(MACHTYPE)))
262 MACHTYPE := alpha
263 endif
265 ifneq (,$(findstring sparc, $(MACHTYPE)))
266 MACHTYPE := sparc
267 endif
269 ifneq (,$(findstring ia64, $(MACHTYPE)))
270 MACHTYPE := ia64
271 endif
273 ifneq (,$(findstring s390, $(MACHTYPE)))
274 ifneq (,$(findstring s390x, $(MACHTYPE)))
275 MACHTYPE := s390x
276 else
277 MACHTYPE := s390
278 endif
279 endif
281 ifneq (,$(findstring armv4l, $(MACHTYPE)))
282 MACHTYPE := armv4l
283 endif
284 ifndef CPUTYPE
285 CPUTYPE := $(POSSIBLE_CPUTYPE)
286 export CPUTYPE
287 endif
290 endif # USE_OLD_MACHINE_CHECKING
292 STANDARD_TARGETS=\
293 opt debug both \
294 optdepend debugdepend bothdepend \
295 optshared debugshared bothshared \
296 optnoshared debugnoshared bothnoshared \
297 optclean debugclean clean \
298 release tagbuild
300 .PHONY: all $(STANDARD_TARGETS)
303 ifeq (,$(findstring $(OSTYPE),linux FreeBSD OpenBSD NetBSD solaris beos Darwin Carbon AIX Nucleus VxWorks rtems QNX))
305 default_target :
306 @echo
307 @echo ######################################################################
308 @echo "Warning: OSTYPE=$(OSTYPE) support has not been confirmed. This may"
309 @echo " be a new operating system not yet encountered, or more"
310 @echo " likely, the OSTYPE and MACHTYPE environment variables are"
311 @echo " set to unusual values. You may need to explicitly set these"
312 @echo " variables for the correct operation of this system."
313 @echo
314 @echo " Currently supported OSTYPE names are:"
315 @echo " linux Linux linux-gnu mklinux"
316 @echo " solaris Solaris SunOS"
317 @echo " FreeBSD OpenBSD NetBSD beos Darwin Carbon"
318 @echo " VxWorks rtems"
319 @echo
320 @echo " **********************************"
321 @echo " *** DO NOT IGNORE THIS MESSAGE ***"
322 @echo " **********************************"
323 @echo
324 @echo " The system almost certainly will not compile! When you get"
325 @echo " it working please send patches to support@equival.com.au"
326 @echo ######################################################################
327 @echo
329 $(STANDARD_TARGETS) :: default_target
331 else
333 default_target : help
335 endif
337 ####################################################
339 # Set default for shared library usage
341 ifndef P_SHAREDLIB
342 P_SHAREDLIB=1
343 else
344 P_SHAREDLIB=0
345 endif
347 # -Wall must be at the start of the options otherwise
348 # any -W overrides won't have any effect
349 STDCCFLAGS += -Wall
351 ifdef RPM_OPT_FLAGS
352 STDCCFLAGS += $(RPM_OPT_FLAGS)
353 endif
355 ifneq ($(OSTYPE),rtems)
356 ifndef SYSINCDIR
357 SYSINCDIR := /usr/include
358 endif
359 endif
361 ####################################################
363 ifeq ($(OSTYPE),linux)
365 ifeq ($(MACHTYPE),x86)
366 ifdef CPUTYPE
367 ifeq ($(CPUTYPE),crusoe)
368 STDCCFLAGS += -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=i686 -malign-functions=0
369 STDCCFLAGS += -malign-jumps=0 -malign-loops=0
370 else
371 STDCCFLAGS += -mcpu=$(CPUTYPE)
372 endif
373 endif
374 endif
376 ifeq ($(MACHTYPE),ia64)
377 STDCCFLAGS += -DP_64BIT
378 endif
380 ifeq ($(MACHTYPE),s390x)
381 STDCCFLAGS += -DP_64BIT
382 endif
384 ifeq ($(MACHTYPE),x86_64)
385 STDCCFLAGS += -DP_64BIT
386 LDLIBS += -lresolv
387 endif
389 ifeq ($(MACHTYPE),ppc64)
390 STDCCFLAGS += -DP_64BIT
391 endif
393 ifeq ($(P_SHAREDLIB),1)
394 ifndef PROG
395 STDCCFLAGS += -fPIC
396 endif # PROG
397 endif # P_SHAREDLIB
400 STATIC_LIBS := libstdc++.a libg++.a libm.a libc.a
401 SYSLIBDIR := $(shell $(PWLIBDIR)/make/ptlib-config --libdir)
403 endif # linux
406 ####################################################
408 ifeq ($(OSTYPE),FreeBSD)
410 ifeq ($(MACHTYPE),x86)
411 ifdef CPUTYPE
412 STDCCFLAGS += -mcpu=$(CPUTYPE)
413 endif
414 endif
416 P_USE_RANLIB := 1
417 #STDCCFLAGS += -DP_USE_PRAGMA # migrated to configure
420 endif # FreeBSD
423 ####################################################
425 ifeq ($(OSTYPE),OpenBSD)
427 ifeq ($(MACHTYPE),x86)
428 STDCCFLAGS += -m486
429 endif
431 LDLIBS += -lossaudio
433 P_USE_RANLIB := 1
434 #STDCCFLAGS += -DP_USE_PRAGMA # migrated to configure
437 endif # OpenBSD
440 ####################################################
442 ifeq ($(OSTYPE),NetBSD)
444 ifeq ($(MACHTYPE),x86)
445 STDCCFLAGS += -m486
446 endif
448 LDLIBS += -lossaudio
450 STDCCFLAGS += -I$(UNIX_INC_DIR) -I$(PWLIBDIR)/include
452 # enable the USE_PTH line to compile using pth
453 # enable the USE_NATIVE_THREADS line to compile using native threads
454 # enable the USE_UNPROVEN_THREADS line to compile using unproven threads
455 #USE_PTH_THREADS := 1
456 #USE_UNPROVEN_THREADS := 1
457 USE_NATIVE_THREADS := 1
459 ifdef P_PTHREADS
460 ifdef USE_NATIVE_THREADS
461 LDLIBS += -lpthread
462 else
463 ifdef USE_PTH_THREADS
464 STDCCFLAGS += -DP_GNU_PTH
465 STDCCFLAGS += -I/usr/pkg/include
466 LDFLAGS += -L/usr/pkg/lib
467 LDLIBS += -lpthread
468 else
469 STDCCFLAGS += -DP_NO_CANCEL
470 STDCCFLAGS += -I/usr/pkg/pthreads/include
471 LDFLAGS += -L/usr/pkg/pthreads/lib
472 LDLIBS += -lpthread
473 CC := /usr/pkg/pthreads/bin/pgcc
474 CPLUS := /usr/pkg/pthreads/bin/pg++
475 endif
476 endif
477 endif
479 P_USE_RANLIB := 1
480 #STDCCFLAGS += -DP_USE_PRAGMA # migrated to configure
483 endif # NetBSD
486 ####################################################
488 ifeq ($(OSTYPE),AIX)
490 STDCCFLAGS += -DP_AIX
491 # -pedantic -g
492 # LDLIBS += -lossaudio
494 STDCCFLAGS += -mminimal-toc
496 #P_USE_RANLIB := 1
497 STDCCFLAGS += -DP_USE_PRAGMA
500 endif # AIX
503 ####################################################
505 ifeq ($(OSTYPE),sunos)
507 # Sparc Sun 4x, using gcc 2.7.2
509 P_USE_RANLIB := 1
510 REQUIRES_SEPARATE_SWITCH = 1
511 #STDCCFLAGS += -DP_USE_PRAGMA # migrated to configure
513 endif # sunos
516 ####################################################
518 ifeq ($(OSTYPE),solaris)
520 # Solaris (Sunos 5.x)
522 ifeq ($(MACHTYPE),x86)
523 DEBUG_FLAG := -gstabs+
524 endif
526 ENDLDLIBS += -lsocket -lnsl -ldl -lposix4
528 # Sparc Solaris 2.x, using gcc 2.x
529 CC := gcc
531 #P_USE_RANLIB := 1
533 #STDCCFLAGS += -DP_USE_PRAGMA # migrated to configure
535 STATIC_LIBS := libstdc++.a libg++.a
536 SYSLIBDIR := /opt/openh323/lib
538 # Rest added by jpd@louisiana.edu, to get .so libs created!
539 ifndef DEBUG
540 ifndef P_SHAREDLIB
541 P_SHAREDLIB=1
542 ifndef PROG
543 STDCCFLAGS += -fPIC
544 endif # PROG
545 endif
546 endif
548 endif # solaris
550 ####################################################
552 ifeq ($(OSTYPE),irix)
554 # should work whith Irix 6.5
556 # IRIX using a gcc
557 CC := gcc
558 STDCCFLAGS += -DP_IRIX
559 LDLIBS += -lsocket -lnsl
561 STDCCFLAGS += -DP_USE_PRAGMA
563 endif # irix
566 ####################################################
568 ifeq ($(OSTYPE),beos)
570 SYSLIBS += -lbe -lmedia -lgame -lroot -lsocket -lbind -ldl
571 STDCCFLAGS += -DBE_THREADS -DP_USE_PRAGMA -Wno-multichar -Wno-format
572 LDLIBS += $(SYSLIBS)
574 MEMORY_CHECK := 0
575 endif # beos
578 ####################################################
580 ifeq ($(OSTYPE),ultrix)
582 # R2000 Ultrix 4.2, using gcc 2.7.x
583 STDCCFLAGS += -DP_ULTRIX
584 STDCCFLAGS += -DP_USE_PRAGMA
585 endif # ultrix
588 ####################################################
590 ifeq ($(OSTYPE),hpux)
591 STDCCFLAGS += -DP_USE_PRAGMA
592 # HP/UX 9.x, using gcc 2.6.C3 (Cygnus version)
593 STDCCFLAGS += -DP_HPUX9
595 endif # hpux
598 ####################################################
600 ifeq ($(OSTYPE),Darwin)
602 # MacOS X or later / Darwin
604 CFLAGS += -fno-common -dynamic
605 LDFLAGS += -multiply_defined suppress
606 ifeq ($(OSRELEASE), 700)
607 ENDLDLIBS += -lresolv
608 endif
609 ENDLDLIBS += -framework AudioToolbox -framework CoreAudio
611 # Quicktime support is still a long way off. But for development purposes,
612 # I am inluding the flags to allow QuickTime to be linked.
613 # Uncomment them if you wish, but it will do nothing for the time being.
615 #HAS_QUICKTIMEX := 1
616 #STDCCFLAGS += -DHAS_QUICKTIMEX
617 #ENDLDLIBS += -framework QuickTime
619 ifeq ($(MACHTYPE),x86)
620 STDCCFLAGS += -m486
621 endif
623 ARCHIVE := libtool -static -o
624 P_USE_RANLIB := 0
626 CC := cc
627 CPLUS := c++
629 endif # Darwin
631 ifeq ($(OSTYPE),Carbon)
633 # MacOS 9 or X using Carbonlib calls
635 STDCCFLAGS += -DP_MACOS
637 # I'm having no end of trouble with the debug memory allocator.
638 MEMORY_CHECK := 0
640 # Carbon is only available for full Mac OS X, not pure Darwin, so the only
641 # currently available architecture is PPC.
642 P_MAC_MPTHREADS := 1
643 STDCCFLAGS += -DP_MAC_MPTHREADS
644 LDLIBS += -prebind -framework CoreServices -framework QuickTime -framework Carbon
646 P_SHAREDLIB := 0
647 P_USE_RANLIB := 1
649 CC := cc
650 CPLUS := c++
652 endif # Carbon
654 ####################################################
656 ifeq ($(OSTYPE),VxWorks)
658 ifeq ($(MACHTYPE),ARM)
659 STDCCFLAGS += -mcpu=arm8 -DCPU=ARMARCH4
660 endif
662 STDCCFLAGS += -DP_VXWORKS -DPHAS_TEMPLATES -DVX_TASKS
663 STDCCFLAGS += -DNO_LONG_DOUBLE
665 STDCCFLAGS += -Wno-multichar -Wno-format
667 MEMORY_CHECK := 0
669 STDCCFLAGS += -DP_USE_PRAGMA
671 endif # VxWorks
674 ####################################################
676 ifeq ($(OSTYPE),rtems)
678 CC := $(MACHTYPE)-rtems-gcc --pipe
679 CPLUS := $(MACHTYPE)-rtems-g++
680 #LD := $(MACHTYPE)-rtems-ld
681 #AR := $(MACHTYPE)-rtems-ar
682 #RUNLIB := $(MACHTYPE)-rtems-runlib
684 SYSLIBDIR := $(RTEMS_MAKEFILE_PATH)/lib
685 SYSINCDIR := $(RTEMS_MAKEFILE_PATH)/lib/include
687 LDFLAGS += -B$(SYSLIBDIR)/ -specs=bsp_specs -qrtems
688 STDCCFLAGS += -B$(SYSLIBDIR)/ -specs=bsp_specs -ansi -fasm -qrtems
690 ifeq ($(CPUTYPE),mcpu32)
691 STDCCFLAGS += -mcpu32
692 LDFLAGS += -mcpu32
693 endif
695 ifeq ($(CPUTYPE),mpc860)
696 STDCCFLAGS += -mcpu=860
697 LDFLAGS += -mcpu=860
698 endif
700 STDCCFLAGS += -DP_RTEMS -DP_HAS_SEMAPHORES
702 P_SHAREDLIB := 0
704 endif # rtems
706 ####################################################
708 ifeq ($(OSTYPE),QNX)
710 ifeq ($(MACHTYPE),x86)
711 STDCCFLAGS += -Wc,-m486
712 endif
714 STDCCFLAGS += -DP_QNX -DP_HAS_RECURSIVE_MUTEX=1 -DFD_SETSIZE=1024
715 LDLIBS += -lasound
716 ENDLDLIBS += -lsocket -lstdc++
718 CC := qcc -Vgcc_ntox86
719 CPLUS := qcc -Vgcc_ntox86_gpp
721 P_USE_RANLIB := 1
722 STDCCFLAGS += -DP_USE_PRAGMA
724 ifeq ($(P_SHAREDLIB),1)
725 STDCCFLAGS += -shared
726 endif
728 endif # QNX6
730 ####################################################
732 ifeq ($(OSTYPE),Nucleus)
734 # Nucleus using gcc
735 STDCCFLAGS += -msoft-float -nostdinc -g
736 STDCCFLAGS += -D__NUCLEUS_PLUS__ -D__ppc -DWOT_NO_FILESYSTEM -DPLUS \
737 -D__HAS_NO_FLOAT -D__USE_STL__ \
738 -D__USE_STD__ \
739 -D__NUCLEUS_NET__ -D__NEWLIB__ \
740 -DP_USE_INLINES=0
741 ifndef WORK
742 WORK = ${HOME}/work
743 endif
744 ifndef NUCLEUSDIR
745 NUCLEUSDIR = ${WORK}/embedded/os/Nucleus
746 endif
747 ifndef STLDIR
748 STLDIR = ${WORK}/embedded/packages/stl-3.2-stream
749 endif
750 STDCCFLAGS += -I$(NUCLEUSDIR)/plus \
751 -I$(NUCLEUSDIR)/plusplus \
752 -I$(NUCLEUSDIR)/net \
753 -I$(NUCLEUSDIR) \
754 -I$(PWLIBDIR)/include/ptlib/Nucleus++ \
755 -I$(WORK)/embedded/libraries/socketshim/BerkleySockets \
756 -I${STLDIR} \
757 -I/usr/local/powerpc-motorola-eabi/include \
758 -I${WORK}/embedded/libraries/configuration
760 UNIX_SRC_DIR = $(PWLIBDIR)/src/ptlib/Nucleus++
761 MEMORY_CHECK = 0
762 endif # Nucleus
765 ###############################################################################
767 # Make sure some things are defined
770 ifndef CC
771 CC := gcc
772 endif
774 ifndef CPLUS
775 ifndef CXX
776 CPLUS := g++
777 else
778 CPLUS := $(CXX)
779 endif
780 endif
782 ifndef INSTALL
783 INSTALL := install
784 endif
786 ifndef AR
787 AR := ar
788 endif
790 ifndef ARCHIVE
791 ifdef P_USE_RANLIB
792 ARCHIVE := $(AR) rc
793 else
794 ARCHIVE := $(AR) rcs
795 endif
796 endif
798 ifndef RANLIB
799 RANLIB := ranlib
800 endif
803 # Further configuration
805 ifndef DEBUG_FLAG
806 DEBUG_FLAG := -g
807 endif
809 ifndef PTLIB_ALT
810 PLATFORM_TYPE = $(OSTYPE)_$(MACHTYPE)
811 else
812 PLATFORM_TYPE = $(OSTYPE)_$(PTLIB_ALT)_$(MACHTYPE)
813 endif
815 ifndef OBJ_SUFFIX
816 ifdef DEBUG
817 OBJ_SUFFIX := d
818 else
819 OBJ_SUFFIX := r
820 endif # DEBUG
821 endif # OBJ_SUFFIX
823 ifndef OBJDIR_SUFFIX
824 OBJDIR_SUFFIX = $(OBJ_SUFFIX)
825 endif
827 ifndef STATICLIBEXT
828 STATICLIBEXT = a
829 endif
831 ifeq ($(P_SHAREDLIB),1)
832 LIB_SUFFIX = $(SHAREDLIBEXT)
833 LIB_TYPE =
834 else
835 LIB_SUFFIX = a
836 LIB_TYPE = _s
837 endif # P_SHAREDLIB
839 ifndef INSTALL_DIR
840 INSTALL_DIR = /usr/local
841 endif
843 ifndef INSTALLBIN_DIR
844 INSTALLBIN_DIR = $(INSTALL_DIR)/bin
845 endif
847 ifndef INSTALLLIB_DIR
848 INSTALLLIB_DIR = $(INSTALL_DIR)/lib
849 endif
852 ###############################################################################
854 # define some common stuff
857 SHELL := /bin/sh
859 .SUFFIXES: .cxx .prc
861 # Required macro symbols
863 # Directories
865 ifdef PREFIX
866 UNIX_INC_DIR = $(PREFIX)/include/ptlib/unix
867 else
868 UNIX_INC_DIR = $(PWLIBDIR)/include/ptlib/unix
869 endif
871 ifndef UNIX_SRC_DIR
872 UNIX_SRC_DIR = $(PWLIBDIR)/src/ptlib/unix
873 endif
875 PW_LIBDIR = $(PWLIBDIR)/lib
877 # set name of the PT library
878 PTLIB_BASE = pt_$(PLATFORM_TYPE)_$(OBJ_SUFFIX)
879 PTLIB_FILE = lib$(PTLIB_BASE)$(LIB_TYPE).$(LIB_SUFFIX)
880 PT_OBJBASE = obj_$(PLATFORM_TYPE)_$(OBJDIR_SUFFIX)
881 PT_OBJDIR = $(PW_LIBDIR)/$(PT_OBJBASE)
883 # set name of the PW library (may not be used)
884 PWLIB_BASE = pw_$(GUI_TYPE)_$(PLATFORM_TYPE)_$(OBJ_SUFFIX)
885 PWLIB_FILE = lib$(PWLIB_BASE)$(LIB_TYPE).$(LIB_SUFFIX)
886 PW_OBJBASE = obj_$(GUI_TYPE)_$(PLATFORM_TYPE)_$(OBJDIR_SUFFIX)
887 PW_OBJDIR = $(PW_LIBDIR)/$(PW_OBJBASE)
889 ###############################################################################
891 # Set up compiler flags and macros for debug/release versions
894 ifdef DEBUG
896 ifndef MEMORY_CHECK
897 MEMORY_CHECK := 1
898 endif
900 STDCCFLAGS += $(DEBUG_FLAG) -D_DEBUG -DNDEBUG
901 LDFLAGS += $(DEBLDFLAGS)
903 else
905 ifneq ($(OSTYPE),Darwin)
906 OPTCCFLAGS += -Os
907 else
908 OPTCCFLAGS += -O2
909 endif
911 ifneq ($(OSTYPE),Carbon)
912 ifneq ($(OSTYPE),Darwin)
913 # Apple does not support -s to remove symbol table/relocation information
914 LDFLAGS += -s
915 endif
916 endif
918 endif # DEBUG
920 # define ESDDIR variables if installed
921 ifdef ESDDIR
922 STDCCFLAGS += -I$(ESDDIR)/include -DUSE_ESD=1
923 ENDLDLIBS += $(ESDDIR)/lib/libesd.a # to avoid name conflicts
924 HAS_ESD = 1
925 endif
927 # feature migrated to configure.in
928 # #define templates if available
929 # ifndef NO_PWLIB_TEMPLATES
930 # STDCCFLAGS += -DPHAS_TEMPLATES
931 # endif
933 # compiler flags for all modes
934 #STDCCFLAGS += -fomit-frame-pointer
935 #STDCCFLAGS += -fno-default-inline
936 #STDCCFLAGS += -Woverloaded-virtual
937 #STDCCFLAGS += -fno-implement-inlines
939 # add OS directory to include path
940 # STDCCFLAGS += -I$(UNIX_INC_DIR) # removed CRS
943 # add library directory to library path and include the library
944 LDFLAGS += -L$(PW_LIBDIR)
946 LDLIBS += -l$(PTLIB_BASE)$(LIB_TYPE)
948 # End of unix.mak