Author: Nathan Phillip Brink Purpose: oer's buildsystem forces -s into LDFLAGS, adds -g on --enable-debug, etc.. The following makes the Makefile confomant to conventions and condenses it. It also removes --enable-profile from configure. It adds --disable-strip to configure so that the package can conform to Gentoo's QA. It also prevents ./configure from overwriting CFLAGS and LDFLAGS. Instructions: Apply and run autoreconf -vfi diff -r 3797f25f96e8 -r 042d97d72773 Makefile.in --- a/Makefile.in Sat Aug 28 00:09:27 2010 -0400 +++ b/Makefile.in Sat Aug 28 02:15:33 2010 -0400 @@ -1,36 +1,42 @@ +# ask for compliance +.POSIX: + prefix = @prefix@ INSTALL_PROG = @INSTALL@ CC = @CC@ +# must be passed to CC when it'll call the linker LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -CFLAGS = @CPPFLAGS@ @CFLAGS@ +# must always be passed to CC +CFLAGS = @CFLAGS@ +# must be passed to CC when compiling C code +CPPFLAGS = @CPPFLAGS@ ALWAYSDEP = config.h Makefile OBJS = ds.o misc.o network.o oer.o parse.o reg.o + +.SUFFIXES: .c .o + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< + all: oer oer: $(ALWAYSDEP) $(OBJS) mycrypt.o - $(CC) $(LDFLAGS) -o oer $(OBJS) $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o oer $(OBJS) $(LIBS) @echo "" @echo " Type \"make install\" to install oer" @echo "" mycrypt: $(ALWAYSDEP) mycrypt.o - $(CC) $(LDFLAGS) -o mycrypt mycrypt.o $(LIBS) -oer.o: $(ALWAYSDEP) oer.c oer.h oer-common.h ds.o network.o misc.o - $(CC) $(CFLAGS) -c oer.c + $(CC) $(CFLAGS) $(LDFLAGS) -o mycrypt mycrypt.o $(LIBS) +oer.o: $(ALWAYSDEP) oer.c oer.h oer-common.h mycrypt.o: $(ALWAYSDEP) mycrypt.c - $(CC) $(CFLAGS) -c mycrypt.c -ds.o: $(ALWAYSDEP) ds.c ds.h oer-common.h oer.h misc.o reg.o - $(CC) $(CFLAGS) -c ds.c +ds.o: $(ALWAYSDEP) ds.c ds.h oer-common.h oer.h reg.o: $(ALWAYSDEP) reg.c reg.h - $(CC) $(CFLAGS) -c reg.c misc.o: $(ALWAYSDEP) misc.c misc.h oer-common.h oer.h - $(CC) $(CFLAGS) -c misc.c -network.o: $(ALWAYSDEP) network.c network.h oer-common.h oer.h parse.o ds.o misc.o - $(CC) $(CFLAGS) -c network.c -parse.o: $(ALWAYSDEP) parse.c parse.h oer-common.h oer.h ds.o misc.o reg.o - $(CC) $(CFLAGS) -c parse.c +network.o: $(ALWAYSDEP) network.c network.h oer-common.h oer.h +parse.o: $(ALWAYSDEP) parse.c parse.h oer-common.h oer.h install: all @./pre_install.sh $(prefix) $(INSTALL_PROG) -.PHONY: clean distclean +.PHONY: all clean distclean install clean: -rm -f oer *.o distclean: diff -r 3797f25f96e8 -r 042d97d72773 acconfig.h --- a/acconfig.h Sat Aug 28 00:09:27 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -#undef SOURCE_LINES -#undef SOURCE_CHARS diff -r 3797f25f96e8 -r 042d97d72773 configure.ac --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configure.ac Sat Aug 28 02:15:33 2010 -0400 @@ -0,0 +1,172 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT([oer], [1.0.66]) +AC_CONFIG_SRCDIR([oer.c]) +AC_CONFIG_HEADER([config.h]) + +dnl This is the default destination +AC_PREFIX_DEFAULT([$HOME/oer]) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_MAKE_SET +AC_PROG_INSTALL + +dnl we need uname +AC_CHECK_PROG(UNAME,uname,uname) + +AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [enable runtime debugging (You should also set CFLAGS="-g")])], [debug=$enableval], [debug=no]) +AC_ARG_ENABLE(opt, [AS_HELP_STRING([--disable-opt], [disable automatic setting of optimization compiler switches])], [opt="$enableval"], [opt=yes]) +AC_ARG_ENABLE([strip], [AS_HELP_STRING([--disable-strip], [Disable automatic stripping of binaries])], [enable_strip="$enableval"], [enable_strip=yes]) + +AC_MSG_CHECKING(system type) +SYSTEM_TYPE=`${UNAME}` +AC_MSG_RESULT($SYSTEM_TYPE) + +IRIX=no +AS_IF([test "x$SYSTEM_TYPE" = "xIRIX"], + [IRIX=yes + enable_strip=no + ]) + +AS_IF([test "$debug" = "yes"], + [AC_DEFINE([DEBUG], [], [Add debugging codepaths])]) + +dnl for devs... +MYCFLAGSADDGCC="-Wstrict-prototypes -Wall" + +dnl strip binaries by default +AS_IF([test "$enable_strip" = "yes" -a "x$IRIX" = "xno"], + [MYLDFLAGSADDCC="$MYLDFLAGSADDCC -s" + MYLDFLAGSADDGCC="$MYLDFLAGSADDGCC -s"]) + +AS_IF([test "$opt" = "yes"], + [MYCFLAGSADDCC="$MYCFLAGSADDCC -O" + MYCFLAGSADDGCC="$MYCFLAGSADDGCC -O2"]) + +dnl system specific compile settings +if test "x${SYSTEM_TYPE}" = "xHP-UX"; then + MYCFLAGSADDCC="${MYCFLAGSADDCC} -Ae" +fi +if test "x${SYSTEM_TYPE}" = "xOSF1"; then + MYCFLAGSADDCC="${MYCFLAGSADDCC} -std -no_intrinsics" +fi +dnl newer SunOS/Solaris have different signal() behaviour +if test "x${SYSTEM_TYPE}" = "xSunOS"; then + AC_DEFINE([NEW_SIGNALS], [], [Support Solaris's signal() behaviour]) +fi +if test "x$IRIX" = "xIRIX"; then + MYCFLAGSADDCC="$MYCFLAGSADDCC -std -no_intrinsics" +fi + +dnl Append compiler CFLAGS and LDFLAGS +dnl assume gcc. Checking x$CC = xgcc is not enough -- there's ${HOST}-gcc, for example... +dnl Check that compiler works with the flags we've generated, falling +dnl back from GCC flags -> generic/system-specific flags -> no flags. +CFLAGS_save="$CFLAGS" +CPPFLAGS_save="$CPPFLAGS" +LDFLAGS_save="$LDFLAGS" + +dnl GCC +CFLAGS="$CFLAGS_save $MYCFLAGSADDGCC" +LDFLAGS="$LDFLAGS_save $MYLDFLAGSADDGCC" + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[fprintf(stderr, "Hello, gcc world!\n");]])], + [:], + [ + dnl system-specific/generic + CFLAGS="$CFLAGS_save $MYCFLAGSADDCC" + LDFLAGS="$LDFLAGS_save $MYLDFLAGSADDCC" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[fprintf(stderr, "Hello, system-specific world!\n");]])], + [:], + [ + dnl no flags (user flags only) + CFLAGS="$CFLAGS_save" + LDFLAGS="$LDFLAGS_save"])]) + +dnl Find out source code size +LINES=`wc -l *.h *.c | tail -1 | sed 's/total/\ /' | tr -d ' '` +CHARS=`wc -c *.h *.c | tail -1 | sed 's/total/\ /' | tr -d ' '` + +dnl export to config.h +AC_DEFINE_UNQUOTED(SOURCE_LINES,${LINES},[Number of source lines]) +AC_DEFINE_UNQUOTED(SOURCE_CHARS,${CHARS},[Number of characters in the source]) + +dnl Checks for libraries (except IRIX) +if test "${IRIX}" = "no"; then + AC_CHECK_LIB(crypt,crypt) + AC_CHECK_LIB(socket,socket) + AC_CHECK_LIB(nsl,connect) + AC_CHECK_LIB(dns,gethostbyname) + AC_CHECK_LIB(dl,dlopen) +fi + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h strings.h crypt.h) + +dnl FreeBSD doesn't like ctype.h to be included, why only The Red Devil knows +if test "x${SYSTEM_TYPE}" != "xFreeBSD"; then + AC_CHECK_HEADERS(ctype.h) +else + AC_MSG_WARN([ + Disabling ctype.h because of FreeBSD. You can safely + ignore the implicit declaration of function isxxxxx messages. + ]) +fi + +dnl check for uname +AC_CHECK_FUNCS(uname) + +dnl check for getaddrinfo +AC_CHECK_FUNCS(getaddrinfo) +if test "${ac_cv_func_getaddrinfo}" = "no"; then + AC_MSG_ERROR([ + Your system does not support the getaddrinfo function call. + (you could try oer 1.0-62 or older.) +]) +fi + +dnl check for locale +AC_CHECK_HEADERS(locale.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T +AC_HEADER_TIME +AC_STRUCT_TM + +dnl Checks for library functions. +AC_TYPE_SIGNAL +AC_CHECK_FUNCS(snprintf) +if test "${ac_cv_func_snprintf}" = "no"; then + AC_MSG_WARN([ + Your system does not have snprintf, using unsafe vsprintf alternative +]) +fi +AC_CHECK_FUNCS(vsprintf) +if test "${ac_cv_func_vsprintf}" = "no"; then + AC_MSG_ERROR([ + Your system does not even have vsprintf. Get a real system! +]) +fi +AC_CHECK_FUNCS(vfprintf) +if test "${ac_cv_func_vfprintf}" = "no"; then + AC_MSG_ERROR([ + Your system does not have vfprintf. Get a real system! +]) +fi + +AC_CONFIG_FILES([ + Makefile + ]) +AC_OUTPUT + +AC_MSG_RESULT([ + Type "make" to compile oer +]) diff -r 3797f25f96e8 -r 042d97d72773 configure.in --- a/configure.in Sat Aug 28 00:09:27 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(README) -AC_CONFIG_HEADER(config.h) - -dnl This is the default destination -AC_PREFIX_DEFAULT($HOME/oer) - -dnl Checks for programs. -AC_PROG_CC -AC_PROG_MAKE_SET -AC_PROG_INSTALL - -dnl we need uname -AC_CHECK_PROG(UNAME,uname,uname) - -AC_ARG_ENABLE(debug, [ --enable-debug switch debug on (off by default)], debug=$enableval) -AC_ARG_ENABLE(opt, [ --enable-opt switch optimization on (on by default)], opt=$enableval) -AC_ARG_ENABLE(profile, [ --enable-profile switch profile on (off by default)], profile=$enableval) - -AC_MSG_CHECKING(system type) -SYSTEM_TYPE=`${UNAME}` -AC_MSG_RESULT($SYSTEM_TYPE) - -STRIP=yes -if test x${SYSTEM_TYPE} = "xIRIX"; then - STRIP=no -fi - -dnl compile defaults -MYCFLAGSADDCC="-O" -MYCFLAGSADDGCC="-O2 -Wstrict-prototypes -Wall" -MYLDFLAGSADDCC="-s" -MYLDFLAGSADDGCC="-s" -if test "$opt" = "no"; then - MYCFLAGSADDCC="" - MYCFLAGSADDGCC="-Wstrict-prototypes -Wall" -fi -if test "$debug" = "yes"; then - MYCFLAGSADDCC="-DDEBUG -g" - MYCFLAGSADDGCC="-DDEBUG -Wstrict-prototypes -Wall -g" - MYLDFLAGSADDCC="" - MYLDFLAGSADDGCC="" -fi -if test "$profile" = "yes"; then - MYCFLAGSADDCC="$-DDEBUG -g -p" - MYCFLAGSADDGCC="-DDEBUG -Wstrict-prototypes -Wall -g -pg" - MYLDFLAGSADDCC="-p" - MYLDFLAGSADDGCC="-pg" -fi - -dnl system specific compile settings -if test "x${SYSTEM_TYPE}" = "xHP-UX"; then - MYCFLAGSADDCC="${MYCFLAGSADDCC} -Ae -D_NO_H_ERRNO" - MYCFLAGSADDGCC="${MYCFLAGSADDGCC} -D_NO_H_ERRNO" -fi -if test "x${SYSTEM_TYPE}" = "xOSF1"; then - MYCFLAGSADDCC="${MYCFLAGSADDCC} -std -no_intrinsics" - MYCFLAGSADDGCC="${MYCFLAGSADDGCC}" -fi -dnl newer SunOS/Solaris have different signal() behaviour -if test "x${SYSTEM_TYPE}" = "xSunOS"; then - MYCFLAGSADDCC="${MYCFLAGSADDCC} -DNEW_SIGNALS" - MYCFLAGSADDGCC="${MYCFLAGSADDGCC} -DNEW_SIGNALS" -fi -IRIX=no -if test "x${SYSTEM_TYPE}" = "xIRIX"; then - MYCFLAGSADDCC="${MYCFLAGSADDCC} -std -no_intrinsics" - MYCFLAGSADDGCC="${MYCFLAGSADDGCC}" - MYLDFLAGSADDCC="" - MYLDFLAGSADDGCC="" - IRIX=yes -fi - -dnl assume gcc -MYCFLAGS="${MYCFLAGSADDGCC}" -MYLDFLAGS="${MYLDFLAGSADDGCC}" -if test "x$CC" != "xgcc"; then - MYCFLAGS="${MYCFLAGSADDCC}" - MYLDDFLAGS="${MYLDFLAGSADDCC}" -fi - -dnl Set compiler CFLAGS -CFLAGS=${MYCFLAGS} - -dnl Set linker LDFLAGS -LDFLAGS=${MYLDFLAGS} - -dnl Find out source code size -LINES=`wc -l *.h *.c | tail -1 | sed 's/total/\ /' | tr -d ' '` -CHARS=`wc -c *.h *.c | tail -1 | sed 's/total/\ /' | tr -d ' '` - -dnl export to config.h -AC_DEFINE_UNQUOTED(SOURCE_LINES,${LINES},[Number of source lines]) - -dnl export to config.h -AC_DEFINE_UNQUOTED(SOURCE_CHARS,${CHARS},[Number of characters in the source]) - -dnl Checks for libraries (except IRIX) -if test "${IRIX}" = "no"; then - AC_CHECK_LIB(crypt,crypt) - AC_CHECK_LIB(socket,socket) - AC_CHECK_LIB(nsl,connect) - AC_CHECK_LIB(dns,gethostbyname) - AC_CHECK_LIB(dl,dlopen) -fi - -dnl Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h strings.h crypt.h) - -dnl FreeBSD doesn't like ctype.h to be included, why only The Red Devil knows -if test "x${SYSTEM_TYPE}" != "xFreeBSD"; then - AC_CHECK_HEADERS(ctype.h) -else - echo "" - echo " Disabling ctype.h because of FreeBSD, you can safely" - echo " ignore the implicit declaration of function isxxxxx messages" - echo "" -fi - -dnl check for uname -AC_CHECK_FUNCS(uname) - -dnl check for getaddrinfo -AC_CHECK_FUNCS(getaddrinfo) -if test "${ac_cv_func_getaddrinfo}" = "no"; then - echo "" - echo " Your system does not support the getaddrinfo function call" - echo " (you could try oer 1.0-62 or older)" - echo "" - exit -fi - -dnl check for locale -AC_CHECK_HEADERS(locale.h) - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T -AC_HEADER_TIME -AC_STRUCT_TM - -dnl Checks for library functions. -AC_TYPE_SIGNAL -AC_CHECK_FUNCS(snprintf) -if test "${ac_cv_func_snprintf}" = "no"; then - echo "" - echo " Your system does not have snprintf, using unsafe vsprintf alternative" - echo "" -fi -AC_CHECK_FUNCS(vsprintf) -if test "${ac_cv_func_vsprintf}" = "no"; then - echo "" - echo " Your system does not have vsprintf. Get a real system!" - echo "" - exit -fi -AC_CHECK_FUNCS(vfprintf) -if test "${ac_cv_func_vfprintf}" = "no"; then - echo "" - echo " Your system does not have vfprintf. Get a real system!" - echo "" - exit -fi - -AC_OUTPUT(Makefile) -AC_MSG_RESULT("") -AC_MSG_RESULT(" Type \"make\" to compile oer") -AC_MSG_RESULT("")