summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--common/basewnd.h14
-rw-r--r--common/defines.h31
-rwxr-xr-xcommon/opengl.h5
-rw-r--r--config.mk78
5 files changed, 123 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index c9028bc..8342fcb 100644
--- a/Makefile
+++ b/Makefile
@@ -36,10 +36,10 @@ all: $(BIN)
static: bin/leocad.static
bin/leocad: $(OBJ) bin
- $(CXX) -o $@ $(OBJ) $(LIBS)
+ $(CXX) -o $@ $(OBJ) $(LIBS) $(LDFLAGS)
bin/leocad.static: $(OBJ) bin
- $(CXX) -static -o $@ $(OBJ) $(LIBS)
+ $(CXX) -static -o $@ $(OBJ) $(LIBS) $(LDFLAGS)
bin:
mkdir bin
diff --git a/common/basewnd.h b/common/basewnd.h
index 1af4db6..f26f4f5 100644
--- a/common/basewnd.h
+++ b/common/basewnd.h
@@ -13,9 +13,9 @@ typedef struct
int index;
UINT command;
} BaseMenuItem;
+#endif
-#else
-
+#ifdef LC_LINUX
#include <gtk/gtk.h>
typedef GtkWidget* BaseWndXID;
typedef struct
@@ -25,6 +25,14 @@ typedef struct
} BaseMenuItem;
#endif
+#ifdef LC_MACOSX
+typedef void* BaseWndXID;
+typedef struct
+{
+ void* Dummy;
+} BaseMenuItem;
+#endif
+
// =============================================================================
// Message Box constants
@@ -74,7 +82,7 @@ class BaseWnd
void SetXID (BaseWndXID id)
{ m_pXID = id; }
-#ifndef WIN32
+#ifdef LC_LINUX
// FIXME: remove
operator GtkWidget* () const
{ return m_pXID; }
diff --git a/common/defines.h b/common/defines.h
index d1b50a7..ebea0ff 100644
--- a/common/defines.h
+++ b/common/defines.h
@@ -4,10 +4,8 @@
#ifndef _DEFINES_H_
#define _DEFINES_H_
-/////////////////////////////////////////////////////////////////////////////
-// System specific
-
-#if !(defined(LC_WINDOWS) || defined(LC_LINUX))
+// Check for supported platforms.
+#if !(defined(LC_WINDOWS) || defined(LC_LINUX) || defined(LC_MACOSX))
#error YOU NEED TO DEFINE YOUR OS
#endif
@@ -55,6 +53,31 @@ int stricmp(const char* str1, const char* str2);
#endif
+#ifdef LC_MACOSX
+#define LC_MAXPATH 1024 //FILENAME_MAX
+
+#define KEY_SHIFT 0x01
+#define KEY_CONTROL 0x02
+#define KEY_ESCAPE 0x03
+#define KEY_TAB 0x04
+#define KEY_INSERT 0x05
+#define KEY_DELETE 0x06
+#define KEY_UP 0x07
+#define KEY_DOWN 0x08
+#define KEY_LEFT 0x09
+#define KEY_RIGHT 0x0A
+#define KEY_PRIOR 0x0B
+#define KEY_NEXT 0x0C
+#define KEY_PLUS '+'
+#define KEY_MINUS '-'
+
+char* strupr(char* string);
+char* strlwr(char* string);
+int stricmp(const char* str1, const char* str2);
+
+#endif
+
+
/////////////////////////////////////////////////////////////////////////////
// LeoCAD constants
diff --git a/common/opengl.h b/common/opengl.h
index 2a56559..6445b5c 100755
--- a/common/opengl.h
+++ b/common/opengl.h
@@ -15,6 +15,11 @@
#include "linux_gl.h"
#endif
+#ifdef LC_MACOSX
+#include <OpenGL/gl.h>
+#include <AGL/agl.h>
+#endif
+
//#include <GL/glu.h> // TODO: remove all glu calls
void gluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez,
GLdouble centerx, GLdouble centery, GLdouble centerz,
diff --git a/config.mk b/config.mk
index 05a0bba..cdc9719 100644
--- a/config.mk
+++ b/config.mk
@@ -22,6 +22,7 @@ ifeq ($(shell uname), Linux)
OS := -DLC_LINUX
OSDIR := linux
+TEST_GTK := 1
endif
@@ -31,10 +32,85 @@ ifeq ($(shell uname), FreeBSD)
OS := -DLC_LINUX
OSDIR := linux
+TEST_GTK := 1
CPPFLAGS += -L/usr/local/lib
endif
+### Macintosh configuration
+
+ifeq ($(shell uname), Darwin)
+
+OS := -DLC_MACOSX
+OSDIR := macosx
+TEST_GTK := 0
+CPPFLAGS += -funsigned-char -I/Developer/Headers/FlatCarbon/
+LDFLAGS += -framework AGL
+
+# The directory tree for the generated bundle
+BUNDLEDIR = bin/LeoCAD.app
+CONTDIR = $(BUNDLEDIR)/Contents
+BINDIR = $(CONTDIR)/MacOS
+RSRCDIR = $(CONTDIR)/Resources
+EN_RSRCDIR = $(RSRCDIR)/English.lproj
+
+NIBS = main.nib
+
+all: bundletree exec bnibs pkginfo infoplist infopliststr
+
+bundletree: $(BUNDLEDIR) $(CONTDIR) $(BINDIR) $(RSRCDIR) $(EN_RSRCDIR)
+
+$(BUNDLEDIR):
+ mkdir $(BUNDLEDIR)
+
+$(CONTDIR):
+ mkdir $(CONTDIR)
+
+$(BINDIR):
+ mkdir $(BINDIR)
+
+$(RSRCDIR):
+ mkdir $(RSRCDIR)
+
+$(EN_RSRCDIR):
+ mkdir $(EN_RSRCDIR)
+
+# The binary executable
+exec: $(BINDIR)/leocad
+
+$(BINDIR)/leocad: bin/leocad
+ cp bin/leocad $(BINDIR)
+
+# The nib's
+BNIBS = $(NIBS:%=$(EN_RSRCDIR)/%)
+
+bnibs: $(BNIBS)
+
+$(BNIBS) : $(EN_RSRCDIR)/%: macosx/English.lproj/%
+ rm -rf $@
+ cp -R $< $@
+ touch $@
+
+# Info.plist
+infoplist : $(CONTDIR)/Info.plist
+
+$(CONTDIR)/Info.plist : macosx/Info.plist
+ cp macosx/Info.plist $@
+
+# PkgInfo
+pkginfo : $(CONTDIR)/PkgInfo
+
+$(CONTDIR)/PkgInfo : macosx/PkgInfo
+ cp macosx/PkgInfo $@
+
+# InfoPlist.strings - this goes inside English.lproj
+infopliststr : $(EN_RSRCDIR)/InfoPlist.strings
+
+$(EN_RSRCDIR)/InfoPlist.strings: macosx/English.lproj/InfoPlist.strings
+ cp $< $@
+
+endif
+
### Default directory
ifeq ($(PREFIX), )
@@ -234,6 +310,7 @@ config:
@rm -f endiantest.c endiantest
#### Check if the user has GTK+ and GLIB installed.
+ifeq ($(TEST_GTK), 1)
@echo -n "Checking if GLIB and GTK+ are installed... "
@if (pkg-config --atleast-version=2.0.0 glib-2.0) && (pkg-config --atleast-version=2.0.0 gtk+-2.0); then \
echo "ok"; \
@@ -245,6 +322,7 @@ config:
rm -rf $(OSDIR)/config.mk; \
exit 1; \
fi
+endif
## Check if the user has libjpeg installed
@echo -n "Checking for jpeg support... "