Skip to content

Instantly share code, notes, and snippets.

@shun-shobon
Last active June 16, 2022 06:57
Show Gist options
  • Save shun-shobon/a245a0ce495c5f959ea909dc3c45044a to your computer and use it in GitHub Desktop.
Save shun-shobon/a245a0ce495c5f959ea909dc3c45044a to your computer and use it in GitHub Desktop.
glpngのmacOS対応スクリプト

glpng

説明

このシェルスクリプトはglpngをmacOS向けにコンパイルするためのパッチを当てるスクリプトです.

使い方

次のコマンドを入力すれば,glpng/にライブラリが生成されます.

curl -sL https://gist.githubusercontent.com/shun-shobon/a245a0ce495c5f959ea909dc3c45044a/raw/glpng.sh | sh
#!/usr/bin/env sh
set -ue
glpng_zip_url="http://teacher.nagano-nct.ac.jp/ito/Springs_of_C/glpng.zip"
glpng_zip="glpng.zip"
glpng_dir="glpng"
curl -sL $glpng_zip_url -o $glpng_zip
unzip $glpng_zip -d $glpng_dir
cd $glpng_dir
patch -up0 <<EOF
diff -ur src/Makefile.LINUX src/Makefile.LINUX
--- src/Makefile.LINUX 1999-08-30 17:20:16.000000000 +0900
+++ src/Makefile.LINUX 2022-06-16 14:56:56.000000000 +0900
@@ -7,11 +7,11 @@
####### Compiler, tools and options
-CC = gcc
-CXX = g++
+CC = gcc-11
+CXX = g++-11
CFLAGS = -pipe -Wall -W -O2 -fno-strength-reduce
CXXFLAGS= -pipe -Wall -W -O2 -fno-strength-reduce
-INCPATH = -I../include
+INCPATH = -I../include -framework OpenGL -framework GLUT
AR = ar cqs
RANLIB =
MOC = moc
diff -ur src/glpng.c src/glpng.c
--- src/glpng.c 2000-07-10 21:27:10.000000000 +0900
+++ src/glpng.c 2022-06-16 14:59:18.000000000 +0900
@@ -25,8 +25,8 @@
#include <windows.h>
#endif
+#include <GLUT/glut.h>
#include <GL/glpng.h>
-#include <GL/gl.h>
#include <stdlib.h>
#include <math.h>
#include "png/png.h"
EOF
cd src
make -f Makefile.LINUX
cd ../..
rm -rf $glpng_zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment