Makefile: don't link all objs to all programs
[rofl0r-agsutils.git] / Makefile
blob4b6c5cab37165479ae565136265e0c5b51d033a0
1 prefix=/usr/local
2 bindir=$(prefix)/bin
4 PROGS_SRCS = \
5 agstract.c \
6 agspack.c \
7 agscriptxtract.c \
8 agssemble.c \
9 agsdisas.c \
10 agssim.c \
11 agsprite.c \
12 agsalphahack.c \
13 agsinject.c
15 PROGS_OBJS = $(PROGS_SRCS:.c=.o)
16 CPROGS = $(PROGS_SRCS:.c=)
17 PROGS = $(CPROGS) agsoptimize agsex
19 LIB_SRCS = \
20 ByteArray.c \
21 Clib32.c \
22 DataFile.c \
23 Script.c \
24 File.c \
25 List.c \
26 MemGrow.c \
27 RoomFile.c \
28 StringEscape.c
30 SPRITE_SRCS = \
31 SpriteFile.c \
32 rle.c \
34 SPRITE_OBJS = $(SPRITE_SRCS:.c=.o)
36 ASM_SRCS = \
37 Assembler.c \
38 preproc.c \
39 tokenizer.c
41 ASM_OBJS = $(ASM_SRCS:.c=.o)
43 LIB_OBJS = $(LIB_SRCS:.c=.o)
45 CFLAGS_WARN = -Wall -Wextra -Wno-unknown-pragmas -Wno-sign-compare -Wno-switch -Wno-unused -Wno-pointer-sign
47 -include config.mak
49 all: $(PROGS)
51 $(PROGS_OBJS): $(LIB_OBJS)
53 agssemble: agssemble.o $(LIB_OBJS) $(ASM_OBJS)
54 agsprite: agsprite.o $(LIB_OBJS) $(SPRITE_OBJS)
56 %.o: %.c
57 $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_WARN) -o $@ -c $<
59 %: %.o $(LIB_OBJS)
60 $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_WARN) -o $@ $^ $(LDFLAGS)
62 rcb:
63 make -f Makefile.binary FNAME=agstract
64 make -f Makefile.binary FNAME=agspack
65 make -f Makefile.binary FNAME=agscriptxtract
66 make -f Makefile.binary FNAME=agssemble
67 make -f Makefile.binary FNAME=agsdisas
68 make -f Makefile.binary FNAME=agsinject
69 make -f Makefile.binary FNAME=agssim
71 clean:
72 rm -f $(CPROGS) $(LIB_OBJS) $(PROGS_OBJS)
73 rm -f *.out
74 rm -f *.o
75 rm -f *.rcb
77 install: $(PROGS:%=$(DESTDIR)$(bindir)/%)
79 $(DESTDIR)$(bindir)/%: %
80 install -D -m 755 $< $@
82 .PHONY: all clean