Showing posts with label make. Show all posts
Showing posts with label make. Show all posts

Tuesday, January 29, 2013

Creating a Kindle EBook Part 1


I was looking up how to create an ebook, now according to this website: How to Format Childrens Ebook it's a matter of creating a html file and including some image files, then zipping them all up and sending them to your kindle.

It's not quite that simple these days. When you send that zipped file out to your kindle, amazon splits it up and you get each item pushed to your device, so if you have 3 pictures, you have 3 pictures plus your html ebook.

The fix for that is to create a .mobi file, now there are some sites that do that, also the program Calibre works, but for now I decided to try using Amazon's solution. Kindlegen

I use ubuntu so I'll be giving the ubuntu version, if you want an example in the Windows version, then let me know, and I'll try to update for that!

Here goes.

I found this little trick out, create a file called kindlegen located at /usr/local/bin
enter in the following (I had to use sudo):

#!/bin/bash
exec /kindlegen "$@"
afterwords use the following command
:/>sudo chmod -x /usr/local/bin/kindlegen

Now whenever you want to convert an html file, simply call kindlegen . Ok we're done with that part.


Lets make a book.

First lets try the following

Based on the website I mentioned at the top they suggest naming things page_nn.jpg, etc, however as long as you keep track, it doesn't really matter the naming (it's for simplicities sake).

This particular book has 3 pages. Duplicate the following lines for each page, and you're set.

Save your file as test.html (or whatever you want, just substitute your filename below)

Next we'll actually create our Mobi File.

Navigate to the folder via commandline:
:/>kindlegen test.html

The resulting file will be called test.mobi

Next login to your amazon account check your account settings and scroll down to manage your kindle.

Click Manage Devices

Here you can find your email address to send your mobi file.

Next email your .mobi file to that email address.

When you see the file visible on the Personal Documents Section. Check your kindle and see if the file has arrived. If not, you can "resend" it using the Personal Documents Section.

Good luck!

Thursday, September 16, 2010

Kernel Modules

My ECE 437 class was assigned the monumental task of writing a filesystem driver for the linux kernel. I did a LOT of reading and finally started writing a few things, but realized I needed to be able to simply compile a kernel module just to see how to do it so I started following along with the kernel module how to here Kernel Module Tutorial

When I ran into the problem where when I called make, I would see the following error:
make[2]: *** No rule to make target `kernel/bounds.c', needed by `kernel/bounds.

I chased around the interwebs for a bit. I found out that it looks like $(PWD) wasn't returning the present directory, so I updated it to shell pwd per this site: Labjack Forums

Here is my makefile (note that in front of commands are TABS, if you replace them with spaces your makefile won't work, you've been warned)

#!/usr/bin/make -f

obj-m += hello_world.o

KERNELDIR=/lib/modules/$(shell uname -r)/build

all:
make -C $(KERNELDIR) M=$(shell pwd) modules

clean:
make -C $(KERNELDIR) M=$(shell pwd) clean




And finally here is my hello world (keep in mind it's pulled from the above tutorial)


/*  
 *  hello_world.c - The simplest kernel module.
 */
#include /* Needed by all modules */
#include /* Needed for KERN_INFO */

int init_module(void)
{
printk("<1>Hello world 1.\n");

/* 
* A non 0 return means init_module failed; module can't be loaded. 
*/
return 0;
}

void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}



Check it out. and give it a try. hopefully it works for you!

calling make all at the command line should compile it all,

and then a simple sudo insmod hello_world.ko

check out if your module was loaded via lsmod, look for it.

Now check your /var/log/messages file for your alert!

Finally do a sudo rmmod hello_world.ko to remove it from the kernel.

Thank you Caleb for the help various commands and the makefile!