List files for dist that are not picked up automatically from build
[lcr.git] / Makefile.am
index dd15966..26e575c 100644 (file)
 ##    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 ##    Boston, MA 02110-1301, USA.
 
-INSTALLdir = $(DESTDIR)/usr/local/lcr
+#INSTALLdir = $(DESTDIR)/usr/local/lcr
 
 pkglogdir=$(localstatedir)/log/@PACKAGE@
 pkgsysconfdir=$(sysconfdir)/@PACKAGE@
 
-#CONFIGdir=$(DESTDIR)$(pkgsysconfdir)
-#SHAREdir=$(DESTDIR)$(pkgdatadir)
-#LOGdir=$(DESTDIR)$(pkglogdir)
-#EXTENSIONdir=$(DESTDIR)$(localstatedir)/lib/lcr
+CONFIGdir=$(pkgsysconfdir)
+SHAREdir=$(pkgdatadir)
+LOGdir=$(pkglogdir)
+EXTENSIONdir=$(localstatedir)/lib/@PACKAGE@/extensions
 
-CONFIGdir=$(INSTALLdir)
-SHAREdir=$(INSTALLdir)
-LOGdir=$(INSTALLdir)
-EXTENSIONdir=$(INSTALLdir)/extensions
+#CONFIGdir=$(INSTALLdir)
+#SHAREdir=$(INSTALLdir)
+#LOGdir=$(INSTALLdir)
+#EXTENSIONdir=$(INSTALLdir)/extensions
 
-astmoddir = $(DESTDIR)/usr/lib/asterisk/modules
+astmoddir = $(libdir)/asterisk/modules
 
 INSTALLATION_DEFINES = \
  -DCONFIG_DATA="\"$(CONFIGdir)\"" \
@@ -118,25 +118,31 @@ chan_lcr_so_SOURCES =
 chan_lcr_so_LDFLAGS = -shared
 chan_lcr_so_LDADD = chan_lcr.po bchannel.po options.po callerid.po select.po
 
+# List chan_lcr specific sources for make dist
+EXTRA_chan_lcr_so_SOURCES = chan_lcr.c chan_lcr.h bchannel.c bchannel.h
+
+
 chan_lcr.po: chan_lcr.c chan_lcr.h
-       $(CC) $(INCLUDES) $(AST_CFLAGS) $(CPPFLAGS) $(CFLAGS) -D_GNU_SOURCE -fPIC -c chan_lcr.c -o chan_lcr.po
+       $(CC) $(INCLUDES) $(AST_CFLAGS) $(CPPFLAGS) $(CFLAGS) -D_GNU_SOURCE -fPIC -c $< -o $@
 
 bchannel.po: bchannel.c bchannel.h
-       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c bchannel.c -o bchannel.po
+       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
 
 callerid.po: callerid.c callerid.h
-       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c callerid.c -o callerid.po
+       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
 
 options.po: options.c options.h
-       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c options.c -o options.po
+       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
 
 select.po: select.c select.h
-       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c select.c -o select.po
+       $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
+
+install-exec-hook: chan_lcr.so
+       $(INSTALL) -d '$(DESTDIR)$(astmoddir)'
+       $(INSTALL) chan_lcr.so '$(DESTDIR)$(astmoddir)'
 
-install-exec-hook:
-       mkdir -p $(astmoddir)
-       $(INSTALL) -d $(astmoddir)
-       $(INSTALL) chan_lcr.so $(astmoddir)
+uninstall-hook:
+       cd '$(DESTDIR)$(astmoddir)' && rm -f chan_lcr.so
 endif
 
 INCLUDES = $(all_includes) $(MISDN_INCLUDE) $(GSM_INCLUDE) $(SS5_INCLUDE) $(SIP_INCLUDE) -Wall $(INSTALLATION_DEFINES)
@@ -155,51 +161,66 @@ lcr_LDADD = $(LIBCRYPTO) $(MISDN_LIB) -lpthread $(GSM_LIB) $(SIP_LIB)
 lcradmin_SOURCES = lcradmin.c cause.c options.c
 genextension_SOURCES = genext.c options.c extension.c
 
+
+# List all headers for make dist
+noinst_HEADERS = \
+       main.h macro.h select.h trace.h options.h tones.h alawulaw.h cause.h interface.h \
+       message.h callerid.h socket_server.h port.h vbox.h endpoint.h endpointapp.h \
+       appbridge.h apppbx.h route.h extension.h join.h joinpbx.h lcrsocket.h
+
+noinst_HEADERS += myisdn.h mISDN.h dss1.h loop.h crypt.h remote.h joinremote.h
+noinst_HEADERS += ss5.h ss5_encode.h ss5_decode.h
+noinst_HEADERS += mncc.h gsm.h gsm_audio.h gsm_bs.h gsm_ms.h
+noinst_HEADERS += ie.cpp sip.h
+
+
 # Special install function to preserve existing configs.
 # Optimization with equivalen results are welcome
+CONFIGFILES = options.conf interface.conf routing.conf directory.list
+TONEDIRS = tones_american tones_efi tones_german vbox_english vbox_german
+
+EXTRA_DIST = default debian $(TONEDIRS)
 
 install-data-hook:
-       @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'
-       mkdir -p $(CONFIGdir)
-       mkdir -p $(SHAREdir)
-       mkdir -p $(LOGdir)
-       mkdir -p $(EXTENSIONdir)
-       @if test -a $(CONFIGdir)/options.conf ; then \
-               echo "NOTE: options.conf already exists, not changed." ; else \
-               cp -v default/options.conf $(CONFIGdir) ; fi
-       @if test -a $(CONFIGdir)/interface.conf ; then \
-               echo "NOTE: interface.conf already exists, not changed." ; else \
-               cp -v default/interface.conf $(CONFIGdir) ; fi
-       @if test -a $(CONFIGdir)/routing.conf ; then \
-               echo "NOTE: routing.conf already exists, not changed." ; else \
-               cp -v default/routing.conf $(CONFIGdir) ; fi
-       @if test -a $(CONFIGdir)/numbering_int.conf ; then \
+       @fns='strcpy strncpy strcat strncat sprintf snprintf' ; \
+       files=$$( find $(srcdir) -type f -name "*.c*" \
+         | $(GREP) -v -e chan_lcr.c -e bchannel.c -e callerid.c ) ; \
+       test -z "$$files" || { for fn in $$fns ; do \
+         $(GREP) -n $$fn $$files ; if test $$? = 0 ; then \
+           ( echo "dont use $$fn, use makro instead." ; exit -1 ) ; \
+         fi ; \
+       done ; }
+       mkdir -p '$(DESTDIR)$(CONFIGdir)'
+       mkdir -p '$(DESTDIR)$(SHAREdir)'
+       mkdir -p '$(DESTDIR)$(LOGdir)'
+       mkdir -p '$(DESTDIR)$(EXTENSIONdir)'
+       @fs='$(CONFIGFILES)' ; for f in $$fs ; do \
+         if test -a "$(DESTDIR)$(CONFIGdir)/$$f" ; then \
+           echo "NOTE: $$f already exists, not changed." ; \
+         else $(INSTALL) -m 644 $(srcdir)/default/$$f "$(DESTDIR)$(CONFIGdir)/" ; fi ; \
+       done
+       @if test -a "$(DESTDIR)$(CONFIGdir)/numbering_int.conf" ; then \
                echo "NOTE: numbering_int.conf is obsolete, please use routing." ; fi
-       @if test -a $(CONFIGdir)/numbering_ext.conf ; then \
+       @if test -a "$(DESTDIR)$(CONFIGdir)/numbering_ext.conf" ; then \
                echo "NOTE: numbering_ext.conf is obsolete, please use routing." ; fi
-       @if test -a $(CONFIGdir)/directory.list ; then \
-               echo "NOTE: directory.list already exists, not changed." ; else \
-               cp -v default/directory.list $(CONFIGdir) ; fi
-       @if test -a $(SHAREdir)/tones_american ; then \
-               echo "NOTE: american tones already exists, not overwritten." ; else \
-               cp -a tones_american $(SHAREdir) ; fi
-       @if test -a $(SHAREdir)/tones_german ; then \
-               echo "NOTE: german tones already exists, not overwritten." ; else \
-               cp -a tones_german $(SHAREdir) ; fi
-       @if test -a $(SHAREdir)/vbox_german ; then \
-               echo "NOTE: german vbox tones already exists, not overwritten." ; else \
-               cp -a vbox_german $(SHAREdir) ; fi
-       @if test -a $(SHAREdir)/vbox_english ; then \
-               echo "NOTE: english vbox tones already exists, not overwritten." ; else \
-               cp -a vbox_english $(SHAREdir) ; fi
-       @if test -a $(SHAREdir)/tones_efi ; then \
-               echo "NOTE: special efi tones already exists, not overwritten." ; else \
-               cp -a tones_efi $(SHAREdir) ; fi
+       @ds='$(TONEDIRS)' ; for d in $$ds ; do \
+         destdir="$(DESTDIR)$(SHAREdir)/$$d" ; \
+         if test -a "$$destdir" ; then \
+           echo "NOTE: $$d already exists, not overwritten." ; \
+         else mkdir -p "$$destdir" ; cp -a $(srcdir)/$$d/* "$$destdir/" ; fi ; \
+       done
+
+
+# Because distuninstallcheck expects relative filenames, we cannot
+# replace './' with $(prefix) in _listfiles. Therefore we do it the
+# other way around to filter out configuration files and tones.
+distcheck_CONFIGdir = echo $(CONFIGdir) | sed 's|^$(prefix)/|./|'
+distcheck_SHAREdir  = echo $(SHAREdir)  | sed 's|^$(prefix)/|./|'
+
+distuninstallcheck_listfiles = find . -type f -print \
+       | $(GREP) -v "$$( $(distcheck_CONFIGdir) )" \
+       | $(GREP) -v "$$( $(distcheck_SHAREdir) )"
+
 
 clean-generic:
        rm -f *.po