rename cgpt files with cgptlib prefix (to avoid conflicts to cgpt utility)

Review URL: http://codereview.chromium.org/2082007
diff --git a/Makefile b/Makefile
index 4db96fa..2a1043c 100644
--- a/Makefile
+++ b/Makefile
@@ -8,9 +8,10 @@
 export INCLUDES = \
 	-I$(TOP)/common/include \
 	-I$(TOP)/cryptolib/include \
-	-I$(TOP)/misclibs/include
+	-I$(TOP)/misclibs/include \
+	-I$(TOP)/cgptlib
 
-SUBDIRS=common cryptolib misclibs vfirmware vkernel utility tests
+SUBDIRS=common cgptlib cryptolib misclibs vfirmware vkernel utility tests
 
 all:
 	for i in $(SUBDIRS); do \
diff --git a/cgptlib/Makefile b/cgptlib/Makefile
index 418163c..5ba386e 100644
--- a/cgptlib/Makefile
+++ b/cgptlib/Makefile
@@ -2,8 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-CFLAGS ?= -Wall -Werror -ansi
-INCLUDES += tests
+CFLAGS += -Wall -Werror -ansi
+INCLUDES += -Itests
 SUBDIRS = tests
 
 all: cgpt.a
@@ -14,11 +14,11 @@
 .c.o:
 	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
 
-cgpt.a: cgpt.o
-	$(AR) rs cgpt.a $<
+cgpt.a: cgptlib.o quick_sort.o crc32.o
+	$(AR) rs $@ $^
 
 clean:
 	for i in $(SUBDIRS); do \
 	( $(MAKE) -C $$i clean ) ; \
 	done
-	rm -f cgpt cgpt-host *.o *~ *.a
+	rm -f *.o *~ *.a
diff --git a/cgptlib/cgpt.c b/cgptlib/cgptlib.c
similarity index 99%
rename from cgptlib/cgpt.c
rename to cgptlib/cgptlib.c
index d509f00..f2deb3f 100644
--- a/cgptlib/cgpt.c
+++ b/cgptlib/cgptlib.c
@@ -3,9 +3,9 @@
  * found in the LICENSE file.
  */
 
-#include "cgpt.h"
+#include "cgptlib.h"
 #include <string.h>
-#include "cgpt_internal.h"
+#include "cgptlib_internal.h"
 #include "crc32.h"
 #include "gpt.h"
 #include "quick_sort.h"
diff --git a/cgptlib/cgpt.h b/cgptlib/cgptlib.h
similarity index 97%
rename from cgptlib/cgpt.h
rename to cgptlib/cgptlib.h
index 1f9f230..ea352e7 100644
--- a/cgptlib/cgpt.h
+++ b/cgptlib/cgptlib.h
@@ -3,8 +3,8 @@
  * found in the LICENSE file.
  */
 
-#ifndef VBOOT_REFERENCE_CGPT_H_
-#define VBOOT_REFERENCE_CGPT_H_
+#ifndef VBOOT_REFERENCE_CGPTLIB_H_
+#define VBOOT_REFERENCE_CGPTLIB_H_
 
 #include "gpt.h"
 #include <stdint.h>
@@ -133,4 +133,4 @@
  *   GPT_ERROR_INVALID_UPDATE_TYPE, invalid 'update_type' is given.
  */
 
-#endif  /* VBOOT_REFERENCE_CGPT_H_ */
+#endif  /* VBOOT_REFERENCE_CGPTLIB_H_ */
diff --git a/cgptlib/cgpt_internal.h b/cgptlib/cgptlib_internal.h
similarity index 94%
rename from cgptlib/cgpt_internal.h
rename to cgptlib/cgptlib_internal.h
index c65f466..fe6f829 100644
--- a/cgptlib/cgpt_internal.h
+++ b/cgptlib/cgptlib_internal.h
@@ -3,11 +3,11 @@
  * found in the LICENSE file.
  */
 
-#ifndef VBOOT_REFERENCE_CGPT_INTERNAL_H_
-#define VBOOT_REFERENCE_CGPT_INTERNAL_H_
+#ifndef VBOOT_REFERENCE_CGPTLIB_INTERNAL_H_
+#define VBOOT_REFERENCE_CGPTLIB_INTERNAL_H_
 
 #include <stdint.h>
-#include "cgpt.h"
+#include "cgptlib.h"
 
 int CheckParameters(GptData *gpt);
 uint32_t CheckHeaderSignature(GptData *gpt);
@@ -79,4 +79,4 @@
 #define CGPT_ATTRIBUTE_PRIORITY_MASK (CGPT_ATTRIBUTE_MAX_PRIORITY << \
                                       CGPT_ATTRIBUTE_PRIORITY_OFFSET)
 
-#endif /* VBOOT_REFERENCE_CGPT_INTERNAL_H_ */
+#endif /* VBOOT_REFERENCE_CGPTLIB_INTERNAL_H_ */
diff --git a/cgptlib/tests/Makefile b/cgptlib/tests/Makefile
index 60871fa..57b7bec 100644
--- a/cgptlib/tests/Makefile
+++ b/cgptlib/tests/Makefile
@@ -2,11 +2,10 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-CC ?= cc
-CFLAGS ?= -Wall -DNDEBUG -Werror -ansi
+CFLAGS += -Wall -DNDEBUG -Werror -ansi
 LIBS = ../cgpt.a ../../common/libcommon.a
-OBJS = cgpt_test.o
-OUT = cgpt_test
+OBJS = cgptlib_test.o quick_sort_test.o
+OUT = cgptlib_test
 
 all: $(OUT)
 
diff --git a/cgptlib/tests/cgpt_test.c b/cgptlib/tests/cgptlib_test.c
similarity index 99%
rename from cgptlib/tests/cgpt_test.c
rename to cgptlib/tests/cgptlib_test.c
index 964232d..b725749 100644
--- a/cgptlib/tests/cgpt_test.c
+++ b/cgptlib/tests/cgptlib_test.c
@@ -3,10 +3,10 @@
  * found in the LICENSE file.
  */
 
-#include "cgpt_test.h"
+#include "cgptlib_test.h"
 #include <string.h>
-#include "cgpt.h"
-#include "cgpt_internal.h"
+#include "cgptlib.h"
+#include "cgptlib_internal.h"
 #include "crc32.h"
 #include "gpt.h"
 #include "quick_sort_test.h"
diff --git a/cgptlib/tests/cgpt_test.h b/cgptlib/tests/cgptlib_test.h
similarity index 84%
rename from cgptlib/tests/cgpt_test.h
rename to cgptlib/tests/cgptlib_test.h
index 3a4191a..9812e77 100644
--- a/cgptlib/tests/cgpt_test.h
+++ b/cgptlib/tests/cgptlib_test.h
@@ -2,8 +2,8 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#ifndef VBOOT_REFERENCE_CGPT_TEST_H_
-#define VBOOT_REFERENCE_CGPT_TEST_H_
+#ifndef VBOOT_REFERENCE_CGPTLIB_TEST_H_
+#define VBOOT_REFERENCE_CGPTLIB_TEST_H_
 
 #include <stdio.h>
 
@@ -31,4 +31,4 @@
     } \
   } while (0)
 
-#endif  /* VBOOT_REFERENCE_CGPT_TEST_H_ */
+#endif  /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */
diff --git a/cgptlib/tests/quick_sort_test.c b/cgptlib/tests/quick_sort_test.c
index 325c2fa..d63d08b 100644
--- a/cgptlib/tests/quick_sort_test.c
+++ b/cgptlib/tests/quick_sort_test.c
@@ -4,7 +4,7 @@
  */
 
 #include "quick_sort_test.h"
-#include "cgpt_test.h"
+#include "cgptlib_test.h"
 #include "quick_sort.h"
 #include "utility.h"