~ubuntu-branches/ubuntu/quantal/wvdial/quantal

« back to all changes in this revision

Viewing changes to wvrules.mk

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Randrianiriana
  • Date: 2011-01-09 18:59:33 UTC
  • mfrom: (3.3.1 experimental) (3.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110109185933-kxifjmo0g6dggf42
Tags: 1.61-2
* New upstream release in unstable:
  + FAQ URL updated (LP: #415524).
* Updated manpage pon.wvdial.1
* Prevent ftbfs with binutils-gold and gcc 4.5 (Closes: #608018, #609573).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# wvrules.mk:  2003 09 09
 
1
# wvrules.mk
2
2
#
3
 
# Copyright (C) 1998-2003 by Avery Pennarun <apenwarr@worldvisions.ca>.
 
3
# Copyright (C) 1998-2007 by Avery Pennarun <apenwarr@alumnit.ca>
 
4
#   and contributors.
4
5
#   Use, distribute, modify, and redistribute freely.  (But if you're nice,
5
6
#   you'll send all your changes back to me.)
6
7
#
11
12
# It will only work with GNU make.
12
13
#
13
14
 
 
15
# we need a default rule, since the 'includes' below can cause trouble
 
16
.PHONY: default all
 
17
default: all
 
18
 
 
19
all: CC CXX
 
20
 
14
21
# if WVSTREAMS_SRC is set assume everything else is set.
15
22
# For packages that use WvStreams use WVSTREAMS_SRC=. for distribution.
16
 
ifeq ($(WVSTREAMS_SRC),)
17
 
  ifeq ($(WVSTREAMS),)
18
 
    $(error The WVSTREAMS variable is not defined)
19
 
  endif
 
23
ifneq ($(WVSTREAMS),)
20
24
  WVSTREAMS_SRC=$(WVSTREAMS)
21
25
  WVSTREAMS_LIB=$(WVSTREAMS)
22
26
  WVSTREAMS_INC=$(WVSTREAMS)/include
26
30
 
27
31
SHELL=/bin/bash
28
32
 
29
 
ifneq ($(wildcard $(WVSTREAMS_SRC)/config.mk),)
30
 
  include $(WVSTREAMS_SRC)/config.mk
31
 
endif
 
33
include $(WVSTREAMS_SRC)/config.defaults.mk
 
34
-include $(WVSTREAMS_SRC)/config.mk
 
35
-include $(WVSTREAMS_SRC)/config.overrides.mk
 
36
-include $(WVSTREAMS_SRC)/local.mk
32
37
 
33
38
ifeq (${EXEEXT},.exe)
34
 
  include $(WVSTREAMS_SRC)/wvrules-win32.mk
 
39
  _WIN32=_WIN32
 
40
  XPATH += $(WVSTREAMS)/win32 $(WVSTREAMS)/win32/cominclude
 
41
  AR=i586-mingw32msvc-ar
 
42
  LIBS += -lssl -lcrypto -lz -lole32 -lrpcrt4 -lwsock32 -lgdi32 -limagehlp \
 
43
          -lxplc-cxx -lxplc -lstdc++
 
44
else
 
45
  CFLAGS += -fPIC
 
46
  CXXFLAGS += -fPIC
35
47
endif
36
48
 
 
49
include $(WVSTREAMS_SRC)/wvrules-$(COMPILER_STANDARD).mk
 
50
 
37
51
ifeq (${WVTESTRUN},)
38
 
  WVTESTRUN=$(WVSTREAMS_BIN)/wvtesthelper
39
 
endif
40
 
 
41
 
ifneq ("$(with_xplc)", "no")
42
 
ifneq ("$(with_xplc)", "")
43
 
  LDFLAGS:=-L$(with_xplc) $(LDFLAGS)
44
 
endif
45
 
  LIBXPLC=-lxplc-cxx
46
 
endif
47
 
 
48
 
LIBWVBASE=$(WVSTREAMS_LIB)/libwvbase.so
49
 
LIBWVUTILS=$(WVSTREAMS_LIB)/libwvutils.so $(LIBWVBASE)
50
 
LIBWVSTREAMS=$(WVSTREAMS_LIB)/libwvstreams.so $(LIBWVUTILS)
51
 
LIBUNICONF=$(WVSTREAMS_LIB)/libuniconf.so $(LIBWVSTREAMS)
52
 
LIBWVQT=$(WVSTREAMS_LIB)/libwvqt.so $(LIBWVSTREAMS)
53
 
LIBWVTEST=$(WVSTREAMS_LIB)/libwvtest.a $(LIBWVUTILS)
54
 
 
55
 
#
56
 
# Initial C compilation flags
57
 
#
58
 
CPPFLAGS += $(CPPOPTS)
59
 
C_AND_CXX_FLAGS += -D_BSD_SOURCE -D_GNU_SOURCE $(OSDEFINE) \
60
 
                  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
61
 
CFLAGS += $(COPTS) $(C_AND_CXX_FLAGS) 
62
 
CXXFLAGS += $(CXXOPTS) $(C_AND_CXX_FLAGS)
63
 
LDFLAGS += $(LDOPTS) -L$(WVSTREAMS_LIB)
64
 
 
65
 
# Default compiler we use for linking
66
 
WVLINK_CC = gcc
67
 
 
68
 
# FIXME: what does this do??
69
 
XX_LIBS := $(XX_LIBS) $(shell $(CC) -lsupc++ -lgcc_eh 2>&1 | grep -q "undefined reference" && echo " -lsupc++ -lgcc_eh")
70
 
 
71
 
ifeq ("$(enable_debug)", "yes")
72
 
  DEBUG:=1
73
 
else
74
 
  DEBUG:=0
75
 
endif
76
 
 
77
 
ifeq ("$(enable_fatal_warnings)", "yes")
78
 
  CXXFLAGS+=-Werror
79
 
  # FIXME: not for C, because our only C file, crypto/wvsslhack.c, has
80
 
  #        a few warnings on purpose.
81
 
  #CFLAGS+=-Werror
82
 
endif
83
 
 
84
 
ifneq ("$(enable_optimization)", "no")
85
 
  CXXFLAGS+=-O2
86
 
  #CXXFLAGS+=-felide-constructors
87
 
  CFLAGS+=-O2
88
 
endif
89
 
 
90
 
ifneq ("$(enable_warnings)", "no")
91
 
  CXXFLAGS+=-Wall -Woverloaded-virtual
92
 
  CFLAGS+=-Wall
93
 
endif
94
 
 
95
 
ifeq ("$(enable_rtti)", "no")
96
 
  CXXFLAGS+=-fno-rtti
97
 
endif
98
 
 
99
 
ifneq ("$(enable_exceptions)", "yes")
100
 
  CXXFLAGS+=-fno-exceptions
101
 
endif
102
 
 
103
 
ifeq ("$(enable_efence)", "yes")
104
 
  EFENCE:=-lefence
105
 
  USE_EFENCE:=1
106
 
endif
107
 
 
108
 
ifeq (USE_EFENCE,1)
109
 
  LDLIBS+=$(EFENCE)
110
 
endif
111
 
 
112
 
ifeq ("$(enable_verbose)", "yes")
113
 
  VERBOSE:=1
114
 
endif
115
 
 
116
 
ifdef DONT_LIE
117
 
  VERBOSE:=1 $(warning DONT_LIE is deprecated, use VERBOSE instead)
118
 
endif
119
 
 
120
 
STRIP=strip --remove-section=.note --remove-section=.comment
121
 
#STRIP=echo
 
52
  WVTESTRUN=$(WVSTREAMS_BIN)/wvtestrunner.pl
 
53
endif
122
54
 
123
55
# macros that expand to the object files in the given directories
124
56
objects=$(sort $(foreach type,c cc,$(call objects_$(type),$1)))
125
 
objects_c=$(patsubst %.c,%.o,$(wildcard $(addsuffix /*.c,$1)))
126
 
objects_cc=$(patsubst %.cc,%.o,$(wildcard $(addsuffix /*.cc,$1)))
127
 
 
128
 
# macro that expands to the subdir.mk files to include
129
 
xsubdirs=$(sort $(wildcard $1/*/subdir.mk)) /dev/null
130
 
 
131
 
# we need a default rule, since the 'includes' below causes trouble
132
 
.PHONY: default all
133
 
default: all
 
57
objects_c=$(filter-out $(WV_EXCLUDES), \
 
58
                $(patsubst %.c,%.o,$(wildcard $(addsuffix /*.c,$1))))
 
59
objects_cc=$(filter-out $(WV_EXCLUDES), \
 
60
                $(patsubst %.cc,%.o,$(wildcard $(addsuffix /*.cc,$1))))
 
61
tests_cc=$(filter-out $(WV_EXCLUDES), \
 
62
                $(patsubst %.cc,%,$(wildcard $(addsuffix /*.cc,$1))))
134
63
 
135
64
# default "test" rule does nothing...
136
 
.PHONY: test runtests clean-valgrind
 
65
.PHONY: test runtests
137
66
test:
138
 
runtests: clean-valgrind
139
 
 
140
 
clean-valgrind:
141
 
        @rm -f valgrind.log.pid*
 
67
runtests:
142
68
 
143
69
%/test:
144
70
        $(MAKE) -C $(dir $@) test
145
71
 
146
 
$(WVSTREAMS_SRC)/rules.local.mk:
147
 
        @true
148
 
 
149
 
-include $(WVSTREAMS_SRC)/rules.local.mk
150
 
 
151
 
#
152
 
# Figure out which OS we're running (for now, only picks out Linux or BSD)
153
 
#
154
 
OS:=$(shell uname -a | awk '{print $$1}' | sed -e 's/^.*BSD/BSD/g' )
155
 
 
156
 
#
157
 
# (Just BSD and LINUX clash with other symbols, so use ISLINUX and ISBSD)
158
 
# This sucks.  Use autoconf for most things!
159
 
#
160
 
ifeq ($(OS),Linux)
161
 
  OSDEFINE:=-DISLINUX
162
 
endif
163
 
 
164
 
ifeq ($(OS),BSD)
165
 
  OSDEFINE:=-DISBSD
166
 
endif
167
 
 
168
 
ifeq ($(CCMALLOC),1)
169
 
 ifeq ($(DEBUG),1)
170
 
   XX_LIBS += -lccmalloc -ldl
171
 
 endif
172
 
endif
173
 
 
174
 
ifeq ($(DEBUG),1)
175
 
  C_AND_CXX_FLAGS += -ggdb -DDEBUG=1
176
 
  LDFLAGS += -ggdb
177
 
else
178
 
  C_AND_CXX_FLAGS += -g -DDEBUG=0
179
 
  #CFLAGS += -DNDEBUG    # I don't like disabling assertions...
180
 
  #CFLAGS += -fomit-frame-pointer  # really evil
181
 
  #CXXFLAGS += -fno-implement-inlines  # causes trouble with egcs 1.0
182
 
  LDFLAGS += -g
183
 
endif
184
 
 
185
 
ifeq ($(PROFILE),1)
186
 
  CFLAGS += -pg
187
 
  LDFLAGS += -pg
188
 
endif
189
 
 
190
 
ifeq ($(STATIC),1)
191
 
  LDFLAGS += -static
192
 
endif
193
 
 
194
72
INCFLAGS=$(addprefix -I,$(WVSTREAMS_INC) $(XPATH))
195
 
CPPFLAGS+=$(INCFLAGS)
196
 
CFLAGS+=$(CPPFLAGS)
197
 
CXXFLAGS+=$(CPPFLAGS)
 
73
CPPFLAGS+=$(INCFLAGS) \
 
74
        -D_BSD_SOURCE -D_GNU_SOURCE $(OSDEFINE) \
 
75
        -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
 
76
        -DUNSTABLE
198
77
 
199
78
ifeq ($(VERBOSE),1)
200
79
  COMPILE_MSG :=
214
93
FORCE:
215
94
 
216
95
ifeq ($(LN_S),)
217
 
LN_S := ln -s
 
96
  LN_S := ln -s
218
97
endif
219
98
ifeq ($(LN),)
220
 
LN := ln
 
99
  LN := ln
221
100
endif
222
101
 
223
102
# Create symbolic links
228
107
# usage: $(wvln,source,dest)
229
108
wvln=$(SYMLINK_MSG)$(LN) -f $1 $2
230
109
 
231
 
# usage: $(wvcc_base,outfile,infile,stem,compiler cflags,mode)
232
 
#    eg: $(wvcc,foo.o,foo.cc,foo,$(CC) $(CFLAGS) -fPIC,-c)
233
 
DEPFILE = $(if $(filter %.o,$1),$(dir $1).$(notdir $(1:.o=.d)),/dev/null)
234
 
define wvcc_base
235
 
        @rm -f "$1"
236
 
        $(COMPILE_MSG)$4 $5 $2 -o $1
237
 
        @# The Perl script here generates the proper dependencies, including
238
 
        @# null dependencies so Make doesn't complain
239
 
        $(DEPEND_MSG)$4 -M -E $< \
240
 
                | perl -we \
241
 
                '$$a = '"'"'$1'"'"'; \
242
 
                $$\ = $$/; \
243
 
                local $$/; \
244
 
                while (<>) { \
245
 
                    for (split(/(?<!\\)$$/m)) { \
246
 
                        s/^[^:]+:\s*/$$a: /; \
247
 
                        print; \
248
 
                        if (s/^$$a: //) { \
249
 
                            map {print "$$_:" unless m/^\\$$/} (split(/\s+/));\
250
 
                        } \
251
 
                    } \
252
 
                }' >$(DEPFILE)
253
 
endef
254
 
wvcc=$(call wvcc_base,$1,$2,$3,$(CC) $(CFLAGS) $($1-CPPFLAGS) $($1-CFLAGS) $4,$(if $5,$5,-c))
255
 
wvcxx=$(call wvcc_base,$1,$2,$3,$(CXX) $(CFLAGS) $(CXXFLAGS) $($1-CPPFLAGS) $($1-CFLAGS) $($1-CXXFLAGS) $4,$(if $5,$5,-c))
256
 
 
257
 
define wvlink_ar
258
 
        $(LINK_MSG)set -e; rm -f $1 $(patsubst %.a,%.libs,$1); \
259
 
        echo $2 >$(patsubst %.a,%.libs,$1); \
260
 
        $(AR) q $1 $(filter %.o,$2); \
261
 
        for d in "" $(filter %.libs,$2); do \
262
 
            if [ "$$d" != "" ]; then \
263
 
                        cd $$(dirname "$$d"); \
264
 
                        $(AR) q $(shell pwd)/$1 $$(cat $$(basename $$d)); \
265
 
                        cd $(shell pwd); \
266
 
                fi; \
267
 
        done; \
268
 
        $(AR) s $1
269
 
endef
 
110
# usage: $(wvcc,outfile,infile,stem,extra_cflags,mode)
 
111
#    eg: $(wvcc,foo.o,foo.cc,foo,-fPIC,-c)
 
112
 
 
113
define wvcc
 
114
        ./CC $(if $5,$5,-c) $3 $($1-CFLAGS) $($1-CPPFLAGS) $4
 
115
endef
 
116
 
 
117
define wvcxx
 
118
        ./CXX $(if $5,$5,-c) $3 $($1-CXXFLAGS) $($1-CPPFLAGS) $4
 
119
endef
 
120
 
270
121
%.so: SONAME=$@$(if $(SO_VERSION),.$(SO_VERSION))
 
122
 
271
123
wvsoname=$(if $($1-SONAME),$($1-SONAME),$(if $(SONAME),$(SONAME),$1))
272
 
define wvlink_so
273
 
        $(LINK_MSG)$(WVLINK_CC) $(LDFLAGS) $($1-LDFLAGS) -Wl,-soname,$(call wvsoname,$1) -shared -o $1 $(filter %.o %.a %.so,$2) $($1-LIBS) $(LIBS) $(XX_LIBS)
 
124
ifdef _WIN32
 
125
  define wvlink_so
 
126
        @echo "Skipping $@ on win32 (can't build shared libraries)"
 
127
  endef
 
128
else
 
129
  define wvlink_so
 
130
        $(LINK_MSG)$(WVLINK_CC) $(LDFLAGS) $($1-LDFLAGS) -Wl,-z,defs -Wl,-soname,$(call wvsoname,$1) -shared -o $1 $(filter %.o %.a %.so,$2) $($1-LIBS) $(LIBS) $(XX_LIBS)
274
131
        $(if $(filter-out $(call wvsoname,$1),$1),$(call wvlns,$1,$(call wvsoname,$1)))
275
 
endef
276
 
 
277
 
wvlink=$(LINK_MSG)$(CC) $(LDFLAGS) $($1-LDFLAGS) -o $1 $(filter %.o %.a %.so, $2) $($1-LIBS) $(LIBS) $(XX_LIBS) $(LDLIBS)
 
132
  endef
 
133
endif
278
134
 
279
135
../%.so:;       @echo "Shared library $@ does not exist!"; exit 1
280
136
../%.a:;        @echo "Library $@ does not exist!"; exit 1
310
166
        @ls -l $@
311
167
 
312
168
#
313
 
# Header files for tcl/tk packages
314
 
#
315
 
pkgIndex.tcl: $(filter-out pkgIndex.tcl,$(wildcard *.tcl))
316
 
        @echo Generating pkgIndex.tcl...
317
 
        @rm -f $@
318
 
        @echo pkg_mkIndex . \
319
 
                $$(echo $^ | sed 's,\.tcl_paths,,') | tclsh
320
 
 
321
 
pkgIndex.tcl $(wildcard *.tcl): .tcl_paths
322
 
.tcl_paths:
323
 
        @echo Generating .tcl_paths...
324
 
        @rm -f $@
325
 
        @find . $(TOPDIR) -name '*.tcl' -printf '%h\n' | sort | uniq | \
326
 
                (echo lappend auto_path \\; sed 's/^.*$$/       & \\/'; echo) >$@.tmp
327
 
        @mv $@.tmp $@
328
 
 
329
 
#
330
169
# We automatically generate header dependencies for .c and .cc files.  The
331
 
# dependencies are stored in the file ".filename.d"
 
170
# dependencies are stored in the file ".filename.d", and we include them
 
171
# automatically here if they exist.
332
172
#
333
 
depfiles_sf = $(wildcard .*.d t/.*.d)
334
 
 
335
 
ifneq ($(depfiles_sf),)
336
 
-include $(depfiles_sf)
337
 
endif
 
173
-include $(shell find . -name '.*.d') /dev/null
338
174
 
339
175
 
340
176
#
358
194
 
359
195
subdirs = $(call subdirs_func,$(subst subdirs,all,$(if $1,$1,$@)),$(if $2,$2,$(SUBDIRS)))
360
196
 
361
 
# # $(call reverse,$(SUBDIRS)) works since GNU make 3.80 only
362
 
# reverse = \
363
 
#       $(if $(1),$(call reverse,$(wordlist 2, 999, $(1))) $(firstword $(1)))
364
 
 
365
197
define shell_reverse
366
198
        revlist="" ; \
367
199
        for word in $(1) ; do \
369
201
        done ; \
370
202
        echo "$${revlist}"
371
203
endef
372
 
 
373
204
reverse = $(shell $(call shell_reverse,$(1)))
374
205
 
375
206
clean_subdirs = $(call subdirs,clean,$(call reverse,$(SUBDIRS)),keep)
382
213
 
383
214
#
384
215
# Auto-clean rule.  Feel free to append to this in your own directory, by
385
 
# defining your own "clean" rule.
 
216
# defining your own "clean" and/or "distclean" rules.
386
217
#
387
218
.PHONY: clean _wvclean
388
219
 
390
221
 
391
222
_wvclean:
392
223
        @echo '--> Cleaning $(shell pwd)...'
393
 
        @rm -f *~ *.tmp *.o *.a *.so *.so.* *.libs *.moc *.d .*.d .depend \
 
224
        @rm -f *~ *.tmp *.o *.a *.so *.so.* *.libs *.dll *.lib *.moc *.d .*.d .depend \
394
225
                 .\#* .tcl_paths pkgIndex.tcl gmon.out core build-stamp \
 
226
                 CC CXX \
395
227
                 wvtestmain
396
228
        @rm -f $(patsubst %.t.cc,%.t,$(wildcard *.t.cc) $(wildcard t/*.t.cc)) \
397
229
                t/*.o t/*~ t/.*.d t/.\#*
399
231
        @rm -f semantic.cache tags
400
232
        @rm -rf debian/tmp
401
233
 
402
 
#
403
 
# default dist rules.
404
 
distclean: clean
405
 
 
406
 
PKGNAME := $(notdir $(shell pwd))
407
 
PPKGNAME := $(shell echo $(PKGNAME) | tr a-z A-Z | tr - _)
408
 
PKGVER := $(shell test -f wvver.h \
409
 
            && cat wvver.h | sed -ne "s/\#define $(PPKGNAME)_VER_STRING.*\"\([^ ]*\).*\".*/\1/p")
410
 
ifneq ($(PKGVER),)
411
 
PKGDIR := $(PKGNAME)-$(PKGVER)
412
 
else
413
 
PKGDIR := $(PKGNAME)
414
 
endif
415
 
ifneq ($(PKGSNAPSHOT),)
416
 
PKGDIR := $(PKGDIR)+$(shell date +%Y%m%d)
417
 
endif
418
 
dist-dir:
419
 
        @echo $(PKGDIR)
420
 
 
421
234
dist-hook:
422
235
 
423
 
dist: dist-hook ChangeLog
 
236
PKGDIR=$(WVPACKAGE_TARNAME)-$(WVPACKAGE_VERSION)
 
237
 
 
238
dist: dist-hook
424
239
        @echo '--> Making dist in ../build/$(PKGDIR)...'
425
240
        @test -d ../build || mkdir ../build
426
241
        @rsync -a --delete --force '$(shell pwd)/' '../build/$(PKGDIR)'
427
 
        @find '../build/$(PKGDIR)' -name .svn -type d -print0 | xargs -0 rm -rf --
428
 
        @find '../build/$(PKGDIR)' -name .cvsignore -type f -print0 | xargs -0 rm -f --
429
 
        @$(MAKE) -C '../build/$(PKGDIR)' distclean
 
242
        cd ../build/$(PKGDIR) && git clean -d -f -x
 
243
        cd ../build/$(PKGDIR) && git log > ChangeLog
 
244
        @find '../build/$(PKGDIR)' -name .git -type d -print0 | xargs -0 rm -rf --
 
245
        @find '../build/$(PKGDIR)' -name .gitignore -type f -print0 | xargs -0 rm -f --
430
246
        @rm -f '../build/$(PKGDIR).tar.gz'
431
247
        @cd ../build; tar -zcf '$(PKGDIR).tar.gz' '$(PKGDIR)'
432
248
        @echo '--> Created tarball in ../build/$(PKGDIR).tar.gz.'
433
 
 
434
 
ChangeLog: FORCE
435
 
        @echo '--> Generating ChangeLog from Subversion...'
436
 
        @rm -f ChangeLog ChangeLog.bak
437
 
        @svn log --xml --verbose | xsltproc svn2cl.xsl - > ChangeLog
438
 
 
439
 
#
440
 
# Make 'tags' file using the ctags program - useful for editing
441
 
#
442
 
#tags: $(shell find -name '*.cc' -o -name '*.[ch]')
443
 
#       @echo '(creating "tags")'
444
 
#       @if [ -x /usr/bin/ctags ]; then /usr/bin/ctags $^; fi