From 7c3c6b99bec920ea850739e62b9fec8a29dc0dc0 Mon Sep 17 00:00:00 2001 From: toni Date: Sat, 14 Nov 2015 22:53:40 +0100 Subject: ~auto(conf|make)~ --- Makefile | 53 ----------------------------------- Makefile.am | 11 ++++++++ Makefile.debug | 53 +++++++++++++++++++++++++++++++++++ autogen.sh | 15 ++++++++++ configure.ac | 68 ++++++++++++++++++++++++++++++++++++++++++++ m4/ax_check_typedef.m4 | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 3 ++ src/ui.c | 1 - 8 files changed, 226 insertions(+), 54 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 Makefile.debug create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 m4/ax_check_typedef.m4 create mode 100644 src/Makefile.am diff --git a/Makefile b/Makefile deleted file mode 100644 index 9efaec9..0000000 --- a/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -CFLAGS = $(shell ncurses5-config --cflags) -Wall -Wundef -Wshadow -D_GNU_SOURCE=1 -fPIC -fomit-frame-pointer -fno-inline -fstrength-reduce -frerun-cse-after-loop -frerun-loop-opt -fexpensive-optimizations -fstrict-aliasing -Os -MD -MP -DBGFLAGS = -g -LDFLAGS = $(shell ncurses5-config --libs) -pthread -lrt -CC = gcc -INSTALL = install -STRIP = strip -VERSION = $(shell if [ -d ./.git ]; then echo -n "git-"; git rev-parse --short HEAD; else echo "1.2a"; fi) -BIN = naskpass -SOURCES = $(wildcard src/*.c) -OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) -DEPS = $(patsubst %.c,%.d,$(SOURCES)) - -all: $(OBJECTS) $(BIN) - -%.o: %.c - $(CC) $(CFLAGS) -D_VERSION=\"$(VERSION)\" -c $< -o $@ - -$(BIN): $(SOURCES) - $(CC) $(LDFLAGS) $(OBJECTS) -o $(BIN) - $(MAKE) -C tests CC='$(CC)' CFLAGS='$(CFLAGS)' all - -strip: $(OBJECTS) $(BIN) - $(STRIP) $(BIN) - -release: all strip - -debug: - @$(MAKE) CFLAGS='$(CFLAGS) $(DBGFLAGS)' - @$(MAKE) -C tests CFLAGS='$(CFLAGS) $(DBGFLAGS)' - -install: - $(INSTALL) -D -m 0755 $(BIN) $(DESTDIR)/lib/cryptsetup/naskpass - $(INSTALL) -D -m 0755 scripts/naskpass.inithook $(DESTDIR)/usr/share/naskpass/naskpass.hook.initramfs - $(INSTALL) -D -m 0755 scripts/naskpass.initscript $(DESTDIR)/usr/share/naskpass/naskpass.script.initramfs - $(INSTALL) -D -m 0755 scripts/naskconf $(DESTDIR)/usr/share/naskpass/naskconf - -uninstall: - rm -f $(DESTDIR)/lib/cryptsetup/naskpass - rm -f $(DESTDIR)/usr/share/initramfs-tools/hooks/naskpass - rm -f $(DESTDIR)/usr/share/naskpass/naskpass.script.initramfs - rm -f $(DESTDIR)/usr/share/naskpass/naskconf - rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share/naskpass - -clean: - rm -f $(DEPS) - rm -f $(OBJECTS) - rm -f $(BIN) - $(MAKE) -C tests clean - -source: - -dh_make --createorig -p naskpass_$(VERSION) -s -y - -.PHONY: all install clean diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..d682608 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,11 @@ +SUBDIRS = src + + +clean-local: + rm -f naskpass + +distclean-local: clean-local + rm -f aclocal.m4 config.log config.status configure + rm -f Makefile.in src/Makefile.in src/aconfig.h.in src/aconfig.h.in~ src/*.d + rm -rf build autom4te.cache + diff --git a/Makefile.debug b/Makefile.debug new file mode 100644 index 0000000..9efaec9 --- /dev/null +++ b/Makefile.debug @@ -0,0 +1,53 @@ +CFLAGS = $(shell ncurses5-config --cflags) -Wall -Wundef -Wshadow -D_GNU_SOURCE=1 -fPIC -fomit-frame-pointer -fno-inline -fstrength-reduce -frerun-cse-after-loop -frerun-loop-opt -fexpensive-optimizations -fstrict-aliasing -Os -MD -MP +DBGFLAGS = -g +LDFLAGS = $(shell ncurses5-config --libs) -pthread -lrt +CC = gcc +INSTALL = install +STRIP = strip +VERSION = $(shell if [ -d ./.git ]; then echo -n "git-"; git rev-parse --short HEAD; else echo "1.2a"; fi) +BIN = naskpass +SOURCES = $(wildcard src/*.c) +OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) +DEPS = $(patsubst %.c,%.d,$(SOURCES)) + +all: $(OBJECTS) $(BIN) + +%.o: %.c + $(CC) $(CFLAGS) -D_VERSION=\"$(VERSION)\" -c $< -o $@ + +$(BIN): $(SOURCES) + $(CC) $(LDFLAGS) $(OBJECTS) -o $(BIN) + $(MAKE) -C tests CC='$(CC)' CFLAGS='$(CFLAGS)' all + +strip: $(OBJECTS) $(BIN) + $(STRIP) $(BIN) + +release: all strip + +debug: + @$(MAKE) CFLAGS='$(CFLAGS) $(DBGFLAGS)' + @$(MAKE) -C tests CFLAGS='$(CFLAGS) $(DBGFLAGS)' + +install: + $(INSTALL) -D -m 0755 $(BIN) $(DESTDIR)/lib/cryptsetup/naskpass + $(INSTALL) -D -m 0755 scripts/naskpass.inithook $(DESTDIR)/usr/share/naskpass/naskpass.hook.initramfs + $(INSTALL) -D -m 0755 scripts/naskpass.initscript $(DESTDIR)/usr/share/naskpass/naskpass.script.initramfs + $(INSTALL) -D -m 0755 scripts/naskconf $(DESTDIR)/usr/share/naskpass/naskconf + +uninstall: + rm -f $(DESTDIR)/lib/cryptsetup/naskpass + rm -f $(DESTDIR)/usr/share/initramfs-tools/hooks/naskpass + rm -f $(DESTDIR)/usr/share/naskpass/naskpass.script.initramfs + rm -f $(DESTDIR)/usr/share/naskpass/naskconf + rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share/naskpass + +clean: + rm -f $(DEPS) + rm -f $(OBJECTS) + rm -f $(BIN) + $(MAKE) -C tests clean + +source: + -dh_make --createorig -p naskpass_$(VERSION) -s -y + +.PHONY: all install clean diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..96fb4e9 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +rm -f config.cache +mkdir -p build + +echo "Looking in current directory for macros." +aclocal -I . +echo "Adding missing files." +automake --add-missing --force-missing +echo "Autoconf, Autoheader, Automake" +autoconf +autoheader +automake --foreign --add-missing --force-missing --copy +exit $? + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..3786c0e --- /dev/null +++ b/configure.ac @@ -0,0 +1,68 @@ +# -*- Autoconf -*- +# configure script generation for ncblog +# + +AC_PREREQ([2.67]) +AC_INIT([naskpass], [0.01], [matzeton@googlemail.com]) +AC_CONFIG_AUX_DIR([build]) +AM_INIT_AUTOMAKE([1.11 foreign no-define -Wall -Werror]) +AM_WITH_DMALLOC +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_CONFIG_SRCDIR([src/aconfig.h.in]) +AC_CONFIG_HEADER([src/aconfig.h]) +AC_CONFIG_MACRO_DIR([m4]) +AC_USE_SYSTEM_EXTENSIONS +CFLAGS="-Os" +LDFLAGS="" + +# Checks for programs. +AM_PROG_AR +AM_PROG_INSTALL_STRIP +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_RANLIB +AC_C_INLINE +AC_PREFIX_DEFAULT([/usr]) +AC_CHECK_TOOL([STRIP],[strip]) + +# Checks for header files. +AC_HEADER_SYS_WAIT +AC_HEADER_TIME +AC_HEADER_STDBOOL +AC_HEADER_STDC +AC_HEADER_STAT +AC_HEADER_DIRENT +AC_HEADER_ASSERT +AC_CHECK_HEADERS([stdio.h stdlib.h stdbool.h string.h unistd.h errno.h sys/stat.h sys/types.h sys/wait.h fcntl.h semaphore.h time.h mqueue.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_COMPUTE_INT +AC_TYPE_UID_T +AC_TYPE_MODE_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT8_T +AX_CHECK_TYPEDEF([size_t], [stdio.h],,[AC_MSG_ERROR([*** Missing size_t typedef in stdio.h])]) +AX_CHECK_TYPEDEF([ssize_t], [stdio.h],,[AC_MSG_ERROR([*** Missing size_t typedef in stdio.h])]) + +# Checks for library functions. +AC_FUNC_FORK +AC_FUNC_MALLOC +AC_FUNC_MMAP +AC_FUNC_REALLOC +AC_FUNC_STRNLEN +AC_FUNC_STAT +AC_FUNC_MKTIME +AC_FUNC_VPRINTF +AC_CHECK_FUNCS([clock_gettime asprintf system printf fprintf mkfifo stat open close fork gettimeofday memmove memcpy memset strdup strndup strerror strstr strlen strnlen strtol],,[AC_MSG_ERROR([*** Missing essential functions.])]) + +AC_DEFINE([HAVE_CONFIG], [1], [Do NOT change THIS!]) +LDFLAGS="${LDFLAGS} -pthread -lrt -lncurses" +AC_SUBST([AM_CFLAGS]) +AC_SUBST([AM_LDFLAGS]) +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT + diff --git a/m4/ax_check_typedef.m4 b/m4/ax_check_typedef.m4 new file mode 100644 index 0000000..13b9d5e --- /dev/null +++ b/m4/ax_check_typedef.m4 @@ -0,0 +1,76 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_typedef.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_TYPEDEF(TYPEDEF, HEADER [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]) +# +# DESCRIPTION +# +# Check if the given typedef-name is recognized as a type. The trick is to +# use a sizeof(TYPEDEF) and see if the compiler is happy with that. +# +# This can be thought of as a mixture of AC_CHECK_TYPE(TYPEDEF,DEFAULT) +# and AC_CHECK_LIB(LIBRARY,FUNCTION,ACTION-IF-FOUND,ACTION-IF-NOT-FOUND). +# +# A convenience macro AX_CHECK_TYPEDEF_ is provided that will not emit any +# message to the user - it just executes one of the actions. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 5 + +AU_ALIAS([AC_CHECK_TYPEDEF], [AX_CHECK_TYPEDEF]) +AC_DEFUN([AX_CHECK_TYPEDEF_], +[dnl +ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` +AC_CACHE_VAL(ac_cv_lib_$ac_lib_var, +[ eval "ac_cv_type_$ac_lib_var='not-found'" + ac_cv_check_typedef_header=`echo ifelse([$2], , stddef.h, $2)` + AC_TRY_COMPILE( [#include <$ac_cv_check_typedef_header>], + [int x = sizeof($1); x = x;], + eval "ac_cv_type_$ac_lib_var=yes" , + eval "ac_cv_type_$ac_lib_var=no" ) + if test `eval echo '$ac_cv_type_'$ac_lib_var` = "no" ; then + ifelse([$4], , :, $4) + else + ifelse([$3], , :, $3) + fi +])]) + +dnl AX_CHECK_TYPEDEF(TYPEDEF, HEADER [, ACTION-IF-FOUND, +dnl [, ACTION-IF-NOT-FOUND ]]) +AC_DEFUN([AX_CHECK_TYPEDEF], +[dnl + AC_MSG_CHECKING([for $1 in $2]) + AX_CHECK_TYPEDEF_($1,$2,AC_MSG_RESULT(yes),AC_MSG_RESULT(no))dnl +]) diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..07b4cfa --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,3 @@ +bin_PROGRAMS=naskpass +naskpass_SOURCES=main.c opt.c status.c ui_ani.c ui.c ui_elements.c ui_input.c ui_ipc.c ui_nwindow.c ui_statusbar.c + diff --git a/src/ui.c b/src/ui.c index bb12936..8b3d49f 100644 --- a/src/ui.c +++ b/src/ui.c @@ -12,7 +12,6 @@ #include #include #include -#include #include "ui.h" #include "ui_ipc.h" -- cgit v1.2.3