]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libfrog/Makefile
libfrog: move crc32c code out of libxfs
[thirdparty/xfsprogs-dev.git] / libfrog / Makefile
index d5a82434f567b2d3d43a44b078433b7bd278da1e..707666e1d7df8c85f9b98a1269bb36c1848b6a30 100644 (file)
@@ -13,6 +13,7 @@ LT_AGE = 0
 CFILES = \
 avl64.c \
 convert.c \
+crc32.c \
 fsgeom.c \
 list_sort.c \
 paths.c \
@@ -23,6 +24,12 @@ topology.c \
 util.c \
 workqueue.c
 
+HFILES = \
+crc32defs.h \
+crc32table.h
+
+LSRCFILES += gen_crc32table.c
+
 CFILES += $(PKG_PLATFORM).c
 PCFILES = darwin.c freebsd.c irix.c linux.c
 LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
@@ -35,7 +42,25 @@ ifeq ($(HAVE_GETMNTINFO),yes)
 LCFLAGS += -DHAVE_GETMNTINFO
 endif
 
-default: ltdepend $(LTLIBRARY)
+LDIRT = gen_crc32table crc32table.h crc32selftest
+
+default: crc32selftest ltdepend $(LTLIBRARY)
+
+crc32table.h: gen_crc32table.c crc32defs.h
+       @echo "    [CC]     gen_crc32table"
+       $(Q) $(BUILD_CC) $(BUILD_CFLAGS) -o gen_crc32table $<
+       @echo "    [GENERATE] $@"
+       $(Q) ./gen_crc32table > crc32table.h
+
+# The selftest binary will return an error if it fails. This is made a
+# dependency of the build process so that we refuse to build the tools on broken
+# systems/architectures. Hence we make sure that xfsprogs will never use a
+# busted CRC calculation at build time and hence avoid putting bad CRCs down on
+# disk.
+crc32selftest: gen_crc32table.c crc32table.h crc32.c crc32defs.h
+       @echo "    [TEST]    CRC32"
+       $(Q) $(BUILD_CC) $(BUILD_CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@
+       $(Q) ./$@
 
 include $(BUILDRULES)