Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Not exactly what you are asking for but I would suggest using cmake instead. Some benefits:

  • less code
  • support for a separate build tree
  • avoiding the white-space (tab) bugs that occur easily in a Makefile

First create a file called CMakeLists.txt with this content:

cmake_minimum_required(VERSION 2.8)
project(outcast)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
file(GLOB client_sources "client/${PLATFORM}/*.c")
add_executable(outcast-client ${client_sources})
target_link_libraries(outcast-client x11)
install(TARGETS outcast-client RUNTIME DESTINATION bin)
file(GLOB server_sources "server/*.c")
add_executable(outcast-server ${server_sources})
install(TARGETS outcast-server RUNTIME DESTINATION bin)

then build and install your programs outcast-client and outcast-server like this

erik@linux:~$ ls ~/outcast_source
CMakeLists.txt client/ server/
erik@linux:~$ mkdir /tmp/build
erik@linux:~$ mkdir /tmp/install
erik@linux:~$ cd /tmp/build/
erik@linux:/tmp/build$ CC=gcc cmake -DPLATFORM=X11 -DCMAKE_INSTALL_PREFIX=/tmp/install ~/outcast_source

Instead of finding the source files with a GLOB expression it is probably better to list them one by one. See http://stackoverflow.com/questions/1027247/best-way-to-specify-sourcefiles-in-cmake https://stackoverflow.com/questions/1027247/best-way-to-specify-sourcefiles-in-cmake

CMake has great support for detecting properties of the build system. You could for instance write something like this in your CMakeLists.txt

find_package(X11)
if(${X11_FOUND})
 file(GLOB client_sources "client/X11/*.c")
 add_executable(outcast-client ${client_sources})
 target_link_libraries(outcast-client ${X11_LIBRARIES})
 install(TARGETS outcast-client RUNTIME DESTINATION bin)
endif()

Not exactly what you are asking for but I would suggest using cmake instead. Some benefits:

  • less code
  • support for a separate build tree
  • avoiding the white-space (tab) bugs that occur easily in a Makefile

First create a file called CMakeLists.txt with this content:

cmake_minimum_required(VERSION 2.8)
project(outcast)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
file(GLOB client_sources "client/${PLATFORM}/*.c")
add_executable(outcast-client ${client_sources})
target_link_libraries(outcast-client x11)
install(TARGETS outcast-client RUNTIME DESTINATION bin)
file(GLOB server_sources "server/*.c")
add_executable(outcast-server ${server_sources})
install(TARGETS outcast-server RUNTIME DESTINATION bin)

then build and install your programs outcast-client and outcast-server like this

erik@linux:~$ ls ~/outcast_source
CMakeLists.txt client/ server/
erik@linux:~$ mkdir /tmp/build
erik@linux:~$ mkdir /tmp/install
erik@linux:~$ cd /tmp/build/
erik@linux:/tmp/build$ CC=gcc cmake -DPLATFORM=X11 -DCMAKE_INSTALL_PREFIX=/tmp/install ~/outcast_source

Instead of finding the source files with a GLOB expression it is probably better to list them one by one. See http://stackoverflow.com/questions/1027247/best-way-to-specify-sourcefiles-in-cmake

CMake has great support for detecting properties of the build system. You could for instance write something like this in your CMakeLists.txt

find_package(X11)
if(${X11_FOUND})
 file(GLOB client_sources "client/X11/*.c")
 add_executable(outcast-client ${client_sources})
 target_link_libraries(outcast-client ${X11_LIBRARIES})
 install(TARGETS outcast-client RUNTIME DESTINATION bin)
endif()

Not exactly what you are asking for but I would suggest using cmake instead. Some benefits:

  • less code
  • support for a separate build tree
  • avoiding the white-space (tab) bugs that occur easily in a Makefile

First create a file called CMakeLists.txt with this content:

cmake_minimum_required(VERSION 2.8)
project(outcast)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
file(GLOB client_sources "client/${PLATFORM}/*.c")
add_executable(outcast-client ${client_sources})
target_link_libraries(outcast-client x11)
install(TARGETS outcast-client RUNTIME DESTINATION bin)
file(GLOB server_sources "server/*.c")
add_executable(outcast-server ${server_sources})
install(TARGETS outcast-server RUNTIME DESTINATION bin)

then build and install your programs outcast-client and outcast-server like this

erik@linux:~$ ls ~/outcast_source
CMakeLists.txt client/ server/
erik@linux:~$ mkdir /tmp/build
erik@linux:~$ mkdir /tmp/install
erik@linux:~$ cd /tmp/build/
erik@linux:/tmp/build$ CC=gcc cmake -DPLATFORM=X11 -DCMAKE_INSTALL_PREFIX=/tmp/install ~/outcast_source

Instead of finding the source files with a GLOB expression it is probably better to list them one by one. See https://stackoverflow.com/questions/1027247/best-way-to-specify-sourcefiles-in-cmake

CMake has great support for detecting properties of the build system. You could for instance write something like this in your CMakeLists.txt

find_package(X11)
if(${X11_FOUND})
 file(GLOB client_sources "client/X11/*.c")
 add_executable(outcast-client ${client_sources})
 target_link_libraries(outcast-client ${X11_LIBRARIES})
 install(TARGETS outcast-client RUNTIME DESTINATION bin)
endif()
fixed a small bug
Source Link

Not exactly what you are asking for but I would suggest usingcmakecmake instead. Some benefits:

http://www.cmake.org

  • less code
  • support for a separate build tree
  • avoiding the white-space (tab) bugs that occur easily in a Makefile

First create a file called CMakeLists.txt with this content:

cmake_minimum_required(VERSION 2.8)
project(outcast)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
file(GLOB client_sources "client/${PLATFORM}/*.c")
add_executable(outcast-client ${client_sources})
target_link_libraries(outcast-client x11)
install(TARGETS outcast-client RUNTIME DESTINATION bin)
file(GLOB server_sources "server/*.c")
add_executable(outcast-server ${server_sources})
install(TARGETS outcast-server RUNTIME DESTINATION bin)

then build and install your programs outcast-client and outcast-server like this

erik@linux:~$ ls ~/outcast_source
CMakeLists.txt client/ server/
erik@linux:~$ mkdir /tmp/build
erik@linux:~$ mkdir /tmp/install
erik@linux:~$ cd /tmp/build/
erik@linux:/tmp/build$ CC=gcc cmake -DPLATFORM=X11 -DCMAKE_INSTALL_PREFIX=/tmp/install ~/outcast_source

Instead of finding the source files with a GLOB expression it is probably better to list them one by one. See http://stackoverflow.com/questions/1027247/best-way-to-specify-sourcefiles-in-cmake

CMake has great support for detecting properties of the build system. You could for instance write something like this in your CMakeLists.txt

find_package(X11)
if(${X11_FOUND})
 file(GLOB client_sources "client/X11/*.c")
 add_executable(outcast-client ${client_sources})
 target_link_libraries(outcast-client ${X11_LIBRARIES})
 install(TARGETS outcast-client RUNTIME DESTINATION bin)
endif()

Not exactly what you are asking for but I would suggest usingcmake instead.

http://www.cmake.org

First create a file called CMakeLists.txt with this content:

cmake_minimum_required(VERSION 2.8)
project(outcast)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
file(GLOB client_sources "client/${PLATFORM}/*.c")
add_executable(outcast-client ${client_sources})
target_link_libraries(outcast-client x11)
install(TARGETS outcast-client RUNTIME DESTINATION bin)
file(GLOB server_sources "server/*.c")
add_executable(outcast-server ${server_sources})
install(TARGETS outcast-server RUNTIME DESTINATION bin)

then build and install your programs outcast-client and outcast-server like this

erik@linux:~$ ls ~/outcast_source
CMakeLists.txt client/ server/
erik@linux:~$ mkdir /tmp/build
erik@linux:~$ mkdir /tmp/install
erik@linux:~$ cd /tmp/build/
erik@linux:/tmp/build$ CC=gcc cmake -DCMAKE_INSTALL_PREFIX=/tmp/install ~/outcast_source

CMake has great support for detecting properties of the build system. You could for instance write something like this in your CMakeLists.txt

find_package(X11)
if(${X11_FOUND})
 file(GLOB client_sources "client/X11/*.c")
 add_executable(outcast-client ${client_sources})
 target_link_libraries(outcast-client ${X11_LIBRARIES})
 install(TARGETS outcast-client RUNTIME DESTINATION bin)
endif()

Not exactly what you are asking for but I would suggest usingcmake instead. Some benefits:

  • less code
  • support for a separate build tree
  • avoiding the white-space (tab) bugs that occur easily in a Makefile

First create a file called CMakeLists.txt with this content:

cmake_minimum_required(VERSION 2.8)
project(outcast)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
file(GLOB client_sources "client/${PLATFORM}/*.c")
add_executable(outcast-client ${client_sources})
target_link_libraries(outcast-client x11)
install(TARGETS outcast-client RUNTIME DESTINATION bin)
file(GLOB server_sources "server/*.c")
add_executable(outcast-server ${server_sources})
install(TARGETS outcast-server RUNTIME DESTINATION bin)

then build and install your programs outcast-client and outcast-server like this

erik@linux:~$ ls ~/outcast_source
CMakeLists.txt client/ server/
erik@linux:~$ mkdir /tmp/build
erik@linux:~$ mkdir /tmp/install
erik@linux:~$ cd /tmp/build/
erik@linux:/tmp/build$ CC=gcc cmake -DPLATFORM=X11 -DCMAKE_INSTALL_PREFIX=/tmp/install ~/outcast_source

Instead of finding the source files with a GLOB expression it is probably better to list them one by one. See http://stackoverflow.com/questions/1027247/best-way-to-specify-sourcefiles-in-cmake

CMake has great support for detecting properties of the build system. You could for instance write something like this in your CMakeLists.txt

find_package(X11)
if(${X11_FOUND})
 file(GLOB client_sources "client/X11/*.c")
 add_executable(outcast-client ${client_sources})
 target_link_libraries(outcast-client ${X11_LIBRARIES})
 install(TARGETS outcast-client RUNTIME DESTINATION bin)
endif()
Source Link

Not exactly what you are asking for but I would suggest using cmake instead.

http://www.cmake.org

First create a file called CMakeLists.txt with this content:

cmake_minimum_required(VERSION 2.8)
project(outcast)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
file(GLOB client_sources "client/${PLATFORM}/*.c")
add_executable(outcast-client ${client_sources})
target_link_libraries(outcast-client x11)
install(TARGETS outcast-client RUNTIME DESTINATION bin)
file(GLOB server_sources "server/*.c")
add_executable(outcast-server ${server_sources})
install(TARGETS outcast-server RUNTIME DESTINATION bin)

then build and install your programs outcast-client and outcast-server like this

erik@linux:~$ ls ~/outcast_source
CMakeLists.txt client/ server/
erik@linux:~$ mkdir /tmp/build
erik@linux:~$ mkdir /tmp/install
erik@linux:~$ cd /tmp/build/
erik@linux:/tmp/build$ CC=gcc cmake -DCMAKE_INSTALL_PREFIX=/tmp/install ~/outcast_source

CMake has great support for detecting properties of the build system. You could for instance write something like this in your CMakeLists.txt

find_package(X11)
if(${X11_FOUND})
 file(GLOB client_sources "client/X11/*.c")
 add_executable(outcast-client ${client_sources})
 target_link_libraries(outcast-client ${X11_LIBRARIES})
 install(TARGETS outcast-client RUNTIME DESTINATION bin)
endif()
lang-c

AltStyle によって変換されたページ (->オリジナル) /