Use autoconf and automake and remove MSVC projects.

This patch is imported from the rinetd Debian package.
This commit is contained in:
Sam Hocevar 2016-01-10 21:39:30 +01:00
parent 39e4d7a0e8
commit acb00a89f9
10 changed files with 241 additions and 145 deletions

16
.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
.auto
.deps
Makefile
Makefile.in
stamp-*
aclocal.m4
autom4te.cache
config.h
config.h.in
config.log
config.status
configure
*.o
rinetd

View File

@ -1,9 +0,0 @@
CFLAGS=-DLINUX -g
rinetd: rinetd.o match.o
gcc rinetd.o match.o -o rinetd
install: rinetd
install -m 700 rinetd /usr/sbin
install -m 644 rinetd.8 /usr/man/man8

13
Makefile.am Normal file
View File

@ -0,0 +1,13 @@
AUTOMAKE_OPTIONS = foreign dist-bzip2
EXTRA_DIST = bootstrap CHANGES index.html \
getopt.c getopt.h $(man_MANS) $(sysconf_DATA)
man_MANS = rinetd.8
sysconf_DATA = rinetd.conf
sbin_PROGRAMS = rinetd
rinetd_SOURCES = rinetd.c match.c match.h
rinetd_CFLAGS = -Wall -Wwrite-strings -I.

139
bootstrap Executable file
View File

@ -0,0 +1,139 @@
#! /bin/sh
# bootstrap — generic bootstrap/autogen.sh script for autotools projects
#
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What the Fuck You Want
# to Public License, Version 2, as published by the WTFPL Task Force.
# See http://www.wtfpl.net/ for more details.
#
# The latest version of this script can be found at the following place:
# http://caca.zoy.org/wiki/build
# Die if an error occurs
set -e
# Guess whether we are using configure.ac or configure.in
if test -f configure.ac; then
conffile="configure.ac"
elif test -f configure.in; then
conffile="configure.in"
else
echo "$0: could not find configure.ac or configure.in"
exit 1
fi
# Check for needed features
auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`"
pkgconfig="`grep '^[ \t]*PKG_PROG_PKG_CONFIG' $conffile >/dev/null 2>&1 && echo yes || echo no`"
libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`"
header="`grep '^[ \t]*A._CONFIG_HEADER' $conffile >/dev/null 2>&1 && echo yes || echo no`"
automake="`grep '^[ \t]*AM_INIT_AUTOMAKE' $conffile >/dev/null 2>&1 && echo yes || echo no`"
aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`"
# Check for automake
amvers="no"
for v in "" "-1.15" "-1.14" "-1.13" "-1.12" "-1.11"; do
if automake${v} --version > /dev/null 2>&1; then
amvers=${v}
break
fi
done
if test "$amvers" = "no"; then
echo "$0: automake not found"
exit 1
fi
# Check for autoconf
acvers="no"
for v in "" "259" "253"; do
if autoconf${v} --version >/dev/null 2>&1; then
acvers="${v}"
break
fi
done
if test "$acvers" = "no"; then
echo "$0: autoconf not found"
exit 1
fi
# Check for libtool
if test "$libtool" = "yes"; then
libtoolize="no"
if glibtoolize --version >/dev/null 2>&1; then
libtoolize="glibtoolize"
else
for v in "16" "15" "" "14"; do
if libtoolize${v} --version >/dev/null 2>&1; then
libtoolize="libtoolize${v}"
break
fi
done
fi
if test "$libtoolize" = "no"; then
echo "$0: libtool not found"
exit 1
fi
fi
# Check for pkg-config
if test "$pkgconfig" = "yes"; then
if ! pkg-config --version >/dev/null 2>&1; then
echo "$0: pkg-config not found"
exit 1
fi
fi
# Remove old cruft
for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done
rm -Rf autom4te.cache
if test -n "$auxdir"; then
if test ! -d "$auxdir"; then
mkdir "$auxdir"
fi
aclocalflags="-I $auxdir -I . ${aclocalflags}"
fi
# Honour M4PATH because sometimes M4 doesn't
save_IFS=$IFS
IFS=:
tmp="$M4PATH"
for x in $tmp; do
if test -n "$x"; then
aclocalflags="-I $x ${aclocalflags}"
fi
done
IFS=$save_IFS
# Explain what we are doing from now
set -x
# Bootstrap package
if test "$libtool" = "yes"; then
${libtoolize} --copy --force
if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then
echo "$0: working around a minor libtool issue"
mv ltmain.sh "$auxdir/"
fi
fi
aclocal${amvers} ${aclocalflags}
autoconf${acvers}
if test "$header" = "yes"; then
autoheader${acvers}
fi
if test "$automake" = "yes"; then
#add --include-deps if you want to bootstrap with any other compiler than gcc
#automake${amvers} --add-missing --copy --include-deps
automake${amvers} --foreign --add-missing --copy
fi
# Remove cruft that we no longer want
rm -Rf autom4te.cache

32
configure.ac Normal file
View File

@ -0,0 +1,32 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
AC_INIT(rinetd, 0.62, sam@hocevar.net)
AC_CONFIG_AUX_DIR(.auto)
AC_CONFIG_SRCDIR([getopt.h])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([no-define tar-ustar silent-rules])
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_CHECK_FUNCS([gethostbyname memset select socket strstr daemon sigaction])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@ -1,3 +1,7 @@
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <ctype.h>
#include "match.h"

View File

@ -1,4 +1,6 @@
#define VERSION "0.62"
#if HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef WIN32
#include <windows.h>
@ -956,7 +958,7 @@ void handleCloseFromLocal(int i)
closesocket(loFds[i]);
loClosed[i] = 1;
if (!reClosed[i]) {
#ifndef LINUX
#ifndef __linux__
#ifndef WIN32
/* Now set up the remote end for a polite closing */
@ -967,7 +969,7 @@ void handleCloseFromLocal(int i)
setsockopt(reFds[i], SOL_SOCKET, SO_SNDLOWAT,
&arg, sizeof(arg));
#endif /* WIN32 */
#endif /* LINUX */
#endif /* __linux__ */
coLog[i] = logLocalClosedFirst;
}
}
@ -982,7 +984,7 @@ void handleCloseFromRemote(int i)
closesocket(reFds[i]);
reClosed[i] = 1;
if (!loClosed[i]) {
#ifndef LINUX
#ifndef __linux__
#ifndef WIN32
/* Now set up the local end for a polite closing */
@ -993,7 +995,7 @@ void handleCloseFromRemote(int i)
setsockopt(loFds[i], SOL_SOCKET, SO_SNDLOWAT,
&arg, sizeof(arg));
#endif /* WIN32 */
#endif /* LINUX */
#endif /* __linux__ */
loClosed[i] = 0;
coLog[i] = logRemoteClosedFirst;
}
@ -1270,13 +1272,13 @@ void openLocalFd(int se, int i)
memcpy(&saddr.sin_addr, &seLocalAddrs[se], sizeof(struct in_addr));
saddr.sin_port = seLocalPorts[se];
#ifndef WIN32
#ifdef LINUX
#ifdef __linux__
j = 0;
setsockopt(loFds[i], SOL_SOCKET, SO_LINGER, &j, sizeof(j));
#else
j = 1024;
setsockopt(loFds[i], SOL_SOCKET, SO_SNDBUF, &j, sizeof(j));
#endif /* LINUX */
#endif /* __linux__ */
#endif /* WIN32 */
j = 1;
ioctlsocket(loFds[i], FIONBIO, &j);
@ -1365,7 +1367,7 @@ void RegisterPID(void)
pid_file_name = pidLogFileName;
}
/* add other systems with wherever they register processes */
#if defined(LINUX)
#if defined(__linux__)
pid_file = fopen(pid_file_name, "w");
if (pid_file == NULL) {
/* non-fatal, non-Linux may lack /var/run... */
@ -1376,7 +1378,7 @@ void RegisterPID(void)
fprintf(pid_file, "%d\n", getpid());
fclose(pid_file);
}
#endif /* LINUX */
#endif /* __linux__ */
}
unsigned char nullAddress[4] = { 0, 0, 0, 0 };
@ -1509,7 +1511,7 @@ int readArgs (int argc,
"manpage for more information.\n");
exit (0);
case 'v':
printf ("rinetd %s\n", VERSION);
printf ("rinetd %s\n", PACKAGE_VERSION);
exit (0);
case '?':
default:

25
rinetd.conf Normal file
View File

@ -0,0 +1,25 @@
#
# this is the configuration file for rinetd, the internet redirection server
#
# you may specify global allow and deny rules here
# only ip addresses are matched, hostnames cannot be specified here
# the wildcards you may use are * and ?
#
# allow 192.168.2.*
# deny 192.168.2.1?
#
# forwarding rules come here
#
# you may specify allow and deny rules after a specific forwarding rule
# to apply to only that forwarding rule
#
# bindadress bindport connectaddress connectport
# logging information
logfile /var/log/rinetd.log
# uncomment the following line if you want web-server style logfile format
# logcommon

View File

@ -1,97 +0,0 @@
# Microsoft Developer Studio Project File - Name="rinetd" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=rinetd - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "rinetd.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "rinetd.mak" CFG="rinetd - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "rinetd - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "rinetd - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "rinetd - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "rinetd - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "rinetd - Win32 Release"
# Name "rinetd - Win32 Debug"
# Begin Source File
SOURCE=.\getopt.c
# End Source File
# Begin Source File
SOURCE=.\match.c
# End Source File
# Begin Source File
SOURCE=.\rinetd.c
# End Source File
# End Target
# End Project

View File

@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "rinetd"=.\rinetd.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################