Skip to content

Commit

Permalink
Add Haiku-specific makefile and error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
przemub authored and carstene1ns committed Jan 27, 2018
1 parent 5753b24 commit f11f015
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Makefile.haiku
@@ -0,0 +1,27 @@
# OpenJazz makefile for Haiku
include openjazz.mk

CXX ?= g++
CXXFLAGS ?= -g -Wall -O2

CXXFLAGS += -D_BSD_SOURCE -DUSE_SOCKETS -DSCALE
LIBS += -lbe -lnetwork

# SDL
CXXFLAGS += $(shell sdl-config --cflags)
LIBS += $(shell sdl-config --libs)

# modplug
CXXFLAGS += -DUSE_MODPLUG $(shell pkg-config --cflags libmodplug)
LIBS += $(shell pkg-config --libs libmodplug)

LIBS += -lm

OpenJazz: $(OBJS)
$(CXX) $(LDFLAGS) -lz $(LIBS) $(OBJS) -o OpenJazz

%.o: %.cpp
$(CXX) $(CXXFLAGS) -Isrc -c $< -o $@

clean:
rm -f OpenJazz $(OBJS)
30 changes: 30 additions & 0 deletions src/main.cpp
Expand Up @@ -57,6 +57,10 @@
#include <pspdisplay.h>
#elif defined(_3DS)
#include <3ds.h>
#elif defined(__HAIKU__)
#include <Alert.h>
#include <FindDirectory.h>
#include <fs_info.h>
#endif

#include <string.h>
Expand Down Expand Up @@ -109,6 +113,22 @@ void startUp (int argc, char *argv[]) {
firstPath = NULL;
#endif

#ifdef __HAIKU__
dev_t volume = dev_for_path("/boot");
char buffer[10 + B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH];
status_t result;

result = find_directory(B_SYSTEM_DATA_DIRECTORY,
volume, false, buffer, sizeof(buffer));
strncat(buffer, "/openjazz/", sizeof(buffer));
firstPath = new Path(firstPath, createString(buffer));

result = find_directory(B_USER_NONPACKAGED_DATA_DIRECTORY,
volume, false, buffer, sizeof(buffer));
strncat(buffer, "/openjazz/", sizeof(buffer));
firstPath = new Path(firstPath, createString(buffer));
#endif

#ifdef __SYMBIAN32__
#ifdef UIQ3
firstPath = new Path(firstPath, createString("c:\\shared\\openjazz\\"));
Expand Down Expand Up @@ -261,6 +281,16 @@ void startUp (int argc, char *argv[]) {
log("of the original game data, eg:");
log(" OpenJazz ~/jazz1");

#ifdef __HAIKU__
char alertBuffer[100+B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
strcpy(alertBuffer, "Unable to find game data files!\n"
"Put the data into the folder:\n");
strncat(alertBuffer, buffer, sizeof(alertBuffer));
BAlert* alert = new BAlert("OpenJazz", alertBuffer, "Exit", NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
#endif

throw e;

}
Expand Down

0 comments on commit f11f015

Please sign in to comment.