Handle TARGET_DIR in universal library building.
[kugel-rb.git] / tools / ucl / src / Makefile
blob14ca1f35ebc9e8ade8af62fe13964e78e11fe109
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
9 CFLAGS = -I../include
10 CC = gcc
12 ifndef V
13 SILENT = @
14 endif
16 ifdef RBARCH
17 CFLAGS += -arch $(RBARCH)
18 endif
21 OUT = $(TARGET_DIR)build$(RBARCH)
23 SOURCES = alloc.c io.c n2b_99.c n2b_d.c n2b_ds.c n2b_to.c n2d_99.c \
24 n2d_d.c n2d_ds.c n2d_to.c n2e_99.c n2e_d.c n2e_ds.c n2e_to.c ucl_crc.c \
25 ucl_dll.c ucl_init.c ucl_ptr.c ucl_str.c ucl_util.c
27 OBJS = $(OUT)/alloc.o $(OUT)/io.o $(OUT)/n2b_99.o $(OUT)/n2b_d.o $(OUT)/n2b_ds.o $(OUT)/n2b_to.o $(OUT)/n2d_99.o \
28 $(OUT)/n2d_d.o $(OUT)/n2d_ds.o $(OUT)/n2d_to.o $(OUT)/n2e_99.o $(OUT)/n2e_d.o $(OUT)/n2e_ds.o $(OUT)/n2e_to.o $(OUT)/ucl_crc.o \
29 $(OUT)/ucl_dll.o $(OUT)/ucl_init.o $(OUT)/ucl_ptr.o $(OUT)/ucl_str.o $(OUT)/ucl_util.o
31 # we don't use $(AR) and $(RANLIB) below since we want the _native_ tools
32 # not the cross-compiler tools
33 libucl$(RBARCH).a: $(OUT) $(OBJS)
34 $(SILENT)ar ruv $(TARGET_DIR)$@ $(OBJS) >/dev/null 2>&1
35 $(SILENT)ranlib $(TARGET_DIR)$@
37 $(OUT)/%.o: %.c
38 @echo CC $<
39 $(SILENT)$(CC) $(CFLAGS) -c $< -o $@
41 # some trickery to build ppc and i386 from a single call
42 ifeq ($(RBARCH),)
43 $(TARGET_DIR)libucli386.a:
44 make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) libucli386.a
46 $(TARGET_DIR)libuclppc.a:
47 make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) libuclppc.a
48 endif
50 libucl-universal: $(TARGET_DIR)libucli386.a $(TARGET_DIR)libuclppc.a
51 @echo lipo $(TARGET_DIR)libucl.a
52 $(SILENT) rm -f $(TARGET_DIR)libucl.a
53 lipo -create $(TARGET_DIR)libuclppc.a $(TARGET_DIR)libucli386.a -output $(TARGET_DIR)libucl.a
55 clean:
56 rm -f $(TARGET_DIR)libucl*.a
57 rm -rf build*
59 $(OUT):
60 @echo MKDIR $(OUT)
61 $(SILENT)mkdir $(OUT)