Merge pull request #8 from biergaizi/upstream
[darwin-xtools.git] / cctools / ar / Makefile
blobfcd160f8a6908515df0f48707ad356e6651dc917
1 ifneq "" "$(SDKROOT)"
2 SDK = -isysroot $(SDKROOT)
3 CC = $(shell xcrun -find -sdk $(SDKROOT) cc)
4 DSYMUTIL = $(shell xcrun -find -sdk ${SDKROOT} dsymutil)
5 else
6 DSYMUTIL = dsymutil
7 endif
9 OFLAG = -Os
10 CFLAGS = -g $(OFLAG) -Wall -I$(SRCROOT)/../include $(SDK)
11 LIBSTUFF = -L$(SYMROOT)/../libstuff -lstuff
12 MKDIRS = /bin/mkdir -p
13 SRCROOT = .
14 OBJROOT = .
15 SYMROOT = .
16 OFILE_DIR = $(OBJROOT)
17 VPATH = $(OFILE_DIR)
19 BINDIR = /usr/bin
20 MANDIR = /usr/share/man
21 DSTDIRS = $(DSTROOT)$(BINDIR) $(DSTROOT)$(MANDIR)/man1 $(DSTROOT)$(MANDIR)/man5
23 HFILES = archive.h extern.h pathnames.h
24 CFILES = append.c ar.c archive.c contents.c delete.c extract.c misc.c move.c \
25 print.c replace.c
26 MAN1 = ar.1
27 MAN5 = ar.5
28 OBJS = $(CFILES:.c=.o)
29 INSTALL_FILES = $(CFILES) $(HFILES) $(MAN1) $(MAN5) Makefile notes
31 PRODUCT = ar
33 all: $(OFILE_DIR) $(SYMROOT) $(PRODUCT).NEW
35 $(PRODUCT).NEW: $(OFILE_DIR) $(SYMROOT) $(OBJS)
36 $(CC) $(RC_CFLAGS) $(SDK) -o $(SYMROOT)/$@ $(OBJS) $(LIBSTUFF)
37 $(DSYMUTIL) $(SYMROOT)/$@
39 .c.o:
40 $(CC) $(CFLAGS) $(RC_CFLAGS) $(COPTS) -c -o $(OFILE_DIR)/$*.o $<
42 clean: shlib_clean
43 -rm -f $(SYMROOT)/$(PRODUCT).NEW
44 -rm -r -f *dSYM
46 shlib_clean:
47 -cd $(OFILE_DIR); rm -f $(OBJS)
48 -rm -f make.out
50 install: all $(DSTDIRS)
51 install -c -s -m 555 $(SYMROOT)/$(PRODUCT).NEW \
52 $(DSTROOT)$(BINDIR)/$(PRODUCT)
53 install -c -m 444 $(MAN1) $(DSTROOT)$(MANDIR)/man1
54 install -c -m 444 $(MAN5) $(DSTROOT)$(MANDIR)/man5
56 installsrc:
57 $(MKDIRS) $(SRCROOT)
58 chmod 755 $(SRCROOT)
59 gnutar cf - $(INSTALL_FILES) | (cd $(SRCROOT); gnutar xf -)
60 chmod 444 $(SRCROOT)/*
62 $(OFILE_DIR) $(SYMROOT) $(DSTDIRS):
63 $(MKDIRS) $@