dahdi-tools/Makefile.legacy
Oron Peled bf9500ab32 automake: migrate tools from Makefile.legacy
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00

221 lines
6.1 KiB
Makefile

#
# Makefile for DAHDI tools
#
# Copyright (C) 2001-2010 Digium, Inc.
#
#
ifeq ($(strip $(foreach var,clean,$(findstring $(var),$(MAKECMDGOALS)))),)
endif
ifeq ($(strip $(foreach var,clean,$(findstring $(var),$(MAKECMDGOALS)))),)
ifneq ($(wildcard makeopts),)
include makeopts
endif
endif
OPTFLAGS=-O2
CFLAGS+=-I. $(OPTFLAGS) -g -fPIC -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
ifneq (,$(findstring ppc,$(UNAME_M)))
CFLAGS+=-fsigned-char
endif
ifneq (,$(findstring x86_64,$(UNAME_M)))
CFLAGS+=-m64
endif
ifeq ($(DAHDI_DEVMODE),yes)
CFLAGS+=-Werror -Wunused -Wundef $(DAHDI_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
endif
ROOT_PREFIX=
# extra cflags to build dependencies. Recursively expanded.
MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
CFLAGS+=$(DAHDI_INCLUDE)
CHKCONFIG := $(wildcard /sbin/chkconfig)
UPDATE_RCD := $(wildcard /usr/sbin/update-rc.d)
ifeq (,$(DESTDIR))
ifneq (,$(CHKCONFIG))
ADD_INITD := $(CHKCONFIG) --add dahdi
else
ifneq (,$(UPDATE_RCD))
ADD_INITD := $(UPDATE_RCD) dahdi defaults 15 30
endif
endif
endif
INITRD_DIR := $(firstword $(wildcard $(DESTDIR)/etc/rc.d/init.d $(DESTDIR)/etc/init.d))
ifneq (,$(INITRD_DIR))
INIT_TARGET := $(INITRD_DIR)/dahdi
COPY_INITD := install -D dahdi.init $(INIT_TARGET)
endif
RCCONF_FILE = /etc/dahdi/init.conf
MODULES_FILE = /etc/dahdi/modules
GENCONF_FILE = /etc/dahdi/genconf_parameters
MODPROBE_FILE = /etc/modprobe.d/dahdi.conf
BLACKLIST_FILE = /etc/modprobe.d/dahdi.blacklist.conf
BASH_COMP_DIR = /etc/bash_completion.d
BASH_COMP_FILE = $(BASH_COMP_DIR)/dahdi
NETSCR_DIR := $(firstword $(wildcard $(DESTDIR)/etc/sysconfig/network-scripts ))
ifneq (,$(NETSCR_DIR))
NETSCR_TARGET := $(NETSCR_DIR)/ifup-hdlc
COPY_NETSCR := install -D ifup-hdlc $(NETSCR_TARGET)
endif
TOOLSVERSION=$(shell build_tools/make_version . dahdi/tools)
# sbindir, libdir, includedir and mandir are defined in makeopts
# (from configure).
LIB_DIR:=$(libdir)
DATA_DIR:=${datadir}/dahdi
CONFIG_DIR:=$(sysconfdir)/dahdi
CONFIG_FILE:=$(CONFIG_DIR)/system.conf
UDEVRULES_DIR:=$(sysconfdir)/udev/rules.d
ASSIGNED_DATA_SCRIPTS:=\
dahdi_handle_device \
dahdi_span_config \
dahdi_auto_assign_compat \
span_config.d/10-dahdi-cfg \
span_config.d/20-fxotune \
span_config.d/50-asterisk \
handle_device.d/10-span-types \
handle_device.d/20-span-assignments
ASSIGNED_CONF:=assigned-spans.conf.sample span-types.conf.sample
# All the man pages. Not just installed ones:
GROFF_PAGES := $(wildcard doc/*.8 xpp/*.8)
GROFF_HTML := $(GROFF_PAGES:%=%.html)
GENERATED_DOCS := $(GROFF_HTML) README.html README.Astribank.html
all:
dahdi_pcap:
$(CC) $(CFLAGS) dahdi_pcap.c -lpcap -o $@ $<
tonezones.txt: zonedata.c
perl -ne 'next unless (/\.(country|description) = *"([^"]*)/); \
print (($$1 eq "country")? "* $$2\t":"$$2\n");' $< \
>$@
%.asciidoc: %.sample
perl -n -e \
'if (/^#($$|\s)(.*)/){ if (!$$in_doc){print "\n"}; $$in_doc=1; print "$$2\n" } else { if ($$in_doc){print "\n"}; $$in_doc=0; print " $$_" }' \
$< \
| perl -p -e 'if (/^ #?(\w+)=/ && ! exists $$cfgs{$$1}){my $$cfg = $$1; $$cfgs{$$cfg} = 1; s/^/\n[[cfg_$$cfg]]\n/}' >$@
docs: $(GENERATED_DOCS)
genconf_parameters.sample: xpp/genconf_parameters
cp $< $@
README.html: README system.conf.asciidoc init.conf.asciidoc tonezones.txt \
UPGRADE.txt genconf_parameters.asciidoc assigned-spans.conf.asciidoc \
span-types.conf.asciidoc
$(ASCIIDOC) -n -a toc -a toclevels=4 $<
README.Astribank.html: xpp/README.Astribank
$(ASCIIDOC) -o $@ -n -a toc -a toclevels=4 $<
# on Debian: this requires the full groff, not just groff-base.
%.8.html: %.8
man -Thtml $^ >$@
htmlman: $(GROFF_HTML)
install: all install-programs
@echo "###################################################"
@echo "###"
@echo "### DAHDI tools installed successfully."
@echo "### If you have not done so before, install init scripts with:"
@echo "###"
@echo "### make config"
@echo "###"
@echo "###################################################"
install-programs: install-utils install-libs
install-utils:
ifeq (,$(wildcard $(DESTDIR)$(CONFIG_FILE)))
$(INSTALL) -d $(DESTDIR)$(CONFIG_DIR)
$(INSTALL) -m 644 system.conf.sample $(DESTDIR)$(CONFIG_FILE)
endif
install -d $(DESTDIR)$(DATA_DIR)
tar cf - -C hotplug $(ASSIGNED_DATA_SCRIPTS) | tar xf - -C $(DESTDIR)$(DATA_DIR)/
install -m 644 $(ASSIGNED_CONF) $(DESTDIR)/$(CONFIG_DIR)/
install -d $(DESTDIR)$(BASH_COMP_DIR)
install -m 644 dahdi-bash-completion $(DESTDIR)$(BASH_COMP_FILE)
install-libs:
ifneq (no,$(USE_SELINUX))
ifeq (,$(DESTDIR))
/sbin/restorecon -v $(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
endif
endif
config:
ifneq (,$(COPY_INITD))
$(COPY_INITD)
endif
ifeq (,$(wildcard $(DESTDIR)$(RCCONF_FILE)))
$(INSTALL) -D -m 644 init.conf.sample $(DESTDIR)$(RCCONF_FILE)
endif
ifeq (,$(wildcard $(DESTDIR)$(MODULES_FILE)))
$(INSTALL) -D -m 644 modules.sample $(DESTDIR)$(MODULES_FILE)
endif
ifeq (,$(wildcard $(DESTDIR)$(GENCONF_FILE)))
$(INSTALL) -D -m 644 xpp/genconf_parameters $(DESTDIR)$(GENCONF_FILE)
endif
ifeq (,$(wildcard $(DESTDIR)$(MODPROBE_FILE)))
$(INSTALL) -D -m 644 modprobe.conf.sample $(DESTDIR)$(MODPROBE_FILE)
endif
ifeq (,$(wildcard $(DESTDIR)$(BLACKLIST_FILE)))
$(INSTALL) -D -m 644 blacklist.sample $(DESTDIR)$(BLACKLIST_FILE)
endif
$(INSTALL) -d $(DESTDIR)$(UDEVRULES_DIR)
$(INSTALL) -D -m 644 dahdi.rules $(DESTDIR)$(UDEVRULES_DIR)/
ifneq (,$(COPY_NETSCR))
$(COPY_NETSCR)
endif
ifneq (,$(ADD_INITD))
$(ADD_INITD)
endif
@echo "DAHDI has been configured."
@echo ""
@echo "List of detected DAHDI devices:"
@echo ""
@if [ `xpp/dahdi_hardware | tee /dev/stderr | wc -l` -eq 0 ]; then \
echo "No hardware found"; \
else \
echo ""; \
echo "run 'dahdi_genconf modules' to load support for only " ;\
echo "the DAHDI hardware installed in this system. By "; \
echo "default support for all DAHDI hardware is loaded at "; \
echo "DAHDI start. "; \
fi
dist:
@./build_tools/make_dist "dahdi-tools" "$(TOOLSVERSION)"
clean:
rm -f *.o tzdriver
rm -f core
rm -rf $(GENERATED_DOCS) *.asciidoc tonezones.txt
rm -f dahdi_pcap
.PHONY: clean all install devel data config install-programs install-libs dist
FORCE:
ifneq ($(wildcard .*.d),)
include .*.d
endif