Sunday, October 27, 2013

Cross platform Makefile

I needed to change my Makefile to output different target information based on the Operating System. This turned out more difficult than I thought since Windows doesn't have uname. I asked some friends, and the gave me some code snippets. To start with find the OSCLASS and OSNAME.
ifeq ($(OS),Windows_NT)
    OSCLASS = windows
    OSNAME=windows
else
    OSCLASS = unix
    UNAME_S := $(shell uname -s)
    ifeq ($(UNAME_S),Linux)
     OSNAME = linux
    endif
    ifeq ($(UNAME_S),Darwin)
        OSNAME = osx
    endif
endif
You can then do switches based upon the compiling OS. The biggest one was that I needed to output to a file. The problem with files that would write to both windows and unix is that the shell commands are different, so I need to address the differences in commands.
ifeq ($(OSCLASS),unix)
    FIXDIR = $1
    COMMANDCAT = cat
else
    FIXDIR = $(subst /,\,$1)
    COMMANDCAT = type
endif
Windows uses "type", whereas unix uses "cat". I then also fix the \ issue to go from the the unix / to the windows \ with the FIXDIR command. When I type "make test", the following will output the contents of info/chunk2.txt and append it to installer/test.inf.
test:
  $(COMMANDCAT) $(call FIXDIR,info/chunk2.txt >> installer/test.inf)
In unix, you will get: cat info/chunk2.txt >> installer/test.inf
In Windows, you get: type info\chunk2.txt >> installer\test.inf

Tuesday, October 15, 2013

Referencing datasheets in BIBTEX.

The CD4007 inverter pair is referenced as far back as papers from the early 1970's.  It's a great IC for teaching, but I really had to think of how to reference it using bibtex. I decided to go with the MISC tag.

@misc{CD4007,
    author={Texas Instruments},
    title={CD4007UB},
    url={http://www.ti.com/lit/ds/symlink/cd4007ub.pdf},
    note={original document from Harris Semiconductor},
    publisher={Texas Instruments},
    year={2012}
}

UPDATE:
Of course, once I decide on a method, I come up with a better method. Include:
\usepackage{url}
in your TEX document, and then you can have a prettier entry.
@misc{CD4007,
  author={Texas Instruments},
  title={CD4007UB},
  howpublished = "\url{http://www.ti.com/lit/ds/symlink/cd4007ub.pdf}",
  note={original document from Harris Semiconductor},
  publisher={Texas Instruments},
  year={2012}
}