commit 379d5a9f769102bf15e8c52c15fc320b82655aad
parent 1a4e7ad76070cf76af76220e493856372b878dc8
Author: William Casarin <jb55@jb55.com>
Date: Fri, 17 Aug 2018 09:57:54 -0700
build: working on osx
binary still needs testing
Fixes #1
Diffstat:
4 files changed, 63 insertions(+), 17 deletions(-)
diff --git a/.travis-setup.sh b/.travis-setup.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+if [[ "$TRAVIS_OS_NAME" == "osx" ]]
+then
+ brew update
+ brew install glfw3
+else
+ # Install GLFW $GLFW_VERSION
+ wget -O glfw.zip "https://github.com/glfw/glfw/releases/download/$GLFW_VERSION/glfw-$GLFW_VERSION.zip"
+ unzip glfw.zip
+ cd glfw-"$GLFW_VERSION"
+ cmake -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX="$HOME"
+ make
+ sudo make install
+ cd ..
+fi
diff --git a/.travis.yml b/.travis.yml
@@ -2,23 +2,19 @@ language: c
sudo: required
dist: trusty
script: make lnvis
+os:
+ - linux
+ - osx
env:
global:
- GLFW_VERSION=3.2.1
- - TRAVIS_CFLAGS="-I/home/travis/include"
- - TRAVIS_LDFLAGS="-L/home/travis/lib"
+ - EXTRA_CFLAGS="-I/home/travis/include"
+ - EXTRA_LDFLAGS="-L/home/travis/lib"
- DISPLAY=:99.0
before_install:
- # Install GLFW $GLFW_VERSION
- - wget -O glfw.zip https://github.com/glfw/glfw/releases/download/$GLFW_VERSION/glfw-$GLFW_VERSION.zip
- - unzip glfw.zip
- - cd glfw-$GLFW_VERSION
- - cmake -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=$HOME
- - make
- - sudo make install
- - cd ..
+ - ./.travis-setup.sh
addons:
apt:
diff --git a/Makefile b/Makefile
@@ -1,10 +1,43 @@
BIN = lnvis
PREFIX ?= /usr/local
-CFLAGS = -Ideps -ggdb -O2 -Wall -Wextra -std=c99 -DJSMN_PARENT_LINKS $(TRAVIS_CFLAGS)
+CFLAGS = -Ideps -ggdb -O2 -Wall -Wextra -std=c99 -DJSMN_PARENT_LINKS $(EXTRA_CFLAGS)
-LDFLAGS = $(TRAVIS_LDFLAGS) -lglfw -lGL -lm
+LDFLAGS = $(EXTRA_LDFLAGS) -lglfw -lm
+ifeq ($(OS),Windows_NT)
+ CCFLAGS += -D WIN32
+ ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
+ CFLAGS += -D AMD64
+ else
+ ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
+ CFLAGS += -D AMD64
+ endif
+ ifeq ($(PROCESSOR_ARCHITECTURE),x86)
+ CFLAGS += -D IA32
+ endif
+ endif
+else
+ UNAME_S := $(shell uname -s)
+ ifeq ($(UNAME_S),Linux)
+ CFLAGS += -D LINUX
+ LDFLAGS += -lGL
+ endif
+ ifeq ($(UNAME_S),Darwin)
+ CCFLAGS += -D OSX
+ LDFLAGS += -framework OpenGL
+ endif
+ UNAME_P := $(shell uname -p)
+ ifeq ($(UNAME_P),x86_64)
+ CFLAGS += -D AMD64
+ endif
+ ifneq ($(filter %86,$(UNAME_P)),)
+ CFLAGS += -D IA32
+ endif
+ ifneq ($(filter arm%,$(UNAME_P)),)
+ CFLAGS += -D ARM
+ endif
+endif
SRCS = main.c
@@ -22,11 +55,12 @@ OBJS = $(SRCS:.c=.o)
all: $(BIN)
-include $(OBJS:.o=.d)
-
%.d: %.c
$(CC) -MM $(CFLAGS) $< > $@
+include $(OBJS:.o=.d)
+
+
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
diff --git a/gl.h b/gl.h
@@ -2,11 +2,11 @@
#ifndef LNVIS_GL_H
#define LNVIS_GL_H
-
+#if defined(__APPLE__)
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
-#ifndef NO_GL_HEADERS
-
void glUniform2fv(GLint location, GLsizei count, const GLfloat *value);
void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);