Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add Makefile, .gitignore and pkg-config file
  • Loading branch information
falkTX committed Apr 11, 2017
1 parent 8fc38f3 commit c0d5a34
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
build/

123 changes: 123 additions & 0 deletions Makefile
@@ -0,0 +1,123 @@
#!/usr/bin/make -f
# Makefile for hylia #
# ------------------ #
# Created by falkTX
#

AR ?= ar
CC ?= gcc
CXX ?= g++

# ----------------------------------------------------------------------------------------------------------------------------
# Fallback to Linux if no other OS defined

ifneq ($(MACOS),true)
ifneq ($(WIN32),true)
LINUX=true
endif
endif

# ----------------------------------------------------------------------------------------------------------------------------
# Set build and link flags

BASE_FLAGS = -Wall -Wextra -pipe -MD -MP
BASE_OPTS = -O3 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -fdata-sections -ffunction-sections

ifeq ($(NOOPT),true)
# No optimization flags
BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
endif

ifneq ($(WIN32),true)
# Not needed for Windows
BASE_FLAGS += -fPIC -DPIC
endif

ifeq ($(DEBUG),true)
BASE_FLAGS += -DDEBUG -O0 -g
ifeq ($(WIN32),true)
BASE_FLAGS += -msse -msse2
endif
else
BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
CXXFLAGS += -fvisibility-inlines-hidden
endif

BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(CXXFLAGS) $(CPPFLAGS)

# ----------------------------------------------------------------------------------------------------------------------------

BUILD_CXX_FLAGS += -Wno-multichar -Wno-unused-variable -Wno-uninitialized -Wno-missing-field-initializers
BUILD_CXX_FLAGS += -Ilink

ifeq ($(LINUX),true)
BUILD_CXX_FLAGS += -DLINK_PLATFORM_LINUX=1
endif

ifeq ($(MACOS),true)
BUILD_CXX_FLAGS += -DLINK_PLATFORM_MACOSX=1
endif

ifeq ($(WIN32),true)
BUILD_CXX_FLAGS += -DLINK_PLATFORM_WINDOWS=1
endif

# ----------------------------------------------------------------------------------------------------------------------------

OBJS = build/hylia.cpp.o
VERSION = 0.0.1

PREFIX = /usr
INCDIR = $(PREFIX)/include
LIBDIR = $(PREFIX)/lib

# ----------------------------------------------------------------------------------------------------------------------------

all: build/hylia.a build/hylia.pc

# ----------------------------------------------------------------------------------------------------------------------------

clean:
rm -rf build

debug:
$(MAKE) DEBUG=true

# ----------------------------------------------------------------------------------------------------------------------------

install: all
install -d $(DESTDIR)$(INCDIR)
install -d $(DESTDIR)$(LIBDIR)/pkgconfig

install -m 644 hylia.h $(DESTDIR)$(INCDIR)
install -m 644 build/hylia.a $(DESTDIR)$(LIBDIR)
install -m 644 build/hylia.pc $(DESTDIR)$(LIBDIR)/pkgconfig

uninstall:
rm -f $(DESTDIR)$(INCDIR)/hylia.h
rm -f $(DESTDIR)$(LIBDIR)/hylia.a
rm -f $(DESTDIR)$(LIBDIR)/pkgconfig/hylia.pc

# ----------------------------------------------------------------------------------------------------------------------------

build/hylia.a: $(OBJS)
@echo "Creating hylia.a"
@rm -f $@
@$(AR) crs $@ $^

build/%.cpp.o: %.cpp
-@mkdir -p build
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@

build/%.pc: %.pc.in
sed \
-e "s|@PREFIX@|$(PREFIX)|" \
-e "s|@INCDIR@|$(INCDIR)|" \
-e "s|@LIBDIR@|$(LIBDIR)|" \
-e "s|@VERSION@|$(VERSION)|" \
hylia.pc.in > $@

-include $(OBJS:%.o=%.d)

# ----------------------------------------------------------------------------------------------------------------------------
10 changes: 10 additions & 0 deletions hylia.pc.in
@@ -0,0 +1,10 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=@LIBDIR@
includedir=@INCDIR@

Name: Hylia
Description: Host transport library for Ableton Link
Version: @VERSION@
Libs: ${libdir}/hylia.a
Cflags: -I${includedir}

0 comments on commit c0d5a34

Please sign in to comment.