diff --git a/Makefile b/Makefile index bb7a216..54df0ea 100644 --- a/Makefile +++ b/Makefile @@ -27,17 +27,9 @@ NAME = libite PKG = $(NAME)-$(VERSION) ARCHIVE = $(PKG).tar.xz -CC ?= $(CROSS)gcc -AR ?= $(CROSS)ar -STRIP ?= $(CROSS)strip -INSTALL := install --backup=off -STRIPINST := $(INSTALL) -s --strip-program=$(CROSS)strip -m 0755 - CFLAGS += -fPIC CFLAGS += -Os -CPPFLAGS += -D_GNU_SOURCE CPPFLAGS += -W -Wall -ARFLAGS = crus DISTFILES = README LICENSE HEADERS = lite.h @@ -54,12 +46,6 @@ SYMLIB = $(LIBNAME).so STATICLIB = $(LIBNAME).a TARGET = $(STATICLIB) $(SOLIB) -# Default install paths -prefix ?= /usr/local -libdir ?= $(prefix)/lib -datadir ?= $(prefix)/share/doc/$(LIBNAME) -incdir ?= $(prefix)/include - # This magic trick looks like a comment, but works on BSD PMake #include include rules.mk @@ -69,6 +55,7 @@ test: $(MAKE) -f copyfile.mk $(MAKE) -f dir.mk $(MAKE) -f fsendfile.mk + $(MAKE) -f makepath.mk $(MAKE) -f pidfilefn.mk $(MAKE) -f rsync.mk diff --git a/makepath.c b/makepath.c index 7cbd6cc..00e5d68 100644 --- a/makepath.c +++ b/makepath.c @@ -55,7 +55,7 @@ int makepath(char *dir) /********************************* UNIT TESTS ************************************/ #ifdef UNITTEST -#include +#include "lite.h" int checkpath(char *dir) { @@ -63,7 +63,8 @@ int checkpath(char *dir) struct stat sb; snprintf(tmp, sizeof(tmp), "ls -ld %s", dir); - system(tmp); + if (system(tmp)) + perror("system"); if (!stat(dir, &sb) && S_ISDIR(sb.st_mode)) return 0; @@ -98,11 +99,11 @@ int main(void) NULL }; - fprintf(stderr, "Testing makepath() ...\n"); + printf("Testing makepath() ...\n"); for (i = 0; list[i] && !ret; i++) ret = test_makepath(list[i]); - fprintf(stderr, "\nCleaning up ...\n"); + printf("\nCleaning up ...\n"); for (i = 0; list[i]; i++) rmdir(list[i]); @@ -112,7 +113,7 @@ int main(void) /** * Local Variables: - * compile-command: "gcc -g -o unittest -D_GNU_SOURCE -DUNITTEST makepath.c && ./unittest" + * compile-command: "make V=1 -f makepath.mk" * version-control: t * indent-tabs-mode: t * c-file-style: "linux" diff --git a/makepath.mk b/makepath.mk new file mode 100644 index 0000000..26d7b47 --- /dev/null +++ b/makepath.mk @@ -0,0 +1,4 @@ +OBJS = +TARGET = makepath.test clean + +include rules.mk diff --git a/rules.mk b/rules.mk index f4df0c8..7a2fc8c 100644 --- a/rules.mk +++ b/rules.mk @@ -3,6 +3,15 @@ # Figure out root of library, unless used as submodule ROOTDIR ?= $(shell pwd) +CC ?= $(CROSS)gcc +AR ?= $(CROSS)ar +STRIP ?= $(CROSS)strip +INSTALL := install --backup=off +STRIPINST := $(INSTALL) -s --strip-program=$(CROSS)strip -m 0755 + +CPPFLAGS += -D_GNU_SOURCE +ARFLAGS = crus + # Default to silent build, use V=1 to get verbose mode. ifeq ($V,1) Q = @@ -16,7 +25,11 @@ REDIRECT = >/dev/null MAKEFLAGS = --no-print-directory --silent endif -export ROOTDIR Q PRINT MAKEFLAGS +# Default install paths +prefix ?= /usr/local +libdir ?= $(prefix)/lib +datadir ?= $(prefix)/share/doc/$(LIBNAME) +incdir ?= $(prefix)/include # Pretty printing and GCC -M for auto dep files %.o: %.c @@ -29,7 +42,7 @@ export ROOTDIR Q PRINT MAKEFLAGS %.test: %.c $(PRINT) " TEST $(subst $(ROOTDIR)/,,$(shell pwd)/)$(@:.test=)\n" - $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -DUNITTEST $< $(OBJS) + $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -g -o $@ -DUNITTEST $< $(OBJS) $(Q)@./$@ $(REDIRECT)