Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (33 sloc) 953 Bytes
vpath %.c ../src
INCLUDE_DIRS = -I../src
INCLUDE_DIRS += -I$(CMOCKA_DIR)/include
CFLAGS = $(INCLUDE_DIRS)
MOCKS = i2c_read_blocking i2c_transmit_blocking
LDFLAGS = -L$(CMOCKA_DIR)/build/src -Wl,-rpath=$(CMOCKA_DIR)/build/src
LDFLAGS += $(foreach MOCK,$(MOCKS),-Wl,--wrap=$(MOCK))
LDFLAGS += -lcmocka
TARGET = test_tmp101
SRC = i2c.c tmp101.c
TEST_SRC = mock_i2c.c test_tmp101.c
SRC_OBJ = $(patsubst %.c,obj/%.o,$(SRC))
TEST_OBJ = $(patsubst %.c,obj/%.o,$(TEST_SRC))
OBJ_DIR = obj
CMOCKA_TAR = cmocka-1.1.0.tar.xz
CMOCKA_DIR = cmocka
all: $(CMOCKA_DIR) $(TARGET)
./$(TARGET)
$(SRC_OBJ): | $(OBJ_DIR)
$(OBJ_DIR):
@mkdir -p $@
$(OBJ_DIR)/%.o : %.c
@echo $<
$(CC) $(CFLAGS) -c $< -o $@
$(TARGET): $(SRC_OBJ) $(TEST_OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
$(CMOCKA_DIR):
mkdir -p $@
tar -xf $(CMOCKA_TAR) -C $@ --strip-components 1
mkdir -p $@/build
@(cd $@/build && cmake ../ && make -s)
clean:
rm -rf $(TARGET) $(OBJ_DIR) $(CMOCKA_DIR)
You can’t perform that action at this time.