Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Makefile to make the compilation easy like an Apple ;) #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
.history
52 changes: 52 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Makefile for asterisk-res_json
# Contributed by Fernando Santos <[email protected]>
#
ASTBIN=$(shell which asterisk)
ASTLIBDIR:=$(shell $(ASTBIN) -rx 'core show settings' | grep 'Module directory' | awk '{print $$3}')
ifeq ($(strip $(ASTLIBDIR)),)
MODULES_DIR:=$(INSTALL_PREFIX)/usr/lib/asterisk/modules
else
MODULES_DIR:=$(INSTALL_PREFIX)$(ASTLIBDIR)
endif

INSTALL:=install
CC:=gcc
ECHO:=echo
OPTIMIZE:=-O2
DEBUG:=-g

RES_JSON_TARGET = res_json.so
RES_JSON_OBJ = res_json.o cJSON.o
RES_JSON_SRC = res_json.c cJSON.c

MODULES = res_json.so

LIBS+=-g -ggdb -I.
LIBS+=$(shell pkg-config --cflags --libs asterisk) -I/usr/local/include/asterisk -I/usr/include/asterisk
CFLAGS += -Wno-missing-field-initializers -Wno-unknown-pragmas -Wextra -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winit-self -Wmissing-format-attribute \
-Wformat=2 -g -fPIC -D_GNU_SOURCE

LDFLAGS += -shared -Wno-unknown-pragmas

.PHONY: install clean

%.o: %.c $(HEADERS)
$(CC) -c $(CFLAGS) -D'AST_MODULE="res_json"' -D'AST_MODULE_SELF_SYM=__internal_res_json_self' -o $@ $<

res_json.so: $(RES_JSON_OBJ)
$(CC) $(LDFLAGS) $(RES_JSON_OBJ) $(LIBS) -o $@

all: $(MODULES)

clean:
find . -name "*.o" -type f -delete
find . -name "*.so" -type f -delete

install: $(MODULES)
$(INSTALL) -m 755 -d $(DESTDIR)$(MODULES_DIR)
$(INSTALL) -m 755 $(MODULES) $(DESTDIR)$(MODULES_DIR)
@echo " +------- res_json Installation Complete ------+"
@echo " + +"
@echo " + res_json app has successfully installed +"
@echo " +---------------------------------------------+"
3 changes: 2 additions & 1 deletion cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#include <float.h>
#include <limits.h>
#include <ctype.h>
#include <asterisk/cJSON.h>

#include "cJSON.h"

static int cJSON_strcasecmp(const char *s1,const char *s2)
{
Expand Down
14 changes: 5 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
if [ ! -s include/asterisk.h ] ; then
echo "please cd into the directory where the asterisk source has been untarred"
exit
fi
cp asterisk-res_json/res_json.c addons/.
cp asterisk-res_json/cJSON.h include/asterisk/.
cp asterisk-res_json/cJSON.c addons/.
echo "edit addons/Makefile: add res_json to the list of modules built, and"
echo " res_json.so: cJSON.o res_json.o"
echo "======================================================================="
echo "# INSTALLING Asterisk res_json.so #"
echo "======================================================================="
make clean && make all && make install

17 changes: 8 additions & 9 deletions res_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@
<support_level>core</support_level>
***/

#include "asterisk.h"
#include <asterisk.h>

#include <asterisk/file.h>
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
#include <asterisk/module.h>
#include <asterisk/app.h>
#include <asterisk/utils.h>


#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/utils.h"
#include "asterisk/cJSON.h"
#include "cJSON.h"

/*** DOCUMENTATION
<function name="JSONPRETTY" language="en_US">
Expand Down