diff --git a/.gitignore b/.gitignore index 5c4ca06..de66884 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,6 @@ missing stamp-h1 config.h *.o +*.a *~ pkg diff --git a/Makefile.am b/Makefile.am index e820c3b..4cd8b39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,20 +3,24 @@ ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE AM_CFLAGS = $(WARN_CFLAGS) -# application core -GLOBALHDR = include/pkgformat.h include/util.h include/pkgreader.h -GLOBALHDR += include/compressor.h include/command.h include/pkgwriter.h -GLOBALHDR += include/image_entry.h include/pkgio.h include/input_file.h +# helper libraries +libutil_a_SOURCES = lib/util/input_file.c lib/util/mkdir_p.c lib/util/util.c +libutil_a_SOURCES += include/util/util.h include/util/input_file.h -MAIN = main/pkg.c main/util.c main/compressor.c main/command.c main/pkgreader.c +# application core +GLOBALHDR = include/pkgformat.h include/pkgreader.h +GLOBALHDR += include/compressor.h include/command.h include/pkgwriter.h +GLOBALHDR += include/image_entry.h include/pkgio.h + +MAIN = main/pkg.c main/compressor.c main/command.c main/pkgreader.c MAIN += main/pkgwriter.c main/image_entry.c main/image_entry_sort.c -MAIN += main/mkdir_p.c main/pkgio_rd_image_entry.c main/pkg_unpack.c -MAIN += main/input_file.c main/dump_toc.c +MAIN += main/pkgio_rd_image_entry.c main/pkg_unpack.c main/dump_toc.c pkg_SOURCES = $(GLOBALHDR) $(MAIN) pkg_CFLAGS = $(AM_CFLAGS) -pkg_LDADD = +pkg_LDADD = libutil.a +noinst_LIBRARIES = libutil.a bin_PROGRAMS = pkg EXTRA_DIST = autogen.sh diff --git a/configure.ac b/configure.ac index 8ebfe14..b9be4ef 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,7 @@ AM_INIT_AUTOMAKE([foreign dist-xz subdir-objects]) AM_SILENT_RULES([yes]) AC_PROG_CC AC_PROG_CC_C99 +AC_PROG_RANLIB AC_PROG_INSTALL m4_ifndef([PKG_PROG_PKG_CONFIG], diff --git a/include/input_file.h b/include/util/input_file.h similarity index 100% rename from include/input_file.h rename to include/util/input_file.h diff --git a/include/util.h b/include/util/util.h similarity index 100% rename from include/util.h rename to include/util/util.h diff --git a/main/input_file.c b/lib/util/input_file.c similarity index 98% rename from main/input_file.c rename to lib/util/input_file.c index 30cc306..9ecfa6f 100644 --- a/main/input_file.c +++ b/lib/util/input_file.c @@ -3,7 +3,7 @@ #include #include -#include "input_file.h" +#include "util/input_file.h" static int prefetch_line(input_file_t *f) { diff --git a/main/mkdir_p.c b/lib/util/mkdir_p.c similarity index 96% rename from main/mkdir_p.c rename to lib/util/mkdir_p.c index 11b9de5..950ea4b 100644 --- a/main/mkdir_p.c +++ b/lib/util/mkdir_p.c @@ -5,7 +5,7 @@ #include #include -#include "util.h" +#include "util/util.h" int mkdir_p(const char *path) { diff --git a/main/util.c b/lib/util/util.c similarity index 98% rename from main/util.c rename to lib/util/util.c index 42ecd20..1df9273 100644 --- a/main/util.c +++ b/lib/util/util.c @@ -2,7 +2,7 @@ #include #include -#include "util.h" +#include "util/util.h" int canonicalize_name(char *filename) { diff --git a/main/cmd/dump/dump.h b/main/cmd/dump/dump.h index 0db98c6..9c69d2c 100644 --- a/main/cmd/dump/dump.h +++ b/main/cmd/dump/dump.h @@ -7,12 +7,13 @@ #include #include +#include "util/util.h" + #include "image_entry.h" #include "pkgformat.h" #include "pkgreader.h" #include "command.h" #include "pkgio.h" -#include "util.h" typedef enum { DUMP_TOC = 0x01, diff --git a/main/cmd/install/install.h b/main/cmd/install/install.h index c64f413..a0c852c 100644 --- a/main/cmd/install/install.h +++ b/main/cmd/install/install.h @@ -9,11 +9,12 @@ #include #include +#include "util/util.h" + #include "image_entry.h" #include "pkgreader.h" #include "command.h" #include "pkgio.h" -#include "util.h" enum { INSTALL_MODE_INSTALL = 0, diff --git a/main/cmd/pack/pack.h b/main/cmd/pack/pack.h index 8da895a..40da3d2 100644 --- a/main/cmd/pack/pack.h +++ b/main/cmd/pack/pack.h @@ -14,13 +14,14 @@ #include #include +#include "util/input_file.h" +#include "util/util.h" + #include "image_entry.h" -#include "input_file.h" #include "compressor.h" #include "pkgformat.h" #include "pkgwriter.h" #include "command.h" -#include "util.h" typedef struct dependency_t { struct dependency_t *next; diff --git a/main/cmd/unpack.c b/main/cmd/unpack.c index 31339b0..1e0e97d 100644 --- a/main/cmd/unpack.c +++ b/main/cmd/unpack.c @@ -4,10 +4,11 @@ #include #include +#include "util/util.h" + #include "pkgreader.h" #include "command.h" #include "pkgio.h" -#include "util.h" static const struct option long_opts[] = { { "root", required_argument, NULL, 'r' }, diff --git a/main/image_entry.c b/main/image_entry.c index 287a6d5..007cf9d 100644 --- a/main/image_entry.c +++ b/main/image_entry.c @@ -3,7 +3,6 @@ #include #include "image_entry.h" -#include "util.h" void image_entry_free(image_entry_t *ent) { diff --git a/main/pkg_unpack.c b/main/pkg_unpack.c index 0864f2a..86db2ab 100644 --- a/main/pkg_unpack.c +++ b/main/pkg_unpack.c @@ -7,7 +7,7 @@ #include #include "pkgio.h" -#include "util.h" +#include "util/util.h" static int create_hierarchy(int dirfd, image_entry_t *list) { diff --git a/main/pkgio_rd_image_entry.c b/main/pkgio_rd_image_entry.c index c83a850..6c94b12 100644 --- a/main/pkgio_rd_image_entry.c +++ b/main/pkgio_rd_image_entry.c @@ -4,7 +4,7 @@ #include #include "pkgio.h" -#include "util.h" +#include "util/util.h" static int read_extra(pkg_reader_t *pkg, image_entry_t *ent) { diff --git a/main/pkgreader.c b/main/pkgreader.c index db50413..fa4d2c8 100644 --- a/main/pkgreader.c +++ b/main/pkgreader.c @@ -7,7 +7,7 @@ #include #include -#include "util.h" +#include "util/util.h" #include "pkgreader.h" #include "compressor.h" diff --git a/main/pkgwriter.c b/main/pkgwriter.c index 4ca9c8f..4831b46 100644 --- a/main/pkgwriter.c +++ b/main/pkgwriter.c @@ -6,7 +6,7 @@ #include #include "pkgwriter.h" -#include "util.h" +#include "util/util.h" struct pkg_writer_t { const char *path;