lzo: update to 2.09
[tomato.git] / release / src / router / lzo / B / generic / Makefile
blob68c6e2fe6749af7f8d02fd944f139dfb5aa418bc
1 # Copyright (C) 1996-2015 Markus F.X.J. Oberhumer
3 # this is modelled after build.sh; needs GNU make 3.80 or better
5 SHELL = /bin/sh
7 ##
8 ## setup flags
9 ##
11 ##top_srcdir ?= ../..
12 top_srcdir ?= $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))../..
13 AR ?= ar
14 CC ?= cc
15 CFLAGS ?= -O
17 CFI = -I$(top_srcdir)/include -I$(top_srcdir) -I$(top_srcdir)/src
18 BNAME = lzo2
19 BLIB = lib$(BNAME).a
21 CF = $(CPPFLAGS) $(CFI) $(CFLAGS)
22 LF = $(LDFLAGS) $(LZO_EXTRA_LDFLAGS)
23 LL = $(BLIB) $(LIBS) $(LZO_EXTRA_LIBS)
27 ## setup files
30 __map = $(foreach __map_v,$(2),$(call $(1),$(__map_v)))
31 __object_filename = $(addsuffix .o,$(basename $(notdir $(1))))
33 BLIB_SOURCES := $(wildcard $(top_srcdir)/src/*.c)
34 BLIB_SOURCES += $(LZO_EXTRA_SOURCES)
35 BLIB_OBJECTS := $(call __map,__object_filename,$(BLIB_SOURCES))
36 PROGRAMS = dict.out lzopack.out precomp.out precomp2.out simple.out lzotest.out
40 ## rules
43 all.targets ?= $(BLIB) $(PROGRAMS) testmini.out
44 all: $(all.targets)
46 clean:
47 rm -f *.d *.o $(BLIB) $(PROGRAMS) testmini.out
49 $(BLIB): $(BLIB_OBJECTS) $(LZO_EXTRA_OBJECTS)
50 rm -f $@
51 $(AR) rcs $@ $^
53 # dynamically construct object rules
54 define BLIB_OBJECT_template
55 $(call __object_filename,$(1)) : $(1) ; $$(CC) $$(CF) $$(LZO_EXTRA_CPPFLAGS) $$(LZO_EXTRA_CFLAGS) -c $$<
56 endef
57 $(foreach s,$(BLIB_SOURCES),$(eval $(call BLIB_OBJECT_template,$(s))))
59 dict.out: $(top_srcdir)/examples/dict.c
60 $(CC) $(CF) $(LF) -o $@ $< $(LL)
61 lzopack.out: $(top_srcdir)/examples/lzopack.c
62 $(CC) $(CF) $(LF) -o $@ $< $(LL)
63 precomp.out: $(top_srcdir)/examples/precomp.c
64 $(CC) $(CF) $(LF) -o $@ $< $(LL)
65 precomp2.out: $(top_srcdir)/examples/precomp2.c
66 $(CC) $(CF) $(LF) -o $@ $< $(LL)
67 simple.out: $(top_srcdir)/examples/simple.c
68 $(CC) $(CF) $(LF) -o $@ $< $(LL)
69 lzotest.out: $(top_srcdir)/lzotest/lzotest.c
70 $(CC) $(CF) $(LF) -o $@ $< $(LL)
72 testmini.out: $(top_srcdir)/minilzo/testmini.c $(top_srcdir)/minilzo/minilzo.c
73 $(CC) $(CF) $(LF) -I$(top_srcdir)/include/lzo -o $@ $^ $(LIBS)
76 # dependencies
77 $(PROGRAMS): $(BLIB)
78 # object dependencies are generated via -MMD
79 -include *.d
82 # debug
83 show_vars:
84 @echo "BLIB_SOURCES = $(BLIB_SOURCES)"
85 @echo "BLIB_OBJECTS = $(BLIB_OBJECTS)"
86 @echo "PROGRAMS = $(PROGRAMS)"
87 @echo "LZO_EXTRA_SOURCES = $(LZO_EXTRA_SOURCES)"
88 @echo "LZO_EXTRA_OBJECTS = $(LZO_EXTRA_OBJECTS)"
90 .PHONY: all clean show_vars