Makefile cleanup
Change-Id: Ia4b310c09cb8323ef5a62132ee27803ebd8127d9
diff --git a/Makefile b/Makefile
index 1679151..8d68a5e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,49 +1,41 @@
# Copyright 2011 Google Inc. All Rights Reserved.
# Author: qianzhang@google.com (ken Zhang)
-#MAKEFILE for cross platform
DEBUG=-g
ifdef DEBUG
- DEBUG_CFLAGS= -g $(DEBUG)
+ DEBUG_CFLAGS:=$(DEBUG)
else
- DEBUG_CFLAGS= -O3
+ DEBUG_CFLAGS:=-O3
endif
-ifdef TARGET
- CROSS_PREFIX:=$(TARGET)
-else
- CROSS_PREFIX:=
-endif
+CC:=$(CROSS_COMPILE)gcc
+LD:=$(CROSS_COMPILE)ld
-CC:=$(CROSS_PREFIX)gcc
-LD:=$(CROSS_PREFIX)ld
-AR:=$(CROSS_PREFIX)ar
-RANLIB:=$(CROSS_PREFIX)ranlib
-STRIP:=$(CROSS_PREFIX)strip
+CFLAGS=-Wall -O2 -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Werror
+LDFLAGS=-L./libhdhomerun -lhdhomerun -lpthread
+SHARED=-fPIC -shared
-CFLAGS= -Wall -fPIC -O2 -Wpointer-arith
+SRCS=sagelog.c hdhomerun_tuner.c hdhomerun_http.c hdhomerun_dev.c utility.c hdhomerun_plugin.c
+INCS=sagelog.h hdhomerun_tuner.h hdhomerun_http.h hdhomerun_dev.h utility.h
+LIBS=libhdhomerun/libhdhomerun.so
-FILES=sagelog.c hdhomerun_tuner.c hdhomerun_http.c hdhomerun_dev.c utility.c hdhomerun_plugin.c
-INC= sagelog.h hdhomerun_tuner.h hdhomerun_http.h hdhomerun_dev.h utility.h
-EXTRA_INCS= ../tvstreamparser
+.PHONY: all
+all: hdhr_plugin.so
-#all:hdhomerun
-all:hdhr_plugin.so
-dep_make:hdrun_dep
+hdhr_plugin.so: $(LIBS) $(SRCS) $(INCS)
+ $(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(SHARED) $(SRCS) $(LDFLAGS) -o $@
-hdhr_plugin.so:dep_make $(FILES) $(INC)
- $(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(FILES) -shared -o hdhr_plugin.so -I$(EXTRA_INCS) -L. -lhdhomerun -lpthread
+hdhomerun: $(LIBS) $(SRCS) $(INCS)
+ $(CC) $(CFLAGS) $(DEBUG_CFLAGS) -DTEST_APP $(SRCS) $(LDFLAGS) -o $@
-hdhomerun:dep_make $(FILES) $(INC)
- $(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(FILES) -DTEST_APP -o hdhomerun -I$(EXTRA_INCS) -L. -lhdhomerun -lpthread
+get_http: hdhomerun_http.c hdhomerun_http.h
+ $(CC) $(CFLAGS) $(DEBUG_CFLAGS) -DHTTP_GET_APP hdhomerun_http.c -o $@
-hdrun_dep:
- make -C libhdhomerun
- cp libhdhomerun/libhdhomerun.so .
-
+.PHONY: $(LIBS)
+$(LIBS):
+ $(MAKE) -C libhdhomerun
+
+.PHONY: clean
clean:
- rm -f $(ALL) hdrun libhdhomerun.so hdhr_plugin.so get_http *~
- make clean -C libhdhomerun
-
-get_http:hdhomerun_http.c hdhomerun_http.h
- $(CC) $(CFLAGS) $(DEBUG_CFLAGS) -DHTTP_GET_APP hdhomerun_http.c -o get_http
+ rm -f hdhr_plugin.so hdhomerun get_http *~
+ $(MAKE) -C libhdhomerun clean