1# Copyright (c) 2022 Huawei Device Co., Ltd. 2# 3# HDF is dual licensed: you can use it either under the terms of 4# the GPL, or the BSD license, at your option. 5# See the LICENSE file in the root of this repository for complete details. 6 7Q = @ 8BUILD_DIR := build 9TARGET := $(BUILD_DIR)/hc-gen 10 11CXX := c++ 12CXX_FLAGS := -std=gnu++14 -s 13CXX_LD_FLAGS := -lstdc++ 14 15SRCS := $(wildcard src/*.cpp) 16OBJECTS := $(patsubst %.cpp,$(BUILD_DIR)/%.o,$(SRCS)) 17 18ifeq ($(LANG),) 19 CXX_FLAGS += -DOS_MINGW 20else 21 CXX_FLAGS += -DOS_UNIX 22endif 23 24all: $(TARGET) 25 26$(OBJECTS): $(BUILD_DIR)/%.o : %.cpp 27 $(Q) echo CC $< 28 $(Q) mkdir -p $(dir $@) 29 $(Q) $(CXX) $(CXX_FLAGS) $(CXX_LD_FLAGS) -c $< -o $@ 30 31$(TARGET): $(OBJECTS) 32 $(Q) echo built $@ 33 $(Q) $(CXX) $(CXX_FLAGS) $(CXX_LD_FLAGS) $^ -o $@ 34 35test: $(TARGET) 36 $(Q) python test/hcgen_test.py $(TARGET) 37 38update_testcase: $(TARGET) 39 $(Q) python test/update_case.py $(TARGET) 40 41clean: 42 $(Q) rm -rf $(BUILD_DIR) 43 44.PHONY: all clean test $(TARGET)