mcst-linux-kernel/patches-2024.06.26/snowball-2.2.0/0002-shared-libraries.patch

71 lines
2.7 KiB
Diff

diff -ruaN snowball-2.2.0/GNUmakefile my_snowball-2.2.0/GNUmakefile
--- snowball-2.2.0/GNUmakefile 2024-04-22 19:46:44.852823656 +0300
+++ my_snowball-2.2.0/GNUmakefile 2024-04-22 19:46:30.592491835 +0300
@@ -180,7 +180,7 @@
INCLUDES=-Iinclude
-all: snowball$(EXEEXT) libstemmer.a stemwords$(EXEEXT) $(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS)
+all: snowball$(EXEEXT) libstemmer.a libstemmer.so stemwords$(EXEEXT) $(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS)
algorithms.mk: libstemmer/mkalgorithms.pl libstemmer/modules.txt
libstemmer/mkalgorithms.pl algorithms.mk libstemmer/modules.txt
@@ -188,7 +188,7 @@
clean:
rm -f $(COMPILER_OBJECTS) $(RUNTIME_OBJECTS) \
$(LIBSTEMMER_OBJECTS) $(LIBSTEMMER_UTF8_OBJECTS) $(STEMWORDS_OBJECTS) snowball$(EXEEXT) \
- libstemmer.a stemwords$(EXEEXT) \
+ libstemmer.a libstemmer.so stemwords$(EXEEXT) \
libstemmer/modules.h \
libstemmer/modules_utf8.h \
$(C_LIB_SOURCES) $(C_LIB_HEADERS) $(C_LIB_OBJECTS) \
@@ -203,7 +203,7 @@
libstemmer/mkinc.mak libstemmer/mkinc_utf8.mak \
libstemmer/libstemmer.c libstemmer/libstemmer_utf8.c \
algorithms.mk
- rm -rf dist
+ rm -rf dist .shared
-rmdir $(c_src_dir)
-rmdir $(python_output_dir)
-rmdir $(js_output_dir)
@@ -230,17 +230,25 @@
libstemmer.a: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
$(AR) -cru $@ $^
+libstemmer.so: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
+ $(CC) $(CFLAGS) -shared $(LDFLAGS) \
+ -Wl,-soname,libstemmer.so.0d \
+ -o $@.0d.0.0 ${^:%=.shared/%}
+ ln -s $@.0d.0.0 $@.0d
+ ln -s $@.0d.0.0 $@
+ $(AR) -crs ${@:.so=.a} $^
+
examples/%.o: examples/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
-stemwords$(EXEEXT): $(STEMWORDS_OBJECTS) libstemmer.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+stemwords$(EXEEXT): $(STEMWORDS_OBJECTS) libstemmer.so
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(STEMWORDS_OBJECTS) -L. -lstemmer
tests/%.o: tests/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
-stemtest$(EXEEXT): $(STEMTEST_OBJECTS) libstemmer.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+stemtest$(EXEEXT): $(STEMTEST_OBJECTS) libstemmer.so
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(STEMTEST_OBJECTS) -L. -lstemmer
csharp_stemwords$(EXEEXT): $(CSHARP_STEMWORDS_SOURCES) $(CSHARP_RUNTIME_SOURCES) $(CSHARP_SOURCES)
$(MCS) -unsafe -target:exe -out:$@ $(CSHARP_STEMWORDS_SOURCES) $(CSHARP_RUNTIME_SOURCES) $(CSHARP_SOURCES)
@@ -747,4 +755,9 @@
ada/bin/stemwords: $(ADA_SOURCES)
cd ada && $(gprbuild) -Pstemwords -p
+%.o: %.c
+ @mkdir -p $(shell dirname ${@:%=.shared/%})
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -fPIC -o ${@:%=.shared/%} $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
.SUFFIXES: .class .java