-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpremake.sh
More file actions
executable file
·134 lines (122 loc) · 3.4 KB
/
premake.sh
File metadata and controls
executable file
·134 lines (122 loc) · 3.4 KB
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
#!/bin/sh
BUILD_OS="unknown"
BUILD_PLATFORM="x32"
BUILD_MAKE="make"
BUILD_MAKE_PLATFORM="32"
BUILD_ARGS=""
BUILD_CPU_COUNT=1
BUILD_USE_CLANG=1
for arg in "$@"; do
case $arg in
"gcc")
BUILD_ARGS=${BUILD_ARGS}" --gcc"
BUILD_USE_CLANG=0
;;
"cuda")
BUILD_ARGS=${BUILD_ARGS}" --cuda"
;;
"pocl")
BUILD_ARGS=${BUILD_ARGS}" --pocl"
;;
"windows")
BUILD_ARGS=${BUILD_ARGS}" --windows"
;;
"internal-debug")
BUILD_ARGS=${BUILD_ARGS}" --internal-debug"
;;
"cl-profiling")
BUILD_ARGS=${BUILD_ARGS}" --cl-profiling"
;;
"gldrawpixels")
BUILD_ARGS=${BUILD_ARGS}" --gldrawpixels"
;;
*)
;;
esac
done
if [ $BUILD_USE_CLANG == 1 ]; then
BUILD_ARGS=${BUILD_ARGS}" --clang"
fi
case $( uname | tr [:upper:] [:lower:] ) in
"darwin")
BUILD_OS="macosx"
BUILD_CPU_COUNT=$(sysctl -n hw.ncpu)
;;
"linux")
BUILD_OS="linux"
# note that this includes hyper-threading and multi-socket systems
BUILD_CPU_COUNT=$(cat /proc/cpuinfo | grep "processor" | wc -l)
;;
[a-z0-9]*"bsd")
BUILD_OS="bsd"
BUILD_MAKE="gmake"
BUILD_CPU_COUNT=$(sysctl -n hw.ncpu)
;;
"cygwin"*)
BUILD_OS="windows"
BUILD_ARGS=${BUILD_ARGS}" --env cygwin"
BUILD_CPU_COUNT=$(env | grep 'NUMBER_OF_PROCESSORS' | sed -E 's/.*=([:digit:]*)/\1/g')
;;
"mingw"*)
BUILD_OS="windows"
BUILD_ARGS=${BUILD_ARGS}" --env mingw"
BUILD_CPU_COUNT=$(env | grep 'NUMBER_OF_PROCESSORS' | sed -E 's/.*=([:digit:]*)/\1/g')
;;
*)
echo "unknown operating system - exiting"
exit
;;
esac
BUILD_PLATFORM_TEST_STRING=""
if [ $BUILD_OS != "windows" ]; then
BUILD_PLATFORM_TEST_STRING=$( uname -m )
else
BUILD_PLATFORM_TEST_STRING=$( gcc -dumpmachine | sed "s/-.*//" )
fi
case $BUILD_PLATFORM_TEST_STRING in
"i386"|"i486"|"i586"|"i686")
BUILD_PLATFORM="x32"
BUILD_MAKE_PLATFORM="32"
BUILD_ARGS=${BUILD_ARGS}" --platform x32"
;;
"x86_64"|"amd64")
BUILD_PLATFORM="x64"
BUILD_MAKE_PLATFORM="64"
BUILD_ARGS=${BUILD_ARGS}" --platform x64"
;;
*)
echo "unknown architecture - using "${BUILD_PLATFORM}
exit;;
esac
echo "using: premake4 --cc=gcc --os="${BUILD_OS}" gmake"${BUILD_ARGS}
premake4 --cc=gcc --os=${BUILD_OS} gmake ${BUILD_ARGS}
sed -i -e 's/\${MAKE}/\${MAKE} -j '${BUILD_CPU_COUNT}'/' Makefile
if [ $BUILD_USE_CLANG == 1 ]; then
# this seems to be the most portable way of inserting chars in front of a file
# note that "sed -i "1i ..." file" is not portable!
mv Makefile Makefile.tmp
echo "export CC=clang" > Makefile
echo "export CXX=clang++" >> Makefile
cat Makefile.tmp >> Makefile
rm Makefile.tmp
fi
sed -i -e 's/-std=c++11/-std=c11/g' lib/Makefile
sed -i -e 's/-Wall -stdlib=libc++/-Wall/g' lib/Makefile
sed -i -e 's/CXXFLAGS += $(CFLAGS)/CXXFLAGS += $(CFLAGS) -std=c++11 -stdlib=libc++/g' lib/Makefile
chmod +x lib/build_version.sh
echo ""
echo "############################################################################"
echo "#"
echo "# NOTE: use '"${BUILD_MAKE}"' to build oclraster"
echo "#"
echo "############################################################################"
echo ""
echo ""
echo "############################################################################"
echo "# if you have just cloned oclraster, but haven't cloned its submodules yet:"
echo "#"
echo "# run: git submodule init && git submodule update && ./premake.sh"
echo "# and on every submodule change: git submodule update"
echo "#"
echo "############################################################################"
echo ""