aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/Makefile
blob: 7ec63b40708b8adaf0dd349e7f51b085c0de2314 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
# Asterisk -- A telephony toolkit for Linux.
# 
# Makefile for dialplan functions
#
# Copyright (C) 2005, Digium
#
# Kevin P. Fleming <kpfleming@digium.com>
#
# This program is free software, distributed under the terms of
# the GNU General Public License
#

FUNCS=pbx_functions.so

BUILTINS=func_md5.o \
         func_math.o \
         func_groupcount.o \
         func_strings.o \
         func_cdr.o \
         func_logic.o \
         func_env.o \
         func_db.o \
         func_timeout.o \
         func_language.o \
         func_moh.o

STANDALONE_FUNCS=$(filter-out $(BUILTINS),$(patsubst %.c,%.o,$(wildcard func*.c)))

FUNCS+=$(STANDALONE_FUNCS:.o=.so)

FUNC_SOURCES=$(BUILTINS:.o=.c)

FUNC_STRUCTS=$(shell grep 'struct ast_custom_function' $(FUNC_SOURCES) | awk '{print $$3};')

CFLAGS+=-fPIC

ifeq ($(findstring BSD,${OSARCH}),BSD)
  CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
endif

all: $(FUNCS)

clean:
	rm -f *.so *.o .depend pbx_functions.h

%.so : %.o
	$(CC) $(SOLINK) -o $@ $<

#$(BUILTINS) : CFLAGS += -DBUILTIN_FUNC

pbx_functions.h: $(FUNC_SOURCES)
	@echo "/* Automatically generated - do not edit */" > $@
	@for f in $(FUNC_SOURCES); do echo "#include \"$$f\"" >> $@; done
	@echo "static struct ast_custom_function *builtins[] = {" >> $@
	@for f in $(FUNC_STRUCTS); do echo "&$$f," >> $@; done
	@echo "};" >> $@

pbx_functions.o: pbx_functions.h

pbx_functions.so: pbx_functions.o #$(BUILTINS)
	$(CC) $(SOLINK) -o $@ $<

install: all
	for x in $(FUNCS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done

ifneq ($(wildcard .depend),)
  include .depend
endif

depend: .depend

.depend: pbx_functions.h
	../build_tools/mkdep $(CFLAGS) `ls *.c`

env:
	env