1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-23 09:16:11 +00:00

makefile: Use standard variables and reuse the environment

This commit is contained in:
Haelwenn (lanodan) Monnier 2018-08-31 01:25:29 +02:00
parent 1b480ae4c2
commit 5fa7760e53
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE

View File

@ -1,18 +1,18 @@
CC=g++ CXX?=g++
CFLAGS=-Wall -O2 -std=gnu++11 CXXFLAGS?=-Wall -O2 -std=gnu++11
LIB?=hidapi LIB?=hidapi
ifeq ($(LIB),libusb) ifeq ($(LIB),libusb)
CPPFLAGS=-Dlibusb CPPFLAGS=-Dlibusb
LDFLAGS=-lusb-1.0 LDFLAGS+=-lusb-1.0
else else
CPPFLAGS=-Dhidapi CPPFLAGS=-Dhidapi
LDFLAGS=-lhidapi-hidraw LDFLAGS+=-lhidapi-hidraw
endif endif
SYSTEMDDIR?=/usr/lib/systemd SYSTEMDDIR?=/usr/lib/systemd
prefix?=$(DESTDIR)/usr PREFIX?=$(DESTDIR)/usr
libdir?=$(prefix)/lib libdir?=$(PREFIX)/lib
includedir?=$(prefix)/include includedir?=$(PREFIX)/include
# Program & versioning information # Program & versioning information
PROGN=g810-led PROGN=g810-led
@ -20,7 +20,7 @@ MAJOR=0
MINOR=2 MINOR=2
MICRO=7 MICRO=7
CFLAGS+=-DVERSION=\"$(MAJOR).$(MINOR).$(MICRO)\" CXXFLAGS+=-DVERSION=\"$(MAJOR).$(MINOR).$(MICRO)\"
APPSRCS=src/main.cpp src/helpers/*.cpp src/helpers/*.h APPSRCS=src/main.cpp src/helpers/*.cpp src/helpers/*.h
LIBSRCS=src/classes/*.cpp src/classes/*.h LIBSRCS=src/classes/*.cpp src/classes/*.h
@ -32,19 +32,19 @@ bin: bin/$(PROGN)
bin/$(PROGN): $(APPSRCS) $(LIBSRCS) bin/$(PROGN): $(APPSRCS) $(LIBSRCS)
@mkdir -p bin @mkdir -p bin
$(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
debug: CFLAGS += -g -Wextra -pedantic debug: CXXFLAGS += -g -Wextra -pedantic
debug: bin/$(PROGN) debug: bin/$(PROGN)
lib/lib$(PROGN).so: $(LIBSRCS) lib/lib$(PROGN).so: $(LIBSRCS)
@mkdir -p lib @mkdir -p lib
$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -shared -Wl,-soname,lib$(PROGN).so -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LDFLAGS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -fPIC -shared -Wl,-soname,lib$(PROGN).so -o lib/lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) $^ $(LDFLAGS)
@ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so @ln -sf lib$(PROGN).so.$(MAJOR).$(MINOR).$(MICRO) lib/lib$(PROGN).so
bin-linked: lib/lib$(PROGN).so bin-linked: lib/lib$(PROGN).so
@mkdir -p bin @mkdir -p bin
$(CC) $(CPPFLAGS) $(CFLAGS) $(APPSRCS) -o bin/$(PROGN) $(LDFLAGS) -L./lib -l$(PROGN) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(APPSRCS) -o bin/$(PROGN) $(LDFLAGS) -L./lib -l$(PROGN)
lib: lib/lib$(PROGN).so lib: lib/lib$(PROGN).so