summaryrefslogtreecommitdiff
path: root/B/generic/Makefile
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-06 22:57:13 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-06 22:57:13 -0800
commit1bb1ce141783168d44a38cd1bb6b822eb13114fc (patch)
treeb72d5afb9da6d9e92e685fb7a689342491600180 /B/generic/Makefile
downloadlzo-1bb1ce141783168d44a38cd1bb6b822eb13114fc.tar.gz
lzo-1bb1ce141783168d44a38cd1bb6b822eb13114fc.tar.bz2
lzo-1bb1ce141783168d44a38cd1bb6b822eb13114fc.zip
Imported Upstream version 2.03upstream/2.03
Diffstat (limited to 'B/generic/Makefile')
-rw-r--r--B/generic/Makefile91
1 files changed, 91 insertions, 0 deletions
diff --git a/B/generic/Makefile b/B/generic/Makefile
new file mode 100644
index 0000000..88caf3a
--- /dev/null
+++ b/B/generic/Makefile
@@ -0,0 +1,91 @@
+# Copyright (C) 1996-2008 Markus F.X.J. Oberhumer
+#
+# this is modelled after build.sh; needs GNU make 3.80 or better
+
+SHELL = /bin/sh
+
+##
+## setup flags
+##
+
+##top_srcdir ?= ../..
+top_srcdir ?= $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))../..
+AR ?= ar
+CC ?= cc
+CFLAGS ?= -O
+
+CFI = -I$(top_srcdir)/include -I$(top_srcdir)
+BNAME = lzo2
+BLIB = lib$(BNAME).a
+
+CF = $(CPPFLAGS) $(CFI) $(CFLAGS)
+LF = $(LDFLAGS) $(LZO_EXTRA_LDFLAGS)
+LL = $(BLIB) $(LIBS) $(LZO_EXTRA_LIBS)
+
+
+##
+## setup files
+##
+
+__map = $(foreach __map_v,$(2),$(call $(1),$(__map_v)))
+__object_filename = $(addsuffix .o,$(basename $(notdir $(1))))
+
+BLIB_SOURCES := $(wildcard $(top_srcdir)/src/*.c)
+BLIB_SOURCES += $(LZO_EXTRA_SOURCES)
+BLIB_OBJECTS := $(call __map,__object_filename,$(BLIB_SOURCES))
+PROGRAMS = dict.out lzopack.out precomp.out precomp2.out simple.out lzotest.out
+
+
+##
+## rules
+##
+
+all.targets ?= $(BLIB) $(PROGRAMS) testmini.out
+all: $(all.targets)
+
+clean:
+ rm -f *.d *.o $(BLIB) $(PROGRAMS) testmini.out
+
+$(BLIB): $(BLIB_OBJECTS) $(LZO_EXTRA_OBJECTS)
+ rm -f $@
+ $(AR) rcs $@ $^
+
+# dynamically construct object rules
+define BLIB_OBJECT_template
+ $(call __object_filename,$(1)) : $(1) ; $$(CC) $$(CF) $$(LZO_EXTRA_CPPFLAGS) $$(LZO_EXTRA_CFLAGS) -c $$<
+endef
+$(foreach s,$(BLIB_SOURCES),$(eval $(call BLIB_OBJECT_template,$(s))))
+
+dict.out: $(top_srcdir)/examples/dict.c
+ $(CC) $(CF) $(LF) -o $@ $< $(LL)
+lzopack.out: $(top_srcdir)/examples/lzopack.c
+ $(CC) $(CF) $(LF) -o $@ $< $(LL)
+precomp.out: $(top_srcdir)/examples/precomp.c
+ $(CC) $(CF) $(LF) -o $@ $< $(LL)
+precomp2.out: $(top_srcdir)/examples/precomp2.c
+ $(CC) $(CF) $(LF) -o $@ $< $(LL)
+simple.out: $(top_srcdir)/examples/simple.c
+ $(CC) $(CF) $(LF) -o $@ $< $(LL)
+lzotest.out: $(top_srcdir)/lzotest/lzotest.c
+ $(CC) $(CF) $(LF) -o $@ $< $(LL)
+
+testmini.out: $(top_srcdir)/minilzo/testmini.c $(top_srcdir)/minilzo/minilzo.c
+ $(CC) $(CF) $(LF) -I$(top_srcdir)/include/lzo -o $@ $^ $(LIBS)
+
+
+# dependencies
+$(PROGRAMS): $(BLIB)
+# object dependencies are generated via -MMD
+-include *.d
+
+
+# debug
+show_vars:
+ @echo "BLIB_SOURCES = $(BLIB_SOURCES)"
+ @echo "BLIB_OBJECTS = $(BLIB_OBJECTS)"
+ @echo "PROGRAMS = $(PROGRAMS)"
+ @echo "LZO_EXTRA_SOURCES = $(LZO_EXTRA_SOURCES)"
+ @echo "LZO_EXTRA_OBJECTS = $(LZO_EXTRA_OBJECTS)"
+
+.PHONY: all clean show_vars
+