Skip to content

Instantly share code, notes, and snippets.

@faried
Created December 3, 2014 11:40
Show Gist options
  • Save faried/175fb02a7da6795e8081 to your computer and use it in GitHub Desktop.
Save faried/175fb02a7da6795e8081 to your computer and use it in GitHub Desktop.
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:
# http://www.gnu.org/software/make/manual/make.html
#
#
# 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
CHIBI_OBJ = $(CHIBI_SRC:.c=.o)
# 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/getos.py
OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
OSNAME := $(shell $(GETOS))
RM := $(OSHELPERS) rm
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
clean:
$(RM) pn1.pexe pn1.bc
%.o: %.c
$(PNACL_CXX) -c -o $@ $< -O2 $(CXXFLAGS) $(LDFLAGS)
pn1.bc: pn1.cc $(CHIBI_OBJ)
$(PNACL_CXX) -o $@ $< $(CHIBI_OBJ) -O2 $(CXXFLAGS) $(LDFLAGS)
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/httpd.py
.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