mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-19 19:01:44 +03:00
65b3ddb81b
This makes it easier for more complicated packages (e.g. network, which needs to install a C shared library) to know where to put things without having to work out the prefix themselves.
61 lines
1.5 KiB
Makefile
61 lines
1.5 KiB
Makefile
RANLIB ?=ranlib
|
|
AR ?=ar
|
|
|
|
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
|
|
|
|
SHLIB_SUFFIX :=.so
|
|
|
|
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`
|
|
|
|
build: $(DYLIBTARGET) $(IDRIS_SRCS)
|
|
@if [ -z "${IDRIS2}" ]; then echo 'variable $$IDRIS2 is not set, aborting'; exit 1; fi
|
|
${IDRIS2} --build network.ipkg
|
|
|
|
$(DYLIBTARGET) : $(OBJS)
|
|
$(CC) -o $(DYLIBTARGET) $(LIBFLAGS) -shared $(OBJS)
|
|
|
|
install:
|
|
@if [ -z "${IDRIS2}" ]; then echo 'variable $$IDRIS2 is not set, aborting'; exit 1; fi
|
|
${IDRIS2} --install network.ipkg
|
|
@if ! [ -d $(TARGET)/network/lib ]; then mkdir $(TARGET)/network/lib; fi
|
|
install $(DYLIBTARGET) $(HDRS) $(TARGET)/network/lib
|
|
|
|
clean :
|
|
rm -rf $(OBJS) $(LIBTARGET) $(DYLIBTARGET) build
|
|
|
|
test: build test.c
|
|
cp $(DYLIBTARGET) lib$(DYLIBTARGET) # to make C linker happy
|
|
$(CC) -o network-tests -L. -I. test.c -l$(LIBNAME)
|
|
LD_LIBRARY_PATH=. ./network-tests
|
|
./lib-tests
|
|
|
|
$(OBJS): $(HDRS)
|
|
|
|
all: $(DYLIBTARGET) $(LIBTARGET)
|
|
${IDRIS2} --build network.ipkg
|
|
|
|
.PHONY: install clean
|