SystemCall run(block) can now exit the run if it returns false
[io/quag.git] / Makefile
blob19af721b0b16945f76bd569d3bcb880c4680c02a
1 INSTALL_PREFIX ?= /usr/local
3 SYS ?= $(shell uname -s)
5 NEEDS_DL := Darwin Linux SunOS syllable
6 ifneq (,$(findstring $(SYS),$(NEEDS_DL)))
7 LFLAGS +=-ldl
8 LFLAGS += -ledit
9 endif
11 NEEDS_M := FreeBSD Linux NetBSD
12 ifneq (,$(findstring $(SYS),$(NEEDS_M)))
13 LFLAGS +=-lm
14 endif
16 #NEEDS_PTHREAD := FreeBSD Linux NetBSD
17 #ifneq (,$(findstring $(SYS),$(NEEDS_PTHREAD)))
18 #LFLAGS +=-lpthread
19 #endif
21 DLL_SUFFIX := so
22 DLL_COMMAND := -shared -Wl,-soname="libiovmall.so"
23 FLAT_NAMESPACE :=
25 LINKDLL := $(CC)
26 LINKDLLOUTFLAG := -o
27 LINKDIRFLAG := -L
28 LINKLIBFLAG := -l
29 DLL_LIB_SUFFIX :=
30 CCOUTFLAG := -o
31 AROUTFLAG :=
32 RANLIB ?= ranlib
33 AR ?= ar
34 ARFLAGS := rcu
36 ifeq ($(SYS),Darwin)
37 DLL_SUFFIX := dylib
38 DLL_COMMAND := -dynamiclib
39 FLAT_NAMESPACE := -flat_namespace
40 endif
42 ifneq (,$(findstring CYGW,$(SYS)))
43 DLL_SUFFIX := dll
44 BINARY_SUFFIX := .exe
45 endif
47 ifneq (,$(findstring MINGW,$(SYS)))
48 DLL_SUFFIX := dll
49 BINARY_SUFFIX := .exe
50 endif
52 ifneq (,$(findstring Windows,$(SYS)))
53 CC := cl -nologo
54 LINKDLL := link
55 LINKDLLOUTFLAG :=-out:
56 DLL_SUFFIX := dll
57 DLL_COMMAND := -dll -debug /INCREMENTAL:NO -subsystem:CONSOLE
58 DLL_EXTRA_LIBS := ws2_32.lib
59 FLAT_NAMESPACE :=
60 AR := link -lib
61 ARFLAGS :=
62 AROUTFLAG := -out:
63 VMALL := vmall_
64 BINARY_SUFFIX := .exe
65 endif
67 ###########################
69 date := $(shell date +'%Y-%m-%d')
71 #libs := $(shell ls libs)
72 libs := basekit coroutine garbagecollector iovm
74 all: addons
76 testaddon:
77 ./_build/binaries/io_static$(BINARY_SUFFIX) addons/$(addon)/tests/run.io
79 vm:
80 $(MAKE) -C tools/editlib_test clean
81 $(MAKE) -C tools/editlib_test || true
82 for dir in $(libs); do INSTALL_PREFIX=$(INSTALL_PREFIX) $(MAKE) -C libs/$$dir; done
83 $(MAKE) vmlib
84 cd tools; $(MAKE)
85 ifneq (,$(findstring Windows,$(SYS)))
86 mt.exe -manifest tools/_build/binaries/io.exe.manifest -outputresource:tools/_build/binaries/io.exe
87 rm tools/_build/binaries/io.exe.manifest
88 mt.exe -manifest tools/_build/binaries/io_static.exe.manifest -outputresource:tools/_build/binaries/io_static.exe
89 rm tools/_build/binaries/io_static.exe.manifest
90 endif
91 mkdir -p _build/binaries || true
92 cp tools/_build/binaries/* _build/binaries
93 @$(MAKE) -s -C tools/editlib_test warn
95 addons: vm
96 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io
97 @$(MAKE) -s -C tools/editlib_test warn
98 @if [ -f errors ]; then cat errors; echo; echo "Note: addons do not to build when libs or headers are missing"; echo; rm errors; fi
100 vmlib:
101 mkdir -p _build || true
102 mkdir -p _build/dll || true
103 $(LINKDLL) $(DLL_COMMAND) $(LINKDLLOUTFLAG)_build/dll/libiovmall.$(DLL_SUFFIX) libs/*/_build/$(VMALL)objs/*.o $(LFLAGS) $(DLL_EXTRA_LIBS)
104 ifneq (,$(findstring Windows,$(SYS)))
105 mt.exe -manifest _build/dll/libiovmall.dll.manifest -outputresource:_build/dll/libiovmall.dll
106 rm _build/dll/libiovmall.dll.manifest
107 endif
108 mkdir -p _build/lib || true
109 $(AR) $(ARFLAGS) $(AROUTFLAG)_build/lib/libiovmall.a\
110 libs/*/_build/$(VMALL)objs/*.o
111 mkdir -p _build/headers || true
112 cp libs/*/_build/headers/* _build/headers
114 # Unlink the io binary before copying so running Io processes will keep running
115 install:
116 umask 022
117 mkdir -p $(INSTALL_PREFIX)/bin || true
118 mkdir -p $(INSTALL_PREFIX)/lib || true
119 rm -f $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
120 cp _build/binaries/io$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin || true
121 chmod ugo+rx $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
122 cp _build/binaries/io_static$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
123 chmod ugo+rx $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX) || true
124 cp _build/dll/* $(INSTALL_PREFIX)/lib || true
125 cp _build/dll/* $(INSTALL_PREFIX)/bin || true
126 cp _build/lib/* $(INSTALL_PREFIX)/lib || true
127 rm -rf $(INSTALL_PREFIX)/lib/io || true
128 mkdir -p $(INSTALL_PREFIX)/lib/io || true
129 cp -fR addons $(INSTALL_PREFIX)/lib/io
130 chmod -R ugo+rX $(INSTALL_PREFIX)/lib/io
132 linkInstall:
133 mkdir -p $(INSTALL_PREFIX)/bin || true
134 ln -sf `pwd`/_build/binaries/io$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
135 chmod ugo+rx $(INSTALL_PREFIX)/bin/io
136 ln -sf `pwd`/_build/binaries/io_static$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
137 chmod ugo+rx $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX)
138 ln -sf `pwd`/_build/dll/* $(INSTALL_PREFIX)/lib
139 ln -sf `pwd`/_build/dll/* $(INSTALL_PREFIX)/bin
140 ln -sf `pwd`/_build/lib/* $(INSTALL_PREFIX)/lib
141 rm -rf $(INSTALL_PREFIX)/lib/io || true
142 mkdir -p $(INSTALL_PREFIX)/lib/io || true
143 ln -s `pwd`/addons $(INSTALL_PREFIX)/lib/io/addons
144 chmod -R ugo+rX $(INSTALL_PREFIX)/lib/io
146 uninstall:
147 rm -rf $(INSTALL_PREFIX)/lib/io
148 rm $(INSTALL_PREFIX)/bin/io
149 rm $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX)
150 rm $(INSTALL_PREFIX)/bin/libiovmall.*
151 rm $(INSTALL_PREFIX)/lib/libiovmall.*
153 doc:
154 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io docs
156 cleanDocs:
157 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io cleanDocs
159 clean:
160 for dir in $(libs); do \
161 $(MAKE) -C libs/$$dir clean; \
162 done
164 cd tools; $(MAKE) cleanDocs; cd ..
165 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io clean || true
166 -rm -f IoBindingsInit.*
167 -rm -rf _build
168 -rm -rf projects/osx/build
169 -rm -rf projects/osxvm/build
170 $(MAKE) -C tools clean
171 $(MAKE) -C tools/editlib_test clean
173 testvm:
174 cd tools; make test
176 testaddons:
177 _build/binaries/io$(BINARY_SUFFIX) build.io runUnitTests
179 test:
180 $(MAKE) testvm
181 $(MAKE) testaddons
183 dist:
184 -rm -f Io-*.tar.gz
185 echo "#define IO_VERSION_NUMBER "$(shell date +'%Y%m%d') > libs/iovm/source/IoVersion.h
186 #git add libs/iovm/source/IoVersion.h
187 #git commit -q --no-verify -m "setting version string for release"
188 git archive --format=tar --prefix=Io-$(date)/ HEAD | gzip > Io-$(date).tar.gz
189 ls -al Io-$(date).tar.gz
191 metrics:
192 ls -1 libs/iovm/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " iovm"'
193 ls -1 libs/basekit/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " basekit"'
194 ls -1 libs/coroutine/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " libcoroutine"'
195 ls -1 libs/*/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " total in core"'
197 aptget:
198 _build/binaries/io$(BINARY_SUFFIX) build.io aptget
200 emerge:
201 _build/binaries/io$(BINARY_SUFFIX) build.io emerge
203 port:
204 _build/binaries/io$(BINARY_SUFFIX) build.io port
206 urpmi:
207 _build/binaries/io$(BINARY_SUFFIX) build.io urpmi
209 .DEFAULT:
210 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io -a $@