Search code examples
macosgcclibusb

Condense gcc statement


I'm using OS X Mavericks (10.9). Is there a way to condense my gcc command a bit, so I don't have to type the following verbose version of a command just to compile?

gcc -L /usr/local/Cellar/libusb/1.0.9/lib -I /usr/local/include -o xout usbtest.c -l usb-1.0

Solution

  • Take devnull's advice and write a Makefile, then all you'll have to do is type:

    make
    

    Here is a quick hint at the sort of thing you'll need:

    INCLUDES=/usr/local/include
    LDIRS=/usr/local/Cellar/libusb/1.0.9/lib
    LIBS=usb-1.0
    CC=gcc
    
    all: xout
    
    xout: usbtest.c
        $(CC) -L $(LDIRS) -I $(INCLUDES) -o xout usbtest.c -l $(LIBS)