Home | History | Annotate | Download | only in lib
      1 #*****************************************************************************
      2 #
      3 #
      4 #Filename   : Makefile.vxworks
      5 #Description: makefile to be used in order to compile libcurl for VxWoorks 6.3.
      6 #
      7 #How to use:
      8 #             1. Adjust environment variables at the file beginning
      9 #             2. Open the Command Prompt window and change directory ('cd')
     10 #                into the 'lib' folder
     11 #             3. Add <CYGWIN>/bin folder to the PATH environment variable
     12 #                For example type 'set PATH=C:/embedded/cygwin/bin;%PATH%'
     13 #             4. Build the library by typing 'make -f ./Makefile.vxworks'
     14 #             As a result the libcurl.a should be created in the 'lib' folder.
     15 #             To clean package use 'make -f ./Makefile.vxworks clean'
     16 #Requirements:
     17 #             1. WinXP machine
     18 #             2. Full CYGWIN installation (open source) with GNU make version
     19 #                v3.78 or higher
     20 #             3. WindRiver Workbench with vxWorks 6.3 (commercial)
     21 #*****************************************************************************
     22 
     23 # ----------------------------------------------------------------------
     24 # Environment
     25 # ----------------------------------------------------------------------
     26 
     27 export WIND_HOME := C:/embedded/Workbench2.5.0.1
     28 export WIND_BASE := $(WIND_HOME)/vxworks-6.3
     29 export WIND_HOST_TYPE := x86-win32
     30 
     31 # BUILD_TYE:= <debug>|<release> (build with debugging info or optimized)
     32 BUILD_TYPE := debug
     33 USER_CFLAGS:=
     34 
     35 # directories where to seek for includes and libraries
     36 OPENSSL_INC := D:/libraries/openssl/openssl-0.9.8zc-vxWorks6.3/include
     37 OPENSSL_LIB := D:/libraries/openssl/openssl-0.9.8zc-vxWorks6.3
     38 ZLIB_INC    := D:/libraries/zlib/zlib-1.2.8-VxWorks6.3/zlib-1.2.8
     39 ZLIB_LIB    := D:/libraries/zlib/zlib-1.2.8-VxWorks6.3/binaries/vxworks_3.1_gnu/Debug/lib
     40 ARES_INC    :=
     41 ARES_LIB    :=
     42 
     43 
     44 # ----------------------------------------------------------------------
     45 # Compiler
     46 # ----------------------------------------------------------------------
     47 
     48 CC := ccppc
     49 AR := arppc
     50 LINK := ccppc
     51 CFLAGS := -D__GNUC__ -D__ppc__ -msoft-float -fno-builtin -mcpu=604 -mlongcall -DCPU=PPC604 -D_GNU_TOOL -Wall -W -Winline $(USER_CFLAGS)
     52 LDFLAGS := -nostdlib -Wl,-i -Wl,-X
     53 INCLUDE_FLAG := -I
     54 C_DEBUGFLAG := -g
     55 C_OPTFLAG := -O2
     56 COMPILE_ONLY_FLAG := -c
     57 OBJ_EXTENSION := .o
     58 CC_OBJ_OUTPUT = -o $@
     59 ARFLAGS := -rc
     60 LIBS_FLAG := -l
     61 LIBS_DIRFLAG:= -L
     62 LD_DEBUGFLAG := $(C_DEBUGFLAG)
     63 EXECUTE_EXTENSION := .out
     64 TOOL_CHAIN_BIN := $(WIND_HOME)/gnu/3.4.4-vxworks-6.3/$(WIND_HOST_TYPE)/bin/
     65 
     66 # ----------------------------------------------------------------------
     67 
     68 # Add -DINET6 if the OS kernel image was built with IPv6 support
     69 # CFLAGS += -DINET6
     70 
     71 # Set up compiler and linker flags for debug or optimization
     72 ifeq ($(BUILD_TYPE), debug)
     73 CFLAGS += $(C_DEBUGFLAG)
     74 LDFLAGS += $(LD_DEBUGFLAG)
     75 else
     76 CFLAGS += $(C_OPTFLAG)
     77 endif
     78 
     79 # ----------------------------------------------------------------------
     80 
     81 # Main Makefile and possible sub-make files
     82 MAKEFILES := Makefile.vxworks
     83 
     84 # List of external include directories
     85 #-----
     86 # IMPORTANT: include OPENSSL directories before system
     87 #            in order to prevent WindRiver OpenSSL to be used.
     88 #-----
     89 INCLUDE_DIRS := ../include $(OPENSSL_INC) $(ZLIB_INC) $(ARES_INC) $(WIND_BASE)/target/h $(WIND_BASE)/target/h/wrn/coreip
     90 
     91 # List of external libraries and their directories
     92 LIBS_LIST := .
     93 LIB_DIRS  := .
     94 ifneq ($(OPENSSL_LIB), )
     95 LIBS_LIST += crypto ssl
     96 LIB_DIRS  += $(OPENSSL_LIB)
     97 endif
     98 ifneq ($(ZLIB_LIB), )
     99 LIBS_LIST += z
    100 LIB_DIRS  += $(ZLIB_LIB)
    101 endif
    102 ifneq ($(ARES_LIB), )
    103 LIBS_LIST += ares
    104 LIB_DIRS  += $(ARES_LIB)
    105 endif
    106 
    107 # Add include and library directories and libraries
    108 CFLAGS += $(INCLUDE_DIRS:%=$(INCLUDE_FLAG)%)
    109 LDFLAGS += $(LIB_DIRS:%=$(LIBS_DIRFLAG)%)
    110 
    111 # List of targets to make for libs target
    112 LIBS_TARGET_LIST := libcurl.a
    113 
    114 # List of execuatble applications to make in addition to libs for all target
    115 EXE_TARGET_LIST :=
    116 
    117 # Support for echoing rules
    118 # If ECHORULES variable was set (for example, using 'make' command line)
    119 #  some shell commands in the rules will be echoed
    120 ifneq ($(strip $(findstring $(ECHORULES), yes YES 1 true TRUE)),)
    121 _@_ :=
    122 else
    123 _@_ := @
    124 endif
    125 
    126 # Directory to hold compilation intermediate files
    127 TMP_DIR := tmp
    128 
    129 # Get sources and headers to be compiled
    130 include Makefile.inc
    131 
    132 # List of headers
    133 INCLUDE_FILES := $(HHEADERS)
    134 INCLUDE_FILES += $(shell find ../include -name \*.h)
    135 
    136 # List of sources
    137 OBJLIST := $(CSOURCES:%.c=$(TMP_DIR)/%$(OBJ_EXTENSION))
    138 
    139 
    140 # ----------------------------------------------------------------------
    141 
    142 #### default rule
    143 # It should be first rule in this file
    144 .PHONY: default
    145 default: libcurl.a
    146 
    147 #### Compiling C files
    148 $(TMP_DIR)/%$(OBJ_EXTENSION): %.c $(MAKEFILES)
    149 	@echo Compiling C file $< $(ECHO_STDOUT)
    150 	@[ -d $(@D) ] || mkdir -p $(@D)
    151 	$(_@_) $(TOOL_CHAIN_BIN)$(CC) $(COMPILE_ONLY_FLAG) $(CFLAGS) $< $(CC_OBJ_OUTPUT)
    152 
    153 #### Creating library
    154 $(LIBS_TARGET_LIST): $(INCLUDE_FILES) $(MAKEFILES) $(OBJLIST)
    155 	@echo Creating library $@ $(ECHO_STDOUT)
    156 	$(_@_) [ -d $(@D) ] || mkdir -p $(@D)
    157 	$(_@_) rm -f $@
    158 	$(_@_) $(TOOL_CHAIN_BIN)$(AR) $(ARFLAGS) $@ $(filter %$(OBJ_EXTENSION), $^)
    159 
    160 #### Creating application
    161 $(EXE_TARGET_LIST): $(INCLUDE_FILES) $(MAKEFILES) $(LIBS_TARGET_LIST)
    162 	@echo Creating application $@
    163 	@[ -d $(@D) ] || mkdir -p $(@D)
    164 	$(_@_) $(TOOL_CHAIN_BIN)$(LINK) $(CC_OBJ_OUTPUT) $($(@)_EXE_OBJ_LIST) $(LDFLAGS) $($(@)_EXE_LIBS_NEEDED:%=$(LIBS_FLAG)%) $(LIBS_LIST:%=$(LIBS_FLAG)%) $(USER_LIBS_LIST) $(USER_LIBS_LIST)
    165 
    166 #### Master Targets
    167 libs: $(LIBS_TARGET_LIST)
    168 	@echo All libs made.
    169 
    170 all: $(LIBS_TARGET_LIST) $(EXE_TARGET_LIST) $(INCLUDE_TARGET_LIST)
    171 	@echo All targets made.
    172 
    173 # Clean up
    174 .PHONY: clean
    175 clean:
    176 	$(_@_) rm -rf $(TMP_DIR)
    177 	@echo libcurl was cleaned.
    178