Skip to content
Browse files

Initial cut of NaCL build configuration

  • Loading branch information...
1 parent 53c2c8f commit 8fa358a015df21c98c885593ed4cedae5f020b05 @johnmccutchan johnmccutchan committed
Showing with 448 additions and 0 deletions.
  1. +368 −0 Makefile.nacl
  2. +21 −0 config/Makefile.nacl-32
  3. +21 −0 config/Makefile.nacl-64
  4. +5 −0 examples/nacl/main.cpp
  5. +33 −0 nacl-regal.sh
View
368 Makefile.nacl
@@ -0,0 +1,368 @@
+include config/version
+
+SHELL = /bin/sh
+ifeq ($(NACL_PACKAGES_BITSIZE), 32)
+SYSTEM = nacl-32
+else
+SYSTEM = nacl-64
+endif
+REGAL_NACL = 1
+SYSTEM.SUPPORTED = $(shell test -f config/Makefile.$(SYSTEM) && echo 1)
+
+ifeq ($(SYSTEM.SUPPORTED), 1)
+include config/Makefile.$(SYSTEM)
+else
+$(error "Platform '$(SYSTEM)' not supported")
+endif
+
+REGAL_DEST ?= /usr
+BINDIR ?= $(REGAL_DEST)/bin
+LIBDIR ?= $(REGAL_DEST)/lib
+
+# To disable stripping of binaries either:
+# - use STRIP= on gmake command-line
+# - edit this makefile to set STRIP to the empty string
+#
+# To disable symlinks:
+# - use LN= on gmake command-line
+
+AR ?= ar
+INSTALL ?= install
+STRIP ?= strip
+RM ?= rm -f
+LN ?= ln -sf
+
+ifeq ($(MAKECMDGOALS), debug)
+OPT = -g
+STRIP :=
+else
+OPT = $(POPT)
+endif
+INCLUDE = -Iinclude
+CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
+
+all debug: regal.lib regal.bin
+
+# REGAL shared and static libraries
+
+export:
+ scripts/Export.py --api gl 4.2 --api wgl 4.0 --api glx 4.0 --api cgl 1.4 --api egl 1.0 --outdir src/regal
+
+LIB.LDFLAGS := -lstdc++ -lpthread -ldl -lm
+LIB.LIBS :=
+
+LIB.SRCS :=
+LIB.SRCS += src/regal/RegalIff.cpp
+LIB.SRCS += src/regal/Regal.cpp
+LIB.SRCS += src/regal/RegalToken.cpp
+LIB.SRCS += src/regal/RegalLog.cpp
+LIB.SRCS += src/regal/RegalInit.cpp
+LIB.SRCS += src/regal/RegalUtil.cpp
+LIB.SRCS += src/regal/RegalConfig.cpp
+LIB.SRCS += src/regal/RegalLookup.cpp
+LIB.SRCS += src/regal/RegalHelper.cpp
+LIB.SRCS += src/regal/RegalContext.cpp
+LIB.SRCS += src/regal/RegalContextInfo.cpp
+LIB.SRCS += src/regal/RegalDispatchEmu.cpp
+LIB.SRCS += src/regal/RegalDispatchLog.cpp
+LIB.SRCS += src/regal/RegalDispatchDebug.cpp
+LIB.SRCS += src/regal/RegalDispatchError.cpp
+LIB.SRCS += src/regal/RegalDispatchLoader.cpp
+LIB.SRCS += src/regal/RegalHttp.cpp
+LIB.SRCS += src/regal/RegalFavicon.cpp
+
+ifneq ($(REGAL_NACL), 1)
+LIB.SRCS += src/mongoose/mongoose.c
+LIB.INCLUDE += -Isrc/mongoose
+endif
+
+LIB.SRCS.NAMES := $(notdir $(LIB.SRCS))
+
+LIB.INCLUDE += -Isrc/boost
+
+LIB.DEPS :=
+LIB.DEPS += include/GL/Regal.h
+LIB.DEPS += src/regal/RegalPrivate.h
+
+LIB.OBJS := $(addprefix tmp/$(SYSTEM)/regal/static/,$(LIB.SRCS.NAMES))
+LIB.OBJS := $(LIB.OBJS:.c=.o)
+LIB.OBJS := $(LIB.OBJS:.cpp=.o)
+LIB.SOBJS := $(addprefix tmp/$(SYSTEM)/regal/shared/,$(LIB.SRCS.NAMES))
+LIB.SOBJS := $(LIB.SOBJS:.c=.o)
+LIB.SOBJS := $(LIB.SOBJS:.cpp=.o)
+
+CFLAGS += -DREGAL_NO_HTTP
+
+regal.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC)
+
+lib:
+ mkdir lib
+
+lib/$(LIB.STATIC): $(LIB.OBJS)
+ $(AR) cr $@ $^
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+lib/$(LIB.SHARED): $(LIB.SOBJS)
+ $(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
+ifneq ($(LN),)
+ $(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
+ $(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
+ifneq ($(LIB.FRAMEWORK),)
+ $(LN) $(LIB.SHARED) lib/$(LIB.FRAMEWORK)
+endif
+endif
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+tmp/$(SYSTEM)/regal/static/%.o: src/regal/%.cpp $(LIB.DEPS)
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(CFLAGS.SO) $(LIB.INCLUDE) -o $@ -c $<
+
+tmp/$(SYSTEM)/regal/shared/%.o: src/regal/%.cpp $(LIB.DEPS)
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) $(LIB.INCLUDE) -o $@ -c $<
+
+tmp/$(SYSTEM)/regal/static/%.o: src/mongoose/%.c $(LIB.DEPS)
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(CFLAGS.SO) $(LIB.INCLUDE) -o $@ -c $<
+
+tmp/$(SYSTEM)/regal/shared/%.o: src/mongoose/%.c $(LIB.DEPS)
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) $(LIB.INCLUDE) -o $@ -c $<
+
+#
+# RegalGLEW
+#
+
+GLEW.SRCS += src/glew/src/glew.c
+GLEW.SRCS.NAMES := $(notdir $(GLEW.SRCS))
+GLEW.OBJS := $(addprefix tmp/$(SYSTEM)/glew/shared/,$(GLEW.SRCS.NAMES))
+GLEW.OBJS := $(GLEW.OBJS:.c=.o)
+GLEW.CFLAGS := -Isrc/glew/include -Isrc/glu/include -DGLEW_EXPORTS -DGLEW_BUILD -DGLEW_REGAL
+GLEW.LIBS := -Llib -lRegal
+GLEW.SHARED := libRegalGLEW.$(EXT.DYNAMIC)
+GLEW.STATIC := libRegalGLEW.a
+
+glew.lib: lib lib/$(GLEW.SHARED)
+
+tmp/$(SYSTEM)/glew/shared/%.o: src/glew/src/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(PICFLAG) $(GLEW.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+
+lib/$(GLEW.SHARED): $(GLEW.OBJS) lib/$(LIB.SHARED)
+ $(LD) $(LDFLAGS.DYNAMIC) -o $@ $^ $(LIB.LDFLAGS) $(GLEW.LIBS) -lpthread
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+#
+# RegalGLEW glewinfo
+#
+
+GLEWINFO.SRCS += src/glew/src/glewinfo.c
+GLEWINFO.SRCS.NAMES := $(notdir $(GLEWINFO.SRCS))
+GLEWINFO.OBJS := $(addprefix tmp/$(SYSTEM)/glewinfo/static/,$(GLEWINFO.SRCS.NAMES))
+GLEWINFO.OBJS := $(GLEWINFO.OBJS:.c=.o)
+GLEWINFO.CFLAGS := -Iinclude -Isrc/glew/include -DGLEW_REGAL
+GLEWINFO.LIBS += -Llib -lRegal -lRegalGLEW $(LDFLAGS.GLUT) $(LDFLAGS.AGL)
+
+ifneq ($(filter linux%,$(SYSTEM)),)
+GLEWINFO.LIBS += -lX11
+endif
+
+tmp/$(SYSTEM)/glewinfo/static/%.o: src/glew/src/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(GLEWINFO.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+
+bin/glewinfo: $(GLEWINFO.OBJS) lib/$(LIB.SHARED) lib/$(GLEW.SHARED)
+ $(LD) -o $@ $^ $(LIB.LDFLAGS) $(GLEWINFO.LIBS)
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+
+ifneq ($(filter darwin%,$(SYSTEM)),)
+glut.lib:
+
+else
+
+#
+# RegalGLUT
+#
+
+# NOT for windows...
+
+GLUT.SRCS += src/glut/src/capturexfont.c
+GLUT.SRCS += src/glut/src/glut_glxext.c
+GLUT.SRCS += src/glut/src/glut_menu.c
+GLUT.SRCS += src/glut/src/glut_menu2.c
+GLUT.SRCS += src/glut/src/layerutil.c
+
+# Windows and Linux...
+
+GLUT.SRCS += src/glut/src/glut_8x13.c
+GLUT.SRCS += src/glut/src/glut_9x15.c
+GLUT.SRCS += src/glut/src/glut_bitmap.c
+GLUT.SRCS += src/glut/src/glut_bwidth.c
+GLUT.SRCS += src/glut/src/glut_cindex.c
+GLUT.SRCS += src/glut/src/glut_cmap.c
+GLUT.SRCS += src/glut/src/glut_cursor.c
+GLUT.SRCS += src/glut/src/glut_dials.c
+GLUT.SRCS += src/glut/src/glut_dstr.c
+GLUT.SRCS += src/glut/src/glut_event.c
+GLUT.SRCS += src/glut/src/glut_ext.c
+GLUT.SRCS += src/glut/src/glut_fcb.c
+GLUT.SRCS += src/glut/src/glut_fullscrn.c
+GLUT.SRCS += src/glut/src/glut_gamemode.c
+GLUT.SRCS += src/glut/src/glut_get.c
+GLUT.SRCS += src/glut/src/glut_hel10.c
+GLUT.SRCS += src/glut/src/glut_hel12.c
+GLUT.SRCS += src/glut/src/glut_hel18.c
+GLUT.SRCS += src/glut/src/glut_init.c
+GLUT.SRCS += src/glut/src/glut_input.c
+GLUT.SRCS += src/glut/src/glut_joy.c
+GLUT.SRCS += src/glut/src/glut_key.c
+GLUT.SRCS += src/glut/src/glut_keyctrl.c
+GLUT.SRCS += src/glut/src/glut_keyup.c
+GLUT.SRCS += src/glut/src/glut_mesa.c
+GLUT.SRCS += src/glut/src/glut_modifier.c
+GLUT.SRCS += src/glut/src/glut_mroman.c
+GLUT.SRCS += src/glut/src/glut_overlay.c
+GLUT.SRCS += src/glut/src/glut_roman.c
+GLUT.SRCS += src/glut/src/glut_shapes.c
+GLUT.SRCS += src/glut/src/glut_space.c
+GLUT.SRCS += src/glut/src/glut_stroke.c
+GLUT.SRCS += src/glut/src/glut_swap.c
+GLUT.SRCS += src/glut/src/glut_swidth.c
+GLUT.SRCS += src/glut/src/glut_tablet.c
+GLUT.SRCS += src/glut/src/glut_teapot.c
+GLUT.SRCS += src/glut/src/glut_tr10.c
+GLUT.SRCS += src/glut/src/glut_tr24.c
+GLUT.SRCS += src/glut/src/glut_util.c
+GLUT.SRCS += src/glut/src/glut_vidresize.c
+GLUT.SRCS += src/glut/src/glut_warp.c
+GLUT.SRCS += src/glut/src/glut_win.c
+GLUT.SRCS += src/glut/src/glut_winmisc.c
+GLUT.SRCS += src/glut/src/glut_ppm.c
+GLUT.SRCS.NAMES := $(notdir $(GLUT.SRCS))
+GLUT.OBJS := $(addprefix tmp/$(SYSTEM)/glut/shared/,$(GLUT.SRCS.NAMES))
+GLUT.OBJS := $(GLUT.OBJS:.c=.o)
+GLUT.CFLAGS := -Isrc/glut/include -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DGLUT_STATIC
+GLUT.LIBS := -Llib -lRegal
+GLUT.LIBS += -lGLU -lX11 -lXmu -lXi
+GLUT.LIBS += -lpthread -lm
+GLUT.SHARED := libRegalGLUT.$(EXT.DYNAMIC)
+GLUT.STATIC := libRegalGLUT.a
+
+glut.lib: lib lib/$(GLUT.SHARED)
+
+tmp/$(SYSTEM)/glut/shared/%.o: src/glut/src/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(PICFLAG) $(GLUT.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+
+lib/$(GLUT.SHARED): $(GLUT.OBJS) lib/$(LIB.SHARED)
+ $(LD) $(LDFLAGS.DYNAMIC) -o $@ $^ $(GLUT.LIBS)
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+endif
+
+# Examples
+
+regal.bin: lib bin bin/nacl.x64.nexe
+
+bin:
+ mkdir bin
+
+#
+# dreamtorus
+#
+
+DREAMTORUS.SRCS += examples/dreamtorus/src/render.cpp
+DREAMTORUS.SRCS += examples/dreamtorus/glut/code/main.cpp
+DREAMTORUS.SRCS.NAMES := $(notdir $(DREAMTORUS.SRCS))
+DREAMTORUS.OBJS := $(addprefix tmp/$(SYSTEM)/dreamtorus/static/,$(DREAMTORUS.SRCS.NAMES))
+DREAMTORUS.OBJS := $(DREAMTORUS.OBJS:.cpp=.o)
+DREAMTORUS.CFLAGS := -Iinclude -Iexamples/dreamtorus/src
+DREAMTORUS.LIBS += -Llib -lRegal $(LDFLAGS.GLUT)
+DREAMTORUS.LIBS += -lm -lpthread
+
+tmp/$(SYSTEM)/dreamtorus/static/%.o: examples/dreamtorus/src/%.cpp
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(DREAMTORUS.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+
+tmp/$(SYSTEM)/dreamtorus/static/%.o: examples/dreamtorus/glut/code/%.cpp
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(DREAMTORUS.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+
+bin/dreamtorus: $(DREAMTORUS.OBJS) lib/$(LIB.SHARED)
+ $(LD) -o $@ $^ $(LIB.LDFLAGS) $(DREAMTORUS.LIBS)
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+#
+# tiger
+#
+
+TIGER.SRCS += examples/tiger/nvpr_tiger.c
+TIGER.SRCS += examples/tiger/tiger.c
+TIGER.SRCS += examples/tiger/xform.c
+TIGER.SRCS.NAMES := $(notdir $(TIGER.SRCS))
+TIGER.OBJS := $(addprefix tmp/$(SYSTEM)/tiger/static/,$(TIGER.SRCS.NAMES))
+TIGER.OBJS := $(TIGER.OBJS:.c=.o)
+TIGER.CFLAGS := -Iinclude
+TIGER.LIBS += -Llib -lRegalGLEW $(LDFLAGS.GLUT) -lRegal
+TIGER.LIBS += -lm -lpthread
+
+tmp/$(SYSTEM)/tiger/static/%.o: examples/tiger/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(TIGER.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+
+bin/tiger: $(TIGER.OBJS) lib/$(GLEW.SHARED) lib/$(LIB.SHARED)
+ $(LD) -o $@ $^ $(TIGER.LIBS)
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+NACLHELLOWORLD.SRCS += examples/nacl/main.cpp
+NACLHELLOWORLD.SRCS.NAMES := $(notdir $(NACLHELLOWORLD.SRCS))
+NACLHELLOWORLD.OBJS := $(addprefix tmp/$(SYSTEM)/nacl/static/,$(NACLHELLOWORLD.SRCS.NAMES))
+NACLHELLOWORLD.OBJS := $(NACLHELLOWORLD.OBJS:.cpp=.o)
+NACLHELLOWORLD.CFLAGS := -Iinclude
+NACLHELLOWORLD.LIBS += -Llib -lRegal
+NACLHELLOWORLD.LIBS += -lm -lpthread
+
+tmp/$(SYSTEM)/nacl/static/%.o: examples/nacl/%.cpp
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(NACLHELLOWORLD.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+
+bin/nacl.x64.nexe: $(NACLHELLOWORLD.OBJS) lib/$(LIB.SHARED)
+ $(LD) -o $@ $^ $(NACLHELLOWORLD.LIBS)
+ifneq ($(STRIP),)
+ $(STRIP) -x $@
+endif
+
+#
+# GLUT dependency for non-Mac builds
+#
+
+ifeq ($(filter darwin%,$(SYSTEM)),)
+bin/tiger: lib/$(GLUT.SHARED)
+bin/dreamtorus: lib/$(GLUT.SHARED)
+endif
+
+clean:
+ $(RM) -r tmp/
+ $(RM) -r lib/
+ $(RM) -r bin/
+ $(RM) glew.pc glewmx.pc
+
+
+.PHONY: export
+.PHONY: regal.lib regal.bin all debug
+.PHONY: clean distclean tardist dist-win32 dist-src
View
21 config/Makefile.nacl-32
@@ -0,0 +1,21 @@
+NAME = $(REGAL_NAME)
+PICFLAG = -fPIC
+LDFLAGS.EXTRA =
+LIBDIR =
+LDFLAGS.GL =
+LDFLAGS.GLUT = -lRegalGLUT
+LDFLAGS.STATIC = -Wl,-Bstatic
+LDFLAGS.DYNAMIC = -Wl,-Bdynamic
+WARN = -Wall -W
+POPT = -O2
+BIN.SUFFIX =
+LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
+LIB.DEVLNK = lib$(NAME).so
+LIB.SHARED = lib$(NAME).so.$(SO_VERSION)
+LIB.STATIC = lib$(NAME).a
+LDFLAGS.SO = -shared
+LIB.SONAME.MX = lib$(NAME)mx.so.$(SO_MAJOR)
+LIB.DEVLNK.MX = lib$(NAME)mx.so
+LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
+LIB.STATIC.MX = lib$(NAME)mx.a
+LDFLAGS.SO.MX = -shared -Wl
View
21 config/Makefile.nacl-64
@@ -0,0 +1,21 @@
+NAME = $(REGAL_NAME)
+PICFLAG = -fPIC
+LDFLAGS.EXTRA =
+LIBDIR =
+LDFLAGS.GL =
+LDFLAGS.GLUT = -lRegalGLUT
+LDFLAGS.STATIC = -Wl,-Bstatic
+LDFLAGS.DYNAMIC = -Wl,-Bdynamic
+WARN = -Wall -W
+POPT = -O2
+BIN.SUFFIX =
+LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
+LIB.DEVLNK = lib$(NAME).so
+LIB.SHARED = lib$(NAME).so.$(SO_VERSION)
+LIB.STATIC = lib$(NAME).a
+LDFLAGS.SO = -shared
+LIB.SONAME.MX = lib$(NAME)mx.so.$(SO_MAJOR)
+LIB.DEVLNK.MX = lib$(NAME)mx.so
+LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
+LIB.STATIC.MX = lib$(NAME)mx.a
+LDFLAGS.SO.MX = -shared -Wl
View
5 examples/nacl/main.cpp
@@ -0,0 +1,5 @@
+#include <cstdio>
+
+int main(int argc, char** argv) {
+ printf("Hello World\n");
+}
View
33 nacl-regal.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# Copyright (c) 2012 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# nacl-regal.sh
+#
+# usage: nacl-regal.sh
+#
+# this script downloads, patches, and builds ffmpeg for Native Client
+#
+
+readonly PACKAGE_NAME=regal
+export NACL_GLIBC=1
+export NACL_PACKAGES_BITSIZE=32
+
+source ../../build_tools/common.sh
+
+export CC=${NACLCC}
+export CXX=${NACLCXX}
+export LD=${NACLLD}
+export AR=${NACLAR}
+export STRIP=${NACLSTRIP}
+export RANLIB=${NACLRANLIB}
+export PKG_CONFIG_PATH=${NACL_SDK_USR_LIB}/pkgconfig
+export PKG_CONFIG_LIBDIR=${NACL_SDK_USR_LIB}
+export FREETYPE_CONFIG=${NACL_SDK_USR_BIN}/freetype-config
+export PATH=${NACL_BIN_PATH}:${PATH};
+
+
+make -f Makefile.nacl $*
+
+exit 0

0 comments on commit 8fa358a

Please sign in to comment.
Something went wrong with that request. Please try again.