1 # Copyright (C) 1996-2015 Markus F.X.J. Oberhumer
3 # this is modelled after build.sh; needs GNU make 3.80 or better
12 top_srcdir ?
= $(dir $(word $(words $(MAKEFILE_LIST
)),$(MAKEFILE_LIST
)))..
/..
17 CFI
= -I
$(top_srcdir
)/include -I
$(top_srcdir
) -I
$(top_srcdir
)/src
21 CF
= $(CPPFLAGS
) $(CFI
) $(CFLAGS
)
22 LF
= $(LDFLAGS
) $(LZO_EXTRA_LDFLAGS
)
23 LL
= $(BLIB
) $(LIBS
) $(LZO_EXTRA_LIBS
)
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
43 all.targets ?
= $(BLIB
) $(PROGRAMS
) testmini.out
47 rm -f
*.d
*.o
$(BLIB
) $(PROGRAMS
) testmini.out
49 $(BLIB
): $(BLIB_OBJECTS
) $(LZO_EXTRA_OBJECTS
)
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
$$<
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
)
78 # object dependencies are generated via -MMD
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