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

Refactored Makefile to support build caching #35

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dualsensectl
*.o
38 changes: 18 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
CC = gcc
CFLAGS += -Wall -Wextra -pedantic
CFLAGS += $(shell pkg-config --cflags dbus-1)
CFLAGS += $(shell pkg-config --cflags hidapi-hidraw)
LIBS += $(shell pkg-config --libs dbus-1)
LIBS += $(shell pkg-config --libs hidapi-hidraw)
LIBS += $(shell pkg-config --libs libudev)
TARGET := dualsensectl
VERSION := 0.6

TARGET = dualsensectl
VERSION = 0.6
OPTFLAGS = -O2 -s -DNDEBUG
CFLAGS += $(OPTFLAGS)

ifeq ($(BUILD),debug)
CFLAGS += -O0 -g
else
CFLAGS += -O2 -s -DNDEBUG
endif
CFLAGS += -DDUALSENSECTL_VERSION=\"$(VERSION)\"
CFLAGS += -Wall -Wextra -pedantic
CFLAGS += $(shell pkg-config --cflags dbus-1)
CFLAGS += $(shell pkg-config --cflags hidapi-hidraw)
LDFLAGS += $(shell pkg-config --libs dbus-1)
LDFLAGS += $(shell pkg-config --libs hidapi-hidraw)
LDFLAGS += $(shell pkg-config --libs libudev)

DEFINES += -DDUALSENSECTL_VERSION=\"$(VERSION)\"
all: $(TARGET)

all:
$(CC) main.c -o $(TARGET) $(DEFINES) $(CFLAGS) $(LIBS)

debug:
make "BUILD=debug"
.PHONE: debug
debug: OPTFLAGS = -Og -g
debug: all

install: all
install -D -m 755 -p $(TARGET) $(DESTDIR)/usr/bin/$(TARGET)
Expand All @@ -32,3 +27,6 @@ uninstall:
rm -f $(DESTDIR)/usr/bin/$(TARGET)
rm -f $(DESTDIR)/usr/share/bash-completion/completions/$(TARGET)
rm -f $(DESTDIR)/usr/share/zsh/site-functions/_$(TARGET)

$(TARGET): main.c
$(CC) $(CFLAGS) $< -o $(TARGET) $(LDFLAGS)
Loading