LCR now runs as a user.
[lcr.git] / Makefile
index cfee9ee..171b57b 100644 (file)
--- a/Makefile
+++ b/Makefile
 #*****************************************************************************/ 
 
 WITH-CRYPTO = 42 # comment this out, if no libcrypto should be used
-#WITH-ASTERISK = 42 # comment this out, if you don't require built-in Asterisk channel driver.
-#WITH-SOCKET = 42 # compile for socket based mISDN (this options is far unfinished !!!)
+WITH-ASTERISK = 42 # comment this out, if you don't require built-in Asterisk channel driver.
 # note: check your location and the names of libraries.
 
 # select location to install
 INSTALL_BIN = /usr/local/bin
+INSTALL_CHAN = /usr/lib/asterisk/modules
 INSTALL_DATA = /usr/local/lcr
 
-ifdef WITH-SOCKET
 LIBS += -lmisdn -lpthread
-else
-LIBS += -lisdnnet -lmISDN -lpthread
-endif
 CHANLIBS += -lmISDN
 
 # give location of the curses or ncurses library
@@ -43,18 +39,16 @@ GENW = ./genwave
 GENRC = ./genrc
 GENEXT = ./genextension
 CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\"
+CFLAGS += -I/usr/include/mISDNuser
 #CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\"
 ifdef WITH-CRYPTO
 CFLAGS += -DCRYPTO
 endif
-ifdef WITH-SOCKET
-CFLAGS += -DSOCKET_MISDN -I/usr/include/mISDNuser
-endif
 ifdef WITH-CRYPTO
 LIBDIR += -L/usr/local/ssl/lib
 CFLAGS += -I/usr/local/ssl/include
-#LIBS += -lcrypto
-LIBS += /usr/local/ssl/lib/libcrypto.a
+LIBS += -lcrypto
+#LIBS += /usr/local/ssl/lib/libcrypto.a
 endif
 
 #all:
@@ -63,14 +57,13 @@ endif
 #      @exit
 
 all: $(CHAN_LCR) $(LCR) $(LCRADMIN) $(GEN) $(GENW) $(GENRC) $(GENEXT)
-       @sh -c 'grep -n strcpy *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strcpy, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n strncpy *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strncpy, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n strcat *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strcat, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n strncat *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strncat, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n sprintf *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use sprintf, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n snprintf *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use snprintf, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strcpy *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strcpy, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strncpy *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strncpy, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strcat *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strcat, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strncat *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strncat, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n sprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use sprintf, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n snprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use snprintf, use makro instead." ; exit -1 ; fi'
        @echo "All LCR binaries done"
-       @sync
        @exit
 
 main.o: main.c *.h Makefile
@@ -80,7 +73,9 @@ message.o: message.c *.h Makefile
        $(PP) -c $(CFLAGS) message.c -o message.o
 
 options.o: options.c *.h Makefile
-       $(PP) -c $(CFLAGS) options.c -o options.o
+       $(CC) -c $(CFLAGS) options.c -o options.o
+options.ooo: options.c *.h Makefile
+       $(PP) -c $(CFLAGS) options.c -o options.ooo
 
 interface.o: interface.c *.h Makefile
        $(PP) -c $(CFLAGS) interface.c -o interface.o
@@ -127,6 +122,11 @@ endpointapp.o: endpointapp.cpp *.h Makefile
 apppbx.o: apppbx.cpp *.h Makefile
        $(PP) -c $(CFLAGS) apppbx.cpp -o apppbx.o
 
+callerid.o: callerid.c *.h Makefile
+       $(CC) -c $(CFLAGS) callerid.c -o callerid.o
+callerid.ooo: callerid.c *.h Makefile
+       $(PP) -c $(CFLAGS) callerid.c -o callerid.ooo
+
 join.o: join.cpp *.h Makefile
        $(PP) -c $(CFLAGS) join.cpp -o join.o
 
@@ -158,13 +158,10 @@ trace.o: trace.c *.h Makefile
        $(PP) -c $(CFLAGS) trace.c -o trace.o
 
 chan_lcr.o: chan_lcr.c *.h Makefile
-       $(CC) -D_GNU_SOURCE  -c $(CFLAGS) chan_lcr.c -o chan_lcr.o
-
-chan_lcr.so: chan_lcr.o *.h Makefile
-       gcc -shared -x $(LDFLAGS) -o chan_lcr.so chan_lcr.o
+       $(CC) -D_GNU_SOURCE -c $(CFLAGS) chan_lcr.c -o chan_lcr.o
 
 bchannel.o: bchannel.c *.h Makefile
-       $(CC) -c $(CFLAGS) bchannel.c -o bchannel.o
+       $(CC) -D_GNU_SOURCE -c $(CFLAGS) bchannel.c -o bchannel.o
 
 
 #$(WIZZARD): wizzard.c Makefile
@@ -172,7 +169,7 @@ bchannel.o: bchannel.c *.h Makefile
 #      -o $(WIZZARD) 
 
 $(LCR): main.o \
-       options.o \
+       options.ooo \
        interface.o \
        extension.o \
        cause.o \
@@ -187,6 +184,7 @@ $(LCR): main.o \
        endpoint.o \
        endpointapp.o \
        apppbx.o \
+       callerid.ooo \
        crypt.o \
        action.o \
        action_vbox.o \
@@ -198,8 +196,8 @@ $(LCR): main.o \
        socket_server.o \
        trace.o
        $(PP) $(LIBDIR) \
-               main.o \
-       options.o \
+       main.o \
+       options.ooo \
        interface.o \
        extension.o \
        cause.o \
@@ -214,6 +212,7 @@ $(LCR): main.o \
        endpoint.o \
        endpointapp.o \
        apppbx.o \
+       callerid.ooo \
        crypt.o \
        action.o \
        action_vbox.o \
@@ -226,13 +225,13 @@ $(LCR): main.o \
        trace.o \
        $(LIBS) -o $(LCR) 
 
-$(LCRADMIN): lcradmin.c cause.c *.h Makefile
+$(LCRADMIN): lcradmin.c cause.c options.c *.h Makefile
        $(PP) $(LIBDIR) $(CFLAGS_LCRADMIN) $(CURSES) -lm lcradmin.c cause.c \
-       -o $(LCRADMIN) 
+       options.c -o $(LCRADMIN) 
+
+$(CHAN_LCR): chan_lcr.o bchannel.o callerid.o options.o *.h Makefile
+       $(CC) -shared -Xlinker -x $(LDFLAGS) -o $(CHAN_LCR) chan_lcr.o bchannel.o callerid.o options.o
 
-$(CHAN_LCR): chan_lcr.o bchannel.o
-       $(CC) $(LIBDIR) chan_lcr.o bchannel.o \
-       $(CHANLIBS) -o $(CHAN_LCR) 
 
 $(LCRWATCH): watch.c *.h Makefile
        $(PP) $(LIBDIR) $(CFLAGS) -lm watch.c \
@@ -250,8 +249,8 @@ $(GENRC): genrc.c *.h Makefile
        $(PP) $(LIBDIR) $(CFLAGS) -lm genrc.c \
        -o $(GENRC) 
 
-$(GENEXT): options.o extension.o genext.o
-       $(PP) $(CFLAGS) options.o extension.o genext.o -o $(GENEXT) 
+$(GENEXT): options.ooo extension.o genext.o
+       $(PP) $(CFLAGS) options.ooo extension.o genext.o -o $(GENEXT) 
 
 #install:
 #      @echo Remember, this is a beta release. To overwrite your current installed
@@ -259,11 +258,11 @@ $(GENEXT): options.o extension.o genext.o
 #      @exit
 
 install:
-       -killall -9 -w -q lcr # the following error must be ignored
+       make
        cp $(LCR) $(INSTALL_BIN)
        cp $(LCRADMIN) $(INSTALL_BIN)
-ifdef WITH_ASTERISK
-       cp $(CHAN_LCR) $(INSTALL_BIN)
+ifdef WITH-ASTERISK
+       cp $(CHAN_LCR) $(INSTALL_CHAN)
 endif
 #      cp $(LCRWATCH) $(INSTALL_BIN)
        cp $(GEN) $(INSTALL_BIN)
@@ -303,12 +302,11 @@ endif
        @if test -a $(INSTALL_DATA)/tones_efi ; then \
                echo "NOTE: special efi tones already exists, not overwritten." ; else \
                cp -a tones_efi $(INSTALL_DATA) ; fi
-       sync
 
 clean:
        touch *
        rm -f $(LCR) $(LCRADMIN) $(CHAN_LCR) $(LCRWATCH) $(GEN) $(GENW) $(GENRC) $(GENEXT)
-       rm -f *.o
+       rm -f *.o *.ooo
        rm -f .*.c.sw* .*.cpp.sw* .*.h.sw*
        rm -f bla nohup.out a.out
        rm -f debug*.log
@@ -318,18 +316,9 @@ tar:
        cd .. &&  tar --exclude=.git -cvzf lcr_`date +%Y%m%d`.tar.gz lcr
 
 start: $(LCR)
-       sync
-       -killall -9 -w -q lcr # the following error must be ignored
-       $(LCR) start
-
-s: $(LCR)
-       sync
-       -killall -9 -w -q lcr # the following error must be ignored
        $(LCR) start
 
 fork: $(LCR)
-       sync
-       -killall -9 -w -q lcr # the following error must be ignored
        $(LCR) fork
 
 snapshot: clean