Skip to content

Commit d8682ff

Browse files
committed
some emscripten support returns
1 parent dbc923b commit d8682ff

File tree

10 files changed

+101
-31
lines changed

10 files changed

+101
-31
lines changed

configure.ac

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,37 @@ AC_PROG_CXX
88
AC_LANG(C++)
99

1010
AC_CONFIG_MACRO_DIRS([m4 m4/autoconf-archive])
11-
AX_CHECK_GL
11+
12+
dnl emscripten
13+
AC_ARG_ENABLE([emscripten],
14+
AS_HELP_STRING([--enable-emscripten], [Build for web with emscripten]),
15+
[], [enable_emscripten=no])
16+
AS_IF([test "x$enable_emscripten" = "xyes"], [
17+
dnl Set up emscripten
18+
m4_include([m4/emscripten.m4])
19+
AC_DEFINE([EMSCRIPTEN], [1], [Define EMSCRIPTEN])
20+
enable_threading=no
21+
], [
22+
dnl Running in a normal OS (not emscripten)
23+
AX_CHECK_GL
24+
25+
# check OS
26+
AC_CANONICAL_HOST
27+
AC_MSG_CHECKING(Freedom)
28+
case $host_os in
29+
darwin*)
30+
# OSX needs CoreFoundation
31+
AC_MSG_RESULT(Apple hoarderware detected)
32+
LIBS="$LIBS -framework CoreFoundation"
33+
;;
34+
linux*)
35+
# limux needs dl
36+
AC_MSG_RESULT(GNU/LINUX detected)
37+
LIBS="$LIBS -ldl"
38+
;;
39+
esac
40+
])
41+
1242

1343
AC_CHECK_LIB(c, dlopen, LIBDL="", AC_CHECK_LIB(dl, dlopen, LIBDL="-ldl"))
1444

@@ -25,6 +55,7 @@ AC_CONFIG_FILES([
2555
src/libprojectM/libprojectM.pc
2656
src/NativePresets/Makefile
2757
src/projectM-sdl/Makefile
58+
src/projectM-emscripten/Makefile
2859
src/projectM-qt/Makefile
2960
src/projectM-pulseaudio/Makefile
3061
])
@@ -37,14 +68,20 @@ AS_IF([test "x$enable_sdl" = "xyes"], [
3768
m4_include([m4/sdl2.m4])
3869
SDL_VERSION=2.0.5
3970
AS_IF([test "$TRAVIS"], [SDL_VERSION=2.0.2]) # travis has old SDL, we don't care
71+
AS_IF([test "EMSCRIPTEN"], [SDL_VERSION=2.0.0]) # emscripten has old SDL, we don't care
4072
AM_PATH_SDL2($SDL_VERSION, :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))
4173
])
4274

75+
dnl glm
76+
AS_IF([test "x$enable_emscripten" != "xyes"], [
77+
AC_CHECK_HEADER([glm/glm.hpp],, AC_MSG_ERROR(libglm is required.))
78+
])
79+
4380
dnl Threading
4481
AC_ARG_ENABLE([threading],
4582
AS_HELP_STRING([--enable-threading], [multhreading]),
4683
[], [enable_threading=yes])
47-
AS_IF([test "x$enable_threading" = "xyes"], [
84+
AS_IF([test "x$enable_threading" = "xyes" && ! test "$EMSCRIPTEN"], [
4885
m4_include([m4/autoconf-archive/ax_pthread.m4])
4986
AX_PTHREAD([
5087
AC_DEFINE([USE_THREADS], [1], [Define USE_THREADS])
@@ -57,8 +94,6 @@ AS_IF([test "x$enable_threading" = "xyes"], [
5794
])
5895
])
5996

60-
AC_CHECK_HEADER([glm/glm.hpp],, AC_MSG_ERROR(libglm is required.))
61-
6297
AC_ARG_ENABLE([gles],
6398
AS_HELP_STRING([--enable-gles], [OpenGL ES support]),
6499
[], [enable_gles=no])
@@ -75,7 +110,7 @@ AC_CONFIG_FILES([src/libprojectM/config.inp.in])
75110
AC_PREFIX_DEFAULT([/usr/local])
76111

77112
AC_PROG_MKDIR_P
78-
113+
79114
AX_CHECK_COMPILE_FLAG([-stdlib=libc++], [
80115
CXXFLAGS="$CXXFLAGS -stdlib=libc++"])
81116

@@ -108,28 +143,14 @@ AS_IF([test "x$enable_qt" = "xyes"], [
108143

109144
AM_CONDITIONAL([ENABLE_SDL], [test "$enable_sdl" = yes])
110145
AM_CONDITIONAL([ENABLE_QT], [test "$enable_qt" = yes])
146+
AM_CONDITIONAL([ENABLE_EMSCRIPTEN], [test "$enable_emscripten" = yes])
111147

112148

113149
my_CFLAGS="-Wall -Wchar-subscripts -Wformat-security -Wmissing-declarations -Wpointer-arith -Wshadow -Wsign-compare -Wtype-limits "
114-
my_CFLAGS+='-DDATADIR_PATH=\""$(pkgdatadir)"\"'
150+
my_CFLAGS+='-DDATADIR_PATH=\""$(pkgdatadir)"\" '
151+
my_CFLAGS+='-I$(top_srcdir)/vendor '
115152
AC_SUBST([my_CFLAGS])
116153

117-
# check OS
118-
AC_CANONICAL_HOST
119-
AC_MSG_CHECKING(Freedom)
120-
case $host_os in
121-
darwin*)
122-
# OSX needs CoreFoundation
123-
AC_MSG_RESULT(Apple hoarderware detected)
124-
LIBS="$LIBS -framework CoreFoundation"
125-
;;
126-
linux*)
127-
# limux needs dl
128-
AC_MSG_RESULT(GNU/LINUX detected)
129-
LIBS="$LIBS -ldl"
130-
;;
131-
esac
132-
133154

134155

135156
AC_OUTPUT
@@ -157,4 +178,5 @@ Threading: ${enable_threading}
157178
SDL: ${enable_sdl}
158179
Qt & Pulseaudio: ${enable_qt}
159180
OpenGLES: ${enable_gles}
181+
Emscripten: ${enable_emscripten}
160182
])

m4/autoconf-archive/ax_check_gl.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ AC_DEFUN_ONCE([_WITH_XQUARTZ_GL],[
232232
# OSX specific setup for OpenGL check
233233
AC_DEFUN([_AX_CHECK_DARWIN_GL], [
234234
AC_REQUIRE([_WITH_XQUARTZ_GL])
235-
AS_IF([test "x$with_xquartz_gl" != "xno"],
235+
AS_IF([test "x$with_xquartz_gl" != "xno" && test "x$EMSCRIPTEN" == "x"],
236236
[GL_LIBS="${GL_LIBS:--lGL}"],
237237
[GL_LIBS="${GL_LIBS:--framework OpenGL}"])
238238
])

m4/emscripten.m4

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
AC_DEFUN([AM_EMSCRIPTEN],
2+
[
3+
AC_MSG_CHECKING(for emscripten compiler)
4+
emscripten_compiler=no
5+
AC_TRY_COMPILE([
6+
#ifndef EMSCRIPTEN
7+
#error "not an emscripten compiler"
8+
#endif
9+
],[
10+
],[
11+
host=javascript-web-emscripten
12+
emscripten_compiler=yes
13+
cross_compiling=yes
14+
])
15+
AC_MSG_RESULT($emscripten_compiler)
16+
AM_CONDITIONAL(EMSCRIPTEN, [test "x$emscripten_compiler" = "xyes"])
17+
])

src/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ if ENABLE_QT
66
PROJECTM_QT_SUBDIR = projectM-qt projectM-pulseaudio
77
endif
88

9-
SUBDIRS=libprojectM NativePresets ${PROJECTM_SDL_SUBDIR} ${PROJECTM_QT_SUBDIR}
9+
if ENABLE_EMSCRIPTEN
10+
PROJECTM_EMSCRIPTEN_SUBDIR = projectM-emscripten
11+
endif
12+
13+
SUBDIRS=libprojectM NativePresets ${PROJECTM_SDL_SUBDIR} ${PROJECTM_QT_SUBDIR} ${PROJECTM_EMSCRIPTEN_SUBDIR}
1014

1115
# system headers/libraries/data to install
1216
# for compatibility reasons here as nobase_include

src/NativePresets/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AM_CPPFLAGS = \
1+
AM_CPPFLAGS = ${my_CFLAGS} \
22
-include $(top_builddir)/config.h \
33
-I${top_srcdir}/src/libprojectM \
44
-I${top_srcdir}/src/libprojectM/Renderer \

src/libprojectM/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ CLEANFILES=
44
SUBDIRS=Renderer NativePresetFactory MilkdropPresetFactory
55

66
AM_CPPFLAGS = \
7-
$(my_CFLAGS) \
7+
${my_CFLAGS} \
88
-include $(top_builddir)/config.h \
99
-DSYSCONFDIR=\""$(sysconfdir)"\" \
1010
-I$(top_srcdir)/src/libprojectM \
11-
-I$(top_srcdir)/src/libprojectM/Renderer
11+
-I$(top_srcdir)/src/libprojectM/Renderer \
12+
-I$(top_srcdir)/vendor
1213

1314
lib_LTLIBRARIES = libprojectM.la # public, possibly-shared library
1415

src/libprojectM/MilkdropPresetFactory/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ Eval.hpp MilkdropPresetFactory.hpp PresetFrameIO.hpp\
1515
Expr.hpp Param.hpp
1616

1717
:
18-
libMilkdropPresetFactory_la_CPPFLAGS = $(my_CFLAGS) \
19-
-I$(top_srcdir)/src/libprojectM $(CG_CFLAGS)
18+
libMilkdropPresetFactory_la_CPPFLAGS = ${my_CFLAGS} \
19+
-I$(top_srcdir)/src/libprojectM

src/libprojectM/Renderer/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ libRenderer_la_CPPFLAGS = ${my_CFLAGS} \
5252
-I$(top_srcdir)/src/libprojectM
5353

5454
libRenderer_la_LDFLAGS = \
55-
${FTGL_LIBS} ${CG_LDFLAGS}
55+
${FTGL_LIBS}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
AM_CPPFLAGS = \
2+
${my_CFLAGS} \
3+
-include $(top_builddir)/config.h \
4+
-DSYSCONFDIR=\""$(sysconfdir)"\" \
5+
-I${top_srcdir}/src/libprojectM \
6+
-I${top_srcdir}/src/libprojectM/Renderer \
7+
USE_SDL=2 \
8+
${SDL_CFLAGS}
9+
10+
REALSRCDIR=${top_srcdir}/src/projectM-sdl
11+
12+
bin_PROGRAMS = projectW.bc
13+
projectW_bc_SOURCES = $(REALSRCDIR)/pmSDL.cpp $(REALSRCDIR)/projectM_SDL_main.cpp $(REALSRCDIR)/pmSDL.hpp
14+
projectW_bc_LDADD = ${SDL_LIBS} ${top_srcdir}/src/libprojectM/libprojectM.la
15+
projectW_bc_LDFLAGS = -static -s USE_SDL=2
16+
projectW_bc_PROGRAM = projectW.bc
17+
18+
# emcc -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1 projectW.bc -o projectW.html

src/projectM-emscripten/README

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
HOW2COMPILE:
1+
Building w/ emscripten
2+
3+
* Activate the emsdk
4+
* `emconfigure ./configure --enable-emscripten --enable-gles --enable-sdl`
5+
* `emmake make -j4`
6+
7+
8+
9+
210

311
emcc -I../libprojectm -I../libprojectM/Renderer -Llib \
412
../libprojectM/KeyHandler.cpp projectM_SDL_emscripten.cpp \

0 commit comments

Comments
 (0)