From acb5cc90a949bfb5747e97db9bc9cd42dedfaa58 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 11 Sep 2022 18:01:02 +1000 Subject: [PATCH] I can't get the shared lib to build on linux --- source/makefile | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/source/makefile b/source/makefile index daf07af..2926f99 100644 --- a/source/makefile +++ b/source/makefile @@ -9,8 +9,23 @@ SRC = $(filter-out $(wildcard *main.c),$(wildcard *.c)) OBJ = $(addprefix $(ODIR)/,$(SRC:.c=.o)) OUTNAME = toy -OUT = ../$(OUTDIR)/$(OUTNAME).dll -LIBLINE =-Wl,--out-implib=../$(OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive +OUT = ../$(OUTDIR)/$(OUTNAME) + +ifeq ($(findstring CYGWIN, $(shell uname)),CYGWIN) + LIBLINE =-Wl,--out-implib=../$(OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive + OUT +=.dll +else ifeq ($(shell uname),Linux) + #I can't get this working as a shared lib + LIBLINE=-Wl,--out-implib=../$(OUTDIR)/lib$(OUTNAME).a -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive + OUT = ../$(OUTDIR)/$(OUTNAME) + CFLAGS += -fPIC +else ifeq ($(OS),Windows_NT) + LIBLINE =-Wl,--out-implib=../$(OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive + OUT +=.dll +else + @echo "Platform test failed - what platform is this?" + exit 1 +endif REPLSRC = $(wildcard repl_main.c) REPLOUT = $(OUTNAME)repl.exe @@ -35,4 +50,4 @@ $(ODIR)/%.o: %.c .PHONY: clean clean: - $(RM) $(ODIR) \ No newline at end of file + $(RM) $(ODIR)