| 1 |
# |
| 2 |
# Makefile for OpenzWave Mac OS X applications |
| 3 |
# Greg Satz |
| 4 |
|
| 5 |
# GNU make only |
| 6 |
|
| 7 |
# requires libudev-dev |
| 8 |
|
| 9 |
.SUFFIXES: .d .cpp .o .a |
| 10 |
.PHONY: default clean |
| 11 |
|
| 12 |
|
| 13 |
DEBUG_CFLAGS := -Wall -Wno-format -ggdb -DDEBUG $(CPPFLAGS) -std=c++11 |
| 14 |
RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-format -O3 $(CPPFLAGS) -std=c++11 |
| 15 |
|
| 16 |
DEBUG_LDFLAGS := -g |
| 17 |
|
| 18 |
top_srcdir := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../../../) |
| 19 |
|
| 20 |
#where is put the temporary library |
| 21 |
LIBDIR ?= $(top_builddir) |
| 22 |
|
| 23 |
INCLUDES := -I $(top_srcdir)/cpp/src -I $(top_srcdir)/cpp/tinyxml/ -I $(top_srcdir)/cpp/hidapi/hidapi/ |
| 24 |
LIBS = $(wildcard $(LIBDIR)/*.so $(LIBDIR)/*.dylib $(top_builddir)/cpp/build/*.so $(top_builddir)/cpp/build/*.dylib ) |
| 25 |
LIBSDIR = $(abspath $(dir $(firstword $(LIBS)))) |
| 26 |
minozwsrc := $(notdir $(wildcard $(top_srcdir)/cpp/examples/MinOZW/*.cpp)) |
| 27 |
VPATH := $(top_srcdir)/cpp/examples/MinOZW |
| 28 |
|
| 29 |
top_builddir ?= $(CURDIR) |
| 30 |
|
| 31 |
default: $(top_builddir)/MinOZW |
| 32 |
|
| 33 |
include $(top_srcdir)/cpp/build/support.mk |
| 34 |
|
| 35 |
-include $(patsubst %.cpp,$(DEPDIR)/%.d,$(minozwsrc)) |
| 36 |
|
| 37 |
#if we are on a Mac, add these flags and libs to the compile and link phases |
| 38 |
ifeq ($(UNAME),Darwin) |
| 39 |
CFLAGS += -DDARWIN |
| 40 |
ifeq ($(DARWIN_MOJAVE_UP),1) |
| 41 |
# Newer macOS releases don't support i386 so only build 64-bit |
| 42 |
TARCH += -arch x86_64 |
| 43 |
else |
| 44 |
# Support older versions of OSX that may need to build both 32-bit and 64-bit |
| 45 |
TARCH += -arch i386 -arch x86_64 |
| 46 |
endif |
| 47 |
endif |
| 48 |
|
| 49 |
# Dup from main makefile, but that is not included when building here.. |
| 50 |
ifeq ($(UNAME),FreeBSD) |
| 51 |
LDFLAGS+= -lusb |
| 52 |
|
| 53 |
ifeq ($(shell test $$(uname -U) -ge 1002000; echo $$?),1) |
| 54 |
ifeq (,$(wildcard /usr/local/include/iconv.h)) |
| 55 |
$(error FreeBSD pre 10.2: Please install libiconv from ports) |
| 56 |
else |
| 57 |
CFLAGS += -I/usr/local/include |
| 58 |
LDFLAGS+= -L/usr/local/lib -liconv |
| 59 |
endif |
| 60 |
endif |
| 61 |
|
| 62 |
else ifeq ($(UNAME),NetBSD) |
| 63 |
LDFLAGS+= -L/usr/pkg/lib -lusb-1.0 |
| 64 |
else ifeq ($(UNAME),SunOS) |
| 65 |
LDFLAGS+= -lusb-1.0 |
| 66 |
endif |
| 67 |
|
| 68 |
$(OBJDIR)/MinOZW: $(patsubst %.cpp,$(OBJDIR)/%.o,$(minozwsrc)) |
| 69 |
@echo "Linking MinOZW" |
| 70 |
@$(LD) $(LDFLAGS) $(TARCH) -o $@ $< $(LIBS) -pthread |
| 71 |
|
| 72 |
$(top_builddir)/MinOZW: $(top_srcdir)/cpp/examples/MinOZW/MinOZW.in $(OBJDIR)/MinOZW |
| 73 |
@echo "Creating Temporary Shell Launch Script" |
| 74 |
@$(SED) \ |
| 75 |
-e 's|[@]LDPATH@|$(LIBSDIR)|g' \ |
| 76 |
< "$<" > "$@" |
| 77 |
@chmod +x $(top_builddir)/MinOZW |
| 78 |
|
| 79 |
clean: |
| 80 |
@rm -rf $(DEPDIR) $(OBJDIR) $(top_builddir)/MinOZW |
| 81 |
|
| 82 |
ifeq ($(XMLLINT),) |
| 83 |
xmltest: $(XMLLINT) |
| 84 |
$(error xmllint command not found.) |
| 85 |
else |
| 86 |
xmltest: $(XMLLINT) |
| 87 |
@$(XMLLINT) --noout --schema ../../../config/zwcfg.xsd zwcfg_*.xml |
| 88 |
@$(XMLLINT) --noout --schema ../../../config/zwscene.xsd zwscene.xml |
| 89 |
endif |
| 90 |
|
| 91 |
install: $(OBJDIR)/MinOZW |
| 92 |
@echo "Installing into Prefix: $(PREFIX)" |
| 93 |
@install -d $(DESTDIR)/$(PREFIX)/bin/ |
| 94 |
@cp $(OBJDIR)/MinOZW $(DESTDIR)/$(PREFIX)/bin/MinOZW |
| 95 |
@chmod 755 $(DESTDIR)/$(PREFIX)/bin/MinOZW |