summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2013-04-21 17:07:01 +0200
committerPali Rohár <pali.rohar@gmail.com>2013-04-21 17:07:01 +0200
commit796dc3a67764b1a7976dc3d3757dacd7c3d391c2 (patch)
treecbf92471f49f53e2a029ed24b345b2df07c91e65 /src
parent1c20e5ff5f95a85f02578b66e9c45d9962865cda (diff)
download0xFFFF-796dc3a67764b1a7976dc3d3757dacd7c3d391c2.tar.bz2
Makefile: Add support for cross compile
Diffstat (limited to 'src')
-rw-r--r--src/Makefile16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Makefile b/src/Makefile
index 8e3e0ac..72c2e61 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,6 +3,10 @@ include ../config.mk
PREFIX ?= /usr/local
INSTALL ?= install
+CC = gcc
+CROSS_CC = $(CROSS_COMPILE)$(CC)
+HOST_CC = $(HOST_COMPILE)$(CC)
+
CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_GNU_SOURCE
CFLAGS += -W -Wall -O2 -pedantic -std=c99
LIBS += -lusb
@@ -16,13 +20,13 @@ MANGEN = mangen
all: $(BIN) $(BIN).1
$(BIN): $(OBJS) $(DEPENDS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(OBJS) $(LIBS)
+ $(CROSS_CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(OBJS) $(LIBS)
-$(MANGEN): $(MANGEN).o $(DEPENDS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+$(MANGEN): $(MANGEN).c $(DEPENDS)
+ $(HOST_CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
$(BIN).1: $(BIN) $(MANGEN) $(DEPENDS)
- ./$(MANGEN) > $@
+ ./$(MANGEN) > $@ || ( $(RM) $@; exit 1 )
libusb-sniff-32.so: libusb-sniff.c $(DEPENDS)
$(CC) $(CFLAGS) $(LDFLAGS) -fPIC -ldl -shared -m32 -o $@ $<
@@ -31,7 +35,7 @@ libusb-sniff-64.so: libusb-sniff.c $(DEPENDS)
$(CC) $(CFLAGS) $(LDFLAGS) -fPIC -ldl -shared -m64 -o $@ $<
%.o: %.c $(DEPENDS)
- $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+ $(CROSS_CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
install: $(BIN) $(BIN).1
$(INSTALL) -D -m 755 $(BIN) $(DESTDIR)$(PREFIX)/bin/$(BIN)
@@ -42,4 +46,4 @@ uninstall:
$(RM) $(DESTDIR)$(PREFIX)/share/man/man1/$(BIN).1
clean:
- -$(RM) $(OBJS) $(BIN) $(MANGEN) $(MANGEN).o $(BIN).1 libusb-sniff-32.so libusb-sniff-64.so
+ -$(RM) $(OBJS) $(BIN) $(MANGEN) $(BIN).1 libusb-sniff-32.so libusb-sniff-64.so