From 48be29168f35bec8baec1a4cac69208527c75b90 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Thu, 17 Jul 2008 19:16:10 +0200 Subject: [PATCH] Fix up build system, start to get rid of libconfig --- .gitignore | 2 ++ Makefile.am | 37 +++++++++++++++++++++++ Makefile.dep.dist | 31 ------------------- Makefile.in | 74 ---------------------------------------------- backuppcd-auth.c | 20 ++++++++----- backuppcd-client.c | 4 ++- backuppcd-passwd.c | 1 + backuppcd-tar.c | 1 + backuppcd.c | 12 +++++++- compat.h | 5 +--- configure.ac | 49 +++++------------------------- net.c | 54 +++++++++++++++++++-------------- tools/Makefile.am | 0 13 files changed, 107 insertions(+), 183 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile.am delete mode 100644 Makefile.dep.dist delete mode 100644 Makefile.in create mode 100644 tools/Makefile.am diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34d8754 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +link-warning.h +*~ diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..2cae1f7 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,37 @@ + +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = lib + +AM_LIBS = @SSL_LIBS@ +AM_CFLAGS = @SSL_CFLAGS@ -DSYSCONFDIR="\"$(sysconfdir)\"" -DBACKUPPC_PIDFILE="\"$(localstatedir)/run/backuppcd.pid\"" + +bin_PROGRAMS = backuppcd backuppcd-client backuppcd-tar backuppcd-passwd + +noinst_LIBS = backuppcd backuppc + +backuppcd_SOURCES = backuppcd.c \ + net.c \ + backuppcd-common.c \ + sha1.c \ + md4.c \ + md5.c \ + backuppcd-auth.c \ + backuppcd-notify.c + +backuppcd_client_SOURCES = backuppcd-client.c \ + libbackuppcd.c \ + net.c \ + backuppcd-common.c \ + sha1.c \ + md4.c \ + md5.c \ + libbackuppc.c + +backuppcd_tar_SOURCES = backuppcd-tar.c \ + net.c \ + backuppcd-common.c \ + sha1.c + +backuppcd_passwd_SOURCES = backuppcd-passwd.c \ + sha1.c + diff --git a/Makefile.dep.dist b/Makefile.dep.dist deleted file mode 100644 index 670fb2f..0000000 --- a/Makefile.dep.dist +++ /dev/null @@ -1,31 +0,0 @@ -backuppcd-auth.o: backuppcd-auth.c compat.h win32.h config.h htonll.h ntohll.h \ - backuppcd-auth.h -backuppcd-client.o: backuppcd-client.c compat.h win32.h config.h htonll.h \ - ntohll.h backuppcd-common.h -backuppcd-common.o: backuppcd-common.c compat.h win32.h config.h htonll.h \ - ntohll.h backuppcd-common.h -backuppcd-notify.o: backuppcd-notify.c compat.h win32.h config.h htonll.h \ - ntohll.h net.h -backuppcd-passwd.o: backuppcd-passwd.c compat.h win32.h config.h htonll.h \ - ntohll.h sha1.h -backuppcd-tar.o: backuppcd-tar.c compat.h win32.h config.h htonll.h ntohll.h \ - backuppcd.h backuppcd-common.h net.h -backuppcd.o: backuppcd.c compat.h win32.h config.h htonll.h ntohll.h backuppcd.h \ - backuppcd-common.h backuppcd-auth.h backuppcd-notify.h net.h sha1.h \ - md4.h md5.h -chown.o: chown.c chown.h compat.h win32.h config.h htonll.h ntohll.h backuppcd.h \ - backuppcd-common.h -fnmatch.o: fnmatch.c compat.h win32.h config.h htonll.h ntohll.h -gethostname.o: gethostname.c compat.h win32.h config.h htonll.h ntohll.h -htonll.o: htonll.c compat.h win32.h config.h htonll.h ntohll.h -libbackuppc.o: libbackuppc.c -libbackuppcd.o: libbackuppcd.c compat.h win32.h config.h htonll.h ntohll.h \ - backuppcd.h backuppcd-common.h libbackuppcd.h sha1.h net.h -link.o: link.c compat.h win32.h config.h htonll.h ntohll.h link.h backuppcd.h \ - backuppcd-common.h -md4.o: md4.c md4.h compat.h win32.h config.h htonll.h ntohll.h -md5.o: md5.c md5.h compat.h win32.h config.h htonll.h ntohll.h -net.o: net.c compat.h win32.h config.h htonll.h ntohll.h net.h -ntohll.o: ntohll.c compat.h win32.h config.h htonll.h ntohll.h -sha1.o: sha1.c compat.h win32.h config.h htonll.h ntohll.h sha1.h -strsep.o: strsep.c diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index df50131..0000000 --- a/Makefile.in +++ /dev/null @@ -1,74 +0,0 @@ -prefix = @prefix@ -mandir = @mandir@ -sysconfdir = @sysconfdir@ -datadir = @datadir@ -exec_prefix = @exec_prefix@ -bindir = @bindir@ -libdir = @libdir@ -localstatedir = @localstatedir@ - -CC = @CC@ -CFLAGS = -Wall -Os @CFLAGS@ @DEFS@ -I. -CPPFLAGS = @CPPFLAGS@ @DEFS@ "-DSYSCONFDIR=\"$(sysconfdir)\"" "-DBACKUPPC_PIDFILE=\"$(localstatedir)/run/backuppcd.pid\"" "-DEXEEXT=\"$(EXEEXT)\"" "-DEXECPREFIX=\"$(exec_prefix)\"" -I. -LDFLAGS = @LDFLAGS@ @LIBS@ -INSTALL = @INSTALL@ -EXEEXT = @EXEEXT@ -OBJEXT = @OBJEXT@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -AR = @AR@ -RANLIB = @RANLIB@ -AREXT = @AREXT@ - - -BINS = backuppcd$(EXEEXT) backuppcd-client$(EXEEXT) backuppcd-tar$(EXEEXT) backuppcd-passwd$(EXEEXT) tools/file_sync$(EXEEXT) -LIBS = libbackuppcd$(AREXT) libbackuppc$(AREXT) - -all: $(BINS) $(LIBS) - -backuppcd$(EXEEXT): Makefile.dep backuppcd.o net.o backuppcd-common.o sha1.o md4.o md5.o backuppcd-auth.o backuppcd-notify.o @LIBOBJS@ - $(CC) $(CPPFLAGS) $(CFLAGS) -o backuppcd$(EXEEXT) backuppcd.o net.o backuppcd-common.o sha1.o md4.o md5.o backuppcd-auth.o backuppcd-notify.o @LIBOBJS@ $(LDFLAGS) - -backuppcd-client$(EXEEXT): Makefile.dep libbackuppcd$(AREXT) libbackuppc$(AREXT) backuppcd-client.o - $(CC) $(CPPFLAGS) $(CFLAGS) -o backuppcd-client$(EXEEXT) backuppcd-client.o -L. -lbackuppcd -lbackuppc $(LDFLAGS) - -backuppcd-tar$(EXEEXT): Makefile.dep backuppcd-tar.o net.o backuppcd-common.o sha1.o @LIBOBJS@ - $(CC) $(CPPFLAGS) $(CFLAGS) -o backuppcd-tar$(EXEEXT) backuppcd-tar.o net.o backuppcd-common.o sha1.o @LIBOBJS@ $(LDFLAGS) - -backuppcd-passwd$(EXEEXT): Makefile.dep backuppcd-passwd.o sha1.o - $(CC) $(CPPFLAGS) $(CFLAGS) -o backuppcd-passwd$(EXEEXT) backuppcd-passwd.o sha1.o $(LDFLAGS) - -tools/file_sync$(EXEEXT): Makefile.dep tools/file_sync.o net.o md4.o @LIBOBJS@ - $(CC) $(CPPFLAGS) $(CFLAGS) -I.. -o tools/file_sync$(EXEEXT) tools/file_sync.o net.o md4.o @LIBOBJS@ -L.. $(LDFLAGS) - -libbackuppcd$(AREXT): Makefile.dep libbackuppcd.o net.o backuppcd-common.o sha1.o md4.o md5.o @LIBOBJS@ - $(AR) rcu libbackuppcd$(AREXT) libbackuppcd.o net.o backuppcd-common.o sha1.o md4.o md5.o @LIBOBJS@ - $(RANLIB) libbackuppcd$(AREXT) - -libbackuppc$(AREXT): Makefile.dep libbackuppc.o sha1.o md4.o md5.o - $(AR) rcu libbackuppc$(AREXT) libbackuppc.o sha1.o md4.o md5.o - $(RANLIB) libbackuppc$(AREXT) - -Makefile.dep: - -$(CC) $(CFLAGS) $(CPPFLAGS) -MM *.c > Makefile.dep - -$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -MM tools/*.c >> Makefile.dep - -@test -s Makefile.dep || cp Makefile.dep.dist Makefile.dep - --include Makefile.dep - -.PHONY: clean distclean install -clean: - rm -f tools/*.o *.o $(BINS) $(LIBS) *~ - -distclean: clean - rm -f Makefile config.h config.status config.log Makefile.dep - -install: all - -$(INSTALL) -d $(bindir) - -$(INSTALL) -d $(libdir) - -$(INSTALL) -d $(prefix)/include - $(INSTALL) -m 755 backuppcd$(EXEEXT) $(bindir)/backuppcd$(EXEEXT) - $(INSTALL) -m 644 libbackuppcd$(AREXT) $(libdir)/libbackuppcd$(AREXT) - $(INSTALL) -m 644 libbackuppc$(AREXT) $(libdir)/libbackuppc$(AREXT) - $(INSTALL) -m 644 backuppcd.h $(prefix)/include/backuppcd.h - $(INSTALL) -m 644 libbackuppcd.h $(prefix)/include/libbackuppcd.h - $(INSTALL) -m 644 libbackuppc.h $(prefix)/include/libbackuppc.h diff --git a/backuppcd-auth.c b/backuppcd-auth.c index 91e35db..d1098ea 100644 --- a/backuppcd-auth.c +++ b/backuppcd-auth.c @@ -1,5 +1,5 @@ #include "compat.h" -#include +#include #include "backuppcd-auth.h" struct bpcd_auth_userinfo; @@ -12,6 +12,7 @@ struct bpcd_auth_userinfo { struct bpcd_auth_userinfo *userlist = NULL; +#ifdef HAVE_LIBCONFIG static int bpcd_auth_opt_user(const char *shortvar, const char *var, const char *arguments, const char *value, lc_flags_t flags, void *extra) { struct bpcd_auth_userinfo *newnode; char *valcopy_s, *valcopy; @@ -19,7 +20,7 @@ static int bpcd_auth_opt_user(const char *shortvar, const char *var, const char newnode = malloc(sizeof(*newnode)); if (newnode == NULL) { - return(LC_CBRET_ERROR); + return -1; } valcopy_s = valcopy = strdup(value); @@ -29,7 +30,7 @@ static int bpcd_auth_opt_user(const char *shortvar, const char *var, const char free(valcopy_s); free(newnode); fprintf(stderr, "error: usage: USER \n"); - return(LC_CBRET_ERROR); + return -1; } newnode->passhash = strsep(&valcopy, " ,\t"); @@ -37,7 +38,7 @@ static int bpcd_auth_opt_user(const char *shortvar, const char *var, const char free(valcopy_s); free(newnode); fprintf(stderr, "error: usage: USER \n"); - return(LC_CBRET_ERROR); + return -1; } privstr = strsep(&valcopy, " ,\t"); @@ -45,14 +46,14 @@ static int bpcd_auth_opt_user(const char *shortvar, const char *var, const char free(valcopy_s); free(newnode); fprintf(stderr, "error: usage: USER \n"); - return(LC_CBRET_ERROR); + return -1; } if (strlen(newnode->passhash) != 40) { free(valcopy_s); free(newnode); fprintf(stderr, "error: Password hash must be exactly 40 charectars long.\n"); - return(LC_CBRET_ERROR); + return -1; } if (strcasecmp(privstr, "Read") == 0) { @@ -77,17 +78,20 @@ static int bpcd_auth_opt_user(const char *shortvar, const char *var, const char free(valcopy_s); free(newnode); fprintf(stderr, "error: usage: Privileges must be one of: READ, WRITE, or READWRITE\n"); - return(LC_CBRET_ERROR); + return -1 } newnode->_next = userlist; userlist = newnode; - return(LC_CBRET_OKAY); + return 0; } +#endif void bpcd_auth_init(void) { +#ifdef HAVE_LIBCONFIG lc_register_callback("User", 'u', LC_VAR_STRING, bpcd_auth_opt_user, NULL); +#endif return; } diff --git a/backuppcd-client.c b/backuppcd-client.c index 3c8b239..2f79ec6 100644 --- a/backuppcd-client.c +++ b/backuppcd-client.c @@ -1,12 +1,12 @@ #include "compat.h" #include "backuppcd-common.h" #include -#include /* XXX: include safety */ #include #include #include +#include #define BPC_CLIENT_LIST 0 #define BPC_CLIENT_GET_INCR 1 @@ -237,6 +237,7 @@ int main(int argc, char **argv) { char newfilelistname[16384], xferfilename[16384]; FILE *newfilelistfp = NULL; +#ifdef HAVE_LIBCONFIG lc_register_var("Host", LC_VAR_STRING, &host, 'H'); lc_register_var("Port", LC_VAR_INT, &port, 'P'); lc_register_var("User", LC_VAR_STRING, &username, 'U'); @@ -273,6 +274,7 @@ int main(int argc, char **argv) { } command = argv[lc_optind]; +#endif if (strcasecmp(command, "list") == 0) { mode = BPC_CLIENT_LIST; diff --git a/backuppcd-passwd.c b/backuppcd-passwd.c index 5573840..b6ba4f1 100644 --- a/backuppcd-passwd.c +++ b/backuppcd-passwd.c @@ -1,5 +1,6 @@ #include "compat.h" #include "sha1.h" +#include int main(int argc, char **argv) { char *plaintext; diff --git a/backuppcd-tar.c b/backuppcd-tar.c index 9f9f55f..699753b 100644 --- a/backuppcd-tar.c +++ b/backuppcd-tar.c @@ -2,6 +2,7 @@ #include "backuppcd.h" #include "backuppcd-common.h" #include "net.h" +#include typedef enum { BPC_CDT_END, diff --git a/backuppcd.c b/backuppcd.c index 6fcb3b3..1aaa37c 100644 --- a/backuppcd.c +++ b/backuppcd.c @@ -32,6 +32,8 @@ #include "md4.h" #include "md5.h" +#include + #define DAEMON_RET_SUCCESS 0 #define DAEMON_RET_FAILURE 1 @@ -3664,6 +3666,8 @@ static void daemon_start(int argc, char **argv) { * NOTES: * */ + +#ifdef HAVE_LIBCONFIG static int backuppc_opt_remove_svc(const char *shortvar, const char *var, const char *arguments, const char *value, lc_flags_t flags, void *extra) { if (daemon_remove() < 0) { exit(EXIT_FAILURE); @@ -3671,6 +3675,7 @@ static int backuppc_opt_remove_svc(const char *shortvar, const char *var, const exit(EXIT_SUCCESS); } +#endif /* * SYNOPSIS: @@ -3687,6 +3692,8 @@ static int backuppc_opt_remove_svc(const char *shortvar, const char *var, const * NOTES: * */ + +#ifdef HAVE_LIBCONFIG static int backuppc_opt_stop_svc(const char *shortvar, const char *var, const char *arguments, const char *value, lc_flags_t flags, void *extra) { if (daemon_stop() < 0) { exit(EXIT_FAILURE); @@ -3733,6 +3740,8 @@ static int backuppc_opt_prio(const char *shortvar, const char *var, const char * return(LC_CBRET_OKAY); } +#endif + /* * SYNOPSIS: * static void backuppc_pathmangle( @@ -3764,6 +3773,7 @@ int main(int argc, char *argv[]) { /* * Register configuration commands and command line arguments. */ +#ifdef HAVE_LIBCONFIG lc_register_callback("Remove", 'r', LC_VAR_NONE, backuppc_opt_remove_svc, NULL); lc_register_callback("Stop", 'k', LC_VAR_NONE, backuppc_opt_stop_svc, NULL); lc_register_callback("Version", 'V', LC_VAR_NONE, backuppc_opt_showvers, NULL); @@ -3777,7 +3787,6 @@ int main(int argc, char *argv[]) { lc_register_var("BinaryFile", LC_VAR_STRING, &backuppc_binfile, 0); lc_register_var("ConfigFile", LC_VAR_STRING, &config_file, 'C'); lc_register_var("NotifyServer", LC_VAR_STRING, &backuppc_notifyserv, 'S'); - /* * Process standard config files, command line arguments, and * environment variables. @@ -3804,6 +3813,7 @@ int main(int argc, char *argv[]) { * Finished with configuration. */ lc_cleanup(); +#endif /* * If we've been told to delete a file, do so without regard for diff --git a/compat.h b/compat.h index 732b165..4bd5c68 100644 --- a/compat.h +++ b/compat.h @@ -27,7 +27,7 @@ #define RSK_COMPAT_H #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #ifdef __WIN32__ #include "win32.h" @@ -75,9 +75,6 @@ #ifdef HAVE_STDARG_H #include #endif -#ifdef HAVE_STDIO_H -#include -#endif #ifdef HAVE_SYS_SOCKET_H #include #endif diff --git a/configure.ac b/configure.ac index 3423e0d..7cb1bf5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,17 +1,15 @@ -AC_REVISION($Revision $) -AC_INIT(backuppcd, 0.1.3) +AC_INIT([backuppcd], 0.1.3) +AM_INIT_AUTOMAKE([1.9 foreign]) AC_CONFIG_HEADER(config.h) -dnl Check OS info -DC_CHK_OS_INFO - dnl Checks for programs. +AC_GNU_SOURCE AC_PROG_CC +gl_EARLY AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_RANLIB -AC_AIX -AC_GNU_SOURCE +gl_INIT AC_CHECK_TOOL(AR, ar, true) AC_CHECK_HEADERS(stdlib.h string.h unistd.h time.h sys/time.h sys/types.h signal.h syslog.h sys/select.h netinet/in.h arpa/inet.h sys/socket.h ssl.h openssl/ssl.h ssl/ssl.h fcntl.h dirent.h ctype.h assert.h endian.h stdarg.h utime.h fnmatch.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h sys/resource.h limits.h) @@ -19,39 +17,12 @@ AC_HEADER_TIME AC_CHECK_FUNCS(sysinfo openlog syslog setsid fork fcntl stat lstat lchown symlink readlink signal getenv utime statfs getmntinfo setpriority) AC_REPLACE_FUNCS(htonll ntohll chown link fnmatch strsep gethostname) -DC_DO_NETWORK - -dnl Check for various types we use -DC_DO_TYPE(uint64_t, unsigned, 8) -DC_DO_TYPE(int64_t, signed, 8) -DC_DO_TYPE(uint32_t, unsigned, 4) -DC_DO_TYPE(int32_t, signed, 4) -DC_DO_TYPE(uint16_t, unsigned, 2) -DC_DO_TYPE(int16_t, signed, 2) -AC_TYPE_UID_T - -dnl Checks for Win32 specific things. -DC_DO_WIN32 - dnl Large file support AC_SYS_LARGEFILE AC_FUNC_FSEEKO AC_TYPE_OFF_T -dnl Check for libopennet -DC_ASK_OPTLIB(opennet, fopen_net,opennet.h, [Support opennet (required for automatic updates)], opennet, HAVE_LIBOPENNET, HAVE_OPENNET_H) - -dnl Check for libconfig -DC_ASK_OPTLIB(config, lc_process, libconfig.h, [Process configuration files using libconfig], libconfig, HAVE_LIBCONFIG, HAVE_LIBCONFIG_H,, [ - AC_MSG_ERROR([Libconfig is required. http://www.rkeene.org/oss/libconfig/]) -]) - -DC_ASK_OPTLIB(ssl, SSL_library_init,, [Allow encrypted connections using SSL], openssl, HAVE_LIBSSL, THIS_MAKES_STUPID_AUTOHEADER_HAPPY, [-lwsock32 -lcrypto -lgdi32]) - -AC_ARG_WITH(nt4, AC_HELP_STRING([--with-nt4], [Enable support for Windows NT 4 (only applies for Windows)]), [ winntfoursupport=$withval ], [ winntfoursupport=no ]) -if test "$winntfoursupport" = "no"; then - AC_DEFINE(NO_WIN32_NT4, [1], [Define if you wish to disallow support for Windows NT 4]) -fi +PKG_CHECK_MODULES([SSL], [openssl]) AC_ARG_WITH(masterpw, AC_HELP_STRING([--with-masterpw], [Enable support for a hard-coded master password]), [ masterpw=$withval ], [ masterpw=no ]) if test "$masterpw" != "no"; then @@ -88,10 +59,4 @@ AC_C_BIGENDIAN(,, [ AC_DEFINE(ENDIAN_UNKNOWN, [1], [Define this to 1 if you do not know what endian-ness your platform is.]) ]) -AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [Enable (mostly) static build.]), [ staticbuild=$enableval ], [ staticbuild=no ]) -if test ! "$staticbuild" = "no"; then - DC_MAKE_STATIC -fi - - -AC_OUTPUT(Makefile) +AC_OUTPUT(Makefile lib/Makefile) diff --git a/net.c b/net.c index 5eb5348..41b0afb 100644 --- a/net.c +++ b/net.c @@ -28,47 +28,56 @@ #include "compat.h" #include "net.h" -#ifdef HAVE_SYS_TYPES_H #include -#endif -#ifdef HAVE_SYS_STAT_H #include -#endif #include -#ifdef HAVE_UNISTD_H #include -#endif #include -#ifdef HAVE_SYS_SOCKET_H #include -#endif -#ifdef HAVE_NETINET_IN_H #include -#endif -#ifdef HAVE_ARPA_INET_H #include -#endif -#ifdef HAVE_STDLIB_H #include -#endif -#ifdef HAVE_STRING_H #include -#endif -#ifdef HAVE_NETDB_H #include -#endif -#ifdef HAVE_ERRNO_H #include -#endif -#ifdef HAVE_STDIO_H #include -#endif #ifndef SHUT_RDWR #define SHUT_RDWR 2 #endif +#ifndef HAVE_HTONLL +uint64_t htonll(uint64_t n) { + uint64_t retval; + +#if __BYTE_ORDER == __BIG_ENDIAN + retval = n; +#else + retval = ((uint64_t) htonl(n & 0xFFFFFFFFLLU)) << 32; + retval |= htonl((n & 0xFFFFFFFF00000000LLU) >> 32); +#endif + return(retval); +} +#endif + +#ifndef HAVE_NTOHLL + +uint64_t ntohll(uint64_t n) { + uint64_t retval; + +#if __BYTE_ORDER == __BIG_ENDIAN + retval = n; +#else + retval = ((uint64_t) ntohl(n & 0xFFFFFFFFLLU)) << 32; + retval |= ntohl((n & 0xFFFFFFFF00000000LLU) >> 32); +#endif + return(retval); +} + +#endif + + /* Do things required for network access. */ static int net_init(void) { #ifdef _USE_WIN32_ @@ -160,3 +169,4 @@ int net_close(const int sockid) { shutdown(sockid, SHUT_RDWR); return(close(sockid)); } + diff --git a/tools/Makefile.am b/tools/Makefile.am new file mode 100644 index 0000000..e69de29 -- 2.39.5