-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake
executable file
·151 lines (144 loc) · 3.92 KB
/
make
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
DSRC="src/"
LINUXSTAT=1 # 1 static build, 0 not
LUALINUX="dep/lua-5.4.2/lua_linux"
LUAWIN="dep/lua-5.4.2/lua_win"
LUAWEB="dep/lua-5.4.2/lua_web"
RAYLIBLIN="dep/raylib-5.5_linux_amd64"
RAYLIBWIN="dep/raylib-5.5_win32_mingw-w64"
RAYLIBWEB="dep/raylib-5.5_webassembly"
if [ $LINUXSTAT -eq 1 ];then
RAYLIBLIN="dep/raylib-5.5_linux_amd64_stat"
fi
CC=gcc
if [ -f "src/main.cpp" ];then
CC=g++
fi
CFLAGS="-g -Wall -L${RAYLIBLIN}/lib -L${LUALINUX}/lib -llua -lraylib -lGL -lm -lpthread -ldl -lrt -lX11"
INC="-I../${RAYLIBLIN}/include -I../${LUALINUX}/include -Isrc"
EXEC="egba"
DOBJ="build/linux64/"
CC2=i686-w64-mingw32-gcc
CFLAGS2="-g -Wall -lm -L${LUAWIN}/lib -llua -L${RAYLIBWIN}/lib -lraylib -lopengl32 -lgdi32 -lwinmm -mwindows -static-libgcc"
if [ -f "src/main.cpp" ];then
CC2=i686-w64-mingw32-g++
CFLAGS2="-g -Wall -lm -L${LUAWIN}/lib -llua -L${RAYLIBWIN}/lib -lraylib -lopengl32 -lgdi32 -lwinmm -mwindows -static-libgcc -static-libstdc++"
fi
#-static-libstdc++ -static-libgcc"
INC2="-I../${LUAWIN}/include -I../${RAYLIBWIN}/include"
# -I/usr/i696-w64-mingw32/include"
EXEC2="egba.exe"
DOBJ2="build/win86/"
TCC="";
TCFLAGS="";
TINC="";
TEXEC="";
TLINK=" ";
TDOBJ=" ";
function init()
{
TCC="$1";#compilo
TINC="$2";#inlcude dir
TCFLAGS="$3";#flag/ lib dir
TEXEC="$4";#out exec
TDOBJ="$5";#obj dir
}
function comp(){
local out;
if [ -f "src/main.c" ];then
cd $DSRC
for i in *.c ;do
out="$TDOBJ${i:0:-2}.o"
rm -f $out;
echo rm -f $out;
command $TCC -c $i $TINC -g -Wall -o ../$out;
echo $TCC -c $i $TINC -o ../$out;
TLINK="$TLINK $out";
done
elif [ -f "src/main.cpp" ];then
cd $DSRC
for i in *.c ;do
out="$TDOBJ${i:0:-2}.o"
rm -f $out;
echo rm -f $out;
command $TCC -c $i $TINC -g -Wall -o ../$out;
echo $TCC -c $i $TINC -o ../$out;
TLINK="$TLINK $out";
done
for i in *.cpp ;do
out="$TDOBJ${i:0:-4}.o"
rm -f $out;
echo rm -f $out;
command $TCC -c $i $TINC -g -Wall -o ../$out;
echo $TCC -c $i $TINC -o ../$out;
TLINK="$TLINK $out";
done
fi
cd ..
}
function link(){
if [ -f $TEXEC ];then
rm $TEXEC
fi
command $TCC $TLINK $TCFLAGS "-o" $TEXEC;
echo $TCC $TLINK $TCFLAGS "-o" $TEXEC;
if [ -f $EXEC ];then
command ./$TEXEC;
else
echo " "
echo "[[ compile error ]]"
fi;
}
OS="`uname`";
if [ $# -eq 0 ];then
if [ $OS == "Linux" ];then
# default linux ./make
rm -f $TEXEC;
init "$CC" "$INC" "$CFLAGS" "$EXEC" "$DOBJ";
comp;
link;
fi
if [ $OS == "Windows" ];then
# default window ./make
rm -f $EXEC2;
init "$CC" "$INC2" "$CFLAGS2" "$EXEC2" "$DOBJ2";
comp;
link;
fi
elif [ "$1" == "w" ];then
# linux to window ./make w
init "$CC2" "$INC2" "$CFLAGS2" "$EXEC2" "$DOBJ2";
comp;
link;
elif [ "$1" == "web" ];then
DEXEC="build/web"
for n in $DEXEC/* ;do
if [ $n != "$DEXEC/favicon.ico" ] && [ $n != "$DEXEC/index.html" ];then
rm -f $n
fi
done
# can craft with void ./asset dir
if [ -f "src/main.cpp" ];then
cd src;
for i in "*.cpp" ;do
em++ -c $i -I$RAYLIBWEB/include -Isrc;
#echo $TCC -c $i -I../include;
done;
cd ..;
em++ -o build/web/index.js src/*.o -Os -Wall $RAYLIBWEB/lib/libraylib.a -I. -Iinclude -L. -Llib -s USE_GLFW=3 -s ASYNCIFY -DPLATFORM_WEB --preload-file ./asset;
# echo "$TCC -o build/web/index.js src/*.o -Os -Wall $RAYLIBWEB/lib/libraylib.a -I. -Iinclude -L. -Llib -s USE_GLFW=3 -s ASYNCIFY -DPLATFORM_WEB --preload-file ./asset"
elif [ -f "src/main.c" ];then
cd src;
for i in "*.c" ;do
emcc -c $i -I../$RAYLIBWEB/include -I../$LUAWEB/include -Isrc;
#echo $TCC -c $i -I../include;
done;
cd ..;
emcc -o build/web/index.js src/*.o -Os -Wall $RAYLIBWEB/lib/libraylib.a $LUAWEB/lib/liblua.a -I. -Iinclude -L. -Llib -s USE_GLFW=3 -s ASYNCIFY -DPLATFORM_WEB --preload-file ./asset;
echo "emcc -o build/web/index.js src/*.o -Os -Wall $RAYLIBWEB/lib/raylib.a -I. -Iinclude -L. -Llib -s USE_GLFW=3 -s ASYNCIFY -DPLATFORM_WEB --preload-file ./asset";
fi
if [ "$2" = "z" ]; then
cd build/web;
zip -o ../index.zip *
fi
fi