# https://github.com/adrian-thurston/ragel/pull/85

--- configure.ac.orig	2021-12-29 04:19:46.000000000 +0800
+++ configure.ac	2022-10-08 06:19:57.000000000 +0800
@@ -47,13 +47,23 @@
 		CPPFLAGS="-I$withval/include ${CPPFLAGS}"
 		CPPFLAGS="-I$withval/include/aapl ${CPPFLAGS}"
 		LDFLAGS="-L$withval/lib ${LDFLAGS}"
-		LIBCOLM_LA="$withval/lib/libcolm.la"
-		LIBFSM_LA="$withval/lib/libfsm.la"
 		COLM_SHARE="$withval/share/colm"
 	],
 	[]
 )
 
+AC_CHECK_LIB(
+	[colm],
+	[colm_run_program],
+	[LIBCOLM_LA=-lcolm],
+	[AC_ERROR([libcolm is required to build ragel])]
+)
+AC_CHECK_LIB(
+	[fsm],
+	[LIBFSM_LA=-lfsm],
+	[AC_ERROR([libfsm is required to build ragel])]
+)
+
 AC_CHECK_FILES(
 	[$COLM],
 	[],

--- src/Makefile.am.orig	2021-12-29 04:19:46.000000000 +0800
+++ src/Makefile.am	2022-10-08 06:05:53.000000000 +0800
@@ -40,7 +40,6 @@
 	parse.c rlreduce.cc
 
 ragel_LDADD = $(LIBFSM_LA) $(LIBCOLM_LA) libragel.la
-ragel_DEPENDENCIES = $(LIBFSM_LA) $(LIBCOLM_LA) libragel.la
 
 BUILT_SOURCES = \
 	version.h \
