aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile102
1 files changed, 102 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..285f70e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,102 @@
+.POSIX:
+
+CONFIGFILE = config.mk
+include $(CONFIGFILE)
+
+OS = linux
+# Linux: linux
+# Mac OS: macos
+# Windows: windows
+include mk/$(OS).mk
+
+
+LIB_MAJOR = 1
+LIB_MINOR = 0
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+LIB_NAME = automata
+
+
+OBJ =\
+ libautomata_reset_kmp_automaton.o\
+ libautomata_clone_kmp_automaton.o\
+ libautomata_compile_kmp_automaton.o\
+ libautomata_execute_kmp_automaton.o\
+ libautomata_reset_mp_automaton.o\
+ libautomata_clone_mp_automaton.o\
+ libautomata_compile_mp_automaton.o\
+ libautomata_execute_mp_automaton.o
+
+TOBJ =\
+ test_kmp_automaton.to\
+ test_mp_automaton.to
+
+HDR =\
+ libautomata.h\
+ common.h
+
+LOBJ = $(OBJ:.o=.lo)
+TEST = $(TOBJ:.to=.t)
+
+
+all: libautomata.a libautomata.$(LIBEXT) $(TEST)
+$(OBJ): $(HDR)
+$(LOBJ): $(HDR)
+$(TOBJ): $(HDR)
+$(TEST): libautomata.a
+
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+.c.lo:
+ $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+.c.to:
+ $(CC) -DTEST -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+.to.t:
+ $(CC) -o $@ $< libautomata.a $(LDFLAGS)
+
+.c.t:
+ $(CC) -DTEST -o $@ $< libautomata.a $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
+
+libautomata.a: $(OBJ)
+ @rm -f -- $@
+ $(AR) rc $@ $(OBJ)
+ $(AR) ts $@ > /dev/null
+
+libautomata.$(LIBEXT): $(LOBJ)
+ $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)
+
+check: $(TEST)
+ @set -e;\
+ for t in $(TEST); do\
+ printf '%s ' $(CHECK_PREFIX) "./$$t"; printf '\n';\
+ $(CHECK_PREFIX) ./"$$t";\
+ done
+
+install: libautomata.a libautomata.$(LIBEXT)
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
+ cp -- libautomata.a "$(DESTDIR)$(PREFIX)/lib/"
+ cp -- libautomata.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libautomata.$(LIBMINOREXT)"
+ $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libautomata.$(LIBMINOREXT)"
+ ln -sf -- libautomata.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libautomata.$(LIBMAJOREXT)"
+ ln -sf -- libautomata.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libautomata.$(LIBEXT)"
+ cp -- libautomata.h "$(DESTDIR)$(PREFIX)/include/"
+
+uninstall:
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libautomata.a"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libautomata.$(LIBMAJOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libautomata.$(LIBMINOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libautomata.$(LIBEXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/include/libautomata.h"
+
+clean:
+ -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.dll *.dylib
+ -rm -f -- *.gch *.gcov *.gcno *.gcda *.$(LIBEXT)
+ -rm -f -- *.t *.to
+
+.SUFFIXES:
+.SUFFIXES: .lo .o .c .t .to
+
+.PHONY: all check install uninstall clean