Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
not the world's greatest makefile...
# Copyright (c) 2013 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.
# GNU Make based build file.  For details on GNU Make see:
# Get pepper directory for toolchain and includes.
# If NACL_SDK_ROOT is not set, then assume it can be found three directories up.
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../..)
CHIBI_ROOT = ../chibi-scheme-0.7
CHIBI_SRC = $(CHIBI_ROOT)/sexp.c $(CHIBI_ROOT)/bignum.c $(CHIBI_ROOT)/eval.c $(CHIBI_ROOT)/opcodes.c \
$(CHIBI_ROOT)/gc.c $(CHIBI_ROOT)/vm.c $(CHIBI_ROOT)/simplify.c
# Project Build flags
WARNINGS := -Wno-long-long -Wall -Wswitch-enum -pedantic -Werror
CXXFLAGS := -pthread -std=gnu++98 $(WARNINGS)
# Compute tool paths
GETOS := python $(NACL_SDK_ROOT)/tools/
OSHELPERS = python $(NACL_SDK_ROOT)/tools/
OSNAME := $(shell $(GETOS))
PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang++
PNACL_FINALIZE := $(PNACL_TC_PATH)/bin/pnacl-finalize
CXXFLAGS := -I$(NACL_SDK_ROOT)/include -I$(NACL_SDK_ROOT)/include/pnacl -I$(CHIBI_ROOT)/include -DSEXP_USE_DL=0
LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lnacl_io -lppapi_cpp -lppapi
# Disable DOS PATH warning when using Cygwin based tools Windows
CYGWIN ?= nodosfilewarning
export CYGWIN
# Declare the ALL target first, to make the 'all' target the default build
all: pn1.pexe
$(RM) pn1.pexe pn1.bc
%.o: %.c
$(PNACL_CXX) -c -o $@ $< -O2 $(CXXFLAGS) $(LDFLAGS)
pn1.bc: $(CHIBI_OBJ)
pn1.pexe: pn1.bc
$(PNACL_FINALIZE) -o $@ $<
# Makefile target to run the SDK's simple HTTP server and serve this example.
HTTPD_PY := python $(NACL_SDK_ROOT)/tools/
.PHONY: serve
serve: all
$(HTTPD_PY) --no-dir-check -C $(CURDIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment