Jump to content

Makefiles


Recommended Posts

I'm doing a programming project on eCos for Uni, which means using Makefiles. So far I've okay as I've been editing one of the example files, but I can't work out how to add a file to the list of things I want to compile. The files I want to add are:

fourierd.c

ddc.c

ddcmaths.h

fftmisc.c

 

The file with my code is called twothreads.c, and use make twothreads to compile it. The Makefile file looks like this:

 

# Mostly written by Jonathan Larmour, Red Hat, Inc.

# This file is in the public domain and may be used for any purpose

 

# PKG_INSTALL_DIR might need to be edited. Right now it is set

# assuming that a user ran pkgconf.tcl in //c/ecos-work on Windows NT,

# or used the Configuration Tool with C:\ecos-work as a build-tree.

#

# You can also override it on the make command-line, e.g.:

# make PKG_INSTALL_DIR=/myecc/install

# or you can set it in your environment

 

PKG_INSTALL_DIR = /home/genuser/ecos-work/install

 

# You must also set XCC to the name of your cross-compiler, including any

# options it needs.

 

# Uncomment one of the below, or invoke make with the name of the compiler

# you want, e.g.:

# make XCC="sparclite-elf-gcc -mcpu=sparclite -msoft-float"

# You can also set XCC in your environment

 

XCC = arm-elf-gcc -mcpu=arm7di # AEB

 

###### VARIABLES

# Any of these can be overriden on the command-line or in your environment

 

ifeq ($(XCC),sh-elf-gcc)

CFLAGS = -ggdb

else

CFLAGS = -g

endif

 

CXXFLAGS = $(CFLAGS)

 

EXTRACFLAGS = -Wall -I$(PKG_INSTALL_DIR)/include -ffunction-sections -fdata-sections

 

EXTRACXXFLAGS = $(EXTRACFLAGS) -fno-exceptions -fno-rtti -fvtable-gc -finit-priority

 

LDFLAGS = -nostartfiles -L$(PKG_INSTALL_DIR)/lib -Wl,--gc-sections

LIBS = -Ttarget.ld -nostdlib

 

LD = $(XCC)

XCXX = $(XCC)

 

###### RULES

 

.PHONY: all clean CCCHECK

 

all: hello twothreads simple-alarm serial

 

clean:

-rm -f twothreads twothreads.o

-rm -f serial serial.o

-rm -f instrument-test instrument-test.o

 

CCCHECK:

ifeq ($(XCC),)

@echo You must set XCC to the name of your cross-compiler

@false

endif

 

 

%.o: %.c

$(XCC) -c -o $*.o $(CFLAGS) $(EXTRACFLAGS) $<

 

%.o: %.cxx

$(XCXX) -c -o $*.o $(CXXFLAGS) $(EXTRACXXFLAGS) $<

 

%.o: %.C

$(XCXX) -c -o $*.o $(CXXFLAGS) $(EXTRACXXFLAGS) $<

 

%.o: %.cc

$(XCXX) -c -o $*.o $(CXXFLAGS) $(EXTRACXXFLAGS) $<

 

 

twothreads: CCCHECK twothreads.o

$(LD) $(LDFLAGS) -o $@ $@.o $(LIBS)

 

serial: CCCHECK serial.o

$(LD) $(LDFLAGS) -o $@ $@.o $(LIBS)

 

instrument-test: CCCHECK instrument-test.o

$(LD) $(LDFLAGS) -o $@ $@.o $(LIBS)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...