]> git.saurik.com Git - apple/libutil.git/blob - Makefile
libutil-25.tar.gz
[apple/libutil.git] / Makefile
1 SHELL := /bin/sh
2
3 VERSION = 1.0
4 CC = xcrun cc
5 CPP = xcrun c++
6 CPPFLAGS = -I$(SRCROOT)
7
8 ifneq ($(SDKROOT),)
9 CFLAGS_SDK = -isysroot $(SDKROOT)
10 LDFLAGS_SDK = -Wl,-syslibroot,$(SDKROOT)
11 endif
12
13 CFLAGS = -Os -g3 -no-cpp-precomp -Wall $(RC_CFLAGS) $(CFLAGS_SDK)
14 LDFLAGS = $(RC_CFLAGS) -install_name /usr/lib/libutil.dylib -compatibility_version $(VERSION) \
15 -current_version $(VERSION) -lstdc++ -exported_symbols_list libutil.exports $(LDFLAGS_SDK)
16 INSTALL = install -c
17 LN = ln
18 MKDIR = mkdir -p
19 STRIP = strip
20 DSYMUTIL = dsymutil
21 AR = ar
22 RANLIB = ranlib
23
24 SRCROOT = .
25 OBJROOT = $(SRCROOT)
26 SYMROOT = $(OBJROOT)
27 DSTROOT =
28
29 LIB := libutil1.0.dylib
30 SRCS := _secure_path.c getmntopts.c humanize_number.c \
31 pidfile.c property.c realhostname.c trimdomain.c uucplock.c \
32 ExtentManager.cpp wipefs.cpp reexec_to_match_kernel.c
33 HDRS := libutil.h mntopts.h wipefs.h
34 MAN3 := _secure_path.3 getmntopts.3 humanize_number.3 pidfile.3 \
35 property.3 realhostname.3 realhostname_sa.3 trimdomain.3 \
36 uucplock.3 wipefs.3 reexec_to_match_kernel.3
37
38 ifeq ($(RC_ProjectName),libutil_Sim)
39 INSTALL_PREFIX = $(SDKROOT)
40 else
41 INSTALL_PREFIX =
42 endif
43
44
45 .SUFFIXES :
46 .SUFFIXES : .c .cpp .h .o
47
48 .PHONY :
49 .PHONY : all installsrc installhdrs install clean installlib installman
50
51 all : $(SYMROOT)/$(LIB)
52
53 #
54 # xbs targets.
55 #
56 installsrc :
57 @if test ! -d $(SRCROOT); then \
58 echo "$(INSTALL) -d $(SRCROOT)"; \
59 $(INSTALL) -d $(SRCROOT); \
60 fi
61 tar cf - . | (cd $(SRCROOT); tar xpf -)
62 @for i in `find $(SRCROOT) | grep "/\.svn$$"`; do \
63 if test -d $$i ; then \
64 echo "rm -rf $$i"; \
65 rm -rf $$i; \
66 fi; \
67 done
68
69 installhdrs :
70 $(INSTALL) -d $(DSTROOT)$(INSTALL_PREFIX)/usr/local/include
71 $(INSTALL) -m 0644 $(HDRS) $(DSTROOT)$(INSTALL_PREFIX)/usr/local/include
72
73
74 ifeq ($(RC_ProjectName),libutil_Sim)
75 install : installhdrs installlib strip install-plist
76 else
77 install : installhdrs installlib strip installman install-plist
78 endif
79
80 clean :
81 rm -f $(patsubst %.cpp,$(OBJROOT)/%.o,$(patsubst %.c,$(OBJROOT)/%.o,$(SRCS)))
82 rm -f $(SYMROOT)/*~
83 rm -f $(SRCROOT)/.\#*
84 rm -f $(SYMROOT)/$(LIB)
85
86 strip:
87 $(STRIP) -x -S $(DSTROOT)$(INSTALL_PREFIX)/usr/lib/$(LIB)
88
89 #
90 # Internal targets and rules.
91 #
92 installlib : $(SYMROOT)/$(LIB)
93 $(DSYMUTIL) $(SYMROOT)/$(LIB) -o $(SYMROOT)/$(LIB).dSYM
94 $(INSTALL) -d $(DSTROOT)$(INSTALL_PREFIX)/usr/lib
95 $(INSTALL) -m 0755 $< $(DSTROOT)$(INSTALL_PREFIX)/usr/lib
96 $(LN) -fs libutil1.0.dylib $(DSTROOT)$(INSTALL_PREFIX)/usr/lib/libutil.dylib
97
98 installman :
99 $(INSTALL) -d $(DSTROOT)/usr/local/share/man/man3
100 @for i in $(MAN3); do\
101 echo "$(INSTALL) -m 0444 $(SRCROOT)/$$i $(DSTROOT)/usr/local/share/man/man3/"; \
102 $(INSTALL) -m 0444 $(SRCROOT)/$$i $(DSTROOT)/usr/local/share/man/man3; \
103 done
104
105 $(OBJROOT)/%.o : $(SRCROOT)/%.c \
106 $(patsubst %.h,$(SRCROOT)/%.h,$(HDRS))
107 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
108
109 $(OBJROOT)/%.o : $(SRCROOT)/%.cpp \
110 $(patsubst %.h,$(SRCROOT)/%.h,$(HDRS))
111 $(CPP) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
112
113 $(SYMROOT)/$(LIB) : $(patsubst %.cpp,$(OBJROOT)/%.o,$(patsubst %.c,$(OBJROOT)/%.o,$(SRCS)))
114 $(CC) -dynamiclib $(LDFLAGS) -o $@ $(patsubst %.cpp,$(OBJROOT)/%.o,$(patsubst %.c,$(OBJROOT)/%.o,$(SRCS)))
115
116 OSV = $(DSTROOT)$(INSTALL_PREFIX)/usr/local/OpenSourceVersions
117 OSL = $(DSTROOT)$(INSTALL_PREFIX)/usr/local/OpenSourceLicenses
118
119 install-plist:
120 $(MKDIR) $(OSV)
121 $(INSTALL) -m 644 $(SRCROOT)/libutil.plist $(OSV)/
122 $(MKDIR) $(OSL)
123 $(INSTALL) -m 644 $(SRCROOT)/libutil.txt $(OSL)/