Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1088 Macos build issues #1096

Open
wants to merge 67 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
9be1852
Merge pull request #7 from navit-gps/master
OLFDB Feb 14, 2021
a683b53
Merge pull request #8 from navit-gps/master
OLFDB Feb 23, 2021
1d2b254
macosbuild
Feb 25, 2021
832daac
macosbuild
Feb 25, 2021
0241fe4
macosbuild
Feb 25, 2021
56c7f7d
macosbuild
Feb 25, 2021
2df2ec6
macosbuild
Feb 25, 2021
bd90261
macosbuild
Feb 25, 2021
dabcb3f
Added locales to bundle
OLFDB Feb 27, 2021
be09582
conditional vehicle/iphone: build it only when UIKit is available
OLFDB Feb 27, 2021
b78f880
create /usr/local/lib/navit
Feb 27, 2021
6184abc
Use this script on a Mac to setup the build environment and build navit
Feb 27, 2021
24f52c8
Changed build procedure
OLFDB Feb 27, 2021
7c8fa5a
Copy whole macos bundle to /usr/local/bin
Feb 27, 2021
7ff14e5
added imagemagick
Feb 27, 2021
e09e1c2
changes to build
OLFDB Feb 27, 2021
c5d1849
Merge branch 'macosbuild' of https://github.com/OLFDB/navit into maco…
OLFDB Feb 27, 2021
77e0b72
added gpsd
OLFDB Feb 27, 2021
4fffff8
formatting, removed unmaintained info
OLFDB Feb 27, 2021
4f94cd1
correction
OLFDB Feb 27, 2021
ef9b6dc
clean up
OLFDB Feb 27, 2021
6e33c24
build macos target in seperate project to have all bundle files
OLFDB Feb 28, 2021
27c4cfb
build macos target in seperate project to have all bundle files
OLFDB Feb 28, 2021
88e6eef
applied astyle
OLFDB Feb 28, 2021
ba9cd87
fix
Feb 28, 2021
0f74a17
A desktop navit.xml using GTK gui as the default
OLFDB Feb 28, 2021
8891fad
Changed install commands
Feb 28, 2021
0bca626
Changed install commands
Feb 28, 2021
b0e09b7
added
Feb 28, 2021
b88324b
changed install command
Feb 28, 2021
1cf5fda
start gpsd service
Feb 28, 2021
5547a36
added gpsd activation
OLFDB Feb 28, 2021
76ba1b3
create
Feb 28, 2021
2e2d029
# WARNING: head commit changed in the meantime
OLFDB Feb 28, 2021
30f7000
added make install
Feb 28, 2021
dcdd2a8
Use command say for speech
OLFDB Feb 28, 2021
1281233
Update
OLFDB Feb 28, 2021
348403a
Update
OLFDB Feb 28, 2021
bd2c68d
Update
OLFDB Feb 28, 2021
171c177
update
OLFDB Feb 28, 2021
60d671f
update
OLFDB Feb 28, 2021
9c4e88b
update
OLFDB Feb 28, 2021
9fd3cf2
update
OLFDB Feb 28, 2021
603d795
update
OLFDB Feb 28, 2021
0fc9770
Codestyle
OLFDB Feb 28, 2021
0a98852
Merge branch 'trunk' into macosbuild
OLFDB Feb 28, 2021
58bad51
When support/espeak is true the #include "event.h" takes the file from
OLFDB Feb 28, 2021
cec0be8
Merge branch 'trunk' into macosbuild
OLFDB Mar 1, 2021
46411ac
Merge branch 'trunk' into macosbuild
OLFDB May 2, 2021
8efc3f2
-DIOS=0 for macbuild
OLFDB Oct 9, 2021
6744c9f
Updates for macos
OLFDB Oct 9, 2021
a315b58
Added CoreText and CoreImage libraries
OLFDB Oct 9, 2021
e6c21a6
Updates from ios build
OLFDB Oct 9, 2021
94e1664
added -x objective-c for macos and ios build
OLFDB Oct 9, 2021
e439567
changed images_resource custom command
OLFDB Oct 9, 2021
d7574be
build a macos bundle
OLFDB Oct 9, 2021
adda6f5
ios changes
OLFDB Oct 9, 2021
a00d22e
Xcode warning and debug level
OLFDB Oct 9, 2021
b952ea9
Xcode warning
OLFDB Oct 9, 2021
3145713
Check struct transformation is set
OLFDB Oct 9, 2021
fad676b
Changes for ios
OLFDB Oct 9, 2021
1b572b2
Compatibility for macos and iOS
OLFDB Oct 9, 2021
c7fcca1
macos xslt file
OLFDB Oct 9, 2021
b36a050
Merge branch 'macosbuild' of https://github.com/OLFDB/navit into HEAD
OLFDB Oct 9, 2021
f60fc5e
astyle
OLFDB Oct 9, 2021
65fb412
astyle
OLFDB Oct 9, 2021
55c7e2b
astyle
OLFDB Oct 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 3.2)

set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.navitproject.navit")
set(MACOSX_BUNDLE_BUNDLE_NAME "Navit")
set(MACOSX_BUNDLE_ICON_FILE "Default.png")
execute_process(COMMAND git describe --tags OUTPUT_VARIABLE MACOSX_BUNDLE_INFO_STRING)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It should be handled if git is not available and if the build isn't run from a git repo (tar source package for example)
  • Variable should be renamed to GIT_VERSION so if can also be used within config.h.in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all thank you for the feedback. I'm working on it.

message(STATUS "Building with CMake V${CMAKE_VERSION}")
message(STATUS "Git Version: ${MACOSX_BUNDLE_INFO_STRING}")

if (DISABLE_CXX)
project(navit C)
else(DISABLE_CXX)
Expand Down Expand Up @@ -714,12 +718,18 @@ if(WINCE)
set_with_reason(support/espeak "Windows detected" TRUE)
endif()
if (APPLE OR USE_UIKIT)
set_with_reason(vehicle/iphone "apple detected" TRUE)
if(NOT USE_UIKIT)
ADD_DEFINITIONS(-DIOS=0)
endif(NOT USE_UIKIT)
if (EXISTS "${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks/UIKit.framework")
set_with_reason(vehicle/iphone "apple detected" TRUE)
endif()
set_with_reason(graphics/cocoa "apple detected" TRUE)
if (EXISTS "${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks/VoiceServices.framework")
set_with_reason(speech/iphone "apple detected" TRUE)
endif()
set(BUILD_BUNDLE TRUE CACHE BOOLEAN "build an osx bundle")
set(NAVIT_COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS} -ObjC")
endif()

if(CMAKE_SIZEOF_VOID_P LESS 8)
Expand Down
17 changes: 17 additions & 0 deletions contrib/macos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would define another project just for macos. I think we should avoid this and work with components within the main project and use cpack (part of cmake) to install everything where its needs to be

project(macosbundle C)

include(ExternalProject)
ExternalProject_Add(navit CMAKE_ARGS
-Dbinding/python=false SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/../)
ExternalProject_Get_Property(navit BINARY_DIR)
ExternalProject_Get_Property(navit SOURCE_DIR)

install(DIRECTORY /usr/local/lib/navit/ DESTINATION ${BINARY_DIR}/navit.app/Contents/Resources)
install(DIRECTORY ${BINARY_DIR}/navit/resources/share/navit/ DESTINATION ${BINARY_DIR}/navit.app/Contents/Resources/share)
install(DIRECTORY ${BINARY_DIR}/navit//resources/share/locale DESTINATION ${BINARY_DIR}/navit.app/Contents/Resources/share)
install(DIRECTORY ${BINARY_DIR}/navit/icons DESTINATION ${BINARY_DIR}/navit.app/Contents/Resources/share)
install(DIRECTORY ${BINARY_DIR}/navit/textures DESTINATION ${BINARY_DIR}/navit.app/Contents/Resources/share)
install(DIRECTORY ${BINARY_DIR}/navit/maps DESTINATION ${BINARY_DIR}/navit.app/Contents/Resources/share)
install(DIRECTORY ${BINARY_DIR}/navit.app DESTINATION /usr/local/bin)
Install(FILES ${SOURCE_DIR}navit/navit_shipped_gtkgui.xml DESTINATION ~/.navit RENAME navit.xml)
117 changes: 37 additions & 80 deletions docs/development/macos_development.rst
Original file line number Diff line number Diff line change
@@ -1,113 +1,70 @@
=================
MacOS Development
=================

Here are some notes about running navit under Apple Mac OSX.

================================================================================================================================
WARNING: These instructions are currently unmaintained. Please feel free to submit a PR if you manage to build navit on Mac OSX.
================================================================================================================================
Here are some notes about running navit under Apple macOS.

What you will need
==================

You need Xcode Tools and MacPorts in order to install navit.

MacPorts developers suggest to install Xcode Tools from http://developer.apple.com/tools/xcode/ and not from the Mac OSX install disk.
See `Mac-How <http://www.mac-how.net/>`_

Make sure you don't have fink installed on your system, it can confuse MacPorts package building and installation.

* GTK Gui: You should only need gtk2 and glib2 via macPorts
* SDL Gui: Untested yet.

Installation instruction
========================

Download Xcode Tools from http://developer.apple.com/tools/xcode/ and install it with X11 SDK

Download and Install MacPorts from http://www.macports.org/, or update your version

.. code-block:: bash

sudo port -d selfupdate

Open up a terminal

make sure your PATH variables has `/opt/local/bin` and `/opt/local/sbin` in it:
------------------

.. code-block:: bash
You need Xcode Tools and homebrew in order to install navit.

echo $PATH
.. code:: shell

If you have macports or fink installed create and use a new user account
to build navit.

Install automake, wget, libtool, gpsd (if you want gps support), gtk2 and glib2 (for gkt GUI) with
For convinience there is the script prepare_navit_macos.sh available
under the navit/scripts directory.

.. code-block:: bash
.. code:: shell

sudo port install automake wget gpsd gtk2 glib2 libtool
$ curl https://raw.githubusercontent.com/OLFDB/navit/macosbuild/scripts/prepare_navit_macos.sh -o prepare_navit_macos.sh

Download navit or checkout it from Git
Then start the installation procedure:

.. code-block:: bash
.. code-block:: bash

git clone [email protected]:navit-gps/navit.git
$ sh prepare_navit_macos.sh

You may also need a header file to handle endian issues (for PPC only)
What is working
---------------

.. code-block:: bash
- internal Gui: Working, but problems with window refresh

wget https://navit.svn.sourceforge.net/svnroot/navit/tags/R0_1_0/navit/projs/CodeBlocks/Win32Extra/byteswap.h
- GTK Gui: Working.

If you want to install navit along the MacPorts packages, you need to use the /opt/local directory as prefix:
- SDL Gui: Untested yet.

.. code-block:: bash
GPSD
----

./autogen.sh && ./configure --prefix=/opt/local --disable-binding-python
You have to add the GPS receiver device to gpsd:

type `make` to build NavIt, and `sudo make install` to install it.

Then, you may edit and adapt your `navit.xml` file. The XML maptype is not supported, however normal Navit binfile works perfectly.
GPSD_SOCKET="/usr/local/var/gpsd.sock" /usr/local/opt/gpsd/sbin/gpsdctl
add /dev/tty.usbserial-XYZ

Speech
======

If you want (spoken) directions, get espeak from http://espeak.sourceforge.net, install as advised and use the following snippet in your navit.xml:

.. code-block:: xml

<speech type="cmdline" data="speak -vde+f4 '%s'"/>

This will tell speak to use a female (f) german (de) voice.


Using xcode
===========

Download one of the `Git sources <https://github.com/navit-gps/navit>`_ that don't contain autogen.sh.

Open X-Code and create a new project. Cocoa will suffice

Add in a new target by clicking the triangle next to "Targets" and selected the location of the navit folder. Delete the previous target.

Delete the default files, and add in the navit files.

In a terminal, go into the navit folder.

.. code-block:: bash
------

./configure --disable-binding-python --disable-sample-map --disable-maptool
If you want (spoken) directions, use the following snippet in your
navit.xml:

xcode can now build the navit
.. code:: xml

<speech type="cmdline" data="say '%s'"/>

You can also use CMake.
This will use the native say command. You can list all available voices
by typing say -v ? in a terminal. Change the command to say -v
<voicename> if you would like a non standard voice to be used. New
voices can be added in system preferences->keyboard->dictation

.. code-block:: bash
Using Xcode
-----------

cd navit && cmake -G Xcode .
cmake -G Xcode ../ -DUSE_PLUGINS=0 -DBUILD_MAPTOOL=1 -DXSLTS=macos
-Dbinding/python=false -DCLANG_ENABLE_OBJC_WEAK=YES

Something went wrong?
=====================
---------------------

Please let us know by filing an issue on Github or reach out on IRC.
19 changes: 14 additions & 5 deletions navit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/support")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/THIS_IS_THE_NAVIT_WORKING_DIR "\r\nThis File should never appear on binary distributions\r\n" )
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/THIS_IS_THE_NAVIT_WORKING_DIR "\r\nOnly Devs should ever see this file" )

IF(APPLE)
# Fix linking on 10.14+. See https://stackoverflow.com/questions/54068035
LINK_DIRECTORIES(/usr/local/lib)
ENDIF()

# navit core
set(NAVIT_SRC announcement.c atom.c attr.c cache.c callback.c command.c config_.c coord.c country.c data_window.c debug.c
event.c file.c geom.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c
Expand Down Expand Up @@ -77,23 +82,27 @@ if(NOT ANDROID)
endif()
endif()
if (BUILD_BUNDLE)
set(EXECUTABLE_NAME navit)
set(APP_ICON_FILE Default.png)
list(APPEND NAVIT_START_SRC resources/share resources/Icon.png resources/Default.png)
add_custom_command(OUTPUT resources/Icon.png COMMAND convert -scale 79x79 -crop 60x60+8+19 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Icon.png)
add_custom_command(OUTPUT resources/Default.png COMMAND convert -scale 79x79 -crop 60x60+8+19 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Default.png)
add_custom_command(OUTPUT resources/Icon.png COMMAND convert -scale 79x79 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Icon.png)
add_custom_command(OUTPUT resources/Default.png COMMAND convert -scale 79x79 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Default.png)
endif()
add_executable(navit ${NAVIT_START_SRC})
target_link_libraries (navit ${NAVIT_LIBNAME})
if(DEFINED NAVIT_BINARY)
set_target_properties(navit PROPERTIES OUTPUT_NAME ${NAVIT_BINARY})
endif(DEFINED NAVIT_BINARY)
if (BUILD_BUNDLE)
target_link_libraries(navit stdc++ "-framework Foundation -framework CoreText -framework CoreImage" objc)
add_custom_command(OUTPUT resources/share COMMAND mkdir -p resources/share)
set_source_files_properties(resources/share resources/Icon.png resources/Default.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set_source_files_properties(${NAVIT_SUPPORT_LIBS} resources/share resources/Icon.png resources/Default.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set_target_properties(navit PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(navit PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
#set_target_properties(navit PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
add_dependencies(navit navit_config_xml_resource)
add_dependencies(navit images_resource)
add_dependencies(navit locale_resource)
add_dependencies(navit textures_resource)
endif()
endif()

Expand Down Expand Up @@ -208,7 +217,7 @@ else()
endforeach()
add_custom_target( navit_config_xml_resource DEPENDS ${XMLCFG_INSTALLED_PATH_LIST} COMMAND mkdir -p resources/share/navit COMMAND cp ${XMLCFG_INSTALLED_PATH_LIST} resources/share/navit)
add_custom_target( locale_resource DEPENDS locales COMMAND mkdir -p resources/share COMMAND cp -a ${CMAKE_CURRENT_BINARY_DIR}/../locale resources/share/locale)
add_custom_target( navit_config_xml ALL DEPENDS ${XMLCFG_OUTPUT_LIST})
add_custom_target( navit_config_xml ALL DEPENDS ${XMLCFG_OUTPUT_LIST} navit_config_xml_resource)
endif()

if (USE_LIBGNUINTL AND NOT HAVE_GLIB)
Expand Down
2 changes: 1 addition & 1 deletion navit/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "config_.h"
#include "command.h"
#include "debug.h"
#include "event.h"
#include "navit/event.h"
#include "callback.h"
#include "country.h"
#include "projection.h"
Expand Down
2 changes: 1 addition & 1 deletion navit/binding/dbus/binding_dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "roadprofile.h"
#include "util.h"
#include "transform.h"
#include "event.h"
#include "navit/event.h"
#include "traffic.h"

static DBusConnection *connection;
Expand Down
2 changes: 1 addition & 1 deletion navit/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "debug.h"
#include "callback.h"
#include "command.h"
#include "event.h"
#include "navit/event.h"
#include "navit_nls.h"

/*
Expand Down
2 changes: 1 addition & 1 deletion navit/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <string.h>
#include <stdlib.h>
#include "event.h"
#include "navit/event.h"
#include "plugin.h"
#include "debug.h"

Expand Down
2 changes: 1 addition & 1 deletion navit/event_glib.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

#include <glib.h>
#include "event.h"
#include "navit/event.h"
#include "event_glib.h"
#include "debug.h"
#include "callback.h"
Expand Down
2 changes: 1 addition & 1 deletion navit/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "util.h"
#include "callback.h"
#include "file.h"
#include "event.h"
#include "navit/event.h"
#include "navit.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion navit/graphics/android/graphics_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "item.h"
#include "xmlconfig.h"
#include "plugin.h"
#include "event.h"
#include "navit/event.h"
#include "debug.h"
#include "callback.h"
#include "android.h"
Expand Down
19 changes: 19 additions & 0 deletions navit/graphics/cocoa/graphics_cocoa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// graphics_cocoa.h
// graphics_cocoa
//
// Created by olf on 12.06.21.
//

#ifndef graphics_cocoa_h
#define graphics_cocoa_h

#if USE_UIKIT
#import <UIKIT/UIKIT.h>
#else
#import <Cocoa/Cocoa.h>
#endif

CGContextRef current_context(void);

#endif /* graphics_cocoa_h */
Loading