一个简单的Makefile

CC=gcc
TARGET=test
SRC=$(wildcard *.c)

OBJECT= ${SRC:.c=.o}
INCLUDES=-I/usr/include/alsa
LDFLAGS=-lasound

all:$(TARGET)

$(OBJECT):$(SRC)
$(CC) -c $(INCLUDES) $<

$(TARGET):$(OBJECT)
$(CC) -o $@ $< $(LDFLAGS)

.PHONY:clean

clean:

@rm -rf $(OBJECT) $(TARGET) *~

######################################################

CROSS_COMPILER=/opt/eldk/usr/bin/ppc_4xxFP-
CC=${CROSS_COMPILER}gcc
#CC=ppc-linux-gcc
TARGET=TEST
SRC=$(wildcard *.c)


OBJECT= ${SRC:.c=.o}


ALSALIBDIR=/opt/alsa2/lib/
ALSAINCDIR=/opt/alsa2/include/






EXTRA_CFLAGS=-I. -I$(ALSAINCDIR)
EXTRA_LFLAGS= -L$(ALSALIBDIR) -lasound
LDFLAGS= $(EXTRA_LFLAGS) -lpthread -rpath-link /opt/eldk/ppc_4xxFP/lib/libm.so.6
LDFLAGS+=  -rpath-link /opt/eldk/ppc_4xxFP/lib/libdl.so.2   


all:$(TARGET)


$(OBJECT):$(SRC)
    $(CC) -c $(EXTRA_CFLAGS) $<


$(TARGET):$(OBJECT)
    $(CC) -o $@ $< $(LDFLAGS)


.PHONY:clean


clean:
    @rm -rf $(OBJECT) $(TARGET) *~


你可能感兴趣的:(一个简单的Makefile)