OSDN Git Service

added add.c extract.c list.c
[lha/olha.git] / makefile
1 CFLAGS=-g -DPROTOTYPES=1 -Wall
2 CPPFLAGS=-I.
3 ifeq (cygwin,$(patsubst CYGWIN%,cygwin,$(shell uname -s)))
4   EXEEXT=.exe
5 else
6   EXEEXT=
7 endif
8 OBJS1 = ar.o io.o encode.o decode.o maketree.o maketbl.o huf.o \
9         strlib.o pathlib.o filelib.o header.o add.o extract.o list.o
10 OBJS2 = getopt_long.o
11
12 OBJS = $(OBJS1) $(OBJS2)
13
14 DEPS = $(OBJS:.o=.d)
15 TARGET = olha$(EXEEXT)
16
17 $(TARGET): $(OBJS)
18         $(CC) $(CFLAGS) $^ -o $@
19
20 proto:
21         sh ./cproto.sh $(OBJS1:.o=.c)
22
23 %.o: %.c
24         $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
25
26 clean:
27         $(RM) $(OBJS) $(TARGET) $(TARGET).stackdump
28
29 distclean: clean
30         $(RM) $(DEPS) tests/test.log
31
32 install: $(TARGET)
33         install -m 755 olha$(EXEEXT) /usr/local/bin
34
35 check: $(TARGET) randtest
36         sh ./tests/lha-test.sh 2 10 3 4 5 7 8 16 11
37         # 12: testing the end of line conversion.
38         # 13: testing the kanji code conversion.
39         # 14: testing to handle symbolic links
40         # 15: testing to self extracting archive
41         # 17: testing to remove relative path
42         # 18: restore directory permission
43         sh ./test.sh
44
45 t: $(TARGET)
46         cd t && python lha-test.py
47
48 randtest: $(TARGET)
49         cd ./randtest && PATH=..:$$PATH ruby randtest.rb
50
51 # include $(wildcard *.d)
52 include $(DEPS)
53
54 %.d: %.c
55         @echo creating $@
56         @set -e; $(CC) -M $(CPPFLAGS) $< \
57                 | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
58                 [ -s $@ ] || rm -f $@
59
60 .PHONY: clean distclean install check t randtest proto