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

OSX Makefile changes #218

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
23 changes: 18 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
CXX?=g++
UNAME := $(shell uname)

CXXFLAGS?=-Wall -O2
LIB?=hidapi
ifeq ($(LIB),libusb)
CPPFLAGS=-Dlibusb
LIBS=-lusb-1.0
else
CPPFLAGS=-Dhidapi
LIBS=-lhidapi-hidraw
ifeq ($(UNAME),Darwin)
LIBS = -lhidapi
else
LIBS = -lhidapi-hidraw
endif
endif
SYSTEMDDIR?=/usr/lib/systemd
$(warning CXX is $(CXX))
# Handle CLANG-specific link syntax
ifeq ($(UNAME),Darwin)
LINK_FLAGS = -Wl,-install_name,lib$(PROGN).so
else
LINK_FLAGS = -Wl,-soname,lib$(PROGN).so
endif

PREFIX?=$(DESTDIR)/usr
libdir?=$(PREFIX)/lib
Expand All @@ -33,13 +46,13 @@ bin: bin/$(PROGN)
bin/$(PROGN): $(APPSRCS) $(LIBSRCS)
@mkdir -p bin
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)

debug: CXXFLAGS += -g -Wextra -pedantic
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 $(LINKFLAGS) -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LIBS)
Copy link

Choose a reason for hiding this comment

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

Shouldn't this be $(LINK_FLAGS) instead of $(LINKFLAGS)?

@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so

bin-linked: lib/lib$(PROGN).so
Expand Down Expand Up @@ -104,7 +117,7 @@ uninstall:
rm $(SYSTEMDDIR)/system/$(PROGN)-reboot.service && \
systemctl daemon-reload && \
rm -R /etc/$(PROGN)

@rm /usr/bin/g213-led
@rm /usr/bin/g410-led
@rm /usr/bin/g413-led
Expand All @@ -114,6 +127,6 @@ uninstall:
@rm /usr/bin/g910-led
@rm /usr/bin/gpro-led
@rm /usr/bin/$(PROGN)

@rm /etc/udev/rules.d/$(PROGN).rules
@udevadm control --reload-rules