convert to cmake
authorFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 19:23:34 +0000 (20:23 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 19:23:34 +0000 (20:23 +0100)
.gitignore
CMakeLists.txt [new file with mode: 0644]
Makefile [deleted file]

index 9784b6a719127313e742c08d792afacd999efc64..268e7f60e41e44266f15d6c2cddefa9c3af791dd 100644 (file)
@@ -1,2 +1,8 @@
+Makefile
+CMakeCache.txt
+CMakeFiles
+*.cmake
+*.a
 *.so
 *.dylib
+install_manifest.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e307cd7
--- /dev/null
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 2.8)
+
+PROJECT(ubox C)
+ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3)
+
+SET(SOURCES avl.c blob.c blobmsg.c hash.c uhtbl.c uloop.c)
+IF("${CMAKE_SYSTEM}" MATCHES "Linux")
+  SET(SOURCES ${SOURCES} unl.c)
+ENDIF("${CMAKE_SYSTEM}" MATCHES "Linux")
+
+ADD_LIBRARY(ubox SHARED ${SOURCES})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+
+FILE(GLOB headers *.h)
+INSTALL(FILES ${headers}
+       DESTINATION include/libubox
+)
+INSTALL(TARGETS ubox
+       LIBRARY DESTINATION lib
+)
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 996d6a6..0000000
--- a/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-CC?=gcc
-CFLAGS?=-O2
-CFLAGS+=-std=gnu99 -Wall -Werror -pedantic -fpic
-LDFLAGS?=
-LIBNL=-lnl-tiny
-PREFIX=/usr
-INCLUDE_DIR=$(PREFIX)/include/libubox
-LIBDIR=$(PREFIX)/lib
-CPPFLAGS=
-
-OS=$(shell uname)
-FILES=blob.c blobmsg.c hash.c uhtbl.c usock.c uloop.c avl.c
-ifeq ($(OS),Linux)
-  FILES += unl.c
-  LIBS += $(LIBNL)
-  LDFLAGS_SHARED=-shared -Wl,-soname,$@
-  SHLIB_EXT=so
-endif
-ifeq ($(OS),Darwin)
-  LDFLAGS_SHARED=-dynamiclib
-  SHLIB_EXT=dylib
-endif
-
-all: libubox.$(SHLIB_EXT)
-
-libubox.$(SHLIB_EXT): $(FILES)
-       $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(LDFLAGS_SHARED)
-
-install-headers:
-       mkdir -p $(INCLUDE_DIR)
-       cp *.h $(INCLUDE_DIR)/
-
-install-lib:
-       mkdir -p $(LIBDIR)
-       cp libubox.$(SHLIB_EXT) $(LIBDIR)/
-
-install: install-lib install-headers
-
-clean:
-       rm -f *.$(SHLIB_EXT)
-