mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-11-23 20:22:34 +03:00
Fix building shared libraries with correct extensions
This commit is contained in:
parent
e7d0b33e64
commit
1c8036dc58
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,5 +15,7 @@
|
||||
/libs/**/build
|
||||
/tests/**/output
|
||||
/tests/**/*.so
|
||||
/tests/**/*.dylib
|
||||
/tests/**/*.dll
|
||||
|
||||
/src/YafflePaths.idr
|
||||
|
1
Makefile
1
Makefile
@ -120,6 +120,7 @@ clean: clean-libs
|
||||
${MAKE} -C src clean
|
||||
${MAKE} -C tests clean
|
||||
${MAKE} -C dist clean
|
||||
${MAKE} -C support/c clean
|
||||
rm -f runtests
|
||||
rm -f idris2 dist/idris2.c
|
||||
|
||||
|
4
libs/network/.gitignore
vendored
4
libs/network/.gitignore
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
/network-tests
|
||||
|
||||
*.d
|
||||
*.o
|
||||
*.obj
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
|
@ -5,7 +5,7 @@ import Network.Socket
|
||||
import Network.Socket.Data
|
||||
import Network.Socket.Raw
|
||||
|
||||
%cg chez libidris_net.so
|
||||
%cg chez libidris_net
|
||||
|
||||
runServer : IO (Either String (Port, ThreadID))
|
||||
runServer = do
|
||||
|
@ -1,18 +1,34 @@
|
||||
RANLIB ?=ranlib
|
||||
AR ?=ar
|
||||
|
||||
SHLIB_SUFFIX :=.so
|
||||
MACHINE := $(shell $(CC) -dumpmachine)
|
||||
ifneq (,$(findstring cygwin, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring mingw, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring windows, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring darwin, $(MACHINE)))
|
||||
OS := darwin
|
||||
SHLIB_SUFFIX := .dylib
|
||||
CFLAGS += -fPIC
|
||||
else
|
||||
OS := unix
|
||||
SHLIB_SUFFIX := .so
|
||||
CFLAGS += -fPIC
|
||||
endif
|
||||
|
||||
|
||||
LIBNAME=idris_net
|
||||
|
||||
OBJS = $(LIBNAME).o
|
||||
HDRS = $(LIBNAME).h
|
||||
CFLAGS := $(CFLAGS)
|
||||
IDRIS_SRCS = Network/Socket.idr Network/Socket/Data.idr Network/Socket/Raw.idr
|
||||
|
||||
ifneq ($(OS), windows)
|
||||
CFLAGS += -fPIC
|
||||
endif
|
||||
|
||||
DYLIBTARGET = $(LIBNAME)$(SHLIB_SUFFIX)
|
||||
LIBTARGET = $(LIBNAME).a
|
||||
TARGET=`${IDRIS2} --libdir`
|
||||
|
@ -10,8 +10,7 @@ import Data.Strings
|
||||
|
||||
-- ------------------------------------------------------------ [ Type Aliases ]
|
||||
|
||||
-- FIXME should be generic name with OS-dependent suffix
|
||||
%cg chez "libidris_net.so"
|
||||
%cg chez "libidris_net"
|
||||
|
||||
public export
|
||||
ByteLength : Type
|
||||
|
7
samples/FFI-readline/readline_glue/.gitignore
vendored
Normal file
7
samples/FFI-readline/readline_glue/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
*.d
|
||||
*.o
|
||||
*.obj
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
@ -1,44 +1,61 @@
|
||||
IDRIS := idris2
|
||||
MACHINE := $(shell $(CC) -dumpmachine)
|
||||
|
||||
ifneq (, $(findstring darwin, $(MACHINE)))
|
||||
OS :=darwin
|
||||
else ifneq (, $(findstring cygwin, $(MACHINE)))
|
||||
OS :=windows
|
||||
else ifneq (, $(findstring mingw, $(MACHINE)))
|
||||
OS :=windows
|
||||
else ifneq (, $(findstring windows, $(MACHINE)))
|
||||
OS :=windows
|
||||
else
|
||||
OS :=unix
|
||||
endif
|
||||
|
||||
ifeq ($(OS), darwin)
|
||||
SHLIB_SUFFIX :=dylib
|
||||
else ifeq ($(OS), windows)
|
||||
SHLIB_SUFFIX :=dll
|
||||
else
|
||||
SHLIB_SUFFIX :=so
|
||||
endif
|
||||
|
||||
LIBTARGET = libidrisreadline.$(SHLIB_SUFFIX)
|
||||
IDRIS := idris2
|
||||
INSTALLDIR = `${IDRIS} --libdir`/readline/lib
|
||||
|
||||
HDRS = idris_readline.h
|
||||
OBJS = idris_readline.o
|
||||
TARGET = libidrisreadline
|
||||
|
||||
READLINE_LIBS := -lreadline
|
||||
READLINE_FLAGS := -fPIC
|
||||
MACHINE := $(shell $(CC) -dumpmachine)
|
||||
ifneq (,$(findstring cygwin, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring mingw, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring windows, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring darwin, $(MACHINE)))
|
||||
OS := darwin
|
||||
SHLIB_SUFFIX := .dylib
|
||||
CFLAGS += -fPIC
|
||||
else
|
||||
OS := unix
|
||||
SHLIB_SUFFIX := .so
|
||||
CFLAGS += -fPIC
|
||||
endif
|
||||
|
||||
CFLAGS = $(READLINE_FLAGS)
|
||||
|
||||
$(LIBTARGET): $(OBJS)
|
||||
$(CC) -o $(LIBTARGET) -shared $(OBJS) $(READLINE_LIBS) $(READLINE_FLAGS)
|
||||
CFLAGS := -Wall -Wextra $(CFLAGS)
|
||||
LDFLAGS := $(LDFLAGS) -lreadline
|
||||
|
||||
SRCS = $(wildcard *.c)
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
DEPS = $(OBJS:.o=.d)
|
||||
|
||||
|
||||
all: ${TARGET}$(SHLIB_SUFFIX)
|
||||
|
||||
$(TARGET)$(SHLIB_SUFFIX): $(OBJS)
|
||||
$(CC) -shared ${LDFLAGS} -o $@ $^
|
||||
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
%.d: %.c
|
||||
@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean :
|
||||
rm -f $(OBJS) $(TARGET)$(SHLIB_SUFFIX)
|
||||
|
||||
cleandep: clean
|
||||
rm -f ${DEPS}
|
||||
|
||||
|
||||
.PHONY: install
|
||||
|
||||
install:
|
||||
@if ! [ -d $(INSTALLDIR) ]; then mkdir -p $(INSTALLDIR); fi
|
||||
install $(LIBTARGET) $(HDRS) $(INSTALLDIR)
|
||||
clean:
|
||||
rm $(OBJS) $(LIBTARGET)
|
||||
|
||||
.PHONY: install clean
|
||||
install $(TARGET)$(SHLIB_SUFFIX) $(wildcard *.h) $(INSTALLDIR)
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <readline/readline.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
rl_compentry_func_t* my_compentry;
|
||||
|
7
support/c/.gitignore
vendored
Normal file
7
support/c/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
*.d
|
||||
*.o
|
||||
*.obj
|
||||
*.a
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
@ -1,22 +1,66 @@
|
||||
LIBTARGET = libidris2_support.a
|
||||
DYLIBTARGET = libidris2_support.so
|
||||
|
||||
.PHONY: build clean install
|
||||
TARGET = libidris2_support
|
||||
|
||||
OBJS = idris_support.o idris_buffer.o
|
||||
CFLAGS := -fPIC -O2 ${CFLAGS}
|
||||
MACHINE := $(shell $(CC) -dumpmachine)
|
||||
ifneq (,$(findstring cygwin, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring mingw, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring windows, $(MACHINE)))
|
||||
OS := windows
|
||||
SHLIB_SUFFIX := .dll
|
||||
else ifneq (,$(findstring darwin, $(MACHINE)))
|
||||
OS := darwin
|
||||
SHLIB_SUFFIX := .dylib
|
||||
CFLAGS += -fPIC
|
||||
else
|
||||
OS := unix
|
||||
SHLIB_SUFFIX := .so
|
||||
CFLAGS += -fPIC
|
||||
endif
|
||||
|
||||
LIBTARGET = $(TARGET).a
|
||||
DYLIBTARGET = ${TARGET}$(SHLIB_SUFFIX)
|
||||
|
||||
CFLAGS := -O2 -Wall -Wextra $(CFLAGS)
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
|
||||
SRCS = $(wildcard *.c)
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
DEPS = $(OBJS:.o=.d)
|
||||
|
||||
|
||||
.PHONY: build
|
||||
|
||||
build : $(LIBTARGET) $(DYLIBTARGET)
|
||||
|
||||
$(LIBTARGET) : $(OBJS)
|
||||
ar rc $(LIBTARGET) $(OBJS)
|
||||
ranlib $(LIBTARGET)
|
||||
ar rc $@ $^
|
||||
ranlib $@
|
||||
|
||||
$(DYLIBTARGET) : $(OBJS)
|
||||
$(CC) -shared $(OBJS) -fPIC -o $(DYLIBTARGET)
|
||||
$(CC) -shared ${LDFLAGS} -o $@ $^
|
||||
|
||||
install: $(LIBTARGET) $(DYLIBTARGET)
|
||||
install $(LIBTARGET) $(DYLIBTARGET) ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
%.d: %.c
|
||||
@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(DYLIBTARGET) $(LIBTARGET)
|
||||
|
||||
cleandep: clean
|
||||
rm -f ${DEPS}
|
||||
|
||||
|
||||
.PHONY: install
|
||||
|
||||
install: $(LIBTARGET) $(DYLIBTARGET)
|
||||
mkdir -p ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
||||
install $(LIBTARGET) $(DYLIBTARGET) ${PREFIX}/idris2-${IDRIS2_VERSION}/lib
|
||||
|
@ -5,7 +5,7 @@ import Network.Socket
|
||||
import Network.Socket.Data
|
||||
import Network.Socket.Raw
|
||||
|
||||
%cg chez libidris_net.so
|
||||
%cg chez libidris_net
|
||||
|
||||
runServer : IO (Either String (Port, ThreadID))
|
||||
runServer = do
|
||||
|
Loading…
Reference in New Issue
Block a user