use LDFLAGS and LIBS properly, and allow dependencies to provide LDFLAGS if needed...
[asterisk/asterisk.git] / channels / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Makefile for channel drivers
5 #
6 # Copyright (C) 1999-2006, Digium, Inc.
7 #
8 # This program is free software, distributed under the terms of
9 # the GNU General Public License
10 #
11
12 ifneq ($(wildcard ../menuselect.makeopts),)
13   include ../menuselect.makeopts
14   include ../menuselect.makedeps
15 endif
16
17 SELECTED_MODS:=$(filter-out $(MENUSELECT_CHANNELS),$(patsubst %.c,%,$(wildcard chan_*.c)) $(patsubst %.cc,%,$(wildcard chan_*.cc)))
18
19 CC_MODS=chan_vpb
20
21 ifeq ($(OSARCH),OpenBSD)
22   PTLIB=-lpt_OpenBSD_x86_r
23   H323LIB=-lh323_OpenBSD_x86_r
24 endif
25
26 ifeq ($(OSARCH),Linux)
27   PTLIB=-lpt_linux_x86_r
28   H323LIB=-lh323_linux_x86_r
29   CHANH323LIB=-ldl
30 endif
31
32 ifeq ($(OSARCH),FreeBSD)
33   PTLIB=-lpt_FreeBSD_x86_r
34   H323LIB=-lh323_FreeBSD_x86_r
35   CHANH323LIB=-pthread
36 endif
37
38 ifeq ($(OSARCH),NetBSD)
39   PTLIB=-lpt_NetBSD_x86_r
40   H323LIB=-lh323_NetBSD_x86_r
41 endif
42
43 ifeq ($(wildcard h323/libchanh323.a),)
44   SELECTED_MODS:=$(filter-out chan_h323,$(SELECTED_MODS))
45 endif
46
47 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/mISDNuser/mISDNlib.h),)
48   SELECTED_MODS:=$(filter-out chan_misdn,$(SELECTED_MODS))
49 endif
50
51 ifndef OPENH323DIR
52   OPENH323DIR=$(HOME)/openh323
53 endif
54
55 ifndef PWLIBDIR
56   PWLIBDIR=$(HOME)/pwlib
57 endif
58
59 all: _all
60
61 include $(ASTTOPDIR)/Makefile.moddir_rules
62
63 clean::
64         rm -f busy.h ringtone.h gentone
65
66 ifneq ($(wildcard $(PWD)/Makefile.ast),)
67   include $(PWD)/Makefile.ast
68 endif
69
70 $(eval $(call ast_make_final_host,gentone,gentone.c))
71 gentone: LIBS+=-lm
72
73 busy.h: gentone
74         ./gentone busy 480 620
75
76 ringtone.h: gentone
77         ./gentone ringtone 440 480
78
79 chan_oss.o: busy.h ringtone.h
80
81 chan_iax2.so: iax2-parser.o iax2-provision.o
82
83 chan_alsa.o: busy.h ringtone.h
84
85 ifeq ($(OSARCH),Linux)
86 chan_h323.so: chan_h323.o h323/libchanh323.a $(PWD)/Makefile.ast
87         $(CC) $(SOLINK) $(H323LDFLAGS) -o $@ $< h323/libchanh323.a $(H323LDLIBS) -lstdc++
88 else
89 chan_h323.so: chan_h323.o h323/libchanh323.a
90         $(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
91 endif
92
93 misdn/chan_misdn_lib.a:
94         make -C misdn
95
96 chan_misdn.o: CFLAGS+=-Imisdn -DCHAN_MISDN_VERSION=\"0.3.0\"
97
98 misdn_config.o: CFLAGS+=-Imisdn -DCHAN_MISDN_VERSION=\"0.3.0\"
99
100 chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a
101 chan_misdn.so: LIBS+=-lisdnnet -lmISDN