diff --git a/moc_test/Makefile b/moc_test/Makefile index 3fa3c3c..62c2e84 100644 --- a/moc_test/Makefile +++ b/moc_test/Makefile @@ -1,17 +1,18 @@ # - all: - cd gortlsdr_moc && gcc -Wall -c librtlsdr_moc.c -o librtlsdr_moc.o - cd gortlsdr_moc && ar rcs librtlsdr_moc.a librtlsdr_moc.o - cd gortlsdr_moc && cp ../../rtlsdr.go . - cd gortlsdr_moc && cp ../../exports.go . - cd gortlsdr_moc && CC="gcc -DMOCK_TEST" go build -tags 'MOC_TEST' --ldflags '-extldflags "-static"' -o gortlsdr_moc.a rtlsdr.go exports.go - go build main_moc.go - cd gortlsdr_moc && rm ./rtlsdr.go ./exports.go + # cd gortlsdr && gcc -fPIC -shared -Wl,-soname,librtlsdr.so.0 -o librtlsdr.so.0 librtlsdr.c + cd gortlsdr && gcc -Wall -c librtlsdr.c -o librtlsdr.o + cd gortlsdr && ar rcs librtlsdr.a librtlsdr.o + cd gortlsdr && cp ../../rtlsdr.go . + cd gortlsdr && cp ../../exports.go . + cd gortlsdr && CC="gcc -DMOCK_TEST" go build --ldflags '-extldflags "-static" "-L."' -o gortlsdr.a rtlsdr.go exports.go + # cd gortlsdr && CC="gcc -Dmock" go build -o gortlsdr.a rtlsdr.go exports.go + go build --ldflags '-extldflags "-L./gortlsdr"' main.go + rm ./gortlsdr/rtlsdr.go ./gortlsdr/exports.go clean: - rm -f main_moc ./gortlsdr_moc/*.o ./gortlsdr_moc/*.a ./gortlsdr_moc/rtlsdr.go ./gortlsdr_moc/exports.go + rm -f main ./gortlsdr/*.o ./gortlsdr/*.a ./gortlsdr/rtlsdr.go ./gortlsdr/exports.go ./gortlsdr/*.0 ./gortlsdr/*.so diff --git a/moc_test/gortlsdr_moc/librtlsdr_moc.c b/moc_test/gortlsdr/librtlsdr.c similarity index 100% rename from moc_test/gortlsdr_moc/librtlsdr_moc.c rename to moc_test/gortlsdr/librtlsdr.c diff --git a/moc_test/gortlsdr_moc/rtl-sdr_moc.h b/moc_test/gortlsdr/rtl-sdr_moc.h similarity index 100% rename from moc_test/gortlsdr_moc/rtl-sdr_moc.h rename to moc_test/gortlsdr/rtl-sdr_moc.h diff --git a/moc_test/main_moc.go b/moc_test/main.go similarity index 99% rename from moc_test/main_moc.go rename to moc_test/main.go index d1b69cc..3e4a1e3 100644 --- a/moc_test/main_moc.go +++ b/moc_test/main.go @@ -9,7 +9,7 @@ package main import ( "log" - rtl "./gortlsdr_moc" + rtl "./gortlsdr" ) func GetDeviceCount() int { diff --git a/rtlsdr.go b/rtlsdr.go index 2ec3c82..147d656 100644 --- a/rtlsdr.go +++ b/rtlsdr.go @@ -18,16 +18,13 @@ import ( // If building libusb from source, to regenerate the configure file use: // $ autoreconf -fvi -#cgo MOC_TEST LDFLAGS: -L. -lrtlsdr_moc - -#cgo linux LDFLAGS: -lrtlsdr -#cgo darwin LDFLAGS: -lrtlsdr +#cgo !windows LDFLAGS: -lrtlsdr #cgo windows CFLAGS: -IC:/WINDOWS/system32 #cgo windows LDFLAGS: -lrtlsdr -LC:/WINDOWS/system32 #include -#ifdef MOC_TEST -#include +#ifdef mock +#include "rtl-sdr_moc.h" #else #include #endif