Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ VERSION=2.11.3

OS := $(shell uname)
ifeq ($(OS),Darwin) # MacOS X
FIND=gfind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gfind is not installed by default on MacOS X. It would be better for us to use the POSIX find syntax.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from the MANIFEST.new make target. It looks like there's no direct equivalent with BSD find, but the same manifest format can be generated portably using (somewhat lengthy) shell scripting:

MANIFEST.new:
	rm -rf tmp
	$(MAKE) install prefix=/usr DESTDIR=$(PWD)/tmp
	find tmp/usr -mindepth 1 | cut -d / -f 3- | while read -r file; do
	  if [ -L "$file" ]; then
	    printf "%s -> %s\n" "$file" "`readlink "$file"`";
	  elif [ -d "$file" ]; then
	    printf "%s/\n" "$file";
	  else
	    printf "%s\n" "$file"
	  fi
	done | LC_ALL=C sort
	rm -rf tmp

Let me know if you'd like me to go ahead and make that change.

However reading this made me realize that the install test added in this PR is circuitous since the manifest is generated by running make install in the first place, so I'll just remove that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's fine to remove the install test and leave MANIFEST.new as-is. It's only used for CI check on Ubuntu, currently.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just to be clear, the uninstall test will not support running on macOS either in that case. If that's fine then the PR has been updated to remove the install test and the only other thing to do would be to remove this FIND assignment since it's unneeded.

SHLIB_EXT = dylib
SHLIB_VERS_EXT = $(MAJOR).dylib
else # GNU/Linux, at least (Windows should probably use cmake)
Expand All @@ -49,7 +50,7 @@ pkgincludedir=$(includedir:$(prefix)/%=%)

# meta targets

.PHONY: all clean data update manifest install
.PHONY: all clean data update manifest install test_install_uninstall

all: libutf8proc.a libutf8proc.$(SHLIB_EXT)

Expand Down Expand Up @@ -118,6 +119,15 @@ ifneq ($(OS),Darwin)
ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR)
endif

uninstall:
$(RM) $(DESTDIR)$(includedir)/utf8proc.h
$(RM) $(DESTDIR)$(libdir)/libutf8proc.a
$(RM) $(DESTDIR)$(libdir)/libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.$(SHLIB_EXT)
$(RM) $(DESTDIR)$(pkgconfigdir)/libutf8proc.pc
ifneq ($(OS),Darwin)
$(RM) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR)
endif

MANIFEST.new:
rm -rf tmp
$(MAKE) install prefix=/usr DESTDIR=$(PWD)/tmp
Expand Down Expand Up @@ -174,6 +184,9 @@ test/misc: test/misc.c test/tests.o utf8proc.o utf8proc.h test/tests.h
test/maxdecomposition: test/maxdecomposition.c test/tests.o utf8proc.o utf8proc.h test/tests.h
$(CC) $(UCFLAGS) $(LDFLAGS) -DUNICODE_VERSION='"'`$(PERL) -ne "/^UNICODE_VERSION=/ and print $$';" data/Makefile`'"' test/maxdecomposition.c test/tests.o utf8proc.o -o $@

test_install_uninstall: manifest
./test/install_uninstall.sh

# make release tarball from master branch
dist:
git archive master --prefix=utf8proc-$(VERSION)/ -o utf8proc-$(VERSION).tar.gz
Expand All @@ -189,7 +202,7 @@ distcheck: dist
make -C utf8proc-$(VERSION) check
rm -rf utf8proc-$(VERSION)

check: test/normtest data/NormalizationTest.txt data/Lowercase.txt data/Uppercase.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/iscase test/custom test/charwidth test/misc test/maxdecomposition test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o
check: test/normtest data/NormalizationTest.txt data/Lowercase.txt data/Uppercase.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/iscase test/custom test/charwidth test/misc test/maxdecomposition test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o test_install_uninstall
$(MAKE) -C bench
test/normtest data/NormalizationTest.txt
test/graphemetest data/GraphemeBreakTest.txt
Expand Down
31 changes: 31 additions & 0 deletions test/install_uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

install_dir=`mktemp -d`
if [ -z "$install_dir" ]; then
echo "install_uninstall error: could not create temporary directory" >&2
exit 1
fi

if ! make install DESTDIR="$install_dir" prefix=""; then
echo "FAILED: make install" >&2
rm -rf "$install_dir"
exit 1
fi

# test uninstallation
if ! make uninstall DESTDIR="$install_dir" prefix=""; then
echo "FAILED: make uninstall" >&2
rm -rf "$install_dir"
exit 1
fi

cut -d ' ' -f 1 MANIFEST.new | while read -r installed_file; do
[ -d "$install_dir/$installed_file" ] && continue
if [ -f "$install_dir/$installed_file" ]; then
echo "FAILED: make uninstall of "$installed_file"" >&2
rm -rf "$install_dir"
exit 1
fi
done

echo "install_uninstall tests SUCCEEDED"