A selection of relatively minor problems in the build system.
[wvstreams.git] / wvrules-posix.mk
blob979716c578b8a60e1efea09b9634f45379843aea
1 LIBWVBASE=$(WVSTREAMS_LIB)/libwvbase.so $(LIBXPLC)
2 LIBWVUTILS=$(WVSTREAMS_LIB)/libwvutils.so $(LIBWVBASE)
3 LIBWVSTREAMS=$(WVSTREAMS_LIB)/libwvstreams.so $(LIBWVUTILS)
4 LIBWVOGG=$(WVSTREAMS_LIB)/libwvoggvorbis.so $(LIBWVSTREAMS)
5 LIBUNICONF=$(WVSTREAMS_LIB)/libuniconf.so $(LIBWVSTREAMS)
6 LIBWVDBUS=$(WVSTREAMS_LIB)/libwvdbus.so $(LIBWVSTREAMS)
7 LIBWVQT=$(WVSTREAMS_LIB)/libwvqt.so $(LIBWVSTREAMS)
8 LIBWVTEST=$(WVSTREAMS_LIB)/libwvtest.a $(LIBWVUTILS)
11 # Initial C compilation flags
13 INCFLAGS=$(addprefix -I,$(WVSTREAMS_INC) $(XPATH))
15 CPPFLAGS += $(CPPOPTS)
16 CFLAGS += $(COPTS)
17 CXXFLAGS += $(CXXOPTS)
18 LDFLAGS += $(LDOPTS) -L$(WVSTREAMS_LIB)
20 # Default compiler we use for linking
21 WVLINK_CC = $(CXX)
23 ifeq ("$(enable_debug)", "yes")
24 DEBUG:=1
25 else
26 DEBUG:=0
27 endif
29 ifeq ("$(enable_fatal_warnings)", "yes")
30 CXXFLAGS+=-Werror
31 # FIXME: not for C, because our only C file, crypto/wvsslhack.c, has
32 # a few warnings on purpose.
33 #CFLAGS+=-Werror
34 endif
36 ifneq ("$(enable_optimization)", "no")
37 CXXFLAGS+=-O2
38 #CXXFLAGS+=-felide-constructors
39 CFLAGS+=-O2
40 endif
42 ifneq ("$(enable_warnings)", "no")
43 #WLACH:FIXME: Conditional on using MSVC
44 # CXXFLAGS+=-Wall -Woverloaded-virtual
45 # CFLAGS+=-Wall
46 endif
48 ifeq ("$(enable_efence)", "yes")
49 EFENCE:=-lefence
50 USE_EFENCE:=1
51 endif
53 ifeq (USE_EFENCE,1)
54 LDLIBS+=$(EFENCE)
55 endif
57 ifeq ("$(enable_verbose)", "yes")
58 VERBOSE:=1
59 endif
61 ifdef DONT_LIE
62 VERBOSE:=1 $(warning DONT_LIE is deprecated, use VERBOSE instead)
63 endif
66 # Figure out which OS we're running (for now, only picks out Linux or BSD)
68 OS:=$(shell uname -a | awk '{print $$1}' | sed -e 's/^.*BSD/BSD/g' )
71 # (Just BSD and LINUX clash with other symbols, so use ISLINUX and ISBSD)
72 # This sucks. Use autoconf for most things!
74 ifeq ($(OS),Linux)
75 OSDEFINE:=-DISLINUX
76 endif
78 ifeq ($(OS),BSD)
79 OSDEFINE:=-DISBSD
80 endif
82 ifeq ($(CCMALLOC),1)
83 ifeq ($(DEBUG),1)
84 XX_LIBS += -lccmalloc -ldl
85 endif
86 endif
88 ifeq ($(DEBUG),1)
89 CFLAGS += -ggdb -DDEBUG=1
90 CXXFLAGS += -ggdb -DDEBUG=1
91 LDFLAGS += -ggdb
92 else
93 CFLAGS += -DDEBUG=0
94 CXXFLAGS += -DDEBUG=0
95 #CFLAGS += -DNDEBUG # I don't like disabling assertions...
96 #CFLAGS += -fomit-frame-pointer # really evil
97 #CXXFLAGS += -fno-implement-inlines # causes trouble with egcs 1.0
98 LDFLAGS +=
99 endif
101 ifeq ($(PROFILE),1)
102 CFLAGS += -pg
103 LDFLAGS += -pg
104 endif
106 ifeq ($(STATIC),1)
107 LDFLAGS += -static
108 endif
110 define wvlink_ar
111 $(LINK_MSG)set -e; rm -f $1 $(patsubst %.a,%.libs,$1); \
112 echo $2 >$(patsubst %.a,%.libs,$1); \
113 $(AR) q $1 $(filter %.o,$2); \
114 for d in "" $(filter %.libs,$2); do \
115 if [ "$$d" != "" ]; then \
116 cd $$(dirname "$$d"); \
117 $(AR) q $(shell pwd)/$1 $$(cat $$(basename $$d)); \
118 cd $(shell pwd); \
119 fi; \
120 done; \
121 $(AR) s $1
122 endef
124 define wvcc_base
125 @rm -f "$1"
126 $(COMPILE_MSG)$4 $5 $2 -o $1
127 @# The Perl script here generates the proper dependencies, including
128 @# null dependencies so Make doesn't complain
129 $(DEPEND_MSG)$4 -M -E $< \
130 | perl -we \
131 '$$a = '"'"'$1'"'"'; \
132 $$\ = $$/; \
133 local $$/; \
134 while (<>) { \
135 for (split(/(?<!\\)$$/m)) { \
136 s/^[^:]+:\s*/$$a: /; \
137 print; \
138 if (s/^$$a: //) { \
139 map {print "$$_:" unless m/^\\$$/} (split(/\s+/));\
142 }' >$(DEPFILE)
143 endef
145 define wvlink_ar
146 $(LINK_MSG)set -e; rm -f $1 $(patsubst %.a,%.libs,$1); \
147 echo $2 >$(patsubst %.a,%.libs,$1); \
148 $(AR) q $1 $(filter %.o,$2); \
149 for d in "" $(filter %.libs,$2); do \
150 if [ "$$d" != "" ]; then \
151 cd $$(dirname "$$d"); \
152 $(AR) q $(shell pwd)/$1 $$(cat $$(basename $$d)); \
153 cd $(shell pwd); \
154 fi; \
155 done; \
156 $(AR) s $1
157 endef
159 wvlink=$(LINK_MSG)$(CC) $(LDFLAGS) $($1-LDFLAGS) -o $1 $(filter %.o %.a %.so, $2) $($1-LIBS) $(LIBS) $(XX_LIBS) $(LDLIBS)