Implement autotools build scripts

This commit is contained in:
quiniouben 2015-12-30 10:30:24 +01:00
parent 3785f97e1e
commit bd4beee119
12 changed files with 53 additions and 57 deletions

View File

@ -1,54 +0,0 @@
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)gcc
STRIP := $(CROSS_COMPILE)strip
# -Wno-multichar is used for vban.h:25 define.
CFLAGS := -DLINUX -ansi -Wpedantic -Wall -Wno-multichar
LDFLAGS := -lasound
# Defaultly compiles release version of the application
CONFIG := release
ifneq ($(filter release%,$(CONFIG)),)
LDFLAGS += -O3
endif
ifneq ($(filter debug%,$(CONFIG)),)
CFLAGS += -g
endif
SOURCES := main.c \
socket.c \
audio.c \
OBJECTS := $(SOURCES:.c=.o)
DEPENDENCIES:= $(SOURCES:.c=.d)
EXECUTABLE := vban_receptor
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
@echo "Linking $@"
@$(LD) $(LDFLAGS) -o "$@" $^
ifneq ($(filter release%,$(CONFIG)),)
@echo "Stripping $@"
@$(STRIP) "$@"
endif
%.o:%.c
@echo "Compiling $<"
@$(CC) -c $(CFLAGS) -MMD -MF "$(patsubst %.o,%.d,$@)" -o "$@" "$<"
-include $(DEPENDENCIES)
install:
@mkdir -p $(DESTDIR)/usr/sbin
@cp $(EXECUTABLE) $(DESTDIR)/usr/sbin
clean:
@echo "Cleaning artifacts and objects"
@rm -f $(OBJECTS) $(DEPENDENCIES) $(EXECUTABLE)
@rm -f *~*
distclean: clean

5
Makefile.am Normal file
View File

@ -0,0 +1,5 @@
# We want to avoid GNU potential warnings
AUTOMAKE_OPTIONS = foreign
# We want to compile source in src, so let's go there
SUBDIRS = src

View File

@ -10,10 +10,15 @@ VBAN is a simple audio over UDP protocol proposed by VB-Audio, see [VBAN Audio w
Compilation and installation
----------------------------
vban_receptor doesn't have a configure script. Nevertheless the makefile is very simple and has some basic variables (CC, LD, STRIP, CROSS_COMPILE, DESTDIR) to define whatever compilation toolchain you wish to use and where you want to install. This will probably evolve in future releases.
So simply use:
vban_receptor uses ALSA, therefore you need to have ALSA library and headers available on your platform.
In standard Linux distributions, ALSA library package is usually named libasound(X) and header files come in package named libasound(X)-dev.
$ make
vban_receptor is distributed with autotools build scripts, therefore, to build, you need to invoke:
$ ./autogen.sh # probably only once for ever
$ ./configure # with or without options
$ make # with or without options
To install, simply invoke:
# make install
Usage

6
autogen.sh Executable file
View File

@ -0,0 +1,6 @@
#! /bin/sh
aclocal \
&& automake --add-missing \
&& autoconf

28
configure.ac Normal file
View File

@ -0,0 +1,28 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([vban_receptor], [v0.5], [quiniouben@yahoo.fr])
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
AC_LANG(C)
# Checks for libraries.
AC_CHECK_HEADERS([alsa/asoundlib.h], [], [AC_MSG_ERROR(Missing ALSA headers)])
AC_CHECK_LIB([asound], [snd_pcm_open], [], [AC_MSG_ERROR(Missing ALSA library)])
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h inttypes.h netinet/in.h stddef.h stdlib.h string.h sys/socket.h unistd.h], [], [AC_MSG_ERROR(Missing some system headers)])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([inet_ntoa memset socket strerror], [], [AC_MSG_ERROR(Missing some system functions)])
AC_OUTPUT(Makefile src/Makefile)

6
src/Makefile.am Normal file
View File

@ -0,0 +1,6 @@
# Let's define some things here
AM_CFLAGS = -ansi -Wpedantic -Wall -Wno-multichar -O2
AM_LDFLAGS = -lasound
bin_PROGRAMS = vban_receptor
vban_receptor_SOURCES = main.c audio.h audio.c socket.h socket.c vban.h

View File

View File