Skip to content

Commit

Permalink
Add autoconf scripts.
Browse files Browse the repository at this point in the history
- Replace Makefile with Makefile.in

- Add configure.ac
  • Loading branch information
sh1r4s3 committed Aug 4, 2019
1 parent 2db37b9 commit adb09b8
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 15 deletions.
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

36 changes: 36 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -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], [[email protected]])
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

0 comments on commit adb09b8

Please sign in to comment.