summaryrefslogtreecommitdiff
path: root/Makefile.pre-autotools
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-03-22 13:55:30 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-03-22 15:32:12 +0000
commitc7a4f00fd701c7e1bd071c7a5aa8199f96833823 (patch)
tree9f3d83669527a1691fd2ad9e687671ba472f6bc4 /Makefile.pre-autotools
parent55551592563c26d28c62d055e3ebc657ad687a0a (diff)
downloadtbdiff-c7a4f00fd701c7e1bd071c7a5aa8199f96833823.tar.gz
Switch to a shared tbdiff library and make this an autotools project.
This commit converts tbdiff to being an autotools-based project. This means that we now support the usual autoreconf -i && ./configure && make && make install process, plus we provide 'make check' for the tbdiff test suite. The tbdiff library is now build as a shared library and is also installed into the system for others to use. The library is libtool-versioned and ships a pkg-config file (tbdiff-1.pc). The headers were adjusted so that only tbdiff/tbdiff.h may be included directly; all others are considered internal. The tbdiff-create and tbdiff-deploy tools were changed to include this header file. The tbdiff library is still GPL, not LGPL. We might want to change this in the future. Thanks to switching to autotools we now have a way to make releases by means of 'make dist' and 'make distcheck'. Unfortunately, the latter currently fails, probably due to something being missing in tbdiff/Makefile.am.
Diffstat (limited to 'Makefile.pre-autotools')
-rw-r--r--Makefile.pre-autotools57
1 files changed, 57 insertions, 0 deletions
diff --git a/Makefile.pre-autotools b/Makefile.pre-autotools
new file mode 100644
index 0000000..da4a3c1
--- /dev/null
+++ b/Makefile.pre-autotools
@@ -0,0 +1,57 @@
+.PHONY: all
+
+CC := gcc
+
+OPT ?= -O2
+
+DESTDIR = /
+PREFIX = /usr
+
+DEPLOY=tbdiff-deploy
+CREATE=tbdiff-create
+
+CFLAGS ?=
+CFLAGS += -g
+CFLAGS += -Wall -Wextra -Werror -Wno-unused-result $(OPT)
+
+SHARED_SRC := libtbd_stat.c libtbd_xattrs.c libtbd_io.c
+DEPLOY_SRC := tbdiff_deploy.c libtbd_create.c
+CREATE_SRC := tbdiff_create.c libtbd_apply.c
+
+DEPLOY_OBJ := $(patsubst %.c,%.o,$(SHARED_SRC) $(DEPLOY_SRC))
+CREATE_OBJ := $(patsubst %.c,%.o,$(SHARED_SRC) $(CREATE_SRC))
+
+all: $(DEPLOY) $(CREATE)
+
+$(DEPLOY): tbdiff_deploy.o libtbd_apply.o libtbd_stat.o libtbd_xattrs.o libtbd_io.o
+ $(CC) $(LDFLAGS) -o $@ $^
+
+$(CREATE): tbdiff_create.o libtbd_create.o libtbd_stat.o libtbd_xattrs.o libtbd_io.o
+ $(CC) $(LDFLAGS) -o $@ $^
+
+%.o: %.c
+ $(CC) $(CFLAGS) -MMD -o $@ -c $<
+
+ifeq (,$(findstring clean,$(MAKECMDGOALS)))
+-include $(patsubst %.c,%.d,$(SHARED_SRC) $(DEPLOY_SRC) $(CREATE_SRC))
+endif
+
+install: $(DEPLOY) $(CREATE)
+ install -m 755 -d $(DESTDIR)$(PREFIX)/bin
+ install $(CREATE) $(DESTDIR)$(PREFIX)/bin
+ install $(DEPLOY) $(DESTDIR)$(PREFIX)/bin
+
+uninstall:
+ rm -rf $(DESTDIR)/$(DEPLOY)
+ rm -rf $(DESTDIR)/$(CREATE)
+
+test:
+ cd tests && ./run_tests.sh && fakeroot -- ./cross_plat.sh && cd ..
+
+.PHONY: clean
+
+check:
+ cd tests && ./run_tests.sh && cd ..
+
+clean:
+ rm -f $(DEPLOY) $(CREATE) *.o *.d