Modified stack unit test makefile (root/csdk/stack/test/makefile) that was
authorDoug Hudson <douglas.hudson@intel.com>
Fri, 15 Aug 2014 18:59:35 +0000 (14:59 -0400)
committerDoug Hudson <douglas.hudson@intel.com>
Fri, 15 Aug 2014 18:59:35 +0000 (14:59 -0400)
broken when root/csdk/makefile mod that created debug and release
subdirectories was pushed.

Note that this unit test MAY be used to verify the build on the build server.

Change-Id: If6075d0d06f233ff4902e480a66dda2cc7248366

csdk/stack/test/makefile

index 868347a..15a4de6 100644 (file)
@@ -1,8 +1,8 @@
-# override with `make BUILD=release`
-# default to debug build
-BUILD   := debug
+# override with `make BUILD=debug`
+# default to release build
+BUILD   := release
 PLATFORM := linux
-CC      := gcc
+CC      := g++
 
 # You must create the file "local.properties" on your local machine which contains any local paths, etc
 # local.properties should NOT be committed to repo
@@ -14,11 +14,14 @@ include ./local.properties
 # NOTE:  to run app, make sure that LD_LIBRARY_PATH env variable
 #        contains $(GTEST_DIR)/lib/.libs
 
+OUT_DIR          := $(PWD)/$(BUILD)
+OBJ_DIR          := $(OUT_DIR)/obj
+
 ifeq ($(ROOT_DIR), )
 ROOT_DIR       = $(PWD)/../..
 endif
 
-OUT_DIR        = $(PWD)
+OUT_DIR          := $(PWD)
 
 OCLOGGER_DIR   = $(ROOT_DIR)/logger
 OCRANDOM_DIR   = $(ROOT_DIR)/ocrandom
@@ -44,21 +47,36 @@ INC_DIRS    += -I$(OCTBSTACK_INC)/internal
 INC_DIRS  += -I$(GTEST_DIR)/include
 
 CC_FLAGS.debug      := -g -O0 -g3 -Wall -ffunction-sections -fdata-sections -fno-exceptions \
-                        -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR) -DTB_LOG
-CC_FLAGS.release    := -g -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s -fno-exceptions \
-                        -std=c++0x $(INC_DIRS) -L$(ROOT_DIR) -DTB_LOG
+                        -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/$(BUILD) -DTB_LOG
+CC_FLAGS.release    := -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s -fno-exceptions \
+                        -std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/$(BUILD) 
                                        
 LDLIBS         += -loctbstack -lpthread -lgtest -lgtest_main
 CPPFLAGS       += $(CC_FLAGS.$(BUILD)) $(LDLIBS) -L$(GTEST_DIR)/lib/.libs
 
-PROGRAMS       = stacktests
+SOURCES := stacktests.cpp
+
+OBJECTS:= $(patsubst %.c, $(OBJ_DIR)/%.o, $(SOURCES))
+
+PROGRAMS := stacktests
 
-all:   $(PROGRAMS) 
+all:   prep_dirs $(OBJECTS) $(PROGRAMS) 
 
-%.o: %.cpp
+prep_dirs:
+       -mkdir -p $(OUT_DIR)
+       -mkdir -p $(OBJ_DIR)
+
+$(OBJ_DIR)/%.o: %.cpp
        $(CC) -c $(CPPFLAGS) $< -o $@
 
+stacktests: $(OBJ_DIR)/stacktests.o 
+       $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
+
 .PHONY: clean
 
-clean:
+clean: legacy_clean
+       -rm -rf release
+       -rm -rf debug
+
+legacy_clean:
        rm -f *.o $(PROGRAMS)