Index: lib/libdpv/GNUmakefile =================================================================== --- /dev/null +++ lib/libdpv/GNUmakefile @@ -0,0 +1,59 @@ +# $FrauBSD$ + +LIB= dpv +SHLIB_MAJOR= 0 +INCS= dpv.h +MAN= dpv.3 + +CFLAGS= -fPIC -Wall -I. -I/usr/include/dialog +LIBS= -lc -ldialog -lfigpar -lncurses +LDFLAGS= -shared $(LIBS) + +PREFIX= /usr +LIBDIR= $(PREFIX)/lib +INCDIR= $(PREFIX)/include +DATADIR= $(PREFIX)/share +MANDIR= $(DATADIR)/man + +SRCS= dpv.c dprompt.c dialogrc.c dialog_util.c status.c util.c +OBJS= dpv.o dprompt.o dialogrc.o dialog_util.o status.o util.o + +all: GNUmakefile lib$(LIB).so.$(SHLIB_MAJOR) $(MAN).gz + +lib$(LIB).so.$(SHLIB_MAJOR): $(OBJS) + $(CC) $(OBJS) $(LDFLAGS) -o $(@) + +$(MAN).gz: $(MAN) + gzip -c $(MAN) > $(@) + +$(OBJS): $(SRCS) + @eval2(){ echo "$$*"; eval "$$@"; }; \ + set -e; \ + for src in $(?); do \ + eval2 $(CC) $(CFLAGS) -c $$src -o $${src%.*}.o; \ + done + +$(SRCS): $(INCS) + touch $(@) + +install: lib$(LIB).so.$(SHLIB_MAJOR) + install -d -o 0 -g 0 -m 755 $(LIBDIR) $(MANDIR)/man3 + install -C -o 0 -g 0 -m 444 lib$(LIB).so.$(SHLIB_MAJOR) $(LIBDIR)/ + ln -sf lib$(LIB).so.$(SHLIB_MAJOR) $(LIBDIR)/lib$(LIB).so + install -C -o 0 -g 0 -m 444 $(INCS) $(INCDIR)/ + install -C -o 0 -g 0 -m 444 $(MAN).gz $(MANDIR)/man3/ + +uninstall: + rm -f $(LIBDIR)/lib$(LIB).so.$(SHLIB_MAJOR) $(LIBDIR)/lib$(LIB).so + rm -f $(INCDIR)/$(INCS) $(MANDIR)/man3/$(MAN).gz + +clean: + rm -f $(OBJS) $(MAN).gz $(MAN).cat.gz + rm -f $(LIB).po $(LIB).So lib$(LIB).so lib$(LIB).so.$(SHLIB_MAJOR) + rm -f lib$(LIB).so.$(SHLIB_MAJOR).full lib$(LIB).so.$(SHLIB_MAJOR).debug + rm -f lib$(LIB).a lib$(LIB)_p.a + +cleandepend: + rm -f .depend .depend.* GPATH GRTAGS GSYMS GTAGS + +cleandir: clean cleandepend Index: lib/libdpv/dialog_util.c =================================================================== --- lib/libdpv/dialog_util.c +++ lib/libdpv/dialog_util.c @@ -25,7 +25,9 @@ */ #include +#ifdef __FBSDID __FBSDID("$FreeBSD$"); +#endif #include @@ -35,7 +37,11 @@ #include #include #include +#ifdef __linux__ +#include +#else #include +#endif #include #include #include Index: lib/libdpv/dialogrc.c =================================================================== --- lib/libdpv/dialogrc.c +++ lib/libdpv/dialogrc.c @@ -25,7 +25,9 @@ */ #include +#ifdef __FBSDID __FBSDID("$FreeBSD$"); +#endif #include @@ -39,6 +41,7 @@ #include #include "dialogrc.h" +#include "dpv_private.h" #define STR_BUFSIZE 255 Index: lib/libdpv/dprompt.h =================================================================== --- lib/libdpv/dprompt.h +++ lib/libdpv/dprompt.h @@ -32,6 +32,7 @@ #include #include "dpv.h" +#include "dpv_private.h" /* Display characteristics */ #define ENV_MSG_DONE "msg_done" Index: lib/libdpv/dprompt.c =================================================================== --- lib/libdpv/dprompt.c +++ lib/libdpv/dprompt.c @@ -25,14 +25,24 @@ */ #include +#ifdef __FBSDID __FBSDID("$FreeBSD$"); +#endif #include +#ifndef _BSD_SOURCE #define _BSD_SOURCE /* to get dprintf() prototype in stdio.h below */ +#endif #include #include +#ifdef __linux__ +#include +#elif !defined(__APPLE__) #include +#else +#include +#endif #include #include #include @@ -44,7 +54,6 @@ #include "dialogrc.h" #include "dprompt.h" #include "dpv.h" -#include "dpv_private.h" #define FLABEL_MAX 1024 @@ -584,8 +593,15 @@ estext_rsize, ""); break; case DPROMPT_DETAILS: /* Past/Current file(s) */ +#ifdef __linux__ + humanize_number(human, pbar_size + 2, fp->read, " ", + HN_AUTOSCALE, HN_NOSPACE | HN_DIVISOR_1000); +#elif !defined(__APPLE__) humanize_number(human, pbar_size + 2, fp->read, "", HN_AUTOSCALE, HN_NOSPACE | HN_DIVISOR_1000); +#else + snprintf(human, sizeof(human), "%"PRIu64, fp->read); +#endif /* Calculate center alignment */ hlen = (int)strlen(human); Index: lib/libdpv/dpv.h =================================================================== --- lib/libdpv/dpv.h +++ lib/libdpv/dpv.h @@ -31,6 +31,8 @@ #include +#include + #ifndef TRUE #define TRUE 1 #endif Index: lib/libdpv/dpv.c =================================================================== --- lib/libdpv/dpv.c +++ lib/libdpv/dpv.c @@ -25,7 +25,9 @@ */ #include +#ifdef __FBSDID __FBSDID("$FreeBSD$"); +#endif #include #include @@ -37,7 +39,11 @@ #include #include #include +#ifdef __linux__ +#include +#else #include +#endif #include #include #include Index: lib/libdpv/dpv_private.h =================================================================== --- lib/libdpv/dpv_private.h +++ lib/libdpv/dpv_private.h @@ -31,6 +31,8 @@ #include +#include + /* Debugging */ extern uint8_t debug; @@ -64,4 +66,28 @@ DPROMPT_MINIMAL, /* whitespace */ }; +/* compatibility */ +#ifndef __DECONST +# define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) +#endif +#ifndef __unused +# ifdef __GNUC__ +# define __unused __attribute__((unused)) +# else +# define __unused +# endif +#endif +#ifndef restrict +# ifdef __GNUC__ +# define restrict __restrict__ +# elif defined(__SUNPRO_CC) && defined(__RESTRICT) +# define restrict __RESTRICT +# else +# define restrict +# endif +#endif +#ifdef __APPLE__ +# define strtonum(nptr,minval,maxval,errstr) strtoll(nptr,(char **)NULL,10) +#endif + #endif /* !_DPV_PRIVATE_H_ */ Index: lib/libdpv/status.c =================================================================== --- lib/libdpv/status.c +++ lib/libdpv/status.c @@ -25,7 +25,9 @@ */ #include +#ifdef __FBSDID __FBSDID("$FreeBSD$"); +#endif #include #include Index: lib/libdpv/util.c =================================================================== --- lib/libdpv/util.c +++ lib/libdpv/util.c @@ -25,15 +25,22 @@ */ #include +#ifdef __FBSDID __FBSDID("$FreeBSD$"); +#endif #include #include #include +#ifdef __linux__ +#include +#else #include +#endif #include #include +#include "dpv_private.h" #include "util.h" extern char **environ;