--- Makefile.orig 2023-09-21 07:05:32.000000000 -0400 +++ Makefile 2023-09-21 07:08:40.000000000 -0400 @@ -14,12 +14,23 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. CC ?= gcc -PREFIX ?= /usr/local +PREFIX ?= @PREFIX@ +# Turn off SDL support with dylib-only builds +ifdef BUILD_QUIRC SDL_CFLAGS := $(shell pkg-config --cflags sdl 2>&1) -SDL_LIBS = $(shell pkg-config --libs sdl) +SDL_LIBS := $(shell pkg-config --libs sdl) +SDL_LIBS += -lSDL -lSDL_gfx +else +SDL_CFLAGS ?= +SDL_LIBS ?= +endif LIB_VERSION = 1.2 +LINKERLIBFLAGS = -dynamiclib -headerpad_max_install_names \ + -current_version $(LIB_VERSION) \ + -compatibility_version $(LIB_VERSION) + CFLAGS ?= -O3 -Wall -fPIC QUIRC_CFLAGS = -Ilib $(CFLAGS) $(SDL_CFLAGS) LIB_OBJ = \ @@ -41,7 +52,7 @@ .PHONY: all v4l sdl opencv install uninstall clean -all: libquirc.so qrtest +all: libquirc.dylib qrtest v4l: quirc-scanner @@ -53,30 +64,30 @@ $(CC) -o $@ tests/dbgutil.o tests/qrtest.o libquirc.a $(LDFLAGS) -lm -ljpeg -lpng inspect: tests/dbgutil.o tests/inspect.o libquirc.a - $(CC) -o $@ tests/dbgutil.o tests/inspect.o libquirc.a $(LDFLAGS) -lm -ljpeg -lpng $(SDL_LIBS) -lSDL_gfx + $(CC) -o $@ tests/dbgutil.o tests/inspect.o libquirc.a $(LDFLAGS) -lm -ljpeg -lpng $(SDL_LIBS) inspect-opencv: tests/dbgutil.o tests/inspect_opencv.o libquirc.a $(CXX) -o $@ tests/dbgutil.o tests/inspect_opencv.o libquirc.a $(LDFLAGS) -lm -ljpeg -lpng $(OPENCV_LIBS) quirc-demo: $(DEMO_OBJ) $(DEMO_UTIL_OBJ) demo/demo.o libquirc.a - $(CC) -o $@ $(DEMO_OBJ) $(DEMO_UTIL_OBJ) demo/demo.o libquirc.a $(LDFLAGS) -lm -ljpeg $(SDL_LIBS) -lSDL_gfx + $(CC) -o $@ $(DEMO_OBJ) $(DEMO_UTIL_OBJ) demo/demo.o libquirc.a $(LDFLAGS) -lm -ljpeg $(SDL_LIBS) quirc-demo-opencv: $(DEMO_UTIL_OBJ) demo/demo_opencv.o libquirc.a $(CXX) -o $@ $(DEMO_UTIL_OBJ) demo/demo_opencv.o libquirc.a $(LDFLAGS) -lm $(OPENCV_LIBS) quirc-scanner: $(DEMO_OBJ) $(DEMO_UTIL_OBJ) demo/scanner.o libquirc.a - $(CC) -o $@ $(DEMO_OBJ) $(DEMO_UTIL_OBJ) demo/scanner.o libquirc.a $(LDFLAGS) -lm -ljpeg + $(CC) -o $@ $(DEMO_OBJ) $(DEMO_UTIL_OBJ) demo/scanner.o libquirc.a $(LDFLAGS) -lm -ljpeg $(SDL_LIBS) libquirc.a: $(LIB_OBJ) rm -f $@ ar cru $@ $(LIB_OBJ) ranlib $@ -.PHONY: libquirc.so -libquirc.so: libquirc.so.$(LIB_VERSION) +.PHONY: libquirc.dylib +libquirc.dylib: libquirc.$(LIB_VERSION).dylib -libquirc.so.$(LIB_VERSION): $(LIB_OBJ) - $(CC) -shared -o $@ $(LIB_OBJ) $(LDFLAGS) -lm +libquirc.$(LIB_VERSION).dylib: $(LIB_OBJ) + $(CC) $(LINKERLIBFLAGS) -install_name $(PREFIX)/lib/$@ -o $@ $(LIB_OBJ) $(LDFLAGS) -lm .c.o: $(CC) $(QUIRC_CFLAGS) -o $@ -c $< @@ -85,18 +96,17 @@ .cxx.o: $(CXX) $(QUIRC_CXXFLAGS) -o $@ -c $< -install: libquirc.a libquirc.so.$(LIB_VERSION) quirc-demo quirc-scanner - install -o root -g root -m 0644 lib/quirc.h $(DESTDIR)$(PREFIX)/include - install -o root -g root -m 0644 libquirc.a $(DESTDIR)$(PREFIX)/lib - install -o root -g root -m 0755 libquirc.so.$(LIB_VERSION) \ +install: libquirc.a libquirc.$(LIB_VERSION).dylib quirc-demo quirc-scanner + install -o @MACPORTSUSER@ -g @MACPORTSUSER@ -m 0644 lib/quirc.h $(DESTDIR)$(PREFIX)/include + install -o @MACPORTSUSER@ -g @MACPORTSUSER@ -m 0644 libquirc.a $(DESTDIR)$(PREFIX)/lib + install -o @MACPORTSUSER@ -g @MACPORTSUSER@ -m 0755 libquirc.$(LIB_VERSION).dylib \ $(DESTDIR)$(PREFIX)/lib - install -o root -g root -m 0755 quirc-demo $(DESTDIR)$(PREFIX)/bin - # install -o root -g root -m 0755 quirc-demo-opencv $(DESTDIR)$(PREFIX)/bin - install -o root -g root -m 0755 quirc-scanner $(DESTDIR)$(PREFIX)/bin + install -o @MACPORTSUSER@ -g @MACPORTSUSER@ -m 0755 quirc-demo $(DESTDIR)$(PREFIX)/bin + install -o @MACPORTSUSER@ -g @MACPORTSUSER@ -m 0755 quirc-scanner $(DESTDIR)$(PREFIX)/bin uninstall: rm -f $(DESTDIR)$(PREFIX)/include/quirc.h - rm -f $(DESTDIR)$(PREFIX)/lib/libquirc.so.$(LIB_VERSION) + rm -f $(DESTDIR)$(PREFIX)/lib/libquirc.$(LIB_VERSION).dylib rm -f $(DESTDIR)$(PREFIX)/lib/libquirc.a rm -f $(DESTDIR)$(PREFIX)/bin/quirc-demo rm -f $(DESTDIR)$(PREFIX)/bin/quirc-demo-opencv @@ -106,7 +116,7 @@ rm -f */*.o rm -f */*.lo rm -f libquirc.a - rm -f libquirc.so.$(LIB_VERSION) + rm -f libquirc.$(LIB_VERSION).dylib rm -f qrtest rm -f inspect rm -f inspect-opencv --- ./demo/camera.c 2022-09-05 08:15:57.000000000 -0400 +++ ./demo/camera.c 2022-09-05 08:23:51.000000000 -0400 @@ -25,6 +25,8 @@ #include #ifdef __OpenBSD__ #include +#elif defined(__APPLE__) +#include #else #include #endif