Skip to content

Commit

Permalink
fix: makefile builds with i686-w64-mingw32
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut authored and aklomp committed Jan 9, 2024
1 parent abe804a commit aceba5a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Makefile
Expand Up @@ -56,6 +56,7 @@ ifdef OPENMP
CFLAGS += -fopenmp
endif

TARGET := $(shell $(CC) -dumpmachine)

.PHONY: all analyze clean

Expand All @@ -64,9 +65,17 @@ all: bin/base64 lib/libbase64.o
bin/base64: bin/base64.o lib/libbase64.o
$(CC) $(CFLAGS) -o $@ $^

lib/libbase64.o: $(OBJS)
$(LD) -r -o $@ $^
$(OBJCOPY) --keep-global-symbols=lib/exports.txt $@
# Workaround: mangle exported function names on MinGW32.
lib/exports.build.txt: lib/exports.txt
ifeq (i686-w64-mingw32, $(TARGET))
sed -e 's/^/_/' $< > $@
else
cp -f $< $@
endif

lib/libbase64.o: lib/exports.build.txt $(OBJS)
$(LD) -r -o $@ $(OBJS)
$(OBJCOPY) --keep-global-symbols=$< $@

lib/config.h:
@echo "#define HAVE_AVX512 $(HAVE_AVX512)" > $@
Expand Down Expand Up @@ -97,4 +106,4 @@ analyze: clean
scan-build --use-analyzer=`which clang` --status-bugs make

clean:
rm -f bin/base64 bin/base64.o lib/libbase64.o lib/config.h $(OBJS)
rm -f bin/base64 bin/base64.o lib/libbase64.o lib/config.h lib/exports.build.txt $(OBJS)

0 comments on commit aceba5a

Please sign in to comment.