USBREDIR_VERSION=0.3.1

# These ones can be overriden from the cmdline
CFLAGS  = -fPIC -g -O2 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Werror
PREFIX  = /usr
LIBDIR  = $(PREFIX)/lib
SBINDIR = $(PREFIX)/bin

# These ones should not be overriden from the cmdline
override CPPFLAGS += -I../usbredirparser -I../usbredirhost -DUSBREDIR_VERSION='"$(USBREDIR_VERSION)"'
override LDFLAGS += -L../usbredirparser -L../usbredirhost

# And last various rules
%.o: %.c
	$(CC) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CFLAGS) -o $@ $<

%.o: %.cpp
	$(CXX) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<

%.so:
	$(CC) -shared $(LDFLAGS) -Wl,-soname,$@.$(LIB_RELEASE) -o $@.$(LIB_RELEASE) $^ $(LIBS_$*)
	ln -f -s $@.$(LIB_RELEASE) $@

%.a:
	$(AR) cqs $@ $^

clean::
	rm -f core core.[0123456789]* *~ *.o *.d *.a *.so* DEADJOE *.orig *.rej $(TARGETS)
