From: Brian Norris <banorris@uci.edu>
Date: Thu, 13 Sep 2012 07:22:55 +0000 (-0700)
Subject: Makefile: fixup Mac dependencies
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=964141f234c1b79f43f2a0988cc5bd55e484f004;p=cdsspec-compiler.git

Makefile: fixup Mac dependencies

Now, Mac OSX builds can just use "make", not "make mac". (This also allows
"make debug" for Mac OSX)
---

diff --git a/Makefile b/Makefile
index 2acdbc7..91acd7e 100644
--- a/Makefile
+++ b/Makefile
@@ -6,10 +6,17 @@ OBJECTS = libthreads.o schedule.o model.o threads.o librace.o action.o \
 	  snapshot.o malloc.o mymemory.o
 
 CPPFLAGS += -Iinclude -I.
-LDFLAGS=-ldl -lrt
-SHARED=-shared
+LDFLAGS = -ldl -lrt
+SHARED = -shared
 
-TESTS=test
+# Mac OSX options
+ifeq ($(UNAME), Darwin)
+CPPFLAGS += -D_XOPEN_SOURCE -DMAC
+LDFLAGS = -ldl
+SHARED = -Wl,-undefined,dynamic_lookup -dynamiclib
+endif
+
+TESTS_DIR = test
 
 program_H_SRCS := $(wildcard *.h) $(wildcard include/*.h)
 program_C_SRCS := $(wildcard *.c) $(wildcard *.cc)
@@ -18,18 +25,13 @@ DEPS = make.deps
 all: $(LIB_SO) $(DEPS) tests
 
 $(DEPS): $(program_C_SRCS) $(program_H_SRCS)
-	$(CXX) $(CPPFLAGS) -MM $(program_C_SRCS) > $(DEPS)
+	$(CXX) -MM $(program_C_SRCS) $(CPPFLAGS) > $(DEPS)
 
 include $(DEPS)
 
 debug: CPPFLAGS += -DCONFIG_DEBUG
 debug: all
 
-mac: CPPFLAGS += -D_XOPEN_SOURCE -DMAC
-mac: LDFLAGS=-ldl
-mac: SHARED=-Wl,-undefined,dynamic_lookup -dynamiclib
-mac: all
-
 docs: *.c *.cc *.h
 	doxygen
 
@@ -44,7 +46,7 @@ malloc.o: malloc.c
 
 clean:
 	rm -f *.o *.so
-	$(MAKE) -C $(TESTS) clean
+	$(MAKE) -C $(TESTS_DIR) clean
 
 mrclean: clean
 	rm -rf docs
@@ -53,4 +55,4 @@ tags::
 	ctags -R
 
 tests:: $(LIB_SO)
-	$(MAKE) -C $(TESTS)
+	$(MAKE) -C $(TESTS_DIR)
diff --git a/common.mk b/common.mk
index 378a659..e9e4060 100644
--- a/common.mk
+++ b/common.mk
@@ -1,9 +1,11 @@
 # A few common Makefile items
 
-CC=gcc
-CXX=g++
+CC = gcc
+CXX = g++
 
-LIB_NAME=model
-LIB_SO=lib$(LIB_NAME).so
+UNAME = $(shell uname)
 
-CPPFLAGS=-Wall -g -O0
+LIB_NAME = model
+LIB_SO = lib$(LIB_NAME).so
+
+CPPFLAGS += -Wall -g -O0