aboutsummaryrefslogtreecommitdiff
path: root/lib/Makefile.vxworks
blob: 288f24bc58c40124a82d92dc1f4fbd21197461f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#*****************************************************************************
#
# $Id$
#
#Filename   : Makefile.vxworks
#Description: makefile to be used in order to compile libcurl for VxWoorks 6.3.
#
#How to use:
#             1. Adjust environment variables at the file begining
#             2. Open the Command Prompt window and change directory ('cd')
#                into the 'lib' folder
#             3. Add <CYGWIN>/bin folder to the PATH environment variable
#                For example type 'set PATH=C:/embedded/cygwin/bin;%PATH%'
#             4. Build the library by typing 'make -f ./Makefile.vxworks'
#             As a result the libcurl.a should be created in the 'lib' folder.
#Requirements:
#             1. WinXP machine
#             2. Full CYGWIN installation (open source) with GNU make version
#                v3.78 or higher
#             3. WindRiver Workbench with vxWorks 6.3 (commercial)
#*****************************************************************************

# ----------------------------------------------------------------------
# Environment
# ----------------------------------------------------------------------

export WIND_HOME := C:/embedded/Workbench2.5.0.1
export WIND_BASE := $(WIND_HOME)/vxworks-6.3
export WIND_HOST_TYPE := x86-win32

# BUILD_TYE:= <debug>|<release> (build with debugging info or optimized)
BUILD_TYPE := debug
USER_CFLAGS:=

# directories where to seek for includes and libraries
OPENSSL_INC := D:/libraries/openssl/openssl-0.9.8a-vxWorks6.3/include
OPENSSL_LIB := D:/libraries/openssl/openssl-0.9.8a-vxWorks6.3
ZLIB_INC    := D:/libraries/zlib/zlib-1.2.3-VxWorks6.3/zlib-1.2.3
ZLIB_LIB    := D:/libraries/zlib/zlib-1.2.3-VxWorks6.3/binaries/vxworks_3.1_gnu/Debug/lib
ARES_INC    :=
ARES_LIB    :=


# ----------------------------------------------------------------------
# Compiler 
# ----------------------------------------------------------------------

CC := ccppc
AR := arppc
LINK := ccppc
CFLAGS := -D__GNUC__ -D__ppc__ -msoft-float -fno-builtin -mcpu=604 -mlongcall -DCPU=PPC604 -D_GNU_TOOL -Wall -W -Winline $(USER_CFLAGS)
LDFLAGS := -nostdlib -Wl,-i -Wl,-X 
INCLUDE_FLAG := -I
C_DEBUGFLAG := -g
C_OPTFLAG := -O2
COMPILE_ONLY_FLAG := -c
OBJ_EXTENSION := .o
CC_OBJ_OUTPUT = -o $@
ARFLAGS := -rc
LIBS_FLAG := -l
LIBS_DIRFLAG:= -L
LD_DEBUGFLAG := $(C_DEBUGFLAG)
EXECUTE_EXTENSION := .out
TOOL_CHAIN_BIN := $(WIND_HOME)/gnu/3.4.4-vxworks-6.3/$(WIND_HOST_TYPE)/bin/

# ----------------------------------------------------------------------

# Add -DINET6 if the OS kernel image was built with IPv6 support
# CFLAGS += -DINET6

# Set up compiler and linker flags for debug or optimization
ifeq ($(BUILD_TYPE), debug)
CFLAGS += $(C_DEBUGFLAG)
LDFLAGS += $(LD_DEBUGFLAG)
else
CFLAGS += $(C_OPTFLAG)
endif

# ----------------------------------------------------------------------

# Main Makefile and possible sub-make files
MAKEFILES := Makefile.vxworks

# List of external include directories
#-----
# IMPORTANT: include OPENSSL directories before system
#            in order to prevent WindRiver OpenSSL to be used.
#-----
INCLUDE_DIRS := ../include $(OPENSSL_INC) $(ZLIB_INC) $(ARES_INC) $(WIND_BASE)/target/h $(WIND_BASE)/target/h/wrn/coreip

# List of external libraries and their directories
LIBS_LIST := .
LIB_DIRS  := .
ifneq ($(OPENSSL_LIB), )
LIBS_LIST += crypto ssl
LIB_DIRS  += $(OPENSSL_LIB)
endif
ifneq ($(ZLIB_LIB), )
LIBS_LIST += z
LIB_DIRS  += $(ZLIB_LIB)
endif
ifneq ($(ARES_LIB), )
LIBS_LIST += ares
LIB_DIRS  += $(ARES_LIB)
endif

# Add include and library directories and libraries
CFLAGS += $(INCLUDE_DIRS:%=$(INCLUDE_FLAG)%)
LDFLAGS += $(LIB_DIRS:%=$(LIBS_DIRFLAG)%)

# List of targets to make for libs target
LIBS_TARGET_LIST := libcurl.a

# List of execuatble applications to make in addition to libs for all target
EXE_TARGET_LIST :=

# Support for echoing rules
# If ECHORULES variable was set (for example, using 'make' command line)
#  some shell commands in the rules will be echoed
ifneq ($(strip $(findstring $(ECHORULES), yes YES 1 true TRUE)),)
_@_ :=
else
_@_ := @
endif

# Directory to hold compilation intermediate files
TMP_DIR := tmp

# List of headers
INCLUDE_FILES := $(shell find . -name \*.h)
INCLUDE_FILES += $(shell find ../include -name \*.h)

# List of sources
SOURCE  := $(shell find . -name \*.c)
OBJLIST := $(SOURCE:%.c=$(TMP_DIR)/%$(OBJ_EXTENSION))


# ----------------------------------------------------------------------

#### default rule
# It should be first rule in this file
.PHONY: default
default: libcurl.a

#### Compiling C files
$(TMP_DIR)/%$(OBJ_EXTENSION): %.c $(MAKEFILES)
	@echo Compiling C file $< $(ECHO_STDOUT)
	@[ -d $(@D) ] || mkdir -p $(@D)
	$(_@_) $(TOOL_CHAIN_BIN)$(CC) $(COMPILE_ONLY_FLAG) $(CFLAGS) $< $(CC_OBJ_OUTPUT)

#### Creating library
$(LIBS_TARGET_LIST): $(INCLUDE_FILES) $(MAKEFILES) $(OBJLIST)
	@echo Creating library $@ $(ECHO_STDOUT)
	$(_@_) [ -d $(@D) ] || mkdir -p $(@D)
	$(_@_) rm -f $@
	$(_@_) $(TOOL_CHAIN_BIN)$(AR) $(ARFLAGS) $@ $(filter %$(OBJ_EXTENSION), $^)

#### Creating application
$(EXE_TARGET_LIST): $(INCLUDE_FILES) $(MAKEFILES) $(LIBS_TARGET_LIST)
	@echo Creating application $@
	@[ -d $(@D) ] || mkdir -p $(@D)
	$(_@_) $(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)

#### Master Targets
libs: $(LIBS_TARGET_LIST)
	@echo All libs made.

all: $(LIBS_TARGET_LIST) $(EXE_TARGET_LIST) $(INCLUDE_TARGET_LIST)
	@echo All targets made.

# Clean up
.PHONY: clean
clean:
	$(_@_) rm -rf $(TMP_DIR)
	@echo libcurl was cleaned.