Skip to content

Commit

Permalink
Merge branch 'arch_19046/add_windows_support_to_http_client_build_pr'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins CI committed Mar 23, 2021
2 parents eaa0ed1 + c6069c0 commit 979523b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
38 changes: 31 additions & 7 deletions agent/sources/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CFLAGS ?= -std=c99 -Wall -Wextra -Wpedantic \
-Wredundant-decls -Wnested-externs -Wmissing-include-dirs \
-D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE
BUILD_CFLAGS=$(CFLAGS)
LDFLAGS ?= -Wl,-z,now -Wl,-z,relro -pie
LDFLAGS ?= -Wl,-z,now -Wl,-z,relro -pie -fstack-protector-strong
BUILD_LDFLAGS=$(LDFLAGS)
# Debug flags
CFLAGS_DEBUG := -O -g3 -DDEBUG -fsanitize=address,undefined
Expand All @@ -42,15 +42,28 @@ endif
CFLAGS_RELEASE := -O2
BUILD_LDFLAGS += -lcurl -lm

BUILD_DEP:=

# to use static tomlc use: make STATIC_TOML=1
# in this case you need to put its sources in ./tomlc99/
ifdef STATIC_TOML
BUILD_CFLAGS += -I./tomlc99
BUILD_LDFLAGS += ./tomlc99/libtoml.a
BUILD_DEP += toml
else
BUILD_LDFLAGS += -ltoml
endif

# Cross compilation
# you need the mingw-w64 package for this
ifeq (windows,$(TARGET))
CC := x86_64-w64-mingw32-gcc
BUILD_DEP += curl
BUILD_CFLAGS += -I./curl/include/
BUILD_LDFLAGS += -L./curl/lib/
EXEC := rudder_client.exe
endif

# build is debug
b : build
build: BUILD_CFLAGS += $(CFLAGS_DEBUG)
Expand All @@ -63,12 +76,23 @@ $(BUILD_DIR):
install -d $(BUILD_DIR)

# No separate dirs for debug and release, we clean at every run
bin-target: clean $(BUILD_DIR) toml $(BUILD_DIR)/$(EXEC)

toml:
ifdef STATIC_TOML
cd tomlc99 && $(MAKE) "CFLAGS=$(BUILD_CFLAGS) -std=c99 -fPIC"
endif
bin-target: clean $(BUILD_DIR) $(BUILD_DEP) $(BUILD_DIR)/$(EXEC)

curl:
wget -nv http://repository.rudder.io/build-dependencies/curl/curl-7.69.1_1-win64-mingw.zip
unzip curl-7.69.1_1-win64-mingw.zip
mv curl-7.69.1-win64-mingw/ curl
rm curl-7.69.1_1-win64-mingw.zip

tomlc99:
wget -nv http://repository.rudder.io/build-dependencies/tomlc99/tomlc99-c5d2e37.tar.gz
tar xf tomlc99-c5d2e37.tar.gz
mv tomlc99-master tomlc99
rm tomlc99-c5d2e37.tar.gz
patch -p1 < toml.patch

toml: tomlc99
cd tomlc99 && $(MAKE) CC=$(CC) "CFLAGS=$(CFLAGS) -std=c99 -fPIC" LDFLAGS="$(LDFLAGS)"

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -c -o $@ $<
Expand Down
11 changes: 11 additions & 0 deletions agent/sources/client/toml.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/tomlc99/Makefile 2021-01-28 03:53:31.000000000 +0100
+++ b/tomlc99/Makefile 2021-03-18 17:24:24.440455804 +0100
@@ -24,7 +24,7 @@
ar -rcs $@ $^

libtoml.so: toml.o
- $(CC) -shared -o $@ $^
+ $(CC) $(LDFLAGS) -shared -o $@ $^

toml_json: toml_json.c $(LIB)

0 comments on commit 979523b

Please sign in to comment.