File dSFMT-sharedlib.patch of Package dSFMT

--- dSFMT-src-2.2.3/Makefile.origin	2013-12-19 05:37:46.000000000 +0100
+++ dSFMT-src-2.2.3/Makefile	2014-06-06 21:21:28.939219524 +0200
@@ -17,23 +17,50 @@
 # We could comple test-alti-Mxxx using gcc 3.3 of osx.
 # We could comple test-alti-Mxxx using gcc 4.0 of osx.
 
+V_MAJOR   = 2
+V_MINOR   = 2
+V_RELEASE = 3
+SONAME    = $(V_MAJOR).$(V_MINOR)
+VERSION   = $(V_MAJOR).$(V_MINOR).$(V_RELEASE)
+
+prefix     = /usr
+includedir = $(prefix)/include
+libdir     = $(prefix)/lib
+SSE2_libdir = $(libdir)/sse2
+DESTDIR    = .
+
+SFMT_MEXP  = 19937
 WARN = -Wmissing-prototypes -Wall #-Winline
 #WARN = -Wmissing-prototypes -Wall -W
 #WARN = /Wall
-OPTI = -O3 -finline-functions -fomit-frame-pointer -DNDEBUG \
--fno-strict-aliasing --param max-inline-insns-single=1800
-#--param inline-unit-growth=500 --param large-function-growth=900 #for gcc 4
-#OPTI = /Ot /Ob2 /Oy /Ox /Oi /GL /G6
-#STD =
-#STD = -std=c89 -pedantic
-#STD = -std=c99 -pedantic
-STD = -std=c99
-CC = gcc
-CCFLAGS = $(OPTI) $(WARN) $(STD)
-ALTIFLAGS = -mabi=altivec -maltivec -DHAVE_ALTIVEC
-OSXALTIFLAGS = -faltivec -maltivec -DHAVE_ALTIVEC
-SSE2FLAGS = -msse2 -DHAVE_SSE2
-#SSE2FLAGS = /arch:SSE2 /DHAVE_SSE2
+OPTI            = -O3 -finline-functions -fomit-frame-pointer -DNDEBUG \
+--param inline-unit-growth=500 --param large-function-growth=900 #for gcc 4
+#-fno-strict-aliasing --param max-inline-insns-single=1800
+#OPTI           = /Ot /Ob2 /Oy /Ox /Oi /GL /G6
+STD             = -std=c99
+CC              = gcc
+LINK            = gcc
+CCFLAGS         = -fPIC $(OPTI) $(WARN) $(STD)
+INCPATH         = -I$(includedir)
+LIBS            = -L$(libdir) -L. -lpthread
+LDFLAGS         = -Wl,--no-undefined -Wl,-z,noexecstack -shared
+ALTIFLAGS       = -mabi=altivec -maltivec -DHAVE_ALTIVEC
+OSXALTIFLAGS    = -faltivec -maltivec -DHAVE_ALTIVEC
+SSE2FLAGS       = -msse2 -DHAVE_SSE2
+#SSE2FLAGS      = /arch:SSE2 /DHAVE_SSE2
+STRIP           =
+COPY_FILE       = cp -f
+COPY_DIR        = $(COPY_FILE) -R
+INSTALL_FILE    = @install -m 644 -p
+INSTALL_DIR     = $(COPY_DIR)
+SYMLINK         = ln -f -s
+DEL_FILE        = rm -rf
+MOVE            = mv -f
+CHK_DIR_EXISTS  = test -d
+CHK_FILE_EXISTS  = test ! -f
+MKDIR           = mkdir -p
+
+TARGET  = dSFMT
 STD_TARGET = test-std-M19937
 ALL_STD_TARGET = test-std-M521 test-std-M1279 test-std-M2203 test-std-M4253 \
 test-std-M11213 test-std-M19937 test-std-M44497 test-std-M86243 \
@@ -46,6 +73,9 @@ SSE2_TARGET = $(STD_TARGET) test-sse2-M1
 ALL_SSE2_TARGET = test-sse2-M521 test-sse2-M1279 test-sse2-M2203 \
 test-sse2-M4253 test-sse2-M11213 test-sse2-M19937 test-sse2-M44497 \
 test-sse2-M86243 test-sse2-M132049 test-sse2-M216091
+
+HEADERS = $(TARGET).h $(TARGET)-params.h $(TARGET)-common.h
+
 # ==========================================================
 # comment out or EDIT following lines to get max performance
 # ==========================================================
@@ -78,7 +108,18 @@ test-sse2-M86243 test-sse2-M132049 test-
 # -----------------
 #CCFLAGS += -march=athlon64
 
-.PHONY: std-check sse2-check alti-check
+DEFINES = -DDSFMT_MEXP=$(SFMT_MEXP)
+
+SHARED_TARGET  = lib$(TARGET).so.$(VERSION)
+SHARED_TARGET0 = lib$(TARGET).so
+SHARED_TARGET1 = lib$(TARGET).so.$(V_MAJOR)
+SHARED_TARGET2 = lib$(TARGET).so.$(SONAME)
+SHARED_TARGETS = $(SHARED_TARGET) $(SHARED_TARGET0) $(SHARED_TARGET1) $(SHARED_TARGET2)
+
+SOURCE = $(TARGET).c $(HEADERS)
+OBJECT = $(TARGET).o
+
+.PHONY: sharedlib std-check sse2-check alti-check
 
 std: $(STD_TARGET)
 
@@ -101,6 +142,9 @@ alti-check: $(ALL_ALTI_TARGET)
 osx-alti-check:
 	make "ALTIFLAGS=$(OSXALTIFLAGS)" alti-check
 
+test-$(TARGET): test.c sharedlib
+	$(CC) $(CCFLAGS) $(INCPATH) $(LIBS) -l$(TARGET) $< -o $@
+
 test-std-M521: test.c dSFMT.c dSFMT.h
 	$(CC) $(CCFLAGS) -DDSFMT_MEXP=521 -o $@ dSFMT.c test.c
 
@@ -146,8 +190,8 @@ test-alti-M11213: test.c dSFMT.c dSFMT.h
 test-sse2-M11213: test.c dSFMT.c dSFMT.h
 	$(CC) $(CCFLAGS) $(SSE2FLAGS) -DDSFMT_MEXP=11213 -o $@ dSFMT.c test.c
 
-test-std-M19937: test.c dSFMT.c dSFMT.h
-	$(CC) $(CCFLAGS) -DDSFMT_MEXP=19937 -o $@ dSFMT.c test.c
+test-std-M19937: sharedlib test.c dSFMT.c dSFMT.h
+	$(CC) $(CCFLAGS) $(LDFLAGS) -I. -L. -DDSFMT_MEXP=19937 -o $@ -l$(TARGET)
 
 test-alti-M19937: test.c dSFMT.c dSFMT.h
 	$(CC) $(CCFLAGS) $(ALTIFLAGS) -DDSFMT_MEXP=19937 -o $@ dSFMT.c test.c
@@ -191,8 +235,54 @@ test-alti-M216091: test.c dSFMT.c dSFMT.
 test-sse2-M216091: test.c dSFMT.c dSFMT.h
 	$(CC) $(CCFLAGS) $(SSE2FLAGS) -DDSFMT_MEXP=216091 -o $@ dSFMT.c test.c
 
+.SUFFIXES: .o .c
+
 .c.o:
-	$(CC) $(CCFLAGS) -c $<
+	@echo $(CCFLAGS)
+	$(CC) $(CCFLAGS) $(DEFINES) -c $<
+
+
+sse2_shared: $(SOURCE)
+	$(CC) $(CCFLAGS) $(SSE2FLAGS) $(DEFINES) -c $<
+
+sharedlib: $(OBJECT)
+	@echo $(LDFLAGS)
+	$(DEL_FILE) $(SHARED_TARGETS)
+	$(LINK) $(LDFLAGS) -Wl,-soname,$(SHARED_TARGET2) -o $(SHARED_TARGET) $<
+	$(SYMLINK) $(SHARED_TARGET) $(SHARED_TARGET0)
+	$(SYMLINK) $(SHARED_TARGET) $(SHARED_TARGET1)
+	$(SYMLINK) $(SHARED_TARGET) $(SHARED_TARGET2)
+
+install: install_headers
+
+install_shared: $(libdir)
+	@echo $(CCFLAGS)
+	@echo $(DESTDIR)
+	@echo $(libdir)
+	$(CHK_DIR_EXISTS) $(DESTDIR)$< || $(MKDIR) $(DESTDIR)$<
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET)
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET0) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET0)
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET1) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET1)
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET2) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET2)
+	$(MOVE) $(SHARED_TARGETS)  $(DESTDIR)$</
+
+install_sse2_shared: $(SSE2_libdir)
+	@echo $(DESTDIR)
+	@echo $(libdir)
+	$(CHK_DIR_EXISTS) $(DESTDIR)$< || $(MKDIR) $(DESTDIR)$<
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET)
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET0) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET0)
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET1) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET1)
+	$(CHK_FILE_EXISTS) $(DESTDIR)$</$(SHARED_TARGET2) || $(DEL_FILE) $(DESTDIR)$</$(SHARED_TARGET2)
+	$(MOVE) $(SHARED_TARGETS)  $(DESTDIR)$</
+
+install_headers: install_shared
+	@echo $(DESTDIR)
+	$(CHK_DIR_EXISTS) $(DESTDIR)$(includedir) || $(MKDIR) $(DESTDIR)$(includedir)
+	$(CHK_DIR_EXISTS) $(DESTDIR)$(libdir)/pkgconfig || $(MKDIR) $(DESTDIR)$(libdir)/pkgconfig
+	$(INSTALL_FILE) $(HEADERS) $(DESTDIR)$(includedir)
 
 clean:
-	rm -f *.o *~ test-*-M*
+	$(DEL_FILE) *.o *~ test-*-M*
+	$(DEL_FILE) *.so *.so.*
+	$(DEL_FILE) test-$(TARGET)
+
+distclean: clean
+	$(DEL_FILE) -r $(DESTDIR)$(prefix)
+
openSUSE Build Service is sponsored by