diff --git a/Makefile b/Makefile index e9c2b25..c2e2c1a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ SUBDIR= psqldbadm psqluseradm -.include +all: + for dir in ${SUBDIR}; do (cd $$dir; make); done diff --git a/misc.c b/misc.c new file mode 100644 index 0000000..9adae5d --- /dev/null +++ b/misc.c @@ -0,0 +1,12 @@ +#include + +char * +strlcpy(char *dest, char *src, size_t n) +{ + char *p; + + p = strncpy(dest, src, n); + dest[n-1] = '\0'; + + return p; +} diff --git a/psqldbadm/Makefile b/psqldbadm/Makefile index 60cdbc3..9d619c6 100644 --- a/psqldbadm/Makefile +++ b/psqldbadm/Makefile @@ -1,13 +1,11 @@ -.PATH: ${.CURDIR} ${.CURDIR}/../psqluseradm/ +#.PATH: .:../psqluseradm/ -CFLAGS= -I/usr/local/include -LDFLAGS=-L/usr/local/lib -lpq +CFLAGS= -I`pg_config --includedir` +LDFLAGS=-lpq PROG= psql-dbadm -SRCS= psql-dbadm.c psqladm.c +OBJS= psql-dbadm.o ../psqluseradm/psqladm.o ../misc.o -NO_MAN= true +${PROG}: ${OBJS} + gcc -o ${PROG} ${OBJS} ${LDFLAGS} -WARNS?= 6 - -.include diff --git a/psqluseradm/Makefile b/psqluseradm/Makefile index cb492f7..faf9ac9 100644 --- a/psqluseradm/Makefile +++ b/psqluseradm/Makefile @@ -1,11 +1,10 @@ -CFLAGS= -I/usr/local/include -LDFLAGS=-L/usr/local/lib -lpq +CFLAGS= -I`pg_config --includedir` +LDFLAGS=-lpq PROG= psql-useradm -SRCS= psql-useradm.c psqladm.c +OBJS= psql-useradm.o psqladm.o ../misc.o -NO_MAN= true +${PROG}: ${OBJS} + gcc -o ${PROG} ${OBJS} ${LDFLAGS} -WARNS?= 6 -.include