2018-05-16 14:47:04 +08:00
|
|
|
MAJOR_VERSION=1
|
|
|
|
MINOR_VERSION=0
|
|
|
|
|
2018-06-01 16:32:07 +08:00
|
|
|
VERSION_H = $(BUILDDIR)/include/acrnprobe/version.h
|
2018-04-25 10:19:46 +08:00
|
|
|
|
2018-07-17 15:55:25 +08:00
|
|
|
LIBS = -lpthread -lxml2 -lcrypto -lrt -lblkid -lext2fs -lcom_err \
|
|
|
|
$(EXTRA_LIBS)
|
2018-09-25 14:57:34 +08:00
|
|
|
INCLUDE += -I $(CURDIR)/include -I $(SYSROOT)/usr/include/libxml2
|
2018-06-01 16:32:07 +08:00
|
|
|
INCLUDE += -I $(BUILDDIR)/include/acrnprobe
|
2018-04-25 10:19:46 +08:00
|
|
|
CFLAGS += $(INCLUDE)
|
2018-09-20 14:14:07 +08:00
|
|
|
CFLAGS += -fdata-sections
|
2020-11-27 00:07:41 +08:00
|
|
|
CFLAGS += -fcommon
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
LDFLAGS += $(LIBS) -Wl,--gc-sections
|
|
|
|
|
|
|
|
TARGET = $(BUILDDIR)/acrnprobe/bin/acrnprobe
|
|
|
|
|
2018-06-01 16:32:07 +08:00
|
|
|
.PHONY: all check_dirs
|
|
|
|
all: $(VERSION_H) check_dirs $(TARGET)
|
2018-06-28 10:36:10 +08:00
|
|
|
rm -f $(VERSION_H)
|
2018-04-25 10:19:46 +08:00
|
|
|
|
acrnprobe: avoid race condition
main.c is compiled while version.h being generated. This will
result following error:
| main.c: In function 'main':
| main.c:95:5: error: 'AP_MAJOR_VERSION' undeclared (first use in this function)
| 95 | AP_MAJOR_VERSION, AP_MINOR_VERSION,
| | ^~~~~~~~~~~~~~~~
| main.c:95:5: note: each undeclared identifier is reported only once for each function it appears in
| main.c:95:23: error: 'AP_MINOR_VERSION' undeclared (first use in this function)
| 95 | AP_MAJOR_VERSION, AP_MINOR_VERSION,
| | ^~~~~~~~~~~~~~~~
| main.c:96:5: error: 'AP_BUILD_VERSION' undeclared (first use in this function)
| 96 | AP_BUILD_VERSION, AP_BUILD_USER,
| | ^~~~~~~~~~~~~~~~
| main.c:96:23: error: 'AP_BUILD_USER' undeclared (first use in this function)
| 96 | AP_BUILD_VERSION, AP_BUILD_USER,
| | ^~~~~~~~~~~~~
| main.c:97:5: error: 'AP_BUILD_TIME' undeclared (first use in this function)
| 97 | AP_BUILD_TIME);
| | ^~~~~~~~~~~~~
Similar issues observed with usercrash too.
To fix this, add version.h header as dependency, to make sure
it is generated successfully.
Tracked-On: #4590
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
2020-04-07 17:47:23 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/obj/%.o:%.c $(VERSION_H)
|
2018-04-25 10:19:46 +08:00
|
|
|
$(CC) -c $(CFLAGS) $< -o $@
|
|
|
|
|
2018-05-09 16:56:15 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/bin/acrnprobe: $(BUILDDIR)/acrnprobe/obj/main.o \
|
|
|
|
$(BUILDDIR)/common/obj/log_sys.o \
|
|
|
|
$(BUILDDIR)/common/obj/cmdutils.o \
|
|
|
|
$(BUILDDIR)/common/obj/fsutils.o \
|
|
|
|
$(BUILDDIR)/common/obj/strutils.o \
|
|
|
|
$(BUILDDIR)/acrnprobe/obj/load_conf.o \
|
|
|
|
$(BUILDDIR)/acrnprobe/obj/channels.o \
|
|
|
|
$(BUILDDIR)/acrnprobe/obj/event_queue.o \
|
|
|
|
$(BUILDDIR)/acrnprobe/obj/event_handler.o \
|
|
|
|
$(BUILDDIR)/acrnprobe/obj/crash_reclassify.o \
|
2018-05-09 17:31:33 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/obj/sender.o \
|
2018-05-09 17:33:56 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/obj/startupreason.o \
|
2018-05-09 17:39:55 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/obj/property.o \
|
|
|
|
$(BUILDDIR)/acrnprobe/obj/probeutils.o \
|
2018-05-10 09:38:01 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/obj/history.o \
|
2018-07-17 15:34:28 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/obj/android_events.o \
|
2019-04-18 16:00:38 +08:00
|
|
|
$(BUILDDIR)/acrnprobe/obj/loop.o \
|
|
|
|
$(BUILDDIR)/acrnprobe/obj/vmrecord.o
|
2018-04-25 10:19:46 +08:00
|
|
|
$(CC) -o $@ $^ $(LDFLAGS)
|
|
|
|
|
2018-06-01 16:32:07 +08:00
|
|
|
.PHONY: clean
|
2018-04-25 10:19:46 +08:00
|
|
|
clean:
|
|
|
|
@echo "Clean objects and binaries"
|
2018-06-01 16:32:07 +08:00
|
|
|
@if [ -e $(VERSION_H) ]; then \
|
|
|
|
$(RM) -f $(VERSION_H); \
|
2018-05-16 14:47:04 +08:00
|
|
|
fi
|
2018-04-25 10:19:46 +08:00
|
|
|
@if [ -d $(BUILDDIR)/acrnprobe/obj ]; then \
|
|
|
|
find $(BUILDDIR)/acrnprobe/obj -name "*.o" -exec $(RM) {} \; 2>&1 || exit 0; \
|
|
|
|
fi
|
|
|
|
@if [ -d $(BUILDDIR)/acrnprobe/bin ]; then \
|
|
|
|
$(RM) -r $(BUILDDIR)/acrnprobe/bin ; \
|
|
|
|
fi
|
|
|
|
@if [ -d $(BUILDDIR)/acrnprobe/obj ]; then \
|
|
|
|
$(RM) -r $(BUILDDIR)/acrnprobe/obj ; \
|
|
|
|
fi
|
|
|
|
|
2018-06-01 16:32:07 +08:00
|
|
|
$(VERSION_H):
|
|
|
|
@if [ ! -d $(BUILDDIR)/include/acrnprobe ]; then \
|
|
|
|
mkdir -p $(BUILDDIR)/include/acrnprobe ; \
|
|
|
|
fi
|
|
|
|
touch $(VERSION_H)
|
2020-04-27 18:51:27 +08:00
|
|
|
@if [ "$(BUILD_VERSION)"x = x ];then \
|
|
|
|
COMMIT=`git log -1 --pretty=format:%h . 2>/dev/null`;\
|
|
|
|
DIRTY=`git diff --name-only $(CURDIR)`;\
|
|
|
|
if [ -n "$$DIRTY" ];then PATCH="$$COMMIT-dirty";else PATCH="$$COMMIT";fi;\
|
|
|
|
else \
|
|
|
|
PATCH="$(BUILD_VERSION)"; \
|
|
|
|
fi; \
|
2020-04-05 15:56:29 +08:00
|
|
|
TIME=$$(date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" "+%Y-%m-%d %H:%M:%S"); \
|
|
|
|
USER="$${USER:-$$(id -u -n)}"; \
|
2018-06-01 16:32:07 +08:00
|
|
|
cat $(CURDIR)/../license_header > $(VERSION_H);\
|
|
|
|
echo "#define AP_MAJOR_VERSION $(MAJOR_VERSION)" >> $(VERSION_H);\
|
|
|
|
echo "#define AP_MINOR_VERSION $(MINOR_VERSION)" >> $(VERSION_H);\
|
|
|
|
echo "#define AP_BUILD_VERSION "\""$$PATCH"\""" >> $(VERSION_H);\
|
|
|
|
echo "#define AP_BUILD_TIME "\""$$TIME"\""" >> $(VERSION_H);\
|
2018-06-28 10:36:10 +08:00
|
|
|
echo "#define AP_BUILD_USER "\""$$USER"\""" >> $(VERSION_H)
|
2018-05-16 14:47:04 +08:00
|
|
|
|
2018-04-25 10:19:46 +08:00
|
|
|
check_dirs:
|
|
|
|
@if [ ! -d $(BUILDDIR)/acrnprobe/bin ]; then \
|
|
|
|
mkdir -p $(BUILDDIR)/acrnprobe/bin ; \
|
|
|
|
fi
|
|
|
|
@if [ ! -d $(BUILDDIR)/acrnprobe/obj ]; then \
|
|
|
|
mkdir -p $(BUILDDIR)/acrnprobe/obj ; \
|
|
|
|
fi
|