forked from google/liquidfun
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
118 lines (110 loc) · 4.87 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
#=BEGIN MIT LICENSE
#
# Copyright (c) 2014 Andras Csizmadia
# http://www.vpmedia.hu
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#=END MIT LICENSE
#
# Purpose: FlasCC library makefile
# Author: Andras Csizmadia
# Version: 1.0.0
# Platform: Windows
# Runtime: Cygwin with FlasCC
# FlashCC SDK root
$?FLASCC:=$(FLASCC_ROOT)/sdk
# C/C++ Compiler arguments
# 1. Remove all warning suppression
# 2. Adds additional warnings
# 3. Maximum optimization
# 4. Java virtual machine arguments
# Optional
# Debug: -O0 -g
$?CCOMPARGS:=-Wall -Wextra -O4 -jvmopt=-Xmx1G
# ActionScript 3.0 Compiler for AVM+ arguments
# 1. Merge the compiled source into a single output file
# 2. Emit metadata information into the bytecode
# 3. Warn on common actionscript mistakes
# 4. Produce an optimized ABC file
# 5. Turn on the inlining of functions
$?ASC2ARGS=-merge -md -warnings -optimize -inline
# SWIG Pre-Processor arguments
# 1. Remove all warning suppression, also implies -Wextra
# 2. Adds the following additional warnings: 202,309,403,512,321,322
# 3. Enable the optimization options: -fastdispatch -fvirtual
# 4. Generate AS3 wrappers
# 5. Enable C++ processing
# 6. Follow all #include statements
# 7. Ignore missing include files
# Optional
# Compile in compact mode: -fcompact
$?SWIGARGS:=-Wall -Wextra -O -as3 -c++ -includeall -ignoremissing
# Path helper
$?UNAME=$(shell uname -s)
ifneq (,$(findstring CYGWIN,$(UNAME)))
$?nativepath=$(shell cygpath -at mixed $(1))
$?unixpath=$(shell cygpath -at unix $(1))
else
$?nativepath=$(abspath $(1))
$?unixpath=$(abspath $(1))
endif
compile:
########################################
# Initializing ...
########################################
mkdir -p build
mkdir -p ./liquidfun/Box2D/Box2D/Dynamics/Controllers/
cp -r ./liquidfun/Contributions/Enhancements/Controllers/* ./liquidfun/Box2D/Box2D/Dynamics/Controllers/
########################################
# Making LiquidFun ...
########################################
cd build && PATH="$(call unixpath,$(FLASCC)/usr/bin):$(PATH)" CC=gcc CXX=g++ CFLAGS="$(CCOMPARGS)" CXXFLAGS="$(CCOMPARGS)" cmake ./../liquidfun/Box2D/ -DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_BUILD_UNITTESTS=OFF
########################################
# Building LiquidFun ...
########################################
cd build && make -j8
########################################
# Generating CXX ...
########################################
cd build && "$(FLASCC)/usr/bin/swig" $(SWIGARGS) -package org.liquidfun -I$(PWD)/src/main/swig -I$(PWD)/liquidfun/Box2D -module LiquidFun -outdir . -o $(PWD)/build/LiquidFun_wrap.cxx $(PWD)/src/main/swig/LiquidFun.i
########################################
# Generating ABC ...
########################################
cd build && java -jar $(call nativepath,$(FLASCC)/usr/lib/asc2.jar) $(ASC2ARGS) -import $(call nativepath,$(FLASCC)/usr/lib/builtin.abc) -import $(call nativepath,$(FLASCC)/usr/lib/playerglobal.abc) LiquidFun.as
########################################
# Generating O ...
########################################
cp -f src/main/templates/exports.txt build/
"$(FLASCC)/usr/bin/g++" $(CCOMPARGS) -I./liquidfun/Box2D -c build/LiquidFun_wrap.cxx -o build/LiquidFun_wrap.o
########################################
# Generating Exports ...
########################################
"$(FLASCC)/usr/bin/nm" build/LiquidFun_wrap.o | grep ' T ' | sed 's/.*__/_/' | sed 's/.* T //' >> build/exports.txt
########################################
# Generating SWC ...
########################################
cd build && "$(FLASCC)/usr/bin/g++" $(CCOMPARGS) -flto-api=exports.txt -I./../liquidfun/Box2D/ LiquidFun.abc LiquidFun_wrap.cxx Box2D/Release/libLiquidFun.a -emit-swc=org.liquidfun.core -o ../LiquidFun.swc -lAS3++ -lFlash++
########################################
# Post cleaning ...
########################################
rm -rf ./liquidfun/Box2D/Box2D/Dynamics/Controllers/
clean:
rm -rf build