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
48export WIND_HOME := C:/embedded/Workbench2.5.0.1
49export WIND_BASE := $(WIND_HOME)/vxworks-6.3
50export WIND_HOST_TYPE := x86-win32
51
52# BUILD_TYE:= <debug>|<release> (build with debugging info or optimized)
53BUILD_TYPE := debug
54USER_CFLAGS:=
55
56# directories where to seek for includes and libraries
57OPENSSL_INC := D:/libraries/openssl/openssl-0.9.8zc-vxWorks6.3/include
58OPENSSL_LIB := D:/libraries/openssl/openssl-0.9.8zc-vxWorks6.3
59ZLIB_INC    := D:/libraries/zlib/zlib-1.2.8-VxWorks6.3/zlib-1.2.8
60ZLIB_LIB    := D:/libraries/zlib/zlib-1.2.8-VxWorks6.3/binaries/vxworks_3.1_gnu/Debug/lib
61ARES_INC    :=
62ARES_LIB    :=
63
64
65# ----------------------------------------------------------------------
66# Compiler
67# ----------------------------------------------------------------------
68
69CC := ccppc
70AR := arppc
71LINK := ccppc
72CFLAGS := -D__GNUC__ -D__ppc__ -msoft-float -fno-builtin -mcpu=604 -mlongcall -DCPU=PPC604 -D_GNU_TOOL -Wall -W -Winline $(USER_CFLAGS)
73LDFLAGS := -nostdlib -Wl,-i -Wl,-X
74INCLUDE_FLAG := -I
75C_DEBUGFLAG := -g
76C_OPTFLAG := -O2
77COMPILE_ONLY_FLAG := -c
78OBJ_EXTENSION := .o
79CC_OBJ_OUTPUT = -o $@
80ARFLAGS := -rc
81LIBS_FLAG := -l
82LIBS_DIRFLAG:= -L
83LD_DEBUGFLAG := $(C_DEBUGFLAG)
84EXECUTE_EXTENSION := .out
85TOOL_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
93ifeq ($(BUILD_TYPE), debug)
94CFLAGS += $(C_DEBUGFLAG)
95LDFLAGS += $(LD_DEBUGFLAG)
96else
97CFLAGS += $(C_OPTFLAG)
98endif
99
100# ----------------------------------------------------------------------
101
102# Main Makefile and possible sub-make files
103MAKEFILES := 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#-----
110INCLUDE_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
113LIBS_LIST := .
114LIB_DIRS  := .
115ifneq ($(OPENSSL_LIB), )
116LIBS_LIST += crypto ssl
117LIB_DIRS  += $(OPENSSL_LIB)
118endif
119ifneq ($(ZLIB_LIB), )
120LIBS_LIST += z
121LIB_DIRS  += $(ZLIB_LIB)
122endif
123ifneq ($(ARES_LIB), )
124LIBS_LIST += ares
125LIB_DIRS  += $(ARES_LIB)
126endif
127
128# Add include and library directories and libraries
129CFLAGS += $(INCLUDE_DIRS:%=$(INCLUDE_FLAG)%)
130LDFLAGS += $(LIB_DIRS:%=$(LIBS_DIRFLAG)%)
131
132# List of targets to make for libs target
133LIBS_TARGET_LIST := libcurl.a
134
135# List of execuatble applications to make in addition to libs for all target
136EXE_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
141ifneq ($(strip $(findstring $(ECHORULES), yes YES 1 true TRUE)),)
142_@_ :=
143else
144_@_ := @
145endif
146
147# Directory to hold compilation intermediate files
148TMP_DIR := tmp
149
150# Get sources and headers to be compiled
151include Makefile.inc
152
153# List of headers
154INCLUDE_FILES := $(HHEADERS)
155INCLUDE_FILES += $(shell find ../include -name \*.h)
156
157# List of sources
158OBJLIST := $(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
166default: 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
188libs: $(LIBS_TARGET_LIST)
189	@echo All libs made.
190
191all: $(LIBS_TARGET_LIST) $(EXE_TARGET_LIST) $(INCLUDE_TARGET_LIST)
192	@echo All targets made.
193
194# Clean up
195.PHONY: clean
196clean:
197	$(_@_) rm -rf $(TMP_DIR)
198	@echo libcurl was cleaned.
199