diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -22,9 +22,15 @@ AC_CONFIG_SRCDIR([src/server/distrend.c] AM_INIT_AUTOMAKE AC_PROG_CC +AC_PROG_LIBTOOL + +PKG_PROG_PKG_CONFIG(0.17.2) + +PKG_CHECK_MODULES(DISTLIBS, libconfuse >= 2.6) AC_CONFIG_FILES([Makefile src/Makefile +src/common/Makefile src/server/Makefile src/client/Makefile ]) diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,1 +1,1 @@ -SUBDIRS = server client +SUBDIRS = common server client diff --git a/src/client/Makefile.am b/src/client/Makefile.am --- a/src/client/Makefile.am +++ b/src/client/Makefile.am @@ -1,2 +1,4 @@ bin_PROGRAMS = distren -distrend_SORUCES = distren.c +distren_SOURCES = distren.c +distren_LDADD = @DISTLIBS_LIBS@ @top_builddir@/src/common/libdistren.la +distren_CXXFLAGS = @DISTLIBS_CFLAGS@ -I@top_srcdir@/src/common diff --git a/src/client/distren.c b/src/client/distren.c --- a/src/client/distren.c +++ b/src/client/distren.c @@ -1,6 +1,3 @@ -#include -#include - /* Copyright 2008 Nathan Phillip Brink, Ethan Zonca @@ -20,22 +17,9 @@ along with distren. If not, see . */ +#include + int main(int argc, char *argv[]) { - - /* Conf File Parser */ - cfg_opt_t opts[] = - { - CFG_STR("test", "mneh", CFGF_NONE), - CFG_END() - }; - cfg_t *cfg; - cfg = cfg_init(opts, CFGF_NONE); - if(cfg_parse(cfg, "distren.conf") == CFG_PARSE_ERROR) - return 1; -/* End Conf File Parser */ - - - cfg_free(cfg); return 0; } diff --git a/src/common/Makefile.am b/src/common/Makefile.am new file mode 100644 --- /dev/null +++ b/src/common/Makefile.am @@ -0,0 +1,6 @@ +pkglib_LTLIBRARIES = libdistren.la + +libdistren_la_SOURCES = options.c options.h +#evidently the following should not be LDADD, but LDFLAGS because automake doesn't like the idea of LDADD for libraries for some reason... or I am very confused +libdistren_la_LIBADD = @DISTLIBS_LIBS@ +libdistren_la_CXXFLAGS = @DISTLIBS_CFLAGS@ diff --git a/src/common/options.c b/src/common/options.c new file mode 100644 --- /dev/null +++ b/src/common/options.c @@ -0,0 +1,52 @@ +/* + Copyright 2008 Nathan Phillip Brink, Ethan Zonca + + This file is a part of distren. + + Distren is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Distren is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with distren. If not, see . +*/ + +#include "options.h" + +#include + +int genericfunc() +{ + + /* Conf File Parser */ + cfg_opt_t opts[] = + { + CFG_STR("test", "mneh", CFGF_NONE), + CFG_END() + }; + cfg_t *cfg; + cfg = cfg_init(opts, CFGF_NONE); + if(cfg_parse(cfg, "distren.conf") == CFG_PARSE_ERROR) + return 1; +/* End Conf File Parser */ + + + cfg_free(cfg); + + cfg = cfg_init(opts, CFGF_NONE); + if(cfg_parse(cfg, "distrend.conf") == CFG_PARSE_ERROR) + return 1; +/* End Conf File Parser */ + +printf("Conf File Test", cfg_getstr(cfg, "test")); + + + cfg_free(cfg); + +} diff --git a/src/common/options.h b/src/common/options.h new file mode 100644 --- /dev/null +++ b/src/common/options.h @@ -0,0 +1,19 @@ +/* + Copyright 2008 Nathan Phillip Brink, Ethan Zonca + + This file is a part of distren. + + Distren is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Distren is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with distren. If not, see . +*/ + diff --git a/src/server/Makefile.am b/src/server/Makefile.am --- a/src/server/Makefile.am +++ b/src/server/Makefile.am @@ -1,2 +1,4 @@ bin_PROGRAMS = distrend -distrend_SORUCES = distrend.c +distrend_SOURCES = distrend.c +distrend_LDADD = @DISTLIBS_LIBS@ @top_builddir@/src/common/libdistren.la +distrend_CXXFLAGS = @DISTLIBS_CFLAGS@ -I@top_srcdir@/src/common diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -1,5 +1,3 @@ -#include -#include /* Copyright 2008 Nathan Phillip Brink, Ethan Zonca @@ -19,24 +17,12 @@ along with distren. If not, see . */ +#include + + + int main(int argc, char *argv[]) { -/* Conf File Parser */ - cfg_opt_t opts[] = - { - CFG_STR("test", "mneh", CFGF_NONE), - CFG_END() - }; - cfg_t *cfg; - cfg = cfg_init(opts, CFGF_NONE); - if(cfg_parse(cfg, "distrend.conf") == CFG_PARSE_ERROR) - return 1; -/* End Conf File Parser */ - -printf("Conf File Test", cfg_getstr(cfg, "test")); - - - cfg_free(cfg); return 0; }