DOWNLOAD_CMD ?= wget
UNZIP ?= bsdtar
MINGW_BINDIR ?= C:\\\\MinGW\\\\bin # Used for InnoSetup script
define BSDTAR
mkdir -p $(DEST_DIR) && bsdtar -x -C$(DEST_DIR) -f $^
endef
define SEVENZIP
7z x -o$(DEST_DIR) $^
endef
define REAL_UNZIP
unzip -d$(DEST_DIR) $^
endef
ifeq ($(UNZIP), bsdtar)
UNZIP_CMD = $(BSDTAR)
else ifeq ($(UNZIP), 7z)
UNZIP_CMD = $(SEVENZIP)
else ifeq ($(UNZIP), unzip)
UNZIP_CMD = $(REAL_UNZIP)
endif
PREFIX ?= c:/chicken-iup
NATIVE_PREFIX = $(subst /,\\\\,$(PREFIX)) # Used for InnoSetup script
CHICKEN_URL = http://code.call-cc.org/releases
ifndef CHICKEN_VERSION
CHICKEN_VERSION = 4.9.0
CHICKEN_PATCHLEVEL = .1
endif
CHICKEN_PKGNAME = chicken-$(CHICKEN_VERSION)$(CHICKEN_PATCHLEVEL)
CHICKEN_DIR = $(CHICKEN_PKGNAME)
CHICKEN_PKG = $(CHICKEN_PKGNAME).tar.gz
CHICKEN_PLATFORM ?= mingw-msys
CHICKEN_PREFIX ?= $(PREFIX)
EGGS = apropos trace regex-case regex-literals format big-chicken pdf sql-de-lite coops tinyclos test regex slime canvas-draw utf8
define GET_FFCALL_CVS
cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/libffcall co ffcall
endef
define GET_FFCALL_PKG
wget http://www.haible.de/bruno/gnu/$(FFCALL_PKG)
tar zxvf $(FFCALL_PKG)
endef
FFCALL_VERSION ?= cvs
FFCALL_PREFIX ?= $(PREFIX)
ifeq ($(FFCALL_VERSION), cvs)
FFCALL_DIR = ffcall
FFCALL_PKG =
GET_FFCALL = $(GET_FFCALL_CVS)
else
FFCALL_DIR = ffcall-$(FFCALL_VERSION)
FFCALL_PKG = ffcall-$(FFCALL_VERSION).tar.gz
GET_FFCALL = $(GET_FFCALL_PKG)
endif
IUP_URL = http://sourceforge.net/projects
IUP_PLATFORM ?= Win32_dllw4
IUP_LIBDIR ?= $(PREFIX)/lib
IM_LONGNAME = imtoolkit
IM_VERSION ?= 3.9
IM_PKG = im-$(IM_VERSION)_$(IUP_PLATFORM)_lib.zip
CD_LONGNAME = canvasdraw
CD_VERSION ?= 5.8.1
CD_PKG = cd-$(CD_VERSION)_$(IUP_PLATFORM)_lib.zip
IUP_LONGNAME = iup
IUP_VERSION ?= 3.13
IUP_PKG = iup-$(IUP_VERSION)_$(IUP_PLATFORM)_lib.zip
SRC_PKGS = $(CHICKEN_PKG) $(FFCALL_PKG)
BIN_PKGS = $(IM_PKG) $(CD_PKG) $(IUP_PKG)
SRC_DIRS = $(CHICKEN_DIR) $(FFCALL_DIR)
.PHONY : all pkgs.prep srcpkgs.get binpkgs.get srcpkgs.verify binpkgs.verify srcpkgs.extract chicken.compile binpkgs.install iup_all.install im.install cd.install iup.install srcpkgs.compile install base.install binpkg.prep strip-lua eggs clean distclean lzma-kludge
all : install binpkg.prep
pkgs.prep : srcpkgs.extract binpkgs.verify
srcpkgs.get : $(CHICKEN_PKG)
$(CHICKEN_PKG) :
$(DOWNLOAD_CMD) $(CHICKEN_URL)/$(CHICKEN_VERSION)/$(CHICKEN_PKG)
# tar zxvf $(CHICKEN_PKG)
binpkgs.get : $(IM_PKG) $(CD_PKG) $(IUP_PKG)
$(IM_PKG) :
$(DOWNLOAD_CMD) $(IUP_URL)/$(IM_LONGNAME)/files/$(IM_VERSION)/Windows%20Libraries/Dynamic/$(IM_PKG)
$(CD_PKG) :
$(DOWNLOAD_CMD) $(IUP_URL)/$(CD_LONGNAME)/files/$(CD_VERSION)/Windows%20Libraries/Dynamic/$(CD_PKG)
$(IUP_PKG) :
$(DOWNLOAD_CMD) $(IUP_URL)/$(IUP_LONGNAME)/files/$(IUP_VERSION)/Windows%20Libraries/Dynamic/$(IUP_PKG)
srcpkgs.verify : srcpkgs.get
chicken.verify : $(CHICKEN_PKG)
ffcall.verify :
binpkgs.verify : binpkgs.get
srcpkgs.extract : srcpkgs.verify $(CHICKEN_DIR) $(FFCALL_DIR)
$(CHICKEN_DIR) : chicken.verify
tar zxvf $(CHICKEN_PKG)
touch $(CHICKEN_DIR)
$(FFCALL_DIR) :
$(GET_FFCALL)
touch $(FFCALL_DIR)
binpkgs.install : binpkgs.verify iup_all.install
iup_all.install : lzma-kludge im.install cd.install iup.install
im.install : DEST_DIR = $(IUP_LIBDIR)
im.install : $(IM_PKG)
$(UNZIP_CMD)
cd.install : DEST_DIR = $(IUP_LIBDIR)
cd.install : $(CD_PKG)
$(UNZIP_CMD)
iup.install : DEST_DIR = $(IUP_LIBDIR)
iup.install : $(IUP_PKG)
$(UNZIP_CMD)
lzma-kludge :
if [ "${UNZIP}" = "bsdtar" ]; then \
cd /bin && ln -sf msys-lzma-5.dll msys-lzma-1.dll; \
fi
srcpkgs.compile : chicken.compile ffcall.compile
chicken.compile : $(CHICKEN_DIR) $(CHICKEN_DIR)/chicken.h.orig
cd $(CHICKEN_DIR) && \
$(MAKE) PLATFORM=$(CHICKEN_PLATFORM) PREFIX=$(CHICKEN_PREFIX)
$(CHICKEN_DIR)/chicken.h.orig : $(CHICKEN_DIR)
cd $(CHICKEN_DIR) && \
patch -p0 <../0001-Disable-getc_unlocked.patch
ffcall.compile : $(FFCALL_DIR)
cd $(FFCALL_DIR) && \
./configure --prefix=$(FFCALL_PREFIX) && \
$(MAKE)
base.install : srcpkgs.compile chicken.install ffcall.install binpkgs.install
# chicken.install : chicken.compile
chicken.install :
cd $(CHICKEN_DIR) && \
$(MAKE) PLATFORM=$(CHICKEN_PLATFORM) PREFIX=$(CHICKEN_PREFIX) install
ffcall.install :
cd $(FFCALL_DIR) && \
$(MAKE) install
install : base.install eggs
eggs :
chicken-install -D disable-iup-web iup
$(foreach egg,$(EGGS),chicken-install -keep-installed $(egg);)
# CAREFUL: this rule removes the entire $PREFIX directory tree!
binpkg.prep : chicken-iup.iss strip-lua
mkdir -p binpkg && \
mv $(PREFIX)/* binpkg && rmdir $(PREFIX)
chicken-iup.iss : chicken-iup.iss.in
sed "s#{%CIUPPrefix%}#$(strip $(NATIVE_PREFIX))#g" $< \
| sed "s#{%ChickenVersion%}#$(strip $(CHICKEN_VERSION)$(CHICKEN_PATCHLEVEL))#g" \
| sed "s#{%MinGWBindir%}#$(strip $(MINGW_BINDIR))#g" > $@
strip-lua :
rm -f $(IUP_LIBDIR)/*lua* $(IUP_LIBDIR)/include/*lua*
clean : chicken.clean ffcall.clean
chicken.clean :
cd $(CHICKEN_DIR) && \
$(MAKE) PLATFORM=$(CHICKEN_PLATFORM) clean
ffcall.clean :
cd $(FFCALL_DIR) && \
$(MAKE) clean
distclean :
rm -rf $(SRC_PKGS) $(BIN_PKGS) $(SRC_DIRS) binpkg Output chicken-iup.iss