Commit 54b87b9f authored by Ludovic Rousseau's avatar Ludovic Rousseau

Convert to autoconf/automake

parent d9c7199b
# PC/SC Lite libraries and headers.
PCSC_CFLAGS ?= $(shell pkg-config libpcsclite --cflags)
PCSC_LDLIBS ?= $(shell pkg-config libpcsclite --libs)
# by default install in /usr/local
DESTDIR ?= /usr/local
VERSION := $(shell pwd | sed s/.*tools-//)
CFLAGS := $(CFLAGS) -DVERSION=\"$(VERSION)\" $(PCSC_CFLAGS)
LDLIBS := $(PCSC_LDLIBS)
# On xBSD systems use
#LDLIBS = -lc_r $(PCSC_LDLIBS)
# on MacOSX
#CFLAGS = -Wall -O2 -DVERSION=\"$(VERSION)\"
#LDLIBS = -framework PCSC
BIN = pcsc_scan
BIN_SCRIPT = ATR_analysis gscriptor scriptor
MAN = pcsc_scan.1.gz gscriptor.1p.gz scriptor.1p.gz ATR_analysis.1p.gz
all: $(BIN) $(MAN)
pcsc_scan: pcsc_scan.o
INSTALL_PREFIX ?= /usr
INSTALL_BIN_DIR ?= $(INSTALL_PREFIX)/bin
INSTALL_DATA_DIR ?= $(INSTALL_PREFIX)/share
INSTALL_MAN_DIR ?= $(INSTALL_DATA_DIR)/man
install: all
install -d $(DESTDIR)$(INSTALL_BIN_DIR)/
install $(BIN) $(DESTDIR)$(INSTALL_BIN_DIR)/
install $(BIN_SCRIPT) $(DESTDIR)$(INSTALL_BIN_DIR)/
install -d $(DESTDIR)$(INSTALL_DATA_DIR)/pcsc
install -m 644 smartcard_list.txt $(DESTDIR)$(INSTALL_DATA_DIR)/pcsc
install -d $(DESTDIR)$(INSTALL_MAN_DIR)/man1/
install -m 644 $(MAN) $(DESTDIR)$(INSTALL_MAN_DIR)/man1/
clean:
rm -f pcsc_scan.o $(BIN) $(MAN)
%.1.gz: %.1
gzip --best $^ --to-stdout > $@
%.1p.gz: %.1p
gzip --best $^ --to-stdout > $@
.PHONY: clean all install Changelog
Changelog:
git log --stat --decorate=short > $@
bin_PROGRAMS = pcsc_scan
pcsc_scan_SOURCES = pcsc_scan.c pcsc_scan.1
pcsc_scan_CFLAGS = $(PCSC_CFLAGS)
pcsc_scan_LDADD = $(PCSC_LIBS)
# uncomment the following if pcsc_scan requires the math library
#pcsc_scan_LDADD=-lm
# install the man pages
man_MANS=pcsc_scan.1
#!/bin/sh
# I use
# - autoconf (GNU Autoconf) 2.64
# - automake (GNU automake) 1.11
# - libtool (GNU libtool) 2.2.6
set -e
set -x
if test -f Makefile; then
make distclean
fi
rm -rf *.cache *.m4 config.guess config.log \
config.status config.sub depcomp ltmain.sh
#(cat m4/*.m4 > acinclude.m4 2> /dev/null)
autoreconf --verbose --install
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([pcsc_scan], [1.4.27])
AC_CONFIG_SRCDIR([pcsc_scan.c])
AM_INIT_AUTOMAKE(1.8 dist-bzip2 no-dist-gzip)
dnl create a config.h file (Automake will add -DHAVE_CONFIG_H)
AM_CONFIG_HEADER(config.h)
AC_SUBST(VERSION)
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CANONICAL_HOST
if test `uname` == 'Darwin'; then
PCSC_PATH="PCSC/"
fi
dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_CC
dnl Checks for libraries.
# check pcsc-lite
PKG_CHECK_EXISTS([libpcsclite],
[PKG_CHECK_MODULES(PCSC, libpcsclite, [],
[
if test -f /usr/local/lib/pkgconfig/libpcsclite.pc -a "x$PKG_CONFIG" != x ; then
AC_MSG_ERROR([use PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure])
else
AC_MSG_WARN([install pcsc-lite])
fi
])],
[AC_MSG_WARN([libpcsclite not found by pkg-config])]
)
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PCSC_CFLAGS"
PCSC_ERROR_MSG="install pcsc-lite, or use ./configure PCSC_CFLAGS=..."
AC_CHECK_HEADER("$PCSC_PATH"winscard.h,, [AC_MSG_ERROR([$PCSC_ERROR_MSG])])
saved_LIBS="$LIBS"
LIBS="$LIBS $PCSC_LIBS"
AC_MSG_CHECKING([for SCardEstablishContext])
AC_TRY_LINK_FUNC(SCardEstablishContext,
[ AC_MSG_RESULT([yes]) ],
[ AC_MSG_ERROR([SCardEstablishContext() not found, install pcsc-lite, or use PCSC_LIBS=... ./configure]) ])
LIBS="$saved_LIBS"
CPPFLAGS="$saved_CPPFLAGS"
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h time.h string.h stdio.h stdlib.h sys/time.h)
AC_HEADER_MAJOR
dnl AC_CHECK_FUNCS(mkfifo)
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment