-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile.fallback
More file actions
168 lines (143 loc) · 5.34 KB
/
Makefile.fallback
File metadata and controls
168 lines (143 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Makefile This file is part of LibWoofer
# Copyright (C) 2022, 2023 Quico Augustijn
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed "as is" in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. If your
# computer no longer boots, divides by 0 or explodes, you are the only
# one responsible. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# version 3 along with this library. If not, see
# <https://www.gnu.org/licenses/gpl-3.0.html>.
#
#
# This is the original manually written Makefile that is now replaced by the
# configurable 'Makefile.in'. This Makefile can still be used to compile the
# software with the default configuration, but you are encouraged to configure
# the project using the `./configure` script before using Make.
SHELL = /bin/sh
# Variables
NAME ?= Woofer
TARNAME ?= woofer
VERSION_MAJOR = 0
VERSION_MINOR = 1
VERSION_PATCH = 0
PACKAGE_VERSION ?= $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
CC ?= gcc
LD ?= ld
AR ?= ar
RANLIB ?= ranlib
MKDIR_P = mkdir -p
LN_S = ln -s
# Build information
TAG = lib$(TARNAME)
OUT_SHARED ?= $(TAG).so.$(PACKAGE_VERSION)
OUT_STATIC ?= $(TAG).a
LINK_SHARED ?= $(TAG).so.$(VERSION_MAJOR)
DIST_PKG = $(TAG)-$(PACKAGE_VERSION)
# Dependencies and targets
DEPENDENCIES = glib-2.0 gio-2.0 gobject-2.0 gstreamer-1.0
PREREQUISITE_LIB = app song player library settings intelligence song_manager \
song_metadata remote mpris statistics notifications \
file_inspector utils characters dlist memory tweaks \
static/gdbus static/gdbus static/mediaplayer2 \
static/options static/resources
PKGCONFIG_FILE = woofer.pc
TAR_FILES = AUTHORS BUGS CODE_OF_CONDUCT.md configure configure.ac \
CONTRIBUTING.md COPYING envsetup.sh INSTALL install-sh \
Makefile.fallback Makefile.in README.md $(TAG).doap
TAR_DIRS = data doc resources src
# Compiler and linker flags
LIBS += -lm
WARN_FLAGS = -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
INC_FLAGS = -I$(SRC_DIR)
MACROS = -DG_LOG_DOMAIN=\"$(TAG)\"
DEBUG_FLAGS = -g -ggdb
# Directories used for compilation
BUILD_DIR = build
SRC_DIR = src
DATA_DIR = data
# Final library target
TARGET_SHARED ?= $(BUILD_DIR)/$(OUT_SHARED)
TARGET_STATIC ?= $(BUILD_DIR)/$(OUT_STATIC)
TARGET_LINK ?= $(BUILD_DIR)/$(LINK_SHARED)
# Get library linking flags
PKG_CFLAGS := `pkg-config --cflags $(DEPENDENCIES)`
PKG_LIBS := `pkg-config --libs $(DEPENDENCIES)`
# Sources and targets
OBJS := $(PREREQUISITE_LIB:%=$(BUILD_DIR)/%.o)
SRCS := $(PREREQUISITE_LIB:%=$(SRC_DIR)/%.c)
# Prerequisites search path
vpath %.c $(SRC_DIR)
vpath %.h $(SRC_DIR)
# Targets that do not generate any files
.PHONY: all resources clean distclean mostlyclean maintainer-clean dist \
dist-gzip dist-xz
# Default target
all: $(TARGET_SHARED) $(TARGET_STATIC) $(TARGET_LINK)
# Final shared library linkage
$(TARGET_SHARED): $(OBJS)
@$(MKDIR_P) $(@D)
$(CC) -shared -o $@ $^ $(LIBS) $(PKG_LIBS) $(CFLAGS) $(LDFLAGS)
# Final static library archive creation
$(TARGET_STATIC): $(OBJS)
@$(MKDIR_P) $(@D)
$(AR) $(ARFLAGS) $@ $^
$(RANLIB) $@
# Shared library symbolic link creation
$(TARGET_LINK): $(TARGET_SHARED)
$(LN_S) -rf $^ $@
# Library object compilation
$(BUILD_DIR)/%.o: %.c %.h
@$(MKDIR_P) $(@D)
$(CC) $(INC_FLAGS) $(MACROS) -fPIC -c $< -o $@ $(PKG_CFLAGS) $(WARN_FLAGS) $(DEBUG_FLAGS) $(CFLAGS) $(CPPFLAGS)
# Recompile resource files
resources: resources/resources.gresource.xml
glib-compile-resources --sourcedir=resources --generate-source --internal $<
glib-compile-resources --sourcedir=resources --generate-header --internal $<
cp -f resources/resources.c src/static/resources.c
cp -f resources/resources.h src/static/resources.h
# Clean all compiled files
clean:
@$(MAKE) mostlyclean
-rm -fv $(TARGET_SHARED) $(TARGET_STATIC) $(TARGET_LINK)
# Clean all generated and compiled files
distclean:
@$(MAKE) clean
-rm -frv autom4te.cache aclocal.m4 config.log config.status Makefile $(DATA_DIR)/$(PKGCONFIG_FILE)
# Clean temporary files
mostlyclean:
-rm -fv $(BUILD_DIR)/*.i $(BUILD_DIR)/*.s $(BUILD_DIR)/*.o
-rm -fv $(BUILD_DIR)/*/*.i $(BUILD_DIR)/*/*.s $(BUILD_DIR)/*/*.o
# Clean almost everything
maintainer-clean:
@echo 'This command is intended for maintainers to use; it'
@echo 'deletes files that may need special tools to rebuild.'
@$(MAKE) distclean
-rm -fv resources/resources.c resources/resources.h resources.gresource
# Create a distribution tar file
dist:
$(MAKE) dist-gzip
# Common operations to create a distribution archive
dist-tar:
@$(MKDIR_P) $(DIST_PKG)
cp -dflRux -t $(DIST_PKG) $(TAR_FILES) $(TAR_DIRS)
-rm -f $(DIST_PKG)/*/$(PKGCONFIG_FILE)
tar -c --remove-files --file=$(DIST_PKG).tar $(DIST_PKG)
-rm -rf $(DIST_PKG)
# Create a distribution tar file, compressed with gzip
dist-gzip: $(TAR_FILES)
$(MAKE) dist-tar
gzip -9 -f $(DIST_PKG).tar
# Create a distribution tar file, compressed with xz
dist-xz: $(TAR_FILES)
$(MAKE) dist-tar
xz $(DIST_PKG).tar