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