diff --git a/Makefile b/Makefile index 8984f4b..f0d0aff 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ -CC=gcc -CFLAGS=-fPIC -CFLAGS_SHARED=-shared +CC?=gcc +CFLAGS?=-fPIC +CFLAGS_SHARED?=-shared OBJ=mma8451.o LIBNAME=libmma8451.so +HEADER=mma8451.h TESTOBJ=mma8451-test.o TESTNAME=mma8451-test @@ -11,8 +12,10 @@ all: compile compile: $(LIBNAME) $(TESTNAME) install: $(LIBNAME) - cp $(LIBNAME) /usr/lib/$(LIBNAME) - cp $(TESTNAME) /usr/bin/$(TESTNAME) + install -d 0755 ${DESTDIR}/usr/lib $(DESTDIR)/usr/bin $(DESTDIR)/usr/include/mma8451 + install -m 0644 $(LIBNAME) $(DESTDIR)/usr/lib/$(LIBNAME) + install -m 0644 $(TESTNAME) $(DESTDIR)/usr/bin/$(TESTNAME) + install -m 0644 $(HEADER) $(DESTDIR)/usr/include/mma8451/$(HEADER) fix-i2c: echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined @@ -24,7 +27,7 @@ clean: $(CC) -c -o $@ $< $(CFLAGS) $(LIBNAME): $(OBJ) - gcc -o $@ $^ $(CFLAGS) $(CFLAGS_SHARED) + $(CC) -o $@ $^ $(CFLAGS) $(CFLAGS_SHARED) $(TESTNAME): $(LIBNAME) $(TESTOBJ) - gcc -o $@ $^ $(CFLAGS) -L. -lmma8451 \ No newline at end of file + $(CC) -o $@ $^ $(CFLAGS) -L. -lmma8451