Skip to content

Commit

Permalink
compile pcre2 vendor dep without autotools
Browse files Browse the repository at this point in the history
doubt autotools is generating much beyond the generic forms of
pcre2.h and config.h on most modern systems. compiling it ourselves
is neater and requires less build deps.
  • Loading branch information
adsr committed Aug 19, 2023
1 parent 8461ef1 commit c29533c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ prefix?=/usr/local
mle_cflags:=-std=c99 -Wall -Wextra -pedantic -Wno-pointer-arith -Wno-unused-result -Wno-unused-parameter -g -O0 -D_GNU_SOURCE -DPCRE2_CODE_UNIT_WIDTH=8 -I. $(CFLAGS) $(CPPFLAGS)
mle_ldflags:=$(LDFLAGS)
mle_dynamic_libs:=-lpcre2-8 -llua5.4
mle_static_libs:=vendor/pcre2/.libs/libpcre2-8.a vendor/lua/liblua5.4.a
mle_static_libs:=vendor/pcre2/libpcre2-8.a vendor/lua/liblua5.4.a
mle_ldlibs:=-lm $(LDLIBS)
mle_objects:=$(patsubst %.c,%.o,$(wildcard *.c))
mle_objects_no_main:=$(filter-out main.o,$(mle_objects))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Runs on Linux, Windows (Cygwin or WSL), FreeBSD, macOS, and more.

### Building

$ sudo apt install git build-essential libtool automake # or equivalent
$ sudo apt install git build-essential # install git, make, gcc, libc-dev
$
$ git clone --recursive https://github.com/adsr/mle.git
$ cd mle
Expand Down
35 changes: 29 additions & 6 deletions vendor/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
lua_cflags:=-std=c99 -Wall -Wextra -g -O3 -DLUA_USE_POSIX $(CFLAGS)
lua_objects:=$(patsubst lua/%.c,lua/%.o,$(filter-out lua/lua.c lua/onelua.c, $(wildcard lua/*.c)))

all: uthash/src/utlist.h pcre2/.libs/libpcre2-8.a lua/liblua5.4.a
pcre2_cflags:=-std=c99 -Wall -Wextra -g -O3 -DPCRE2_CODE_UNIT_WIDTH=8 -DSUPPORT_JIT -DHAVE_CONFIG_H $(CFLAGS)
pcre2_objects:=$(addprefix pcre2/src/, \
pcre2_auto_possess.o pcre2_chartables.o pcre2_compile.o pcre2_config.o \
pcre2_context.o pcre2_convert.o pcre2_dfa_match.o pcre2_error.o pcre2_extuni.o \
pcre2_find_bracket.o pcre2_jit_compile.o pcre2_maketables.o pcre2_match.o \
pcre2_match_data.o pcre2_newline.o pcre2_ord2utf.o pcre2_pattern_info.o \
pcre2_script_run.o pcre2_serialize.o pcre2_string_utils.o pcre2_study.o \
pcre2_substitute.o pcre2_substring.o pcre2_tables.o pcre2_ucd.o pcre2_ucptables.o \
pcre2_valid_utf.o pcre2_xclass.o)

all: uthash/src/utlist.h pcre2/libpcre2-8.a lua/liblua5.4.a

uthash/src/utlist.h:
command -v git && git submodule update --init

pcre2/.libs/libpcre2-8.a:
cd pcre2 && ./autogen.sh && ./configure && $(MAKE)

lua/liblua5.4.a: $(lua_objects)
$(AR) rcs $@ $(lua_objects)

$(lua_objects): %.o: %.c
$(CC) -c $(lua_cflags) $< -o $@

pcre2/libpcre2-8.a: $(pcre2_objects)
$(AR) rcs $@ $(pcre2_objects)

pcre2/src/pcre2.h: pcre2/src/pcre2.h.generic
cp -f $< $@

pcre2/src/config.h: pcre2/src/config.h.generic
cp -f $< $@

pcre2/src/pcre2_chartables.c: pcre2/src/pcre2_chartables.c.dist
cp -f $< $@

$(pcre2_objects): %.o: %.c
$(CC) -c $(pcre2_cflags) $< -o $@

$(pcre2_objects:.o=.c): pcre2/src/pcre2.h pcre2/src/config.h

clean:
rm -f pcre2/libpcre2-8.a pcre2/src/pcre2.h pcre2/src/config.h pcre2/src/pcre2_chartables.c $(pcre2_objects)
rm -f lua/liblua5.4.a $(lua_objects)
rm -f pcre2/src/config.h.in~
-test -f pcre2/Makefile && $(MAKE) -C pcre2 clean

.NOTPARALLEL:

Expand Down

0 comments on commit c29533c

Please sign in to comment.