2011-10-21 02:21:43 +00:00
|
|
|
# make ... for both libusb and libsg
|
|
|
|
#
|
|
|
|
# make CONFIG_USE_LIBSG=0 ...
|
|
|
|
# for just libusb
|
|
|
|
#
|
2011-10-06 23:22:33 +00:00
|
|
|
VPATH=src
|
|
|
|
|
2011-10-21 02:21:43 +00:00
|
|
|
SOURCES_LIB=stlink-common.c stlink-usb.c
|
2011-10-06 23:22:33 +00:00
|
|
|
OBJS_LIB=$(SOURCES_LIB:.c=.o)
|
2011-10-21 02:21:43 +00:00
|
|
|
TEST_PROGRAMS=test_usb
|
2011-10-23 02:23:53 +00:00
|
|
|
LDFLAGS=-L. -lstlink -lusb-1.0
|
2011-10-21 02:21:43 +00:00
|
|
|
|
|
|
|
ifeq ($(CONFIG_USE_LIBSG),)
|
|
|
|
CONFIG_USE_LIBSG=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(CONFIG_USE_LIBSG),0)
|
|
|
|
SOURCES_LIB+=stlink-sg.c
|
|
|
|
CFLAGS+=-DCONFIG_USE_LIBSG=1
|
|
|
|
LDFLAGS+=-lsgutils2
|
|
|
|
TEST_PROGRAMS+=test_sg
|
|
|
|
endif
|
2011-10-06 23:22:33 +00:00
|
|
|
|
2011-10-07 19:32:19 +00:00
|
|
|
CFLAGS+=-g
|
2011-10-21 02:21:43 +00:00
|
|
|
CFLAGS+=-DCONFIG_USE_LIBUSB=1
|
|
|
|
CFLAGS+=-DDEBUG=1
|
2011-10-07 19:32:19 +00:00
|
|
|
CFLAGS+=-std=gnu99
|
2011-10-06 23:22:33 +00:00
|
|
|
CFLAGS+=-Wall -Wextra
|
|
|
|
|
|
|
|
|
|
|
|
LIBRARY=libstlink.a
|
|
|
|
|
2011-10-21 02:21:43 +00:00
|
|
|
all: $(LIBRARY) flash gdbserver $(TEST_PROGRAMS)
|
2011-10-06 23:22:33 +00:00
|
|
|
|
|
|
|
$(LIBRARY): $(OBJS_LIB)
|
|
|
|
@echo "objs are $(OBJS_LIB)"
|
|
|
|
$(AR) -cr $@ $^
|
|
|
|
@echo "done making library"
|
|
|
|
|
|
|
|
|
|
|
|
test_sg: test_sg.o $(LIBRARY)
|
|
|
|
@echo "building test_sg"
|
2011-10-07 02:47:37 +00:00
|
|
|
$(CC) test_sg.o $(LDFLAGS) -o $@
|
2011-10-06 23:22:33 +00:00
|
|
|
|
|
|
|
test_usb: test_usb.o $(LIBRARY)
|
|
|
|
@echo "building test_usb"
|
|
|
|
$(CC) test_usb.o $(LDFLAGS) -o $@
|
|
|
|
@echo "done linking"
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
@echo "building $^ into $@"
|
|
|
|
$(CC) $(CFLAGS) -c $^ -o $@
|
|
|
|
@echo "done compiling"
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(OBJS_LIB)
|
|
|
|
rm -rf $(LIBRARY)
|
|
|
|
rm -rf test_usb*
|
|
|
|
rm -rf test_sg*
|
2011-10-20 01:39:57 +00:00
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
$(MAKE) -C flash clean
|
|
|
|
$(MAKE) -C gdbserver clean
|
2011-10-06 23:22:33 +00:00
|
|
|
|
2011-10-20 01:39:57 +00:00
|
|
|
flash:
|
2011-10-21 02:21:43 +00:00
|
|
|
$(MAKE) -C flash CONFIG_USE_LIBSG="$(CONFIG_USE_LIBSG)"
|
2011-10-20 01:39:57 +00:00
|
|
|
|
|
|
|
gdbserver:
|
2011-11-06 17:26:12 +00:00
|
|
|
$(MAKE) -C gdbserver CONFIG_USE_LIBSG="$(CONFIG_USE_LIBSG)"
|
2011-10-20 01:39:57 +00:00
|
|
|
|
|
|
|
.PHONY: clean all flash gdbserver
|