Fix linking with --as-needed.

Also remove all hardcoding from the Makefile.
This commit is contained in:
Karl Linden 2017-10-28 15:12:16 +02:00
parent 3224c912c8
commit 06a972be33
No known key found for this signature in database
GPG Key ID: C0F669D8CE2576AB
1 changed files with 13 additions and 11 deletions

View File

@ -2,23 +2,25 @@ CXXFLAGS ?= -O2
PREFIX ?= /usr/local PREFIX ?= /usr/local
all: xkblayout-state headers := XKeyboard.h X11Exception.h
sources := XKeyboard.cpp wrapper.cpp
objects := $(sources:.cpp=.o)
program := xkblayout-state
XKeyboard.o: XKeyboard.cpp XKeyboard.h X11Exception.h all: $(program)
$(objects): %.o: %.cpp $(headers)
$(CXX) $(CXXFLAGS) -Wall -c -o $@ $< $(CXX) $(CXXFLAGS) -Wall -c -o $@ $<
wrapper.o: wrapper.cpp XKeyboard.h $(program): $(objects)
$(CXX) $(CXXFLAGS) -Wall -c -o $@ $< $(CXX) $(CXXFLAGS) -lX11 $(LDFLAGS) -o $@ $^
xkblayout-state: XKeyboard.o wrapper.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -lX11 -o xkblayout-state $^
clean: clean:
rm -f xkblayout-state XKeyboard.o wrapper.o rm -f $(program) $(objects)
install: xkblayout-state install: $(program)
install xkblayout-state $(DESTDIR)$(PREFIX)/bin install $(program) $(DESTDIR)$(PREFIX)/bin
dist: dist:
tar cfa xkblayout-state-v1b.tar.gz Makefile README.md wrapper.cpp X11Exception.h XKeyboard.cpp XKeyboard.h tar cfa $(program)-v1b.tar.gz Makefile README.md $(headers) $(sources)