Alex Hixon avatar 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.

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"
+INSTALL=install
+DESTDIR=/usr
+bindir=/bin
+libdir=/lib
+
 .c.o:
-	$(CC) -g -Wall $(CFLAGS) $(INCS) -c $*.c $*.h
+	$(CC) -g -Wall -DHAVE_CONFIG_H $(CFLAGS) $(INCS) -c $*.c $*.h
 
 all: loader
 
 clean:
 	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
+
+uninstall:
+	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"
+
+#endif
 
 #include "loader.h"
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 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");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.