Add make target for macOS universal binary.

Issue #315
This commit is contained in:
John McNamara 2020-11-14 21:29:06 +00:00
parent 110af3ff4d
commit ff35a56934
5 changed files with 24 additions and 9 deletions

View File

@ -32,6 +32,21 @@ ifndef USE_NO_MD5
endif
$(Q)$(MAKE) -C src
universal_binary :
$(Q)$(MAKE) clean
$(Q)TARGET_ARCH="-target x86_64-apple-macos10.12" $(MAKE) all
$(Q)mv lib/libxlsxwriter.a libxlsxwriter_x86_64.a
$(Q)mv lib/libxlsxwriter.dylib libxlsxwriter_x86_64.dylib
$(Q)$(MAKE) clean
$(Q)TARGET_ARCH="-target arm64-apple-macos11" $(MAKE) all
$(Q)mv lib/libxlsxwriter.a lib/libxlsxwriter_arm64.a
$(Q)mv lib/libxlsxwriter.dylib lib/libxlsxwriter_arm64.dylib
$(Q)mv libxlsxwriter_x86_64.a libxlsxwriter_x86_64.dylib lib
$(Q)lipo -create -output lib/libxlsxwriter.a lib/libxlsxwriter_x86_64.a lib/libxlsxwriter_arm64.a
$(Q)lipo -create -output lib/libxlsxwriter.dylib lib/libxlsxwriter_x86_64.dylib lib/libxlsxwriter_arm64.dylib
# Build the example programs.
examples :
$(Q)$(MAKE) -C examples

View File

@ -148,7 +148,7 @@ ARCH = -m32
endif
$(LIBXLSXWRITER_SO) : $(SOBJS)
$(Q)$(CC) $(LDFLAGS) $(SOFLAGS) $(ARCH) -o $@ $(MINIZIP_SO) $(TMPFILEPLUS_SO) $(MD5_SO) $^ $(LIBS)
$(Q)$(CC) $(LDFLAGS) $(SOFLAGS) $(ARCH) $(TARGET_ARCH) -o $@ $(MINIZIP_SO) $(TMPFILEPLUS_SO) $(MD5_SO) $^ $(LIBS)
# The test library.
$(LIBXLSXWRITER_TO) : $(TOBJS)
@ -159,10 +159,10 @@ test_compile : $(OBJS)
# Targets for the object files.
%.o : %.c $(HDRS)
$(Q)$(CC) -I$(INC_DIR) $(CFLAGS) $(CXXFLAGS) -c $<
$(Q)$(CC) -I$(INC_DIR) $(CFLAGS) $(CXXFLAGS) $(TARGET_ARCH) -c $<
%.so : %.c $(HDRS)
$(Q)$(CC) $(FPIC) -I$(INC_DIR) $(LDFLAGS) $(CFLAGS) $(CXXFLAGS) -c $< -o $@
$(Q)$(CC) $(FPIC) -I$(INC_DIR) $(LDFLAGS) $(CFLAGS) $(CXXFLAGS) $(TARGET_ARCH) -c $< -o $@
%.to : %.c $(HDRS)
$(Q)$(CC) -g -O3 -DTESTING -I$(INC_DIR) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

View File

@ -33,10 +33,10 @@ endif
all: md5.o md5.so
%.o : %.c
$(Q)$(CC) -c $(CFLAGS) $<
$(Q)$(CC) -c $(CFLAGS) $(TARGET_ARCH) $<
%.so : %.c
$(Q)$(CC) $(FPIC) -c $(CFLAGS) $< -o $@
$(Q)$(CC) $(FPIC) -c $(CFLAGS) $(TARGET_ARCH) $< -o $@
clean:
$(Q)/bin/rm -f *.o *.so

View File

@ -40,10 +40,10 @@ endif
all: ioapi.o zip.o ioapi.so zip.so
%.o : %.c
$(Q)$(CC) -c $(CFLAGS) $<
$(Q)$(CC) -c $(CFLAGS) $(TARGET_ARCH) $<
%.so : %.c
$(Q)$(CC) $(FPIC) -c $(CFLAGS) $< -o $@
$(Q)$(CC) $(FPIC) -c $(CFLAGS) $(TARGET_ARCH) $< -o $@
clean:
$(Q)/bin/rm -f *.o *.so

View File

@ -33,10 +33,10 @@ endif
all: tmpfileplus.o tmpfileplus.so
%.o : %.c
$(Q)$(CC) -c $(CFLAGS) $<
$(Q)$(CC) -c $(CFLAGS) $(TARGET_ARCH) $<
%.so : %.c
$(Q)$(CC) $(FPIC) -c $(CFLAGS) $< -o $@
$(Q)$(CC) $(FPIC) -c $(CFLAGS) $(TARGET_ARCH) $< -o $@
clean:
$(Q)/bin/rm -f *.o *.so