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