Mercurial > libunicode
changeset 29:31bbe01fe501
make: ditch GNU make
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 07 Feb 2023 17:48:14 +0100 |
parents | f06312a7432b |
children | 303403de1314 |
files | .hgignore CMakeLists.txt GNUmakefile INSTALL.md |
diffstat | 4 files changed, 28 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Tue Feb 07 14:30:33 2023 +0100 +++ b/.hgignore Tue Feb 07 17:48:14 2023 +0100 @@ -8,6 +8,9 @@ \.d$ \.o$ +# Usual CMake build directory. +^build + # Test files. ^tests/test-unicode$
--- a/CMakeLists.txt Tue Feb 07 14:30:33 2023 +0100 +++ b/CMakeLists.txt Tue Feb 07 17:48:14 2023 +0100 @@ -102,3 +102,26 @@ target_include_directories(${t} PRIVATE ${CMAKE_SOURCE_DIR}/extern/libdt) add_test(NAME ${t} COMMAND ${t}) endforeach () + +# +# Commands to regenerate unicode.c and fetch UnicodeData.txt, requires POSIX +# compliant system. +# +add_custom_target( + regenerate + COMMAND + curl http://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt + -o ${CMAKE_SOURCE_DIR}/gen/UnicodeData.txt + COMMAND + cat ${CMAKE_SOURCE_DIR}/gen/unicode-before.c + > ${CMAKE_SOURCE_DIR}/unicode.c + COMMAND + cat ${CMAKE_SOURCE_DIR}/gen/UnicodeData.txt | awk -f ${CMAKE_SOURCE_DIR}/gen/mkutf.awk + >> ${CMAKE_SOURCE_DIR}/unicode.c + COMMAND + cat ${CMAKE_SOURCE_DIR}/gen/unicode-after.c + >> ${CMAKE_SOURCE_DIR}/unicode.c + COMMENT + "Regenerating unicode.c from UnicodeData.txt" +) +
--- a/GNUmakefile Tue Feb 07 14:30:33 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -# -# GNUmakefile -- GNU Makefile for libunicode -# -# Copyright (c) 2013-2023 David Demelier <markand@malikania.fr> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -PREFIX := /usr/local -INCDIR := $(PREFIX)/include -LIBDIR := $(PREFIX)/lib -MANDIR := $(PREFIX)/share/man - -VERSION := 1.0.0 - -LIB_SRCS := unicode.c -LIB_OBJS := $(LIB_SRCS:.c=.o) -LIB_DEPS := $(LIB_SRCS:.c=.d) -LIB := libunicode.a - -TESTS_SRCS := tests/test-unicode.c -TESTS_OBJS := $(TESTS_SRCS:.c=) - -override CFLAGS += -fPIC - -all: $(LIB) - -gen/UnicodeData.txt: - curl http://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt -o $@ - -unicode.c: gen/UnicodeData.txt gen/mkutf.awk - cat gen/unicode-before.c > unicode.c - cat gen/UnicodeData.txt | awk -f gen/mkutf.awk >> unicode.c - cat gen/unicode-after.c >> unicode.c - -$(LIB): $(LIB_OBJS) - $(AR) -rc $@ $(LIB_OBJS) - -$(TESTS_OBJS): | $(LIB) -$(TESTS_OBJS): private CFLAGS += -Iextern/libdt -I. -$(TESTS_OBJS): private LDLIBS += $(LIB) - -tests: $(TESTS_OBJS) - for t in $(TESTS_OBJS); do ./$$t; done - -install: - mkdir -p $(DESTDIR)$(LIBDIR) - cp libunicode.a $(DESTDIR)$(LIBDIR) - mkdir -p $(DESTDIR)$(INCDIR) - cp unicode.h $(DESTDIR)$(INCDIR) - mkdir -p $(DESTDIR)$(MANDIR)/man3 - cp libunicode.3 $(DESTDIR)$(MANDIR)/man3 - -clean: - rm -f $(LIB) $(LIB_DEPS) $(LIB_OBJS) $(TESTS_OBJS) - -.PHONY: all clean install tests
--- a/INSTALL.md Tue Feb 07 14:30:33 2023 +0100 +++ b/INSTALL.md Tue Feb 07 17:48:14 2023 +0100 @@ -17,7 +17,7 @@ ------------ The file unicode.c is generated from gen/ subdirectory. Edit the appropriate -files and run `make` in top level directory to regenerate them. +files and run `regenerate` target from CMake build directory. Installation ------------ @@ -25,7 +25,7 @@ The module is small enough to be incorporated verbatim into your project, but it still possible to install it system wide. -### Using CMake (recommended) +### Using CMake Using [CMake][cmake] you get proper CMake package configuration files, shared libraries and `pkg-config` files. @@ -54,18 +54,4 @@ add_executable(example example.c) target_link_libraries(example unicode::libunicode) -### Using GNU make (not recommended) - -Using [GNU make][gmake] (not recommended, only static library): - - $ make - # make install - -The test suite is available using: - - $ make tests - -On some systems you make need to call `gmake` rather than `make`. - [cmake]: http://cmake.org -[gmake]: https://www.gnu.org/software/make