Skip to content
Open
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
18 changes: 16 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
ifndef OS
OS:=$(shell uname)
endif
Comment on lines +1 to +3

@DanEble DanEble Oct 18, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've done a little more research. According to https://stackoverflow.com/a/12099167,
OS will be set in the environment on Windows systems, so this should work fine for Windows in addition to systems with uname.


CXX?=g++
CXXFLAGS?=-Wall -O2
LIB?=hidapi
Expand All @@ -6,7 +10,11 @@ ifeq ($(LIB),libusb)
LIBS=-lusb-1.0
else
CPPFLAGS=-Dhidapi
LIBS=-lhidapi-hidraw
ifeq ($(OS),Darwin)
LIBS=-lhidapi
else
LIBS=-lhidapi-hidraw
endif
endif
SYSTEMDDIR?=/usr/lib/systemd

Expand All @@ -24,6 +32,12 @@ CXXFLAGS+=-std=gnu++11 -DVERSION=\"$(MAJOR).$(MINOR).$(MICRO)\"
APPSRCS=src/main.cpp src/helpers/*.cpp
LIBSRCS=src/classes/*.cpp

ifeq ($(OS),Darwin)
SONAME_OPT=-install_name
else
SONAME_OPT=-soname
endif

.PHONY: all bin debug clean setup install uninstall lib install-lib install-dev

all: lib/lib$(PROGN).so bin/$(PROGN)
Expand All @@ -39,7 +53,7 @@ debug: bin/$(PROGN)

lib/lib$(PROGN).so: $(LIBSRCS)
@mkdir -p lib
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -fPIC -shared -Wl,-soname,lib$(PROGN).so -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LIBS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -fPIC -shared -Wl,$(SONAME_OPT),lib$(PROGN).so -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LIBS)
@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so

bin-linked: lib/lib$(PROGN).so
Expand Down