commit f9cac98ab537f64ee5d283f37e223372ecc4580c
parent 26a5b920f52ac24b4b15863a9c39f14ab79c6083
Author: Thordur Bjornsson <thorduri@secnorth.net>
Date: Sat, 16 Nov 2013 12:41:58 +0100
Detect OS rather then supplying a build target
Diffstat:
Makefile | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
@@ -13,19 +13,20 @@ CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
CFLAGS+=-Wsign-compare -Iincludes -g
LDFLAGS+=-rdynamic -lssl -lcrypto -lz
-default:
- @echo "Please specify a build target [linux | bsd | osx]"
-
-linux:
- @LDFLAGS="-ldl" CFLAGS="-D_GNU_SOURCE=1" S_SRC=src/linux.c make kore
-
-bsd:
- @S_SRC=src/bsd.c make kore
-
-osx:
- @LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include/" make bsd
-
-kore: $(S_OBJS)
+OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
+ifeq ("$(OSNAME)", "darwin")
+ CFLAGS+=-I/opt/local/include/
+ LDFLAGS+=-L/opt/local/lib
+ S_SRC+=src/bsd.c
+else ifeq ("$(OSNAME)", "linux")
+ CFLAGS+=-D_GNU_SOURCE=1
+ LDFLAGS+=-ldl
+ S_SRC+=src/linux.c
+else
+ S_SRC+=src/bsd.c
+endif
+
+all: $(S_OBJS)
$(CC) $(CFLAGS) $(S_OBJS) $(LDFLAGS) -o $(BIN)
.c.o:
@@ -33,3 +34,5 @@ kore: $(S_OBJS)
clean:
rm -f src/*.o $(BIN)
+
+.PHONY: clean