1
- LIBVER ?=$(shell vtool -show-build $(shell brew --prefix) /lib/libgetargv.dylib | awk '/minos/{print $$2}')
2
- export MACOSX_DEPLOYMENT_TARGET =$(LIBVER )
3
- VERSION =0.1
4
- COMPAT_VERSION := $(shell echo $(VERSION ) | cut -f1 -d.) .0
5
-
6
- CODESIGN_PREFIX := cam.narzt.
7
- KEYCHAIN := ~/Library/Keychains/login.keychain-db
8
- CERT_IDENTITY := $(shell security find-identity -v -p codesigning | sed -Ee 's/.* "([^"]+) ".*/\1/g' | grep -Fve ' valid identit' -e ' CA')
9
-
10
- SRC_DIR = src
11
- OBJ_DIR = obj
12
- LIB_DIR = lib
13
-
14
- PREFIX := /usr/local
15
- CXX =clang++
16
- CPPFLAGS += -MMD -MP
17
-
18
- COMPILER_VERSION := $(shell $(CXX ) --version | grep version | grep -o -m 1 "[0-9]\+\.[0-9]\+\.* [0-9]* " | head -n 1)
19
- COMPILER_VERSION_NUMBER := $(shell echo $(COMPILER_VERSION ) | sed -e 's/\.\([0-9][0-9]\) /\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
20
- CLANG_13_OR_MORE := $(shell expr $(COMPILER_VERSION_NUMBER ) \>= 130106)
21
- ifneq ($(CLANG_13_OR_MORE ) ,0)
22
- # supported: c++11, c++14, c++17, c++20
23
- # future: c++2b
24
- CXXFLAGS := --std=c++20 -O3 -Iinclude
25
- else
26
- CXXFLAGS := --std=c++17 -O3 -Iinclude
27
- endif
28
-
29
- EXTRA_CXXFLAGS := -pedantic-errors -Weverything -Wno-c++98-compat -Wno-pre-c++20-compat-pedantic -Wno-poison-system-directories
30
- LDFLAGS += -Llib -fvisibility=default -fPIC
31
- LDLIBS += -lgetargv
32
-
33
- LIB_SHORT_NAME = getargv++
34
- DYLIB_FILENAME = lib$(LIB_SHORT_NAME ) .$(VERSION ) .dylib
35
- DYLIB = lib/$(DYLIB_FILENAME )
36
- SOURCES = $(wildcard $(SRC_DIR ) /* .cpp)
37
- OBJECTS = $(SOURCES:$(SRC_DIR ) /%.cpp=$(OBJ_DIR ) /%.o )
1
+ include Makefile-variables
38
2
39
- .PHONY := db clean dylib install_dylib lint
3
+ .PHONY := db clean dylib install install_dylib lint dmg
40
4
.DEFAULT_GOAL := dylib
41
5
42
6
dylib : $(DYLIB )
43
7
8
+ install : install_dylib
9
+
44
10
install_dylib : $(DYLIB )
45
11
install -d $(PREFIX ) /$(LIB_DIR )
46
12
install $(DYLIB ) $(PREFIX ) /$(DYLIB )
@@ -62,10 +28,10 @@ $(DYLIB): $(OBJECTS) | $(LIB_DIR)
62
28
$(OBJ_DIR ) /% .o : $(SRC_DIR ) /% .cpp | $(OBJ_DIR )
63
29
$(CXX ) $(EXTRA_CXXFLAGS ) $(CXXFLAGS ) $(CPPFLAGS ) -c -fPIC $< -o $@
64
30
65
- $(OBJ_DIR ) $(LIB_DIR ) :
31
+ $(OBJ_DIR ) $(LIB_DIR ) $( FAKE_ROOT ) $( PKG_DIR ) :
66
32
mkdir -p $@
67
33
68
- docs :
34
+ docs : doxygen.conf $( SOURCES ) $( HEADERS )
69
35
doxygen -q doxygen.conf
70
36
71
37
db : compile_commands.json
@@ -74,10 +40,46 @@ compile_commands.json: Makefile
74
40
$(shell brew --prefix bear) /bin/bear -- make -B $(OBJECTS )
75
41
76
42
clean :
77
- @$(RM ) -rf $(OBJ_DIR ) $(LIB_DIR ) docs
43
+ @$(RM ) -rf $(OBJ_DIR ) $(LIB_DIR ) docs $( FAKE_ROOT ) $( PKG_DIR )
78
44
79
45
lint : compile_commands.json
80
46
for file in $( SOURCES) ; do /usr/bin/xcrun -r clangd --enable-config --clang-tidy --log=error --check=$$ file; done
81
47
$(shell brew --prefix llvm) /bin/scan-build -enable-checker security -enable-checker unix -enable-checker valist $(MAKE ) -B dylib
82
48
49
+ dmg : $(DMG )
50
+
51
+ $(DMG ) : $(PRODUCT )
52
+ hdiutil create -fs " $( DMG_FS) " -volname " $( DMG_VOLUME_NAME) " -srcfolder " $( PKG_DIR) " -ov -format " $( DMG_FORMAT) " " $@ "
53
+
54
+ $(DISTRIBUTION ) : $(SRC_DIR ) /dist.xml
55
+ < $< > $@ sed \
56
+ -e ' s/OS_VERSION/$(MACOS_VER_NUM)/g' \
57
+ -e ' s/ARCH/$(ARCH)/g' \
58
+ -e ' s/VERSION/$(VERSION)/g' \
59
+ -e ' s/LIB_PKG_NAME/$(LIB_PKG:$(PKG_DIR)/%=%)/g' \
60
+ -e ' s/LIB_ID/$(LIB_BUNDLE_IDENTIFIER)/g' \
61
+ -e ' s/LIB_NAME/$(LIB_NAME)/g'
62
+
63
+ $(PRODUCT ) : $(LIB_PKG ) $(DISTRIBUTION )
64
+ productbuild \
65
+ --identifier $(PRODUCT_BUNDLE_IDENTIFIER ) \
66
+ --version $(VERSION ) \
67
+ --package-path $(PKG_DIR ) \
68
+ --resources ./ \
69
+ --distribution $(DISTRIBUTION ) \
70
+ $(SIGN_PACKAGE_FLAG ) \
71
+ $@
72
+ @$(RM ) $^
73
+
74
+ $(LIB_PKG ) : $(FAKE_ROOT ) | $(PKG_DIR )
75
+ @$(RM ) -rf $(FAKE_ROOT ) /*
76
+ $(MAKE ) PREFIX=$(FAKE_ROOT ) install_dylib
77
+ pkgbuild --root $(FAKE_ROOT ) \
78
+ --identifier " $( LIB_BUNDLE_IDENTIFIER) " \
79
+ --version " $( VERSION) " \
80
+ $(PKG_VERSION_FLAG ) \
81
+ --install-location " $( PREFIX) " \
82
+ $(SIGN_PACKAGE_FLAG ) \
83
+ $@
84
+
83
85
-include $(OBJECTS :.o=.d)
0 commit comments