diff --git a/.gitignore b/.gitignore index cd04a06aa..ed7985f3b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ src/y.tab.c ssld/ssld tools/convertilines tools/convertklines +tools/genssl.sh tools/mkpasswd tools/viconf include/serno.h diff --git a/Makefile.in b/Makefile.in index 80cab4129..729a54bed 100644 --- a/Makefile.in +++ b/Makefile.in @@ -24,10 +24,17 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ mandir = @mandir@ +libdir = @libdir@ +pkglibdir = @pkglibdir@ moduledir = @moduledir@ helpdir = @helpdir@ confdir = @confdir@ logdir = @logdir@ +rundir = @rundir@ +pkgrundir = @pkgrundir@ +localstatedir = @localstatedir@ +pkglocalstatedir= @pkglocalstatedir@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ # Default CFLAGS # CFLAGS = -g -O2 -DNDEBUG @@ -118,21 +125,27 @@ lint: install-mkdirs: @echo "ircd: setting up ircd directory structure" -@if test ! -d $(DESTDIR)$(prefix); then \ - mkdir $(DESTDIR)$(prefix); \ + mkdir -p -m 755 $(DESTDIR)$(prefix); \ fi -@if test ! -d $(DESTDIR)$(bindir); then \ - mkdir $(DESTDIR)$(bindir); \ + mkdir -p -m 755 $(DESTDIR)$(bindir); \ fi -@if test ! -d $(DESTDIR)$(confdir); then \ - mkdir $(DESTDIR)$(confdir); \ + mkdir -p -m 755 $(DESTDIR)$(confdir); \ fi -@if test ! -d $(DESTDIR)$(mandir); then \ - mkdir $(DESTDIR)$(mandir); \ + mkdir -p -m 755 $(DESTDIR)$(mandir); \ fi -@if test ! -d $(DESTDIR)$(logdir); then \ - mkdir $(DESTDIR)$(logdir); \ + mkdir -p -m 755 $(DESTDIR)$(logdir); \ fi - + -@if test ! -d '$(DESTDIR)$(pkgrundir)'; then \ + mkdir -p -m 755 '$(DESTDIR)$(pkgrundir)'; \ + fi + -@if test ! -d '$(DESTDIR)$(pkglocalstatedir)'; then \ + mkdir -p -m 755 '$(DESTDIR)$(pkglocalstatedir)'; \ + fi + install: install-mkdirs all @for i in $(SUBDIRS); do \ echo "install ==> $$i";\ diff --git a/aclocal.m4 b/aclocal.m4 index 83a647d20..b2aec7a9b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -2,8 +2,12 @@ AC_DEFUN([AC_DEFINE_DIR], [ test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - ac_define_dir=`eval echo [$]$2` - ac_define_dir=`eval echo [$]ac_define_dir` + last_ac_define_dir=`eval echo [$]$2` + ac_define_dir=`eval echo [$]last_ac_define_dir` + while test "x[$]last_ac_define_dir" != "x[$]ac_define_dir"; do + last_ac_define_dir="[$]ac_define_dir" + ac_define_dir=`eval echo [$]last_ac_define_dir` + done $1="$ac_define_dir" AC_SUBST($1) ifelse($3, , diff --git a/bandb/Makefile.in b/bandb/Makefile.in index 49ba3288c..644f40ec8 100644 --- a/bandb/Makefile.in +++ b/bandb/Makefile.in @@ -22,8 +22,12 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @libdir@ libexecdir = @libexecdir@ +pkglibexecdir = @pkglibexecdir@ confdir = @confdir@ localstatedir = @localstatedir@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ + +PROGRAM_PREFIX = @PROGRAM_PREFIX@ ZIP_LIB = @ZLIB_LD@ @@ -34,7 +38,9 @@ CPPFLAGS = ${INCLUDES} @CPPFLAGS@ CFLAGS += -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION=1 -PROGS = bandb bantool +pkglibexec_PROGS = bandb +bin_PROGS = bantool +PROGS = $(pkglibexec_PROGS) $(bin_PROGS) BANDB_SOURCES = \ bandb.c \ @@ -64,12 +70,18 @@ bantool: ${BANTOOL_OBJECTS} install: build @echo "ircd: installing bandb ($(PROGS))" - @for i in $(PROGS); do \ - if test -f $(DESTDIR)$(bindir)/$$i; then \ - $(MV) $(DESTDIR)$(bindir)/$$i $(DESTDIR)$(bindir)/$$i.old; \ + @for i in $(bin_PROGS); do \ + if test -f $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; then \ + $(MV) $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i.old; \ fi; \ - $(INSTALL_BIN) $$i $(DESTDIR)$(bindir); \ + $(INSTALL_BIN) $$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; \ done + @for i in $(pkglibexec_PROGS); do \ + if test -f '$(DESTDIR)$(pkglibexecdir)/'$$i; then \ + $(MV) '$(DESTDIR)$(pkglibexecdir)/'$$i '$(DESTDIR)$(pkglibexecdir)/'$$i.old; \ + fi; \ + $(INSTALL_BIN) $$i '$(DESTDIR)$(pkglibexecdir)/'$$i; \ + done .c.o: ${CC} ${CPPFLAGS} ${CFLAGS} -c $< diff --git a/configure.ac b/configure.ac index 29bcfa2a4..9ab0cbf98 100644 --- a/configure.ac +++ b/configure.ac @@ -225,12 +225,37 @@ if test "$LEX" = ":"; then AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.]) fi +AC_ARG_ENABLE([fhs-paths], + [AS_HELP_STRING([--enable-fhs-paths], [User more FHS-like pathnames (for packagers).])], + [], + [dnl detect if the user appears to want --enable-fhs-paths + AS_IF([test "$libexecdir" = '${exec_prefix}/libexec' && \ + test "$localstatedir" = '${prefix}/var' && \ + test "$libdir" = '${exec_prefix}/lib'], + [enable_fhs_paths=no], + [enable_fhs_paths=yes]) + ]) dnl use directory structure of cached as default (hack) -if test "$libexecdir" = '${exec_prefix}/libexec' && - test "$localstatedir" = '${prefix}/var'; then - libexecdir='${bindir}' +AS_IF([test "x$enable_fhs_paths" = "xyes"], + [dnl Avoid name collisions. + pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}' + rundir=${rundir-'${prefix}/run'} + pkgrundir='${rundir}/${PACKAGE_TARNAME}' + pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'], + [libexecdir='${bindir}' + pkglibexecdir='${libexecdir}' + rundir='${sysconfdir}' + pkgrundir='${rundir}' localstatedir='${prefix}' -fi + pkglocalstatedir='${sysconfdir}']) +pkglibdir='${libdir}/${PACKAGE_TARNAME}' +AC_SUBST([pkglibdir]) +AC_SUBST([rundir]) +AC_SUBST([pkgrundir]) +AC_SUBST([pkglocalstatedir]) +AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as band database]]) +AC_SUBST([pkglibexecdir]) +AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live]) dnl Checks for header files. AC_HEADER_STDC @@ -595,7 +620,7 @@ AC_HELP_STRING([--with-confdir=DIR], AC_MSG_RESULT(yes) AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.]) AC_SUBST_DIR([confdir]) ], - [ confdir='${prefix}/etc' + [ confdir='${sysconfdir}' AC_MSG_RESULT(no) AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.]) AC_SUBST_DIR([confdir])] @@ -610,14 +635,13 @@ AC_ARG_WITH(logdir, AC_HELP_STRING([--with-logdir=DIR], [Directory where to write logfiles.]), [ logdir=`echo $withval | sed 's/\/$//'` - AC_MSG_RESULT(yes) - AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.]) - AC_SUBST_DIR([logdir]) ], - [ logdir='${prefix}/logs' - AC_MSG_RESULT(no) - AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.]) - AC_SUBST_DIR([logdir])] -) + AC_MSG_RESULT(yes)], + [ AS_IF([test "x$enable_fhs_paths" = "xyes"], + [logdir='${localstatedir}/log/${PACKAGE_TARNAME}'], + [logdir='${prefix}/logs']) + AC_MSG_RESULT(no)]) +AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.]) +AC_SUBST_DIR([logdir]) dnl ********************************************************************** dnl Check for --with-helpdir @@ -628,14 +652,13 @@ AC_ARG_WITH(helpdir, AC_HELP_STRING([--with-helpdir=DIR], [Directory to install help files.]), [ helpdir=`echo $withval | sed 's/\/$//'` - AC_MSG_RESULT(yes) - AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help files are installed.]) - AC_SUBST_DIR([helpdir]) ], - [ helpdir='${prefix}/help' - AC_MSG_RESULT(no) - AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help file are installed.]) - AC_SUBST_DIR([helpdir])] -) + AC_MSG_RESULT(yes) ], + [ AS_IF([test "x$enable_fhs_paths" = "xyes"], + [helpdir='${datadir}/${PACKAGE_TARNAME}/help'], + [helpdir='${prefix}/help']) + AC_MSG_RESULT(no) ]) +AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.]) +AC_SUBST_DIR([helpdir]) dnl ********************************************************************** dnl Check for --with-moduledir @@ -643,17 +666,44 @@ dnl ********************************************************************** AC_MSG_CHECKING([whether to modify moduledir]) AC_ARG_WITH(moduledir, -AC_HELP_STRING([--with-moduledir=DIR], - [Directory to install modules.]), + [AC_HELP_STRING([--with-moduledir=DIR], + [Directory to install modules.])], [ moduledir=`echo $withval | sed 's/\/$//'` - AC_MSG_RESULT(yes) - AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.]) - AC_SUBST_DIR([moduledir]) ], - [ moduledir='${prefix}/modules' + AC_MSG_RESULT(yes)], + [ AS_IF([test "x$enable_fhs_paths" = "xyes"], + [moduledir='${pkglibdir}/modules'], + [moduledir='${prefix}/modules']) AC_MSG_RESULT(no) - AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.]) - AC_SUBST_DIR([moduledir])] -) + ]) +AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.]) +AC_SUBST_DIR([moduledir]) + +dnl Check for --with-rundir + +AC_MSG_CHECKING([whether or modify rundir]) +AC_ARG_WITH([rundir], + [AC_HELP_STRING([--with-rundir=DIR], + [Directory in which to store pidfile.])], + [AC_MSG_RESULT([yes]) + rundir=`echo $withval | sed 's/\/$//'`], + [AC_MSG_RESULT([no]) + AS_IF([test "x$enable_fhs_paths" = "xyes"], + [rundir='${prefix}/run'], + [rundir='${sysconfdir}'])]) +AC_SUBST([rundir]) +AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.]) + +dnl Installed utility program prefixes (does not affect binaries +dnl installed into pkglibexecdir) +AC_MSG_CHECKING([for program prefix]) +AC_ARG_WITH([program-prefix], + [AS_HELP_STRING([--with-program-prefix=], [If set, programs installed into PATH will be installed with names prefixed by this prefix.])], + [test "x$with_program_prefix" = "xno" && with_program_prefix=], + [with_program_prefix=]) +AC_MSG_RESULT(["$with_program_prefix"]) +PROGRAM_PREFIX="$with_program_prefix" +AC_SUBST([PROGRAM_PREFIX]) +AC_DEFINE_UNQUOTED([PROGRAM_PREFIX], ["$with_program_prefix"], [String with which all programs intended to be in PATH are prefixed.]) dnl ********************************************************************** dnl Branding @@ -1197,9 +1247,11 @@ AC_CONFIG_FILES( \ src/Makefile \ modules/Makefile \ tools/Makefile \ + tools/genssl.sh \ doc/Makefile \ help/Makefile \ ) +AC_CONFIG_COMMANDS([tools/genssl.sh_chmod], [chmod 755 tools/genssl.sh]) AC_OUTPUT diff --git a/doc/Makefile.in b/doc/Makefile.in index 5d48353c6..e78b2071b 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -15,6 +15,8 @@ RM = @RM@ CP = @CP@ TOUCH = @TOUCH@ +PROGRAM_PREFIX = @PROGRAM_PREFIX@ + prefix = @prefix@ exec_prefix = @exec_prefix@ exec_suffix = @exec_suffix@ @@ -73,8 +75,8 @@ install: install-mkdirs build @echo "ircd: installing manpage" @for i in $(MANPAGES); do \ - if test ! -f $(DESTDIR)$(mandir)/$$i; then \ - $(INSTALL_DATA) $$i $(DESTDIR)$(mandir); \ + if test ! -f $(DESTDIR)$(mandir)/$(PROGRAM_PREFIX)$$i; then \ + $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/$(PROGRAM_PREFIX)$$i; \ fi; \ done diff --git a/extensions/Makefile.in b/extensions/Makefile.in index 75a3f4a54..9b1632776 100644 --- a/extensions/Makefile.in +++ b/extensions/Makefile.in @@ -16,7 +16,14 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SUID = @INSTALL_PROGRAM@ -o root -m 4755 SHELL = /bin/sh -AUTOMODULEDIR = @moduledir@/extensions + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +libdir = @libdir@ +pkglibdir = @pkglibdir@ +moduledir = @moduledir@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +AUTOMODULEDIR = $(moduledir)/extensions SSL_LIBS = @SSL_LIBS@ SSL_INCLUDES = @SSL_INCLUDES@ diff --git a/help/Makefile.in b/help/Makefile.in index 534b36f84..587f08664 100644 --- a/help/Makefile.in +++ b/help/Makefile.in @@ -7,7 +7,9 @@ INSTALL_DATA= @INSTALL_DATA@ RM= @RM@ prefix= @prefix@ -exec_prefix= @execprefix@ +exec_prefix= @exec_prefix@ +datarootdir = @datarootdir@ +datadir = @datadir@ helpdir= @helpdir@ uhelpdir= ${helpdir}/users ohelpdir= ${helpdir}/opers diff --git a/include/config.h b/include/config.h index 664ff7c32..cc1ab2f1f 100644 --- a/include/config.h +++ b/include/config.h @@ -59,14 +59,13 @@ #define HPATH HELP_DIR "/opers" /* files */ -#define SPATH BINPATH "/ircd" /* ircd executable */ -#define LIPATH LIBPATH "/libircd" SHARED_SUFFIX /* ircd library */ +#define SPATH BINPATH "/" PROGRAM_PREFIX "ircd" /* ircd executable */ #define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */ #define MPATH ETCPATH "/ircd.motd" /* MOTD file */ #define LPATH LOGPATH "/ircd.log" /* ircd logfile */ -#define PPATH ETCPATH "/ircd.pid" /* pid file */ +#define PPATH PKGRUNDIR "/ircd.pid" /* pid file */ #define OPATH ETCPATH "/opers.motd" /* oper MOTD file */ -#define DBPATH ETCPATH "/ban.db" /* bandb file */ +#define DBPATH PKGLOCALSTATEDIR "/ban.db" /* bandb file */ /* IGNORE_BOGUS_TS * Ignore bogus timestamps from other servers. Yes this will desync diff --git a/libratbox/acinclude.m4 b/libratbox/acinclude.m4 index 4a0c6e136..e1e75a5c0 100644 --- a/libratbox/acinclude.m4 +++ b/libratbox/acinclude.m4 @@ -2,8 +2,12 @@ AC_DEFUN([AC_DEFINE_DIR], [ test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - ac_define_dir=`eval echo [$]$2` - ac_define_dir=`eval echo [$]ac_define_dir` + last_ac_define_dir=`eval echo [$]$2` + ac_define_dir=`eval echo [$]last_ac_define_dir` + while test "x[$]last_ac_define_dir" != "x[$]ac_define_dir"; do + last_ac_define_dir="[$]ac_define_dir" + ac_define_dir=`eval echo [$]last_ac_define_dir` + done $1="$ac_define_dir" AC_SUBST($1) ifelse($3, , diff --git a/modules/Makefile.in b/modules/Makefile.in index 8f5d2a725..c4f2c9fc3 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -28,7 +28,11 @@ SSL_INCLUDES = @SSL_INCLUDES@ IRCDLIBS = @LIBS@ $(SSL_LIBS) prefix = @prefix@ +exec_prefix = @exec_prefix@ +libdir = @libdir@ +pkglibdir = @pkglibdir@ moduledir = @moduledir@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ # Change this later! -- adrian automoduledir = @moduledir@/autoload diff --git a/src/Makefile.in b/src/Makefile.in index dc7dcef2c..a2fd0c708 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -12,7 +12,7 @@ RM = @RM@ LEX = @LEX@ LEXLIB = @LEXLIB@ PICFLAGS = @PICFLAGS@ -CFLAGS = @IRC_CFLAGS@ -DIRCD_PREFIX=\"@prefix@\" +CFLAGS = @IRC_CFLAGS@ LDFLAGS = @LDFLAGS@ MKDEP = @MKDEP@ -DIRCD_PREFIX=\"@prefix@\" MV = @MV@ @@ -23,6 +23,9 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @libdir@ libexecdir = @libexecdir@ +pkglibexecdir = @pkglibexecdir@ + +PROGRAM_PREFIX = @PROGRAM_PREFIX@ DOLLAR = $$ @@ -36,7 +39,7 @@ SSL_INCLUDES = @SSL_INCLUDES@ IRCDLIBS = @MODULES_LIBS@ -L../libratbox/src/.libs -lratbox @LIBS@ $(SSL_LIBS) INCLUDES = -I../include -I../libratbox/include $(SSL_INCLUDES) -CPPFLAGS = ${INCLUDES} @CPPFLAGS@ +CPPFLAGS = ${INCLUDES} -DIRCD_PREFIX=\"@prefix@\" @CPPFLAGS@ default: all @@ -133,10 +136,10 @@ install: install-mkdirs build fi @echo "ircd: installing ircd ($(PROGS))" @for i in $(PROGS); do \ - if test -f $(DESTDIR)$(bindir)/$$i; then \ - $(MV) $(DESTDIR)$(bindir)/$$i $(DESTDIR)$(bindir)/$$i.old; \ + if test -f $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; then \ + $(MV) $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i.old; \ fi; \ - $(INSTALL_BIN) $$i $(DESTDIR)$(bindir); \ + $(INSTALL_BIN) $$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; \ done version.c: version.c.SH diff --git a/src/bandbi.c b/src/bandbi.c index eda44b304..5c9933e26 100644 --- a/src/bandbi.c +++ b/src/bandbi.c @@ -85,7 +85,7 @@ start_bandb(void) rb_setenv("BANDB_DPATH", ConfigFileEntry.dpath, 1); if(bandb_path == NULL) { - rb_snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", BINPATH, suffix); + rb_snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", PKGLIBEXECDIR, suffix); if(access(fullpath, X_OK) == -1) { @@ -95,8 +95,8 @@ start_bandb(void) if(access(fullpath, X_OK) == -1) { ilog(L_MAIN, - "Unable to execute bandb in %s or %s/bin", - BINPATH, ConfigFileEntry.dpath); + "Unable to execute bandb%s in %s or %s/bin", + suffix, PKGLIBEXECDIR, ConfigFileEntry.dpath); return 0; } } diff --git a/src/sslproc.c b/src/sslproc.c index 8b929436e..51078fbf2 100644 --- a/src/sslproc.c +++ b/src/sslproc.c @@ -261,7 +261,7 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co if(ssld_path == NULL) { - rb_snprintf(fullpath, sizeof(fullpath), "%s/ssld%s", BINPATH, suffix); + rb_snprintf(fullpath, sizeof(fullpath), "%s/ssld%s", PKGLIBEXECDIR, suffix); if(access(fullpath, X_OK) == -1) { @@ -270,8 +270,8 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co if(access(fullpath, X_OK) == -1) { ilog(L_MAIN, - "Unable to execute ssld%s in %s/bin or %s", - ConfigFileEntry.dpath, suffix, BINPATH); + "Unable to execute ssld%s in %s or %s/bin", + suffix, PKGLIBEXECDIR, ConfigFileEntry.dpath); return 0; } } diff --git a/ssld/Makefile.in b/ssld/Makefile.in index 3b49f8400..cdf3b8537 100644 --- a/ssld/Makefile.in +++ b/ssld/Makefile.in @@ -22,8 +22,12 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @libdir@ libexecdir = @libexecdir@ +pkglibexecdir = @pkglibexecdir@ confdir = @confdir@ localstatedir = @localstatedir@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ + +PROGRAM_PREFIX = @PROGRAM_PREFIX@ ZIP_LIB = @ZLIB_LD@ @@ -32,7 +36,8 @@ IRCDLIBS = @MODULES_LIBS@ -L../libratbox/src/.libs -lratbox @LIBS@ $(SSL_LIBS) $ INCLUDES = -I. -I../include -I../libratbox/include $(SSL_INCLUDES) CPPFLAGS = ${INCLUDES} @CPPFLAGS@ -PROGS = ssld +pkglibexec_PROGS = ssld +PROGS = $(pkglibexec_PROGS) SOURCES = \ ssld.c @@ -47,14 +52,27 @@ build: all ssld: ${OBJECTS} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${IRCDLIBS} -install: build +install-mkdirs: + -@for dir in '$(bindir)' '$(pkglibexecdir)'; do \ + if test ! -d '$(DESTDIR)'"$${dir}"; then \ + mkdir -p -m 755 '$(DESTDIR)'"$${dir}"; \ + fi; \ + done + +install: install-mkdirs build @echo "ircd: installing ssld ($(PROGS))" - @for i in $(PROGS); do \ + @for i in $(bin_PROGS); do \ if test -f $(DESTDIR)$(bindir)/$$i; then \ - $(MV) $(DESTDIR)$(bindir)/$$i $(DESTDIR)$(bindir)/$$i.old; \ + $(MV) $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i.old; \ fi; \ - $(INSTALL_BIN) $$i $(DESTDIR)$(bindir); \ + $(INSTALL_BIN) $$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; \ done + @for i in $(pkglibexec_PROGS); do \ + if test -f '$(DESTDIR)$(pkglibexecdir)/'$$i; then \ + $(MV) '$(DESTDIR)$(pkglibexecdir)/'$$i '$(DESTDIR)$(pkglibexecdir)/'$$i.old; \ + fi; \ + $(INSTALL_BIN) $$i '$(DESTDIR)$(pkglibexecdir)/'$$i; \ + done .c.o: ${CC} ${CPPFLAGS} ${CFLAGS} -c $< diff --git a/tools/Makefile.in b/tools/Makefile.in index 93ae067d6..062713273 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -15,6 +15,8 @@ MV = @MV@ RM = @RM@ LN = @LN@ +PROGRAM_PREFIX = @PROGRAM_PREFIX@ + IRCDLIBS = -L../libratbox/src/.libs -lratbox @LIBS@ INCLUDES = -I../include -I../libratbox/include CPPFLAGS = ${INCLUDES} @CPPFLAGS@ @@ -45,13 +47,14 @@ convertilines: convertilines.c convertklines: convertklines.c $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) convertklines.c -o convertklines $(IRCDLIBS) -genssl.sh: +genssl.sh: genssl.sh.in + cd .. && ./config.status tools/genssl.sh && ./config.status tools/genssl.sh_chmod clean: $(RM) -f encspeed viconf chkconf mkpasswd *~ core *.exe convertklines convertilines distclean: clean - $(RM) -f Makefile + $(RM) -f genssl.sh Makefile lint: lint -aacgprxhH $(CPPFLAGS) -DIRCD_PREFIX=\"@prefix@\" $(convertklines_SOURCES) $(mkpasswd_SOURCES) $(viconf_SOURCES) $(encspeed_SOURCES) >>../lint.out @@ -91,11 +94,11 @@ install-mkdirs: install: install-mkdirs build @echo "ircd: installing tools ($(PROGS))" @for i in $(PROGS); do \ - if test -f $(DESTDIR)$(bindir)/$$i; then \ - $(MV) $(DESTDIR)$(bindir)/$$i $(DESTDIR)$(bindir)/$$i.old; \ + if test -f $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; then \ + $(MV) $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i.old; \ fi; \ - $(INSTALL_BIN) $$i $(DESTDIR)$(bindir); \ + $(INSTALL_BIN) $$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; \ done; \ - $(RM) -f $(DESTDIR)$(bindir)/vimotd - $(LN) $(DESTDIR)$(bindir)/viconf $(DESTDIR)$(bindir)/vimotd + $(RM) -f $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)vimotd + $(LN) $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)viconf $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)vimotd diff --git a/tools/genssl.sh b/tools/genssl.sh deleted file mode 100755 index de7f16513..000000000 --- a/tools/genssl.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -echo "Generating self-signed certificate .. " -openssl req -x509 -nodes -newkey rsa:1024 -keyout ../etc/ssl.key -out ../etc/ssl.cert - -echo "Generating Diffie-Hellman file for secure SSL/TLS negotiation .. " -openssl dhparam -out ../etc/dh.pem 1024 - -echo " -Now change these lines in the IRCd config file: - - ssl_private_key = "etc/ssl.key"; - ssl_cert = "etc/ssl.cert"; - ssl_dh_params = "etc/dh.pem"; - -Enjoy using ssl. -" diff --git a/tools/genssl.sh.in b/tools/genssl.sh.in new file mode 100755 index 000000000..2e65f6553 --- /dev/null +++ b/tools/genssl.sh.in @@ -0,0 +1,29 @@ +#!/bin/sh +prefix="@prefix@" +exec_prefix="@exec_prefix@" +sysconfdir="@sysconfdir@" + +echo "Generating self-signed certificate .. " +openssl req -x509 -nodes -newkey rsa:1024 -keyout "${sysconfdir}"/ssl.key -out "${sysconfdir}"/ssl.cert + +echo "Generating Diffie-Hellman file for secure SSL/TLS negotiation .. " +openssl dhparam -out "${sysconfdir}"/dh.pem 1024 + +# If sysconfdir is relative to prefix, make the path relative. I.e., +# prefix=/usr and sysconfdir=/etc -> relative_sysconfdir=/etc, +# prefix=/home/binki/chary and sysconfdir=/home/binki/chary/etc -> +# relative_sysconfdir=etc +relative_sysconfdir="${sysconfdir#${prefix%/}/}" +relative_sysconfdir="${relative_sysconfdir%/}" + +cat < #include "config.h" +#ifndef PROGRAM_PREFIX +#define PROGRAM_PREFIX "" +#endif /* wait.h is in /include on solaris, likely on other SYSV machines as well * but wait.h is normally in /include/sys on BSD boxen, @@ -45,7 +48,7 @@ int main(int argc, char *argv[]) else p++; - if(strcmp(p, "vimotd") == 0) + if(strcmp(p, PROGRAM_PREFIX "vimotd") == 0) filename = MPATH; if(LockedFile(filename))