Skip to content

Commit

Permalink
Have makefile run test manually
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Mar 25, 2024
1 parent 5767e48 commit 878173c
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
# Unix only makefile
-include config.mak

CFLAGS=-Isrc/ -g -fpic -Wall -Wshadow -Wcast-qual -Wpedantic -Werror=incompatible-pointer-types -Werror=deprecated-declarations
CFLAGS+=-D CAMLIB_NO_COMPAT -D VERBOSE
CFLAGS := -Isrc/ -g -fpic -Wall -Wshadow -Wcast-qual -Wpedantic -Werror=incompatible-pointer-types -Werror=deprecated-declarations
CFLAGS += -D CAMLIB_NO_COMPAT -D VERBOSE

# All platforms need these object files
CAMLIB_CORE=operations.o packet.o enums.o data.o enum_dump.o lib.o canon.o liveview.o bind.o ip.o ml.o log.o conv.o generic.o canon_adv.o
FILES=$(addprefix src/,$(CAMLIB_CORE))
CAMLIB_CORE := operations.o packet.o enums.o data.o enum_dump.o lib.o canon.o liveview.o bind.o ip.o ml.o log.o conv.o generic.o canon_adv.o
FILES := $(addprefix src/,$(CAMLIB_CORE))

EXTRAS=src/canon_adv.o
EXTRAS := src/canon_adv.o

# Unix-specific
CFLAGS+=$(shell pkg-config --cflags libusb-1.0)
LDFLAGS?=$(shell pkg-config --libs libusb-1.0)
FILES+=src/libusb.o src/transport.o
CFLAGS += $(shell pkg-config --cflags libusb-1.0)
LDFLAGS ?= $(shell pkg-config --libs libusb-1.0)
FILES += src/libusb.o src/transport.o

# TODO: implement as CAMLIB_VERSION
COMMIT=$(shell git rev-parse HEAD)
CFLAGS+='-DCAMLIB_COMMIT="$(COMMIT)"'

# TODO: add LDFLAGS to fix mac builds
libcamlib.so: $(FILES) $(EXTRAS)
$(CC) -shared $(FILES) -o libcamlib.so

# MacOS dylib
ifeq ($(TARGET),m)
CFLAGS+=-I/usr/local/include/libusb-1.0
CFLAGS += -I/usr/local/include/libusb-1.0
libcamlib.dylib: $(FILES)
$(CC) -shared $(FILES) -L/usr/local/lib -lusb-1.0 -o libcamlib.so
endif
Expand All @@ -36,7 +31,7 @@ endif
-include src/*.d lua/*.d lua/lua-cjson/*.d

# PTP decoder
DEC_FILES=src/dec/main.o src/enums.o src/enum_dump.o src/packet.o src/conv.o src/log.o
DEC_FILES := src/dec/main.o src/enums.o src/enum_dump.o src/packet.o src/conv.o src/log.o
dec: $(DEC_FILES)
$(CC) $(DEC_FILES) $(CFLAGS) -o $@

Expand All @@ -45,7 +40,7 @@ stringify:
python3 stringify.py

clean:
rm -rf *.o src/*.o src/dec/*.o *.out test-ci test/*.o examples/*.o *.exe dec *.dll *.so libusb-fake-ptp DUMP \
rm -rf *.o src/*.o src/dec/*.o *.out test-ci test/*.o examples/*.o examples/*.d *.exe dec *.dll *.so DUMP \
lua/*.o lua/lua-cjson/*.o src/*.d examples/*.d lua/*.d lua/lua-cjson/*.d
cd examples && make clean

Expand All @@ -54,9 +49,10 @@ install: libcamlib.so
-mkdir /usr/include/camlib
cp src/*.h /usr/include/camlib/

test-ci: test/test.o $(FILES)
$(CC) test/test.o $(FILES) $(LDFLAGS) $(CFLAGS) -o test-ci
test:
bash test/myci.sh
test-ci: test/test.o $(FILES) ../vcam/libusb.so
$(CC) test/test.o $(FILES) -L../vcam/ -Wl,-rpath=../vcam/ -lusb -lexif $(CFLAGS) -o test-ci

test: test-ci
./test-ci

.PHONY: all clean install stringify test

0 comments on commit 878173c

Please sign in to comment.