Commit 079b2f6564ee7fbd71071aedde0c3c317b985d46

Stefan Sperling 2018-09-08T16:56:10

add a Makefile hierarchy which builds the whole show

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..103d8cd
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+SUBDIR = libexec got tog regress
+
+.include <bsd.subdir.mk>
diff --git a/Makefile.inc b/Makefile.inc
new file mode 100644
index 0000000..894e86c
--- /dev/null
+++ b/Makefile.inc
@@ -0,0 +1,13 @@
+GOT_LIBEXECDIR = ${HOME}/bin
+
+CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
+#CFLAGS += -DGOT_PACK_NO_MMAP
+#CFLAGS += -DGOT_NO_OBJ_CACHE
+
+.if defined(PROFILE)
+CC = gcc
+CPPFLAGS += -DPROFILE
+DEBUG = -O0 -pg
+.else
+DEBUG = -O0 -g
+.endif
diff --git a/got/Makefile b/got/Makefile
index 2f31fc4..e8932c8 100644
--- a/got/Makefile
+++ b/got/Makefile
@@ -6,21 +6,10 @@ SRCS=		got.c blame.c commit_graph.c delta.c diff.c diffoffset.c \
 		object_idset.c object_parse.c opentemp.c path.c pack.c \
 		privsep.c reference.c repository.c sha1.c worktree.c inflate.c
 
-GOT_LIBEXECDIR = ${HOME}/bin
 CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib \
 	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
-.if defined(PROFILE)
-CC = gcc
-CPPFLAGS += -DPROFILE
-DEBUG = -O0 -pg
-.else
-DEBUG = -O0 -g
-.endif
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 # For now, default to installing binary in ~/bin
 GROUP!=id -g -n
diff --git a/libexec/Makefile b/libexec/Makefile
new file mode 100644
index 0000000..33f7998
--- /dev/null
+++ b/libexec/Makefile
@@ -0,0 +1,3 @@
+SUBDIR = got-read-blob got-read-commit got-read-object got-read-tree
+
+.include <bsd.subdir.mk>
diff --git a/libexec/Makefile.inc b/libexec/Makefile.inc
new file mode 100644
index 0000000..01b5f23
--- /dev/null
+++ b/libexec/Makefile.inc
@@ -0,0 +1 @@
+.include "../Makefile.inc"
diff --git a/libexec/got-read-blob/Makefile b/libexec/got-read-blob/Makefile
index 261f1cc..564acd4 100644
--- a/libexec/got-read-blob/Makefile
+++ b/libexec/got-read-blob/Makefile
@@ -7,23 +7,12 @@ SRCS=		got-read-blob.c delta.c error.c inflate.c object_parse.c \
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
-.if defined(PROFILE)
-CC = gcc
-CPPFLAGS += -DPROFILE
-DEBUG = -O0 -pg
-.else
-DEBUG = -O0 -g
-.endif
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 # For now, default to installing binary in ~/bin
-LIBEXECDIR = ${HOME}/bin
 GROUP!=id -g -n
 install:
 	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${LIBEXECDIR}/${PROG}
+	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
 
 # Don't install man pages yet
 NOMAN = Yes
diff --git a/libexec/got-read-commit/Makefile b/libexec/got-read-commit/Makefile
index fe09198..1470f72 100644
--- a/libexec/got-read-commit/Makefile
+++ b/libexec/got-read-commit/Makefile
@@ -7,23 +7,12 @@ SRCS=		got-read-commit.c delta.c error.c inflate.c object_parse.c \
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
-.if defined(PROFILE)
-CC = gcc
-CPPFLAGS += -DPROFILE
-DEBUG = -O0 -pg
-.else
-DEBUG = -O0 -g
-.endif
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 # For now, default to installing binary in ~/bin
-LIBEXECDIR = ${HOME}/bin
 GROUP!=id -g -n
 install:
 	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${LIBEXECDIR}/${PROG}
+	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
 
 # Don't install man pages yet
 NOMAN = Yes
diff --git a/libexec/got-read-object/Makefile b/libexec/got-read-object/Makefile
index 71a0ac8..9cb00e1 100644
--- a/libexec/got-read-object/Makefile
+++ b/libexec/got-read-object/Makefile
@@ -7,23 +7,12 @@ SRCS=		got-read-object.c delta.c error.c inflate.c object_parse.c \
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
-.if defined(PROFILE)
-CC = gcc
-CPPFLAGS += -DPROFILE
-DEBUG = -O0 -pg
-.else
-DEBUG = -O0 -g
-.endif
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 # For now, default to installing binary in ~/bin
-LIBEXECDIR = ${HOME}/bin
 GROUP!=id -g -n
 install:
 	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${LIBEXECDIR}/${PROG}
+	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
 
 # Don't install man pages yet
 NOMAN = Yes
diff --git a/libexec/got-read-tree/Makefile b/libexec/got-read-tree/Makefile
index c6079e3..600541d 100644
--- a/libexec/got-read-tree/Makefile
+++ b/libexec/got-read-tree/Makefile
@@ -7,23 +7,12 @@ SRCS=		got-read-tree.c delta.c error.c inflate.c object_parse.c \
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
 DPADD = ${LIBZ} ${LIBUTIL}
-.if defined(PROFILE)
-CC = gcc
-CPPFLAGS += -DPROFILE
-DEBUG = -O0 -pg
-.else
-DEBUG = -O0 -g
-.endif
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 # For now, default to installing binary in ~/bin
-LIBEXECDIR = ${HOME}/bin
 GROUP!=id -g -n
 install:
 	${INSTALL} ${INSTALL_COPY} -o ${USER} -g ${GROUP} \
-	-m ${BINMODE} ${PROG} ${LIBEXECDIR}/${PROG}
+	-m ${BINMODE} ${PROG} ${GOT_LIBEXECDIR}/${PROG}
 
 # Don't install man pages yet
 NOMAN = Yes
diff --git a/regress/Makefile b/regress/Makefile
new file mode 100644
index 0000000..31e2dae
--- /dev/null
+++ b/regress/Makefile
@@ -0,0 +1,3 @@
+SUBDIR = delta idset repository worktree
+
+.include <bsd.subdir.mk>
diff --git a/regress/Makefile.inc b/regress/Makefile.inc
new file mode 100644
index 0000000..01b5f23
--- /dev/null
+++ b/regress/Makefile.inc
@@ -0,0 +1 @@
+.include "../Makefile.inc"
diff --git a/regress/delta/Makefile b/regress/delta/Makefile
index 4f7ab90..f616387 100644
--- a/regress/delta/Makefile
+++ b/regress/delta/Makefile
@@ -5,8 +5,6 @@ SRCS = delta.c error.c opentemp.c path.c inflate.c delta_test.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lz
-DEBUG = -O0 -g
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
 
 NOMAN = yes
 
diff --git a/regress/idset/Makefile b/regress/idset/Makefile
index b4eade2..2b4ff87 100644
--- a/regress/idset/Makefile
+++ b/regress/idset/Makefile
@@ -7,8 +7,6 @@ SRCS = error.c object.c privsep.c sha1.c pack.c inflate.c path.c opentemp.c \
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
-DEBUG = -O0 -g
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
 
 NOMAN = yes
 
diff --git a/regress/repository/Makefile b/regress/repository/Makefile
index 2ee86e3..babe389 100644
--- a/regress/repository/Makefile
+++ b/regress/repository/Makefile
@@ -6,14 +6,9 @@ SRCS = path.c repository.c error.c reference.c object.c object_idcache.c \
 	pack.c privsep.c delta.c fileindex.c worktree.c inflate.c \
 	repository_test.c
 
-GOT_LIBEXECDIR = ${HOME}/bin
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib \
 	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
 LDADD = -lutil -lz
-DEBUG = -O0 -g
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 NOMAN = yes
 
diff --git a/regress/worktree/Makefile b/regress/worktree/Makefile
index 1819712..c4b341e 100644
--- a/regress/worktree/Makefile
+++ b/regress/worktree/Makefile
@@ -5,14 +5,9 @@ SRCS = worktree.c repository.c object.c object_idcache.c object_idset.c \
 	object_parse.c opentemp.c path.c error.c reference.c sha1.c pack.c \
 	privsep.c delta.c inflate.c fileindex.c worktree_test.c
 
-GOT_LIBEXECDIR = ${HOME}/bin
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib \
 	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
 LDADD = -lutil -lz
-DEBUG = -O0 -g
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 NOMAN = yes
 
diff --git a/tog/Makefile b/tog/Makefile
index a3a05e3..ae6ee69 100644
--- a/tog/Makefile
+++ b/tog/Makefile
@@ -7,21 +7,10 @@ SRCS=		tog.c blame.c commit_graph.c delta.c diff.c diffoffset.c \
 		privsep.c reference.c repository.c sha1.c worktree.c \
 		utf8.c inflate.c
 
-GOT_LIBEXECDIR = ${HOME}/bin
 CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib \
 	-DGOT_LIBEXECDIR=${GOT_LIBEXECDIR}
 LDADD = -lpanel -lncursesw -lutil -lz -lpthread
 DPADD = ${LIBZ} ${LIBUTIL}
-.if defined(PROFILE)
-CC = gcc
-CPPFLAGS += -DPROFILE
-DEBUG = -O0 -pg
-.else
-DEBUG = -O0 -g
-.endif
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
-#CFLAGS += -DGOT_PACK_NO_MMAP
-#CFLAGS += -DGOT_NO_OBJ_CACHE
 
 # For now, default to installing binary in ~/bin
 GROUP!=id -g -n