This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

lwIP in a makefile


Hi, maybe these question sounds stupid to you,
but i am a newbie in ecos!
When i install the lwIP into my project and it is displayed on ecos_lib/ecos_build and ecos_lib/ecos_install
do i have to mention it again on my makefile???
I must port the lwIP into an existing project!
If i include the <lwip/api.h> and <lwIP/sys.h>
i got always undefined references to ntohl,
i am now sure that the solution must be in that makefile, has anybody a clue or a kick to help me??
i am not familar yet in writing them studying www.gnu.org/manual


# *********** project-structure ***************
# |
# |- src	- complete .c \ sourcecode
# |- bin	- absolute Objects (.out) and binary files (.bin .s)
# |- obj	- Objects (compiled and assembled source files)
# |Makefile	- this makefile



# ********************************************************************
# **						ECOS-LIBARY								**
# ********************************************************************
				INSTALL_DIR= ecos_lib/ecos_install

# ********************************************************************
# **						INCLUDE MAKEFILES						**
# ********************************************************************

include $(INSTALL_DIR)/include/pkgconf/ecos.mak


# ******************************************************************** # ** Name of binary and absolute objects ** # ** ** # ** you can specify the name of the ** # ** absolute object and binary files ** # ********************************************************************

TARGET := lwip.out


# ******************************************************************** # ** auto flash absolute object to device ** # ** ** # ** you can specify the type of object transferred ** # ** to the device (sirfflashcl has to be located ** # ** in path FLASH_TOOL) ** # ********************************************************************

				FLASH_PORT := 1
				FLASH_TOOL := /dos_d/dev/sirf-prog/sirfflashcl


# ******************************************************************** # ** compiler option settings ** # ******************************************************************** # Compiler:

	CC	:= $(ECOS_COMMAND_PREFIX)gcc
	CPP	:= $(ECOS_COMMAND_PREFIX)g++
	S	:= $(ECOS_COMMAND_PREFIX)gcc
	DUMP := $(ECOS_COMMAND_PREFIX)objdump
	COPY := $(ECOS_COMMAND_PREFIX)objcopy
	LINKER:= $(CC)

# Flags:

# defines
DEFINES := -DDEBUG -D__ECOS__ -DNAV_ONLY_ECOS -DARM -DHW_TRACK -DUSE_GSP2_ROM_FP


	#global flags
		GLOBALFLAGS := -Wall -I. -I./src -I$(INSTALL_DIR)/include \

OPTIMIZE := -g -Os -fomit-frame-pointer

	#C
		CFLAGS 		:= $(GLOBALFLAGS) $(DEFINES)

	#C++
		CPPFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions

	#S
		SFLAGS 	:=

#LINKER
LINKERFLAGS := -nostartfiles -L $(INSTALL_DIR)/lib -Ttarget.ld $(ECOS_GLOBAL_LDFLAGS)
LINKERFLAGS += -Wl,--allow-multiple-definition


# YOU SHOULDN'T HAVE TO CHANGE ANYTHING BELOW THIS LINE

# **** project specific directories ****
#.c \ sourcecode
SRC_DIR= src
# object files (assembled S/c/cpp files, which are linked)
OBJ_DIR= obj
# libary files ( *.* files, which need to be included)
# (files are assembled/compiled into objects or if already objects, included to the Linker
LIB_DIR= lib
# binary files and absolute objects (.bin .s .out - linked objects)
BIN_DIR= bin
# lwip tcpip stack


# **** project specific variables ****

	# all sourcefiles (+ relative src-path)
	SRCS := $(filter %.c %.cxx %.cpp %.S,$(wildcard $(SRC_DIR)/*))

	# all objects made from sourcefiles(+ relative src-path)
	SRC_OBJS := $(patsubst %,%.o,$(notdir $(basename $(SRCS))))

#LIBARY variables
	# objects and libaries which are already in lib
	ORG_LIB_OBJS := $(wildcard $(LIB_DIR)/*.o) $(wildcard $(LIB_DIR)/*.a)

	# objects which will be created from S/c/cpp files in lib
	LIB_SRCS := $(filter %.c \ %.c \xx %.c \pp %.S,$(wildcard $(LIB_DIR)/*))

	LIB_OBJS := $(patsubst %,%.o,$(basename $(LIB_SRCS)))
	LIB_OBJS := $(filter-out $(LIB_OBJS), $(ORG_LIB_OBJS)) $(LIB_OBJS)
	LIB_HEADERS := $(addprefix -I ,$(wildcard $(LIB_DIR)/*.h))

	# all header files for libary objects
	LIBARY_HEADERS := $(LIB_HEADERS) $(DEV_LIB_HEADERS)

	# all needed commands (depencies if one file has changed)
	MAKE_CMD := $(SRC_OBJS) $(LIB_OBJS)

	# search directories for object files
	VPATH =	$(SRC_DIR):$(LIB_DIR):$(OBJ_DIR)

.PHONY : all clean install rebuild showfiles

# .SILENT :

# **** make options ****
all:	showfiles $(TARGET)
	@echo ""
	@echo "------------------------------------------"
	@echo "ALL       : Build completed"

clean:
	@echo "CLEAN     : Cleaning generated obj & bin"
	@echo "            delete obj\*.o *.out, *.bin, *.s"
	@rm -f $(OBJ_DIR)/*.o
#	@rm -f $(LIB_DIR)/*.o
	@rm -f $(BIN_DIR)/*.bin $(BIN_DIR)/*.out $(BIN_DIR)/*.lst $(BIN_DIR)/*.s
	@echo ""

rebuild: clean depend all

install: $(TARGET)
@echo ""
@echo "------------------------------------------"
@echo "INSTALL : Flashing $(basename $(TARGET)).bin to device on COM$(FLASH_PORT)"
@$(FLASH_TOOL) $(BIN_DIR)/$(basename $(TARGET)).s -l $(FLASH_PORT)


depend:
	@echo ""
	@echo "------------------------------------------"
	@echo "DEPEND    : Make dependencies from $(SRCS)"
	$(CC) -MM $(CFLAGS) $(SRCS) $(LIB_SRCS) > .depend

showfiles:
	@echo ""
	@echo "------------------------------------------"
	@echo "ALL       : creating objects (compiled & assembled sources)"

# **** implementation ****

$(TARGET): $(MAKE_CMD)
@echo ""
@echo "LINKER : linking files to an absolute object $(TARGET)"
@echo " src : $(SRC_OBJS)"
@echo " lib : $(LIB_OBJS)"
@echo ""
$(LINKER) $(LINKERFLAGS) $(LIBARY_HEADERS) $(addprefix $(OBJ_DIR)/,$(SRC_OBJS)) $(LIB_OBJS) -o $(BIN_DIR)/$(TARGET)
$(DUMP) -tC $(BIN_DIR)/$(TARGET) | grep "\.text\|\.data\|\.rodata\|\.bss" | sort > $(BIN_DIR)/$(basename $(TARGET)).lst
@echo ""
@echo "OBJCOPY : transforming absolute object to S-Record/Binary "
@echo " $(TARGET) ==> $(basename $(TARGET)).bin"
$(COPY) -O binary $(BIN_DIR)/$(TARGET) $(BIN_DIR)/$(basename $(TARGET)).bin
@echo " $(TARGET) ==> $(basename $(TARGET)).s"
$(COPY) -O srec --adjust-vma=0xC0000000 $(BIN_DIR)/$(TARGET) $(BIN_DIR)/$(basename $(TARGET)).s


# OBJECTS

# compiling objects (.c sources into .o) - called by srcname.o

%.o: %.c
	@echo "   $(notdir $@):     $< ==> obj/$(notdir $@)"
	$(CC) $(CFLAGS) $(OPTIMIZE) -c -o $(OBJ_DIR)/$(notdir $@) $<

%.o: %.cxx
	@echo "   $(notdir $@):     $< ==> obj/$(notdir $@)"
	$(CPP) $(CPPFLAGS) $(OPTIMIZE) -c -o $(OBJ_DIR)/$(notdir $@) $<

%.o: %.cpp
	@echo "   $(notdir $@):     $< ==> obj/$(notdir $@)"
	$(CPP) $(CPPFLAGS) $(OPTIMIZE) -c -o $(OBJ_DIR)/$(notdir $@) $<

%.o: %.S
	@echo "   $(notdir $@):     $< ==> obj/$(notdir $@)"
	$(S) $(CFLAGS) $(OPTIMIZE) -c -o $(OBJ_DIR)/$(notdir $@) $<

# **** include dependency files if they exist ****
-include .depend



--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]