diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -1,31 +1,43 @@ CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ +#CXX = $(PREFIX)-g++ +CXX = clang++-3.6 LD = $(CXX) INCLUDE = -Iinclude/ LIB = -lhidapi-libusb BUILD = build -CXXFLAGS = -std=c++14 +CXXFLAGS = -std=c++14 -fPIC +SOFLAGS = -shared CXXSOURCES = $(wildcard *.cc) -OBJ = $(CXXSOURCES:%.cc:$(BUILD)/%.o) +OBJ = $(CXXSOURCES:%.cc=$(BUILD)/%.o) +DEPENDS = $(CXXSOURCES:%.cc=$(BUILD)/%.d) -$(BUILD)/libnitrokey.so: $(OBJ) - $(CXX) -shared $(OBJ) -o $@ +all: $(OBJ) $(BUILD)/libnitrokey.so unittest -$(BUILD)/%.o: %.cc - $(CXX) -c $< -o $@ $(INCLUDE) $(CXXFLAGS) +$(BUILD)/libnitrokey.so: $(OBJ) $(DEPENDS) + $(CXX) $(SOFLAGS) $(OBJ) $(LIB) -o $@ + +$(BUILD)/%.d: %.cc + $(CXX) -M $< -o $@ $(INCLUDE) $(CXXFLAGS) -all: $(OBJ) $(BUILD)/libnitrokey.so +$(BUILD)/%.o: %.cc $(DEPENDS) + $(CXX) -c $< -o $@ $(INCLUDE) $(CXXFLAGS) clean: - rm $(OBJ) - rm $(BUILD)/libnitrokey.so + rm -f $(OBJ) + rm -f $(BUILD)/libnitrokey.so + make -C unittest clean mrproper: clean - rm $(BUILD)/*.d + rm -f $(BUILD)/*.d + make -C unittest mrproper + +unittest: $(BUILD)/libnitrokey.so + make -C unittest + cd unittest/build && ln -fs ../../build/libnitrokey.so . -.PHONY: all clean mrproper +.PHONY: all clean mrproper unittest include $(wildcard build/*.d) |