Alex Hixon  committed f94a519

Added an 'install' target and config.h.

It should now be possible to build and install the firmware loader onto
the local system. You can override the installation path when running
make install.

There's still a bit of an issue with creating Debian packages; for some
reason, dh_make runs 'make install' but ends up forcing it to install in
/bin rather than /usr/bin.

Now that I think about it, we probably should be using /usr/sbin instead.

  • Participants
  • Parent commits f65c81a
  • Branches default

Comments (0)

Files changed (3)

+# For build target
 LIBS=`pkg-config --libs glib-2.0 libusb`
 INCS=`pkg-config --cflags glib-2.0 libusb`
+# For install target
+FIRMWARE="r5u87x-05ca-1803.fw" "r5u87x-05ca-1810.fw" "r5u87x-05ca-1812.fw" "r5u87x-05ca-1830.fw" "r5u87x-05ca-1832.fw" "r5u87x-05ca-1833.fw" "r5u87x-05ca-1834.fw" "r5u87x-05ca-1835.fw" "r5u87x-05ca-1836.fw" "r5u87x-05ca-1837.fw" "r5u87x-05ca-1839.fw" "r5u87x-05ca-183a.fw" "r5u87x-05ca-183b.fw" "r5u87x-05ca-183e.fw" "r5u87x-05ca-1841.fw" "r5u87x-05ca-1870_1.fw" "r5u87x-05ca-1870.fw"
-	$(CC) -g -Wall $(CFLAGS) $(INCS) -c $*.c $*.h
+	$(CC) -g -Wall -DHAVE_CONFIG_H $(CFLAGS) $(INCS) -c $*.c $*.h
 all: loader
 	rm -fr *.o loader
 	rm -fr *.gch loader
-	rm *~
+	#rm *~
+install:	all
+	./mkinstalldirs $(DESTDIR)$(bindir)
+	$(INSTALL) -m 0755 loader $(DESTDIR)$(bindir)/r5u87x-loader
+	./mkinstalldirs $(DESTDIR)$(libdir)/r5u87x/ucode
+	@for fw in $(FIRMWARE); do \
+	    echo "$(INSTALL) -m 0644 ucode/$$fw $(DESTDIR)$(libdir)/r5u87x/ucode/$$fw" ; \
+	    $(INSTALL) -m 0666 ucode/$$fw $(DESTDIR)$(libdir)/r5u87x/ucode/$$fw || exit 1 ; \
+    done
+	rm -fv $(DESTDIR)$(bindir)/r5u87x-loader
+	rm -rfv $(DESTDIR)$(libdir)/r5u87x
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+#define VERSION "0.1"
+#define PREFIX "/usr"
+#define UCODEDIR "/usr/lib/r5u87x"
 #include "loader.h"
+#include "config.h"
 static gchar    *firmware       = "ucode/r5u87x-%vid%-%pid%.fw";
 static gboolean force_clear     = FALSE;
 static gboolean no_load         = FALSE;
     // Open the firmware file
     if ((fd = g_open (firmware, O_RDONLY)) == -1) {
+        #ifdef UCODEDIR
+        firmware = g_build_filename (UCODEDIR, firmware, NULL);
+        //loader_msg ("Trying %s\n", firmware);
+        if ((fd = g_open (firmware, O_RDONLY)) == -1) {
+            loader_error ("Failed to open %s. Does it exist?\n", firmware);
+        }
+        #else
         loader_error ("Failed to open %s. Does it exist?\n", firmware);
+        #endif
     // Possibly not the best way to do this, but hey, it's certainly easy
         loader_error ("%s\n", error->message);
+    #ifdef VERSION
+    loader_msg ("r5u87x firmware loader v%s\n", VERSION);
+    #else
+    loader_msg ("r5u87x firmware loader (unknown version)\n");
+    #endif
     usb_init ();
     if (usb_find_busses () == 0) {
         loader_error ("Failed to find any USB busses.\n");