more SystemCall fixes
[io/quag.git] / Makefile
blobab06e1965973c39b9c4c82f297568409d72df2ff
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 mkdir -p _build/binaries || true
86 cp tools/_build/binaries/* _build/binaries
87 @$(MAKE) -s -C tools/editlib_test warn
89 addons: vm
90 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io
91 @$(MAKE) -s -C tools/editlib_test warn
92 @if [ -f errors ]; then cat errors; echo; echo "Note: addons do not to build when libs or headers are missing"; echo; rm errors; fi
94 vmlib:
95 mkdir -p _build || true
96 mkdir -p _build/dll || true
97 $(LINKDLL) $(DLL_COMMAND) $(LINKDLLOUTFLAG)_build/dll/libiovmall.$(DLL_SUFFIX) libs/*/_build/$(VMALL)objs/*.o $(LFLAGS) $(DLL_EXTRA_LIBS)
98 mkdir -p _build/lib || true
99 $(AR) $(ARFLAGS) $(AROUTFLAG)_build/lib/libiovmall.a\
100 libs/*/_build/$(VMALL)objs/*.o
101 mkdir -p _build/headers || true
102 cp libs/*/_build/headers/* _build/headers
104 # Unlink the io binary before copying so running Io processes will keep running
105 install:
106 umask 022
107 mkdir -p $(INSTALL_PREFIX)/bin || true
108 mkdir -p $(INSTALL_PREFIX)/lib || true
109 rm -f $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
110 cp _build/binaries/io$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin || true
111 chmod ugo+rx $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
112 cp _build/binaries/io_static$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
113 chmod ugo+rx $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX) || true
114 cp _build/dll/* $(INSTALL_PREFIX)/lib || true
115 cp _build/dll/* $(INSTALL_PREFIX)/bin || true
116 cp _build/lib/* $(INSTALL_PREFIX)/lib || true
117 rm -rf $(INSTALL_PREFIX)/lib/io || true
118 mkdir -p $(INSTALL_PREFIX)/lib/io || true
119 cp -fR addons $(INSTALL_PREFIX)/lib/io
120 chmod -R ugo+rX $(INSTALL_PREFIX)/lib/io
122 linkInstall:
123 mkdir -p $(INSTALL_PREFIX)/bin || true
124 ln -sf `pwd`/_build/binaries/io$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
125 chmod ugo+rx $(INSTALL_PREFIX)/bin/io
126 ln -sf `pwd`/_build/binaries/io_static$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
127 chmod ugo+rx $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX)
128 ln -sf `pwd`/_build/dll/* $(INSTALL_PREFIX)/lib
129 ln -sf `pwd`/_build/dll/* $(INSTALL_PREFIX)/bin
130 ln -sf `pwd`/_build/lib/* $(INSTALL_PREFIX)/lib
131 rm -rf $(INSTALL_PREFIX)/lib/io || true
132 mkdir -p $(INSTALL_PREFIX)/lib/io || true
133 ln -s `pwd`/addons $(INSTALL_PREFIX)/lib/io/addons
134 chmod -R ugo+rX $(INSTALL_PREFIX)/lib/io
136 uninstall:
137 rm -rf $(INSTALL_PREFIX)/lib/io
138 rm $(INSTALL_PREFIX)/bin/io
139 rm $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX)
140 rm $(INSTALL_PREFIX)/bin/libiovmall.*
141 rm $(INSTALL_PREFIX)/lib/libiovmall.*
143 doc:
144 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io docs
146 cleanDocs:
147 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io cleanDocs
149 clean:
150 for dir in $(libs); do \
151 $(MAKE) -C libs/$$dir clean; \
152 done
154 cd tools; $(MAKE) cleanDocs; cd ..
155 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io clean || true
156 -rm -f IoBindingsInit.*
157 -rm -rf _build
158 -rm -rf projects/osx/build
159 -rm -rf projects/osxvm/build
160 $(MAKE) -C tools clean
161 $(MAKE) -C tools/editlib_test clean
163 testvm:
164 cd tools; make test
166 testaddons:
167 _build/binaries/io$(BINARY_SUFFIX) build.io runUnitTests
169 test:
170 $(MAKE) testvm
171 $(MAKE) testaddons
173 dist:
174 -rm -f Io-*.tar.gz
175 echo "#define IO_VERSION_NUMBER "$(shell date +'%Y%m%d') > libs/iovm/source/IoVersion.h
176 #git add libs/iovm/source/IoVersion.h
177 #git commit -q --no-verify -m "setting version string for release"
178 git archive --format=tar --prefix=Io-$(date)/ HEAD | gzip > Io-$(date).tar.gz
179 ls -al Io-$(date).tar.gz
181 metrics:
182 ls -1 libs/iovm/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " iovm"'
183 ls -1 libs/basekit/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " basekit"'
184 ls -1 libs/coroutine/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " libcoroutine"'
185 ls -1 libs/*/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " total in core"'
187 aptget:
188 _build/binaries/io$(BINARY_SUFFIX) build.io aptget
190 emerge:
191 _build/binaries/io$(BINARY_SUFFIX) build.io emerge
193 port:
194 _build/binaries/io$(BINARY_SUFFIX) build.io port
196 urpmi:
197 _build/binaries/io$(BINARY_SUFFIX) build.io urpmi
199 .DEFAULT:
200 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io -a $@