Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- git clone git://github.com/bagder/curl.git
- mv curl/CMakeLists.txt curl/CMakeLists.old
- awk ' 1
- /^project/ {
- print "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -m32\")"
- print "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -m32\")"
- } ' curl/CMakeLists.old >> curl/CMakeLists.txt
- mkdir .bin_curl; pushd .bin_curl
- cmake ../curl \
- -DBUILD_CURL_TESTS=OFF \
- -DBUILD_CURL_EXE=OFF \
- -DCURL_STATICLIB=ON \
- -DCURL_DISABLE_LDAP=ON \
- -DCURL_DISABLE_CRYPTO_AUTH=ON \
- -DCMAKE_USE_OPENSSL=OFF \
- -DCURL_ZLIB=OFF \
- -DHAVE_LIBIDN=OFF
- make
- popd
- mkdir .bin; pushd .bin
- echo \
- '#include <stdio.h>
- #include <sys/socket.h>
- #include "curl/curl.h"
- int get_qwerty(void)
- {
- CURL *curl;
- CURLcode res;
- curl = curl_easy_init();
- if(curl) {
- curl_easy_setopt(curl, CURLOPT_URL, "http://www.haxx.se/curl.html");
- /* example.com is redirected, so we tell libcurl to follow redirection */
- curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
- /* Perform the request, res will get the return code */
- res = curl_easy_perform(curl);
- /* Check for errors */
- if(res != CURLE_OK)
- fprintf(stderr, "curl_easy_perform() failed: %s\n",
- curl_easy_strerror(res));
- /* always cleanup */
- curl_easy_cleanup(curl);
- }
- return 0;
- }
- ' > library.cpp
- echo \
- '#ifndef __LIBRARY_H__
- #define __LIBRARY_H__
- int get_qwerty(void);
- #endif //__LIBRARY_H__
- ' > library.h
- echo \
- '#include <stdio.h>
- #include "library.h"
- int main()
- {
- printf("\nmain-start.\n\n");
- get_qwerty();
- printf("\nmain-end.\n\n");
- return 0;
- }
- ' > main.cpp
- echo \
- 'CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
- set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
- INCLUDE_DIRECTORIES(.)
- FILE(GLOB CurlLibrary ${CMAKE_SOURCE_DIR}/curl.a/*.o)
- ADD_LIBRARY(foo STATIC library.cpp ${CurlLibrary})
- ADD_EXECUTABLE(main main.cpp)
- TARGET_LINK_LIBRARIES(main foo)
- ' > CMakeLists.txt
- mkdir curl
- cp ../.bin_curl/include/curl/*.h ./curl/
- cp ../curl/include/curl/*.h ./curl/
- mkdir curl.a; pushd curl.a
- ar x ../../.bin_curl/lib/libcurl.a
- popd
- cmake .
- make
- ./main
- popd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement