December2009
Makefile breaks when making targets of another Makefile
In GNU’s Make manual, there’s a description of how to use one Makefile to call targets of another Makefile. You have to use $(MAKE) in order for it to work properly. I’ve found one little snag that’s not mentioned. If my target name is the same as the directory name where the other Makefile is, it will never work. It always says it’s up to date! If I change the target name, it works fine.
Build script to utilize Makefiles to build multiple applications
You have a bunch of related applications, each has their own Makefile that knows only about their own application, but you have dependencies where one app needs to be built before another. Here’s a skeleton bash script for building any one thing or everything.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#!/bin/bash function build { echo "*** BUILDING APP: $1 ***" cd $1/src if [ $? != 0 ]; then fail $1 else make if [ $? != 0 ]; then make install if [ $? != 0 ]; then fail $1 fi fi fi cd - } function fail { echo "*** ERROR: Failed while attempting to build $1 ***" echo "Exiting..." exit 1 } function usage { echo "Usage: $0 [APPNAME]" echo "Builds apps. Handles dependencies automagically." } case $1 in "app_name_1") build app_dir_1 ;; "app_name_2") build app_dir_1 build app_dir_2 ;; "app_name_3") build app_dir_1 build app_dir_3 ;; "all") build app_dir_1 build app_dir_2 build app_dir_3 ;; *) usage exit 2 ;; esac exit 0 |
This makes it very easy to add dependencies and new applications to the chain. All you have to do is add a section to the case statement for a new app, and call build for each of its dependencies.
You can also do this with a Makefile that just has targets. Each target would call the individual Makefile’s targets. If you only need to do the simple make && make install for each app, then a Makefile would be shorter and simpler. But I like the flexibility this script affords if you need to add funky code later, such as processing other code that doesn’t have an associated Makefile or moving source around to different directories.
Handle command line arguments with getopt in Python
Here’s a way to use getopt to handle arguments when creating command line applications. It works quite well with the standard help (–help or -h) by showing usage when bad arguments are passed.
Hidden Title Challenges in Call of Duty Modern Warfare 2
I normally use the guided missile or Counter UAV with the Harrier and either the Pavelow or Chopper Gunner, but I decided to mix it up one match and selected Harrier, Emergency Airdrop, and Pavelow. The kills needed for these three are 6, 7, and 8. When I got all three in a row, I got a new title. I say challenges because I think it’s a challenge to complete the tasks in order to get all the titles and emblems. And they’re hidden because there’s no instructions on how to unlock all the titles and emblems!
Hardware Device Management in Linux using udev
Udev creates and removes device nodes in /dev, based on events the kernel sends out on device discovery or removal. In other words, Udev is the system that maps hardware devices to files you can interact with in the /dev directory. Udev runs in user space and creates points in /dev when the kernel detects and recognizes new hardware as it’s attached. It’s only been around since 2003/2004. All modern distributions use udev instead of the now depreciated hotplug.
How to disable enemy text chat in Modern Warfare 2
The only useful text chat is the friendly team chat. The public chat that defaults to the ‘t’ button is useless. The only thing you’ll see there is whining, complaining, and other types of spam. I found it not only useless and annoying, but distracting sometimes. 1/20th of all text is team chat, so it’s much less intrusive. Everything in the configuration file I describe below is user interface stuff. There’s no hacks or cheats available here.
Store and access passwords safely with python’s keyring
Python’s keyring lib supports Windows win32crypto, Mac OS X’s SXKeychain, KDE’s KWallet, Gnome’s keyring, and encrypted or unencrypted password files. When your application wants to store or fetch data from the keyring, it will just work.