Skip to content

Unify Makefiles. #5

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
167 changes: 154 additions & 13 deletions linux/Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,182 @@
# Makefile

#
# Command Line Options:
# USE_LIBAVCODEC=0:
# Use the platform libavcodecs for MP3/AAC instead of the embedded,
# license restricted variants.
# license restricted variants.
# DEBUG=0: Debug build.
# Glibc mtrace will be enabled. MALLOC_TRACE must be defined in the
# environment to activate.
# NVWA_DIR=<source location>:
# Integrate a cross platform new/delete leak detector.
# Downloadable from http://wyw.dcweb.cn/leakage.htm
#
#

.PHONY: default all clean ubuntu raspbian ubuntu-install ubuntu-uninstall raspbian-install raspbian-uninstall

all: ubuntu raspbian
all: ubuntu raspbian

clean:
-$(MAKE) -f Makefile.ubuntu clean
$(MAKE) -f Makefile.raspbian clean
-$(MAKE) platform-clean OSPLATFORM=ubuntu
$(MAKE) platform-clean OSPLATFORM=raspbian

ubuntu:
$(MAKE) -f Makefile.ubuntu
$(MAKE) default OSPLATFORM=ubuntu

raspbian:
$(MAKE) -f Makefile.raspbian
$(MAKE) default OSPLATFORM=raspbian

ubuntu-install:
$(MAKE) -f Makefile.ubuntu install
$(MAKE) instal OSPLATFORM=ubuntul

ubuntu-uninstall:
$(MAKE) -f Makefile.ubuntu uninstall
$(MAKE) uninstal OSPLATFORM=ubuntul

raspbian-install:
$(MAKE) -f Makefile.raspbian install
$(MAKE) install OSPLATFORM=raspbian

raspbian-uninstall:
$(MAKE) -f Makefile.raspbian uninstall
$(MAKE) uninstall OSPLATFORM=raspbian

# GTK Specifics
GTK_CFLAGS := $(shell pkg-config --cflags gtk+-3.0)
GTK_LIBS := $(shell pkg-config --libs gtk+-3.0)

# indicate to build that we have selected a valid target
HWPLATFORM=$(shell uname -i)
ifeq ($(OSPLATFORM), ubuntu)
ifeq ($(HWPLATFORM),i686)
CXX = g++
TARG_ARCH = Linux-x86
else
ifeq ($(HWPLATFORM),x86_64)
CXX = g++
TARG_ARCH = Linux-x64
else
$(error please build on an x86/x64 Ubunutu machine)
endif
endif
else
ifeq ($(HWPLATFORM),$(filter $(HWPLATFORM),i686 x86_64))
CXX = arm-linux-gnueabihf-g++
TARG_ARCH = Linux-armhf
else
CXX = g++
TARG_ARCH = Linux-armhf
endif
endif

TARGET = $(OSPLATFORM)/openhome-player

INSTALL = install
RESOURCEDIR = ../dependencies/$(TARG_ARCH)/ohMediaPlayer/res

PREFIX = /usr

# The directory to install the application to
BINDIR = $(PREFIX)/bin

# The directory to install the resource files to.
RESDIR = $(PREFIX)/share/openhome-player

# The directory to install changelog and license to
DOCDIR = $(PREFIX)/share/doc/openhome-player

CXXFLAGS = -c -Wall -std=c++11 $(GTK_CFLAGS) -DTARG_ARCH=$(TARG_ARCH) \
-fstack-protector -fstack-check

# If 'DEBUG=0 is specified on the command line build a debug biuld.
ifdef DEBUG
BUILD_TYPE = Debug
OBJ_DIR = $(OSPLATFORM)/debug-objs
CXXFLAGS += -g -O0 -DDEBUG
else
BUILD_TYPE = Release
OBJ_DIR = $(OSPLATFORM)/objs
endif

#FIXME
UNITY_LIBS=

ifeq ($(XDG_CURRENT_DESKTOP),Unity)
UNITY_LIBS = -lappindicator3
endif

RESTRICTED_CODECS=

ifdef USE_LIBAVCODEC
RESTRICTED_CODECS = -lavresample -lavutil -lavcodec -lavformat
CXXFLAGS += -DUSE_LIBAVCODEC
else
RESTRICTED_CODECS = -lCodecAdts -lCodecAac -lCodecAacBase -lCodecMp3
endif

LIBS = $(GTK_LIBS) $(UNITY_LIBS) -lnotify -lasound -lSourcePlaylist -lSourceSongcast -lSourceUpnpAv -lSourceRadio -lShell -lohMediaPlayer -lWebAppFramework -lConfigUi -lohNetGeneratedProxies -lohNetCore $(RESTRICTED_CODECS) -lCodecAifc -lCodecAlac -lCodecAlacBase -lCodecPcm -lCodecAiff -lCodecAiffBase -lCodecVorbis -llibOgg -lCodecFlac -lCodecWav -lohPipeline -lpthread -lssl -lcrypto -ldl

INCLUDES = -I../dependencies/$(TARG_ARCH)/ohMediaPlayer/include -I../dependencies/$(TARG_ARCH)/ohNetmon/include -I../dependencies/$(TARG_ARCH)/openssl/include -I../dependencies/$(TARG_ARCH)/ohNetGenerated-$(TARG_ARCH)-$(BUILD_TYPE)/include/ohnet/OpenHome/Net/Core

LIBS += -L../dependencies/$(TARG_ARCH)/ohMediaPlayer/lib -L../dependencies/$(TARG_ARCH)/ohNetmon/lib -L../dependencies/$(TARG_ARCH)/openssl/lib

LIBS += -L../dependencies/$(TARG_ARCH)/ohNet-$(TARG_ARCH)-$(BUILD_TYPE)/lib
INCLUDES += -I../dependencies/$(TARG_ARCH)/ohNet-$(TARG_ARCH)-$(BUILD_TYPE)/include/ohnet

LIBS += -L../dependencies/$(TARG_ARCH)/ohNetGenerated-$(TARG_ARCH)-$(BUILD_TYPE)/lib

# Build for Unity desktop if required.
ifeq ($(XDG_CURRENT_DESKTOP),Unity)
CXXFLAGS += -DUSE_UNITY
INCLUDES += -I/usr/include/libappindicator3-0.1
endif

OBJECTS = $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(wildcard *.cpp))
HEADERS = $(wildcard *.h)

ifdef NVWA_DIR
# Include the new/delete leak checker in debug builds.
OBJECTS += $(NVWA_DIR)/debug_new.o
endif

ifdef NVWA_DIR
# New/Delete leak checker, if available.
CXXFLAGS += -DUSE_NVWA
INCLUDES += -I$(NVWA_DIR)
HEADERS += $(wildcard $(NVWA_DIR)/*.h)
endif


.PHONY: default all platform-clean build install uninstall

default: build $(TARGET)
all: default

$(OBJ_DIR)/%.o: %.cpp $(HEADERS)
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

.PRECIOUS: $(TARGET) $(OBJECTS)

$(TARGET): $(OBJECTS)
$(CXX) $(OBJECTS) -Wall $(LIBS) -o $@

build:
@mkdir -p $(OBJ_DIR)

platform-clean:
rm -rf $(OSPLATFORM)/objs $(OSPLATFORM)/debug-objs
rm -f $(TARGET)
ifdef NVWA_DIR
rm $(NVWA_DIR)/*.o
endif

install:
$(INSTALL) -m 755 -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(RESDIR) $(DESTDIR)$(RESDIR)/res
$(INSTALL) -m 755 $(TARGET) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 644 OpenHome-48x48.png $(DESTDIR)$(RESDIR)
$(INSTALL) -m 644 OpenHome-Light-48x48.png $(DESTDIR)$(RESDIR)
$(INSTALL) -m 644 copyright $(DESTDIR)$(DOCDIR)
cp -R $(RESOURCEDIR) $(DESTDIR)$(RESDIR)

uninstall:
rm $(DESTDIR)$(BINDIR)/$(TARGET)
rm -rf $(DESTDIR)$(DOCDIR)
rm -rf $(DESTDIR)$(RESDIR)
127 changes: 0 additions & 127 deletions linux/Makefile.combined

This file was deleted.

Loading