From adb09b8340698e8fadec6c3acb9fd0894a1da67e Mon Sep 17 00:00:00 2001 From: Nikita Ermakov Date: Sun, 4 Aug 2019 23:36:41 +0300 Subject: [PATCH] Add autoconf scripts. - Replace Makefile with Makefile.in - Add configure.ac --- Makefile | 15 --------------- Makefile.in | 36 +++++++++++++++++++++++++++++++++++ configure.ac | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 15 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.in create mode 100644 configure.ac diff --git a/Makefile b/Makefile deleted file mode 100644 index c5a6ee3..0000000 --- a/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -CC=gcc -DAEMON=runns -CLIENT=runnsctl - -all: $(DAEMON) $(CLIENT) - -$(DAEMON): runns.o - $(CC) -o $@ $< - -$(CLIENT): client.o - $(CC) -o $@ $< - -.PHONY: client -clean: - rm -f $(DAEMON) $(CLIENT) *.o diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..386af39 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,36 @@ +CC=@CC@ +LD=@CC@ +PREFIX=@prefix@ + +CFLAGS=@CFLAGS@ +DAEMON=runns +CLIENT=runnsctl +HELPER=build-net clean-net +_ := $() $() +comma := , + +all: $(DAEMON) $(CLIENT) + +$(DAEMON): runns.o + $(CC) -o $@ $< + +$(CLIENT): client.o + $(CC) -o $@ $< + +.PHONY: client +clean: + rm -f $(DAEMON) $(CLIENT) *.o + +.PHONY: install +install: $(DAEMON) $(CLIENT) $(HELPER) + mkdir -p $(DESTDIR)/$(PREFIX)/bin + cp {$(subst $(_),$(comma),$^)} $(DESTDIR)/$(PREFIX)/bin/ + chmod 755 $(DESTDIR)/$(PREFIX)/bin/{$(subst $(_),$(comma),$^)} + +.PHONY: uninstall +uninstall: $(CLIENT) $(DAEMON) $(HELPER) + rm -f $(DESTDIR)/$(PREFIX)/bin/{$(subst $(_),$(comma),$^)} + +.PHONY: distclean +distclean: + rm -vrf $(DAEMON) $(CLIENT) *.o Makefile autom4te.cache config.log config.status diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..cbcc664 --- /dev/null +++ b/configure.ac @@ -0,0 +1,53 @@ +dnl +dnl Process this file in order to make a configure script +dnl + +dnl Setup autoconf +AC_INIT([runns], [1.0], [coffe92@gmail.com]) +dnl AM_INIT_AUTOMAKE + +dnl Debug option +AC_ARG_ENABLE(debug, + AS_HELP_STRING([--enable-debug],[enable debugging, defult: no]), + [case "${enableval}" in + yes) debug = true ;; + no) debug = false ;; + *) AC_MSG_ERROR([bad value ${enablevalue} for --enable-debug]) ;; + esac], [debug=false]) + +dnl Check dependences +echo "Cheking dependences" +AC_LANG(C) +AC_CHECK_TOOL(IPTABLES, iptables, "", PATH="$PATH:/sbin") +AC_CHECK_TOOL(IP, ip) +AC_CHECK_TOOL(GAWK, gawk) + +dnl Disable all CFLAGS if it was not declarated +if [test -z $CFLAGS; ] then + if test x"${debug}" == x"true"; then + CFLAGS="-g -O0" + else + CFLAGS="-O2" + fi +fi +AC_PROG_CC + +if [ test "x$IPTABLES" == "x"; ] then + AC_MSG_ERROR([iptables is required]) +fi + +if [ test "x$IP" == "x"; ] then + AC_MSG_ERROR([ip from iproute2 is required]) +fi + +if [ test "x$GAWK" == "x"; ] then + AC_MSG_ERROR([gawk is required]) +fi + +dnl Get source code path +dnl AC_DEFINE_UNQUOTED([SRC_PATH], ["$srcdir"], [source path]) + +dnl Configure Makefile from Makefile.in +AC_CONFIG_FILES([Makefile]) + +AC_OUTPUT