xref: /freebsd/sys/contrib/xz-embedded/userspace/Makefile (revision e32fecd0c2c3ee37c47ee100f169e7eb0282a873)
1#
2# Makefile
3#
4# Author: Lasse Collin <lasse.collin@tukaani.org>
5#
6# This file has been put into the public domain.
7# You can do whatever you want with this file.
8#
9
10# gcc -std=gnu89 is used because Linux uses it. It is fine to omit it as
11# the code is also C99/C11 compatible. With clang you may wish to omit
12# either -std=gnu89 or -pedantic as having both gives quite a few warnings.
13CC = gcc -std=gnu89
14BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
15		-DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
16CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK -DXZ_DEC_CONCATENATED
17CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra -Wno-long-long
18RM = rm -f
19VPATH = ../linux/include/linux ../linux/lib/xz
20COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
21COMMON_OBJS = $(COMMON_SRCS:.c=.o)
22XZMINIDEC_OBJS = xzminidec.o
23BYTETEST_OBJS = bytetest.o
24BUFTEST_OBJS = buftest.o
25BOOTTEST_OBJS = boottest.o
26XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
27PROGRAMS = xzminidec bytetest buftest boottest
28
29ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
30
31all: $(PROGRAMS)
32
33%.o: %.c $(XZ_HEADERS)
34	$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
35
36xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
37	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
38
39bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
40	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
41
42buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
43	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
44
45boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
46	$(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
47
48.PHONY: clean
49clean:
50	-$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BYTETEST_OBJS) \
51		$(BUFTEST_OBJS) $(BOOTTEST_OBJS) $(PROGRAMS)
52