summaryrefslogtreecommitdiff
path: root/xpp/utils/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/utils/Makefile')
-rw-r--r--xpp/utils/Makefile50
1 files changed, 34 insertions, 16 deletions
diff --git a/xpp/utils/Makefile b/xpp/utils/Makefile
index b7d77f3..a278a80 100644
--- a/xpp/utils/Makefile
+++ b/xpp/utils/Makefile
@@ -1,33 +1,51 @@
PEDANTIC = -ansi -pedantic -std=c99
-CC = gcc
RANLIB = ranlib
-INSTALL = install
-INSTALL_DATA = install -m 644
-BINDIR = /usr/sbin
-DATADIR = /usr/share/zaptel
-MANDIR = /usr/share/man/man8
+TOPDIR ?= ../..
+
+-include $(TOPDIR)/makeopts
+
+INSTALL_DATA = $(INSTALL) -m 644
+
+SBINDIR = $(prefix)/sbin
+DATADIR = $(datadir)/zaptel
+MANDIR = $(mandir)/man8
HOTPLUG_USB_DIR = /etc/hotplug/usb
-DATA_FILES = $(wildcard ../init_data_*.cmd *.hex) init_fxo_modes
+XPD_FIRMWARE = $(wildcard ../firmwares/*.hex)
+XPD_INIT_DATA = $(XPD_FIRMWARE) init_fxo_modes
+XPD_INIT = $(wildcard ../init_card_?_*) ../calibrate_slics
+
+# Variables that should be defined above, but need sane defaults:
+# FIXME: Are those values really sane?
+HOSTCC ?= $(CC)
+PBX_LIBUSB ?= 1
+DRIVER_DIR ?= $(TOPDIR)
-WCTDM=../../wctdm.c
+WCTDM=$(DRIVER_DIR)/wctdm.c
CFLAGS = -g -Wall $(EXTRA_CFLAGS)
-TARGETS = libhexfile.a fpga_load test_parse init_fxo_modes
+TARGETS = init_fxo_modes print_modes adj_clock
+PROG_INSTALL = genzaptelconf adj_clock
+MAN_INSTALL = genzaptelconf.8 adj_clock.8
+ifeq ($(PBX_LIBUSB),1)
+TARGETS += libhexfile.a fpga_load test_parse
+PROG_INSTALL += fpga_load
+MAN_INSTALL += fpga_load.8
+endif
all: $(TARGETS)
install: all
$(INSTALL) -d $(DESTDIR)$(BINDIR)
- $(INSTALL) genzaptelconf fpga_load $(DESTDIR)$(BINDIR)/
+ $(INSTALL) $(PROG_INSTALL) $(DESTDIR)$(BINDIR)/
$(INSTALL) -d $(DESTDIR)$(DATADIR)
- $(INSTALL_DATA) $(DATA_FILES) $(DESTDIR)$(DATADIR)/
- $(INSTALL) ../initialize_registers ../calibrate_slics $(DESTDIR)$(DATADIR)/
+ $(INSTALL_DATA) $(XPD_INIT_DATA) $(DESTDIR)$(DATADIR)/
+ $(INSTALL) $(XPD_INIT) $(DESTDIR)$(DATADIR)/
$(INSTALL) -d $(DESTDIR)$(MANDIR)
- $(INSTALL_DATA) fpga_load.8 genzaptelconf.8 $(DESTDIR)$(MANDIR)/
+ $(INSTALL_DATA) $(MAN_INSTALL) $(DESTDIR)$(MANDIR)/
$(INSTALL) -d $(DESTDIR)$(HOTPLUG_USB_DIR)
$(INSTALL_DATA) xpp_fxloader.usermap $(DESTDIR)$(HOTPLUG_USB_DIR)/
$(INSTALL) xpp_fxloader $(DESTDIR)$(HOTPLUG_USB_DIR)/
@@ -40,16 +58,16 @@ fpga_load: fpga_load.o libhexfile.a
$(CC) -L. -o $@ $@.o $(EXTRA_LIBS) -lhexfile -lusb
hexfile.o: hexfile.c hexfile.h
- $(CC) $(CFLAGS) $(PEDANTIC) -c $*.c
+ $(CC) $(CFLAGS) $(PEDANTIC) -c $<
test_parse.o: test_parse.c hexfile.h
- $(CC) $(CFLAGS) $(PEDANTIC) -c $*.c
+ $(CC) $(CFLAGS) $(PEDANTIC) -c $<
test_parse: test_parse.o libhexfile.a
$(CC) -L. -o $@ $@.o $(EXTRA_LIBS) -lhexfile -lusb
print_modes.o: print_modes.c wctdm_fxomodes.h
- $(HOSTCC) $(CFLAGS) -c $^
+ $(HOSTCC) $(CFLAGS) -c $<
wctdm_fxomodes.h: $(WCTDM)
perl -n -e 'print if (/^static struct fxo_mode {$$/ .. /};$$/)' $(WCTDM) >$@