Skip to content

Commit

Permalink
workflow: properly generate version.h
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Dec 6, 2023
1 parent fe701b8 commit f1627aa
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,32 @@ TARGET_OBJS = $(filter-out third_party/%, $(filter-out tests/%, $(OBJS)))
all: version
+make $(TARGET)

install: version
+make $(TARGET)
install $(TARGET) $(DESTDIR)/usr/local/bin/

.SUFFIXES:

ifeq (1,$(USE_LIBDATACHANNEL))
camera-streamer: $(LIBDATACHANNEL_PATH)/build/libdatachannel-static.a
endif

camera-streamer: $(filter-out cmd/%, $(TARGET_OBJS)) $(filter cmd/camera-streamer/%, $(TARGET_OBJS))
$(CCACHE) $(CXX) $(CFLAGS) -o $@ $^ $(LDLIBS)

.PHONY: version
version:
echo "#define GIT_VERSION \"$(GIT_VERSION)\"\n#define GIT_REVISION \"$(GIT_REVISION)\"" > version.h.tmp
if $(CXX) $(CFLAGS) -o /dev/null -c tests/libcamera/orientation.cc 2>/dev/null; then \
if $(CCACHE) $(CXX) $(CFLAGS) -o tests/libcamera/orientation.o -c tests/libcamera/orientation.cc 2>/dev/null; then \
echo "#define LIBCAMERA_USES_ORIENTATION" >> version.h.tmp; \
else \
echo "#define LIBCAMERA_USES_TRANSFORM" >> version.h.tmp; \
fi
diff -u version.h version.h.tmp || mv version.h.tmp version.h
-rm -f version.h.tmp

%: cmd/% $(TARGET_OBJS)
$(CCACHE) $(CXX) $(CFLAGS) -o $@ $(filter-out cmd/%, $^) $(filter $</%, $^) $(LDLIBS)

install: $(TARGET)
install $(TARGET) $(DESTDIR)/usr/local/bin/

clean:
rm -f .depend $(OBJS) $(OBJS:.o=.d) $(HTML_SRC) $(TARGET)
rm -f .depend $(OBJS) $(OBJS:.o=.d) $(HTML_SRC) $(TARGET) version.h

headers:
find -name '*.h' | xargs -n1 $(CCACHE) $(CC) $(CFLAGS) -std=gnu17 -Wno-error -c -o /dev/null
Expand All @@ -104,6 +105,7 @@ headers:
%.o: %.cc
$(CCACHE) $(CXX) -std=c++17 -MMD $(CFLAGS) -c -o $@ $<

.PRECIOUS: html/%.c
html/%.c: html/%
xxd -i $< > $@.tmp
mv $@.tmp $@
Expand Down

0 comments on commit f1627aa

Please sign in to comment.