Browse Source

Sort out some more compile flags for Mac

Craig Tiller 10 years ago
parent
commit
96b49557ec
2 changed files with 28 additions and 12 deletions
  1. 14 6
      Makefile
  2. 14 6
      templates/Makefile.template

+ 14 - 6
Makefile

@@ -2,6 +2,14 @@
 # This currently builds C and C++ code.
 # This currently builds C and C++ code.
 
 
 
 
+
+# Basic platform detection
+HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
+ifeq ($(SYSTEM),)
+SYSTEM = $(HOST_SYSTEM)
+endif
+
+
 # Configurations
 # Configurations
 
 
 VALID_CONFIG_opt = 1
 VALID_CONFIG_opt = 1
@@ -115,10 +123,15 @@ LDFLAGS += $(LDFLAGS_$(CONFIG))
 CFLAGS += -std=c89 -pedantic
 CFLAGS += -std=c89 -pedantic
 CXXFLAGS += -std=c++11
 CXXFLAGS += -std=c++11
 CPPFLAGS += -g -fPIC -Wall -Werror -Wno-long-long
 CPPFLAGS += -g -fPIC -Wall -Werror -Wno-long-long
-LDFLAGS += -g -pthread -fPIC
+LDFLAGS += -g -fPIC
 
 
 INCLUDES = . include gens
 INCLUDES = . include gens
+ifeq ($(SYSTEM),Darwin)
+LIBS = m z
+else
 LIBS = rt m z pthread
 LIBS = rt m z pthread
+LDFLAGS += -pthread
+endif
 LIBSXX = protobuf
 LIBSXX = protobuf
 LIBS_PROTOC = protoc protobuf
 LIBS_PROTOC = protoc protobuf
 
 
@@ -156,11 +169,6 @@ HOST_LDLIBS = $(LDLIBS)
 # These are automatically computed variables.
 # These are automatically computed variables.
 # There shouldn't be any need to change anything from now on.
 # There shouldn't be any need to change anything from now on.
 
 
-HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
-ifeq ($(SYSTEM),)
-SYSTEM = $(HOST_SYSTEM)
-endif
-
 ifeq ($(SYSTEM),MINGW32)
 ifeq ($(SYSTEM),MINGW32)
 SHARED_EXT = dll
 SHARED_EXT = dll
 endif
 endif

+ 14 - 6
templates/Makefile.template

@@ -19,6 +19,14 @@
     return 'gens/' + m.group(1) + '.pb.cc'
     return 'gens/' + m.group(1) + '.pb.cc'
 %>
 %>
 
 
+
+# Basic platform detection
+HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
+ifeq ($(SYSTEM),)
+SYSTEM = $(HOST_SYSTEM)
+endif
+
+
 # Configurations
 # Configurations
 
 
 VALID_CONFIG_opt = 1
 VALID_CONFIG_opt = 1
@@ -132,10 +140,15 @@ LDFLAGS += $(LDFLAGS_$(CONFIG))
 CFLAGS += -std=c89 -pedantic
 CFLAGS += -std=c89 -pedantic
 CXXFLAGS += -std=c++11
 CXXFLAGS += -std=c++11
 CPPFLAGS += -g -fPIC -Wall -Werror -Wno-long-long
 CPPFLAGS += -g -fPIC -Wall -Werror -Wno-long-long
-LDFLAGS += -g -pthread -fPIC
+LDFLAGS += -g -fPIC
 
 
 INCLUDES = . include gens
 INCLUDES = . include gens
+ifeq ($(SYSTEM),Darwin)
+LIBS = m z
+else
 LIBS = rt m z pthread
 LIBS = rt m z pthread
+LDFLAGS += -pthread
+endif
 LIBSXX = protobuf
 LIBSXX = protobuf
 LIBS_PROTOC = protoc protobuf
 LIBS_PROTOC = protoc protobuf
 
 
@@ -173,11 +186,6 @@ HOST_LDLIBS = $(LDLIBS)
 # These are automatically computed variables.
 # These are automatically computed variables.
 # There shouldn't be any need to change anything from now on.
 # There shouldn't be any need to change anything from now on.
 
 
-HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
-ifeq ($(SYSTEM),)
-SYSTEM = $(HOST_SYSTEM)
-endif
-
 ifeq ($(SYSTEM),MINGW32)
 ifeq ($(SYSTEM),MINGW32)
 SHARED_EXT = dll
 SHARED_EXT = dll
 endif
 endif