Skip to content

Commit 95454e1

Browse files
committed
update makefile, support compile windows target on linux
1 parent 6be3de6 commit 95454e1

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

Diff for: common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
#if defined(__MINGW32__)
5555
#include <winsock2.h>
56-
#include <Ws2tcpip.h >
56+
#include <ws2tcpip.h>
5757
typedef unsigned char u_int8_t;
5858
typedef unsigned short u_int16_t;
5959
typedef unsigned int u_int32_t;

Diff for: makefile

+30-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cc_mips24kc_be=/toolchains/lede-sdk-17.01.2-ar71xx-generic_gcc-5.4.0_musl-1.1.16
55
cc_mips24kc_le=/toolchains/lede-sdk-17.01.2-ramips-mt7621_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin/mipsel-openwrt-linux-musl-g++
66
#cc_arm= /toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ -march=armv6 -marm
77
cc_arm= /toolchains/arm-2014.05/bin/arm-none-linux-gnueabi-g++
8+
cc_mingw_cross=x86_64-w64-mingw32-g++-posix
89
#cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
910

1011
FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers
@@ -17,6 +18,7 @@ TARGETS=amd64 arm mips24kc_be x86 mips24kc_le
1718

1819
TAR=${NAME}_binaries.tar.gz `echo ${TARGETS}|sed -r 's/([^ ]+)/tinymapper_\1/g'` version.txt
1920

21+
# targets for nativei (non-cross) compile
2022
all:git_version
2123
rm -f ${NAME}
2224
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O2
@@ -40,6 +42,19 @@ mac:git_version
4042
cygwin:git_version
4143
rm -f ${NAME}
4244
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O2 -D_GNU_SOURCE
45+
46+
#targes for general cross compile
47+
48+
cross:git_version
49+
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -O2
50+
51+
cross2:git_version
52+
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -lgcc_eh -O2
53+
54+
cross3:git_version
55+
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -O2
56+
57+
#targets only for debug purpose
4358
fast: git_version
4459
rm -f ${NAME}
4560
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb
@@ -50,6 +65,18 @@ debug2: git_version
5065
rm -f ${NAME}
5166
${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -Wformat-nonliteral -ggdb
5267

68+
#targets only for cross compile windows targets on linux
69+
70+
mingw_cross:git_version #to build this and the below one you need 'mingw-w64' installed (the cross compile version on linux)
71+
rm -f ${NAME}
72+
${cc_mingw_cross} -o ${NAME}.exe -I. ${SOURCES} ${FLAGS} -ggdb -static -O2 -lws2_32
73+
74+
mingw_cross_wepoll:git_version #to compile you need a pacthed version of libev with wepoll backend
75+
rm -f ${NAME}
76+
${cc_mingw_cross} -o ${NAME}_wepoll.exe -I. main.cpp log.cpp common.cpp fd_manager.cpp ${FLAGS} -ggdb -static -O2 -DNO_LIBEV_EMBED -D_WIN32 -lev -lws2_32
77+
78+
#targets only for 'make release'
79+
5380
mips24kc_be: git_version
5481
${cc_mips24kc_be} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O2
5582

@@ -58,21 +85,14 @@ mips24kc_le: git_version
5885

5986
amd64:git_version
6087
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O2
61-
x86:git_version
88+
89+
x86:git_version #to build this you need 'g++-multilib' installed
6290
${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O2 -m32
6391
arm:git_version
6492
${cc_arm} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O2 -ggdb
6593

66-
cross:git_version
67-
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -O2
68-
69-
cross2:git_version
70-
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -lgcc_eh -O2
71-
72-
cross3:git_version
73-
${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -O2
7494

75-
release: ${TARGETS}
95+
release: ${TARGETS}
7696
cp git_version.h version.txt
7797
tar -zcvf ${TAR}
7898

@@ -83,4 +103,3 @@ clean:
83103

84104
git_version:
85105
echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > git_version.h
86-

0 commit comments

Comments
 (0)