libgrapheme

grapheme cluster utility library
git clone git://git.suckless.org/libgrapheme
Log | Files | Refs | LICENSE

Makefile (3245B)


      1 # See LICENSE file for copyright and license details
      2 # libgrapheme - grapheme cluster utility library
      3 .POSIX:
      4 
      5 include config.mk
      6 
      7 LIB = src/boundary src/codepoint src/grapheme src/util
      8 TEST = test/grapheme_boundary test/utf8-decode test/utf8-encode
      9 DATA = data/emoji data/grapheme_boundary data/grapheme_boundary_test
     10 
     11 MAN3 = man/grapheme_bytelen.3
     12 MAN7 = man/libgrapheme.7
     13 
     14 all: libgrapheme.a libgrapheme.so
     15 
     16 data/emoji.h: data/emoji.txt data/emoji
     17 data/grapheme_boundary.h: data/grapheme_boundary.txt data/grapheme_boundary
     18 data/grapheme_boundary_test.h: data/grapheme_boundary_test.txt data/grapheme_boundary_test
     19 
     20 data/emoji.o: data/emoji.c config.mk data/datautil.h
     21 data/grapheme_boundary.o: data/grapheme_boundary.c config.mk data/datautil.h
     22 data/grapheme_boundary_test.o: data/grapheme_boundary_test.c config.mk data/datautil.h
     23 data/datautil.o: data/datautil.c config.mk data/datautil.h
     24 src/boundary.o: src/boundary.c config.mk data/emoji.h data/grapheme_boundary.h grapheme.h
     25 src/codepoint.o: src/codepoint.c config.mk grapheme.h
     26 src/grapheme.o: src/grapheme.c config.mk grapheme.h
     27 src/util.o: src/util.c config.mk src/util.h
     28 test/grapheme_boundary.o: test/grapheme_boundary.c config.mk data/grapheme_boundary_test.h grapheme.h
     29 test/utf8-encode.o: test/utf8-encode.c config.mk grapheme.h
     30 test/utf8-decode.o: test/utf8-decode.c config.mk grapheme.h
     31 
     32 data/emoji: data/emoji.o data/datautil.o
     33 data/grapheme_boundary: data/grapheme_boundary.o data/datautil.o
     34 data/grapheme_boundary_test: data/grapheme_boundary_test.o data/datautil.o
     35 test/grapheme_boundary: test/grapheme_boundary.o libgrapheme.a
     36 test/utf8-encode: test/utf8-encode.o libgrapheme.a
     37 test/utf8-decode: test/utf8-decode.o libgrapheme.a
     38 
     39 data/emoji.txt:
     40 	wget -O $@ https://www.unicode.org/Public/13.0.0/ucd/emoji/emoji-data.txt
     41 
     42 data/grapheme_boundary.txt:
     43 	wget -O $@ https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt
     44 
     45 data/grapheme_boundary_test.txt:
     46 	wget -O $@ https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakTest.txt
     47 
     48 $(DATA:=.h):
     49 	$(@:.h=) < $(@:.h=.txt) > $@
     50 
     51 $(DATA):
     52 	$(CC) -o $@ $(LDFLAGS) $@.o data/datautil.o
     53 
     54 $(TEST):
     55 	$(CC) -o $@ $(LDFLAGS) $@.o libgrapheme.a
     56 
     57 .c.o:
     58 	$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
     59 
     60 libgrapheme.a: $(LIB:=.o)
     61 	$(AR) rc $@ $?
     62 	$(RANLIB) $@
     63 
     64 libgrapheme.so: $(LIB:=.o)
     65 	$(CC) -o $@ -shared $?
     66 
     67 test: $(TEST)
     68 	for m in $(TEST); do ./$$m; done
     69 
     70 install: all
     71 	mkdir -p "$(DESTDIR)$(LIBPREFIX)"
     72 	mkdir -p "$(DESTDIR)$(INCPREFIX)"
     73 	mkdir -p "$(DESTDIR)$(MANPREFIX)/man3"
     74 	mkdir -p "$(DESTDIR)$(MANPREFIX)/man7"
     75 	cp -f $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3"
     76 	cp -f $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7"
     77 	cp -f libgrapheme.a "$(DESTDIR)$(LIBPREFIX)"
     78 	cp -f libgrapheme.so "$(DESTDIR)$(LIBPREFIX)"
     79 	cp -f grapheme.h "$(DESTDIR)$(INCPREFIX)"
     80 
     81 uninstall:
     82 	for m in $(MAN3); do rm -f "$(DESTDIR)$(MANPREFIX)/man3/`basename $$m`"; done
     83 	for m in $(MAN7); do rm -f "$(DESTDIR)$(MANPREFIX)/man7/`basename $$m`"; done
     84 	rm -f "$(DESTDIR)$(LIBPREFIX)/libgrapheme.a"
     85 	rm -f "$(DESTDIR)$(LIBPREFIX)/libgrapheme.so"
     86 	rm -f "$(DESTDIR)$(INCPREFIX)/grapheme.h"
     87 
     88 clean:
     89 	rm -f $(DATA:=.h) $(DATA:=.o) data/datautil.o $(LIB:=.o) $(TEST:=.o) $(DATA) $(TEST) libgrapheme.a libgrapheme.so
     90 
     91 clean-data:
     92 	rm -f $(DATA:=.txt)